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

Remove deprecated functions in noise module #1624

Merged
merged 19 commits into from
Mar 7, 2023

Conversation

itoko
Copy link
Contributor

@itoko itoko commented Oct 18, 2022

Summary

Remove deprecated functions in noise module, e.g. NoiseModel.add_nonlocal_quantum_error, support of json-like input for QuantumError and standard_gates argument in many standard_errors.
Note that NoiseModel.from_dict is NOT removed exceptionally until alternative methods for serialize/deserialize NoiseModel objects are provided.

Details and comments

  • Completely remove noise.errors.errorutils and utils.noise_remapper
  • Remove deprecated methods in NoiseModel and QuantumError
  • Remove deprecated argument standard_gates in noise.errors.standard_errors
  • Update tests not to use deprecated functions
  • Deprecate warnings argument in NoiseModel (updated from PendingDeprecationWarning)

The following PRs must be merged before this PR.

@itoko itoko added this to the Aer 0.12.0 milestone Oct 18, 2022
@mtreinish mtreinish self-assigned this Oct 18, 2022
@hhorii
Copy link
Collaborator

hhorii commented Jan 24, 2023

@itoko Can you add a release note for removing and adding deprecation?

@itoko
Copy link
Contributor Author

itoko commented Feb 7, 2023

Qiskit/qiskit-tutorials#1397 should resolve the CI failure.

@itoko
Copy link
Contributor Author

itoko commented Feb 7, 2023

One more blocking fix: Qiskit/qiskit#9542
Maybe we should not rush to merge this commit.

Copy link
Member

@mtreinish mtreinish left a 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.

Comment on lines 12 to 24
- |
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.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed at a8eb0e6

qiskit_aer/noise/errors/quantum_error.py Outdated Show resolved Hide resolved
qiskit_aer/noise/errors/standard_errors.py Outdated Show resolved Hide resolved
qiskit_aer/noise/noise_model.py Outdated Show resolved Hide resolved
Comment on lines +1096 to +1145
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)
Copy link
Member

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.

@hhorii hhorii merged commit f205ddf into Qiskit:main Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants