Skip to content

Commit debfb00

Browse files
committed
Add depol2 test
Signed-off-by: Ben Howe <[email protected]>
1 parent d48abfa commit debfb00

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

unittests/integration/noise_tester.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ struct bell {
2828
}
2929
};
3030

31+
struct bell_depolarization2 {
32+
void operator()(double prob) __qpu__ {
33+
cudaq::qubit q, r;
34+
h(q);
35+
x<cudaq::ctrl>(q, r);
36+
cudaq::apply_noise<cudaq::depolarization2>(prob, q, r);
37+
}
38+
};
39+
40+
struct bell_depolarization2_vec {
41+
void operator()(double prob) __qpu__ {
42+
cudaq::qvector q(2);
43+
h(q[0]);
44+
x<cudaq::ctrl>(q[0], q[1]);
45+
cudaq::apply_noise<cudaq::depolarization2>(prob, q);
46+
}
47+
};
48+
3149
#endif
3250
#if defined(CUDAQ_BACKEND_DM) || defined(CUDAQ_BACKEND_TENSORNET)
3351
// Stim does not support arbitrary cudaq::kraus_channel specification.
@@ -322,6 +340,21 @@ CUDAQ_TEST(NoiseTest, checkDepolType) {
322340
cudaq::unset_noise(); // clear for subsequent tests
323341
}
324342

343+
CUDAQ_TEST(NoiseTest, checkApplyDepol2) {
344+
cudaq::set_random_seed(13);
345+
double probability = 0.1;
346+
cudaq::noise_model noise{};
347+
noise.register_channel<cudaq::depolarization2>();
348+
cudaq::set_noise(noise);
349+
auto counts = cudaq::sample(bell_depolarization2{}, probability);
350+
counts.dump();
351+
EXPECT_EQ(4, counts.size());
352+
counts = cudaq::sample(bell_depolarization2_vec{}, probability);
353+
counts.dump();
354+
EXPECT_EQ(4, counts.size());
355+
cudaq::unset_noise(); // clear for subsequent tests
356+
}
357+
325358
#endif
326359
#if defined(CUDAQ_BACKEND_DM) || defined(CUDAQ_BACKEND_STIM) || \
327360
defined(CUDAQ_BACKEND_TENSORNET)

0 commit comments

Comments
 (0)