Skip to content

Commit

Permalink
tweak example
Browse files Browse the repository at this point in the history
  • Loading branch information
obliviateandsurrender committed Jul 12, 2024
1 parent 48ada9a commit 5b03736
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pennylane_qiskit/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,8 +1068,7 @@ def load_noise_model(noise_model, **kwargs) -> qml.NoiseModel:
instead of the complete list of matrices. Default is ``True``.
options (dict[str, Union[int, float]]): optional parameters related to tolerance and rounding:
- decimals (int): number of decimal places to round the Kraus matrices for errors to.
If not provided, the default value of ``10`` is used.
- decimals (int): number of decimal places to round the Kraus matrices. Default is ``10``.
- atol (float): the relative tolerance parameter. Default value is ``1e-05``.
- rtol (float): the absolute tolernace parameters. Defualt value is ``1e-08``.
Expand All @@ -1093,7 +1092,7 @@ def load_noise_model(noise_model, **kwargs) -> qml.NoiseModel:
>>> error_1 = noise.depolarizing_error(0.001, 1) # 1-qubit noise
>>> error_2 = noise.depolarizing_error(0.01, 2) # 2-qubit noise
>>> noise_model = noise.NoiseModel()
>>> noise_model.add_all_qubit_quantum_error(error_1, ['rz', 'ry']) # rz and ry gates get error_1
>>> noise_model.add_all_qubit_quantum_error(error_1, ['rz', 'ry']) # rz/ry gates get error_1
>>> noise_model.add_all_qubit_quantum_error(error_2, ['cx']) # cx gates get error_2
>>> load_noise_model(noise_model)
NoiseModel({
Expand All @@ -1113,17 +1112,18 @@ def load_noise_model(noise_model, **kwargs) -> qml.NoiseModel:
pauli_mats = [
ft.reduce(np.kron, prod, 1.0)
for prod in it.product(
(tuple(map(qml.matrix, tuple(getattr(qml, i)(0) for i in ["I", "X", "Y", "Z"])))), repeat=2,
map(qml.matrix, tuple(getattr(qml, i)(0) for i in ["I", "X", "Y", "Z"]))
repeat=2
)
]
pauli_prob = error_2.probabilities
kraus_dops = [np.sqrt(prob) * kraus_op for prob, kraus_op in zip(pauli_prob, kraus_ops)]
kraus_ops = [np.sqrt(prob) * kraus_op for prob, kraus_op in zip(pauli_prob, pauli_mats)]
c0 = qml.noise.op_eq(qml.RZ) | qml.noise.op_eq(qml.RY)
c1 = qml.noise.op_eq(qml.CNOT)
n0 = qml.noise.partial_wires(qml.DepolarizingChannel, 0.001)
n1 = qml.noise.partial_wires(qml.QubitChanel(kraus_dops))
n1 = qml.noise.partial_wires(qml.QubitChanel(kraus_ops))
equivalent_pl_noise_model = qml.NoiseModel({c0: n0, c1: n1})
"""
Expand Down
3 changes: 1 addition & 2 deletions pennylane_qiskit/noise_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ def _build_noise_model_map(noise_model, **kwargs) -> Tuple[dict, dict]:
transforming Kraus operators to a Choi matrix, wherever required. Default is ``False``.
options (dict[str, Union[int, float]]): optional parameters related to tolerance and rounding:
- decimals (int): number of decimal places to round the Kraus matrices for errors to.
If not provided, the default value of ``10`` is used.
- decimals (int): number of decimal places to round the Kraus matrices. Default is ``10``.
- atol (float): the relative tolerance parameter. Default value is ``1e-05``.
- rtol (float): the absolute tolernace parameters. Defualt value is ``1e-08``.
Expand Down

0 comments on commit 5b03736

Please sign in to comment.