-
Notifications
You must be signed in to change notification settings - Fork 368
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
Remove deprecated functions in noise module #1624
Conversation
@itoko Can you add a release note for removing and adding deprecation? |
Qiskit/qiskit-tutorials#1397 should resolve the CI failure. |
One more blocking fix: Qiskit/qiskit#9542 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this LGTM, it's a pretty straightforward removal of stuff we deprecated some time ago. Just a few small inline comments, the only reason I didn't approve is I think we should include some more details in the release note about some of these removals.
- | | ||
A deprecated ``standard_gates`` argument broadly used in several methods and functions | ||
across :mod:`~.noise` module has been removed. | ||
- | | ||
The constructor of :class:`QuantumError` has now dropped deprecated arguments, | ||
``number_of_qubits``, ``standard_gates`` and ``atol``, and the support of deprecated | ||
json-like objects for ``noise_ops`` argument. | ||
- | | ||
The deprecated :mod:`utils.noise_remapper` and :mod:`noise.errors.errorutils` modules | ||
have been entirely removed. | ||
- | | ||
All deprecated functions and classes | ||
in :mod:`utils.noise_transformation` module has been removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these release notes are there any alternatives available? It'd be good to document what existing users should do instead or why they're not longer supported. Also listing the specifics can be helpful, just being a bit more explicit about what was removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed at a8eb0e6
def _standard_gate_unitary(name): | ||
# To be removed with from_dict | ||
unitary_matrices = { | ||
("id", "I"): | ||
np.eye(2, dtype=complex), | ||
("x", "X"): | ||
np.array([[0, 1], [1, 0]], dtype=complex), | ||
("y", "Y"): | ||
np.array([[0, -1j], [1j, 0]], dtype=complex), | ||
("z", "Z"): | ||
np.array([[1, 0], [0, -1]], dtype=complex), | ||
("h", "H"): | ||
np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2), | ||
("s", "S"): | ||
np.array([[1, 0], [0, 1j]], dtype=complex), | ||
("sdg", "Sdg"): | ||
np.array([[1, 0], [0, -1j]], dtype=complex), | ||
("t", "T"): | ||
np.array([[1, 0], [0, np.exp(1j * np.pi / 4)]], dtype=complex), | ||
("tdg", "Tdg"): | ||
np.array([[1, 0], [0, np.exp(-1j * np.pi / 4)]], dtype=complex), | ||
("cx", "CX", "cx_01"): | ||
np.array([[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]], dtype=complex), | ||
("cx_10",): | ||
np.array([[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]], dtype=complex), | ||
("cz", "CZ"): | ||
np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, -1]], dtype=complex), | ||
("swap", "SWAP"): | ||
np.array([[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]], dtype=complex), | ||
("ccx", "CCX", "ccx_012", "ccx_102"): | ||
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 0]], | ||
dtype=complex), | ||
("ccx_021", "ccx_201"): | ||
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], | ||
[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0]], | ||
dtype=complex), | ||
("ccx_120", "ccx_210"): | ||
np.array([[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0]], | ||
dtype=complex) | ||
} | ||
|
||
return next((value for key, value in unitary_matrices.items() if name in key), None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more efficient to build this off of https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/circuit/library/standard_gates/__init__.py#L108 since most of these can be built from the standard gate objects' .to_matrix()
methods. But this is also a much smaller set and contains things outside the standard gate library too. So this is not critical, I was just surprised to see this.
Summary
Remove deprecated functions in noise module, e.g.
NoiseModel.add_nonlocal_quantum_error
, support of json-like input forQuantumError
andstandard_gates
argument in manystandard_errors
.Note that
NoiseModel.from_dict
is NOT removed exceptionally until alternative methods for serialize/deserializeNoiseModel
objects are provided.Details and comments
noise.errors.errorutils
andutils.noise_remapper
NoiseModel
andQuantumError
standard_gates
innoise.errors.standard_errors
warnings
argument inNoiseModel
(updated from PendingDeprecationWarning)The following PRs must be merged before this PR.