Skip to content

Commit 3bdd93f

Browse files
authored
Use new CUDA-Q noise models in examples (#120)
Signed-off-by: Ben Howe <[email protected]>
1 parent e1ff321 commit 3bdd93f

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

docs/sphinx/components/qec/introduction.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ Function Variants
813813
# Memory circuit with noise model
814814
noise = cudaq.NoiseModel()
815815
# Configure noise
816-
noise.add_all_qubit_channel("x", qec.TwoQubitDepolarization(0.01), 1)
816+
noise.add_all_qubit_channel("x", cudaq.Depolarization2(0.01), 1)
817817
syndromes, measurements = qec.sample_memory_circuit(
818818
code, # QEC code instance
819819
numShots=1000, # Number of shots
@@ -889,7 +889,7 @@ Example of running a memory experiment:
889889
890890
# Configure noise
891891
noise = cudaq.NoiseModel()
892-
noise.add_all_qubit_channel("x", qec.TwoQubitDepolarization(0.01), 1)
892+
noise.add_all_qubit_channel("x", cudaq.Depolarization2(0.01), 1)
893893
894894
# Run memory experiment
895895
syndromes, measurements = qec.sample_memory_circuit(
@@ -930,7 +930,7 @@ Example of running a memory experiment:
930930
931931
// Configure noise model
932932
cudaq::noise_model noise;
933-
noise.add_all_qubit_channel("x", cudaq::qec::two_qubit_depolarization(0.1),
933+
noise.add_all_qubit_channel("x", cudaq::depolarization2(0.1),
934934
/*num_controls=*/1);
935935
936936
// Run memory experiment
@@ -970,20 +970,20 @@ Additional Noise Models
970970
noise.add_all_qubit_channel('h', cudaq.BitFlipChannel(0.001))
971971
972972
# Specify two qubit errors
973-
noise.add_all_qubit_channel("x", qec.TwoQubitDepolarization(p), 1)
973+
noise.add_all_qubit_channel("x", cudaq.Depolarization2(p), 1)
974974
975975
.. tab:: C++
976976

977977
.. code-block:: cpp
978978
979979
cudaq::noise_model noise;
980980
981-
# Add multiple error channels
981+
// Add multiple error channels
982982
noise.add_all_qubit_channel(
983-
"x", cudaq::BitFlipChannel(/*probability*/ 0.01));
983+
"x", cudaq::bit_flip_channel(/*probability*/ 0.01));
984984
985-
# Specify two qubit errors
985+
// Specify two qubit errors
986986
noise.add_all_qubit_channel(
987-
"x", cudaq::qec::two_qubit_depolarization(/*probability*/ 0.01),
987+
"x", cudaq::depolarization2(/*probability*/ 0.01),
988988
/*numControls*/ 1);
989989

docs/sphinx/examples/qec/cpp/circuit_level_noise.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024 NVIDIA Corporation & Affiliates. *
2+
* Copyright (c) 2024 - 2025 NVIDIA Corporation & Affiliates. *
33
* All rights reserved. *
44
* *
55
* This source code and the accompanying materials are made available under *
@@ -46,9 +46,8 @@ int main() {
4646
cudaq::noise_model noise;
4747

4848
// Add a depolarization noise channel after each cx gate
49-
noise.add_all_qubit_channel(
50-
"x", cudaq::qec::two_qubit_depolarization(/*probability*/ 0.01),
51-
/*numControls*/ 1);
49+
noise.add_all_qubit_channel("x", cudaq::depolarization2(/*probability*/ 0.01),
50+
/*numControls*/ 1);
5251

5352
// Perform a noisy z-basis memory circuit experiment
5453
auto [syndromes, data] = cudaq::qec::sample_memory_circuit(

docs/sphinx/examples/qec/python/circuit_level_noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# error probabily
2323
p = 0.01
2424
noise = cudaq.NoiseModel()
25-
noise.add_all_qubit_channel("x", qec.TwoQubitDepolarization(p), 1)
25+
noise.add_all_qubit_channel("x", cudaq.Depolarization2(p), 1)
2626

2727
# prepare logical |0> state, tells the sampler to do z-basis experiment
2828
statePrep = qec.operation.prep0

docs/sphinx/examples_rst/qec/circuit_level_noise.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Here's how to use CUDA-Q QEC to perform a circuit-level noise model experiment i
4949

5050
3. Noise model:
5151
- To add noisy gates we use the `cudaq.NoiseModel` type.
52-
- CUDA-Q supports the generation of arbitrary noise channels, but here we use a `qec.TwoQubitDepolarization` channel to add a depolarization channel.
52+
- CUDA-Q supports the generation of arbitrary noise channels. Here we use a `cudaq.Depolarization2` channel to add a depolarization channel.
5353
- This is added to the `CX` gate by adding it to the `X` gate with 1 control.
5454
- This noisy gate is added to every qubit via that `noise.add_all_qubit_channel` function.
5555

0 commit comments

Comments
 (0)