Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversion support for Qiskit noise models #577

Merged
merged 16 commits into from
Jul 25, 2024
Merged
Prev Previous commit
Next Next commit
update kwarg
obliviateandsurrender committed Jul 18, 2024
commit 62b88e8a8dcd4dfd8d269dfcbcf95d225dcd760b
12 changes: 6 additions & 6 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
@@ -2236,31 +2236,31 @@ def test_build_noise_model(self):
pl_model_map = {
op_in("Identity")
& wires_in(0): qml.ThermalRelaxationError(
pe=0.0, t1=26981.9403362283, t2=26034.6676428009, tq=1.0, wires=AnyWires
pe=0.0, t1=26981.9403362283, t2=26034.6676428009, tg=1.0, wires=AnyWires
),
op_in("Identity")
& wires_in(1): qml.ThermalRelaxationError(
pe=0.0, t1=30732.034088541, t2=28335.6514829973, tq=1.0, wires=AnyWires
pe=0.0, t1=30732.034088541, t2=28335.6514829973, tg=1.0, wires=AnyWires
),
(op_in("U1") & wires_in(0))
| (op_in("U1") & wires_in(1)): qml.DepolarizingChannel(
p=0.08999999999999997, wires=AnyWires
),
op_in("U2")
& wires_in(0): qml.ThermalRelaxationError(
pe=0.4998455776, t1=7.8227384666, t2=7.8226559459, tq=1.0, wires=AnyWires
pe=0.4998455776, t1=7.8227384666, t2=7.8226559459, tg=1.0, wires=AnyWires
),
op_in("U2")
& wires_in(1): qml.ThermalRelaxationError(
pe=0.4998644198, t1=7.8227957211, t2=7.8226273195, tq=1.0, wires=AnyWires
pe=0.4998644198, t1=7.8227957211, t2=7.8226273195, tg=1.0, wires=AnyWires
),
op_in("U3")
& wires_in(0): qml.ThermalRelaxationError(
pe=0.4996911588, t1=7.8227934813, t2=7.8226284393, tq=1.0, wires=AnyWires
pe=0.4996911588, t1=7.8227934813, t2=7.8226284393, tg=1.0, wires=AnyWires
),
op_in("U3")
& wires_in(1): qml.ThermalRelaxationError(
pe=0.4997288404, t1=7.8229079927, t2=7.8225711871, tq=1.0, wires=AnyWires
pe=0.4997288404, t1=7.8229079927, t2=7.8225711871, tg=1.0, wires=AnyWires
),
op_in("CNOT")
& wires_in([0, 1]): qml.QubitChannel(

Unchanged files with check annotations Beta

noise = qml.noise.partial_wires(error)
if isinstance(error, qml.QubitChannel) and kwargs.get("verbose", False):
kraus_shape = qml.math.shape(error.data)
num_kraus, num_wires = kraus_shape[0], int(np.log2(kraus_shape[1]))
noise = _rename(f"QubitChannel(num_kraus={num_kraus}, num_wires={num_wires})")(noise)

Check warning on line 1110 in pennylane_qiskit/converter.py

Codecov / codecov/patch

pennylane_qiskit/converter.py#L1108-L1110

Added lines #L1108 - L1110 were not covered by tests
if isinstance(error, qml.QubitChannel) and not kwargs.get("verbose", False):
if decimals := kwargs.get("decimal_places", None):
kraus_matrices = list(np.round(error.data, decimals=decimals))
noise = _rename(f"QubitChannel(Klist={kraus_matrices})")(noise)

Check warning on line 1115 in pennylane_qiskit/converter.py

Codecov / codecov/patch

pennylane_qiskit/converter.py#L1114-L1115

Added lines #L1114 - L1115 were not covered by tests
model_map[fcond] = noise