-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Clifford does not use StabilizerTable as internal data and PendingDeprecation of PauliTable and StabilizerTable #7269
Clifford does not use StabilizerTable as internal data and PendingDeprecation of PauliTable and StabilizerTable #7269
Conversation
Pull Request Test Coverage Report for Build 3149420026
💛 - Coveralls |
Perhaps it's also relevant to check the RB performance since it requires to generate and compose large sequences of random Cliffords. |
@ShellyGarion Thanks. I checked RB:
|
Thanks @ikkoham - but now I think that this benchmark is only for the transpilation process, and does not benchmark the actual generation of the RB sequences themselves... |
I see. then, we need to add more benchmarks to Qiskit repository. EDITED: I'll add the benchmark for the tutorial here. |
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.
This looks like a good approach to me. Left a few suggestions for some small improvements.
from qiskit.quantum_info.operators.symplectic.clifford_circuits import ( | ||
_append_x, | ||
) | ||
from qiskit.quantum_info.states.quantum_state import QuantumState | ||
|
||
|
||
class StabilizerState(QuantumState): |
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.
Doesn't need to be in this PR, but we should improve the init method of StabilizerState
so it can also be constructed from a PauliList, or data format that can itself be used to initialize a PauliList.
releasenotes/notes/deprecate-stabilizer-table-9efd08c7de1a5b4d.yaml
Outdated
Show resolved
Hide resolved
In |
@ShellyGarion Thank you for your comments. It is true that the previous codes are hard to read. So, I added methods: |
|
||
# Validate table is a symplectic matrix | ||
if validate and not Clifford._is_symplectic(self._table.array): | ||
if validate and not Clifford._is_symplectic(self.tableau[:, :-1]): |
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.
Consider defining a property and a setter for the symplectic part of the clifford tableau, say symplectic
, instead of the previous cliff.table.array
and not call tableau[:, :-1]
(which appears several times in the code).
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.
Thanks. The properties are nice. The property name symplectic
is well used in the literature? I know that we check the symplectic inner product in the method _is_symplectic
, but I don't know whether Z components and X components is called symplectic.
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.
The 2nx2n array in the clifford tableau is a symplectic binary matrix, see e.g. https://arxiv.org/abs/1406.2170 (eq. 3 and 4) and https://en.wikipedia.org/wiki/Symplectic_group for the definition.
But of course, it's possible to choose a different name if you like.
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.
Yeah, it's an element of symplectic group. Thank you for the explanation. Then, I prefer Clifford.symplectic_matrix
(a bit long).
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.
Add in c1a8f98. It is more readable.
release. Instead, the :class:`~qiskit.quantum_info.PauliList` should be used. | ||
With this change, :attr:`.Clifford.table`, :attr:`.Clifford.stabilizer`, and | ||
:attr:`.Clifford.destabilizer` have been deprecated so that you should use | ||
:attr:`.Clifford.tableau`, :attr:`.Clifford.stabilizers`, :attr:`.Clifford.destabilizers`. |
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.
The methods now are called Clifford.stab
and Clifford.destab
?
Also, there are other new methods added.
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.
Just bumping this comment in my review too.
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.
This PR LGTM. It makes significant changes in the Clifford class API, but it seems to still contain all the needed functionality of a Clifford class.
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.
I'm still concerned that some of the deprecations in Clifford
tell users to used functions/attributes that are being added in the same PR, which breaks our deprecation policy. That said, this PR has been bounced from Terra releases so many times now (albeit in large part because it was breaking the deprecation policy...) that it may be more healthy for the development of the class to bend the rules this time. I'm concerned about affecting downstream users, but honestly, I think a large number of people are working around the Qiskit Clifford
class right now because it's too slow, and we're currently blocking updates to that because of this PR.
Could you check through that all the deprecation notices are pointing to the right place, just one last time, and then I'll sign off on this.
release. Instead, the :class:`~qiskit.quantum_info.PauliList` should be used. | ||
With this change, :attr:`.Clifford.table`, :attr:`.Clifford.stabilizer`, and | ||
:attr:`.Clifford.destabilizer` have been deprecated so that you should use | ||
:attr:`.Clifford.tableau`, :attr:`.Clifford.stabilizers`, :attr:`.Clifford.destabilizers`. |
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.
Just bumping this comment in my review too.
@deprecate_function( | ||
"Indexing or iterating through a Clifford object directly is deprecated as of " | ||
"Qiskit Terra 0.22.0 and will be removed no sooner than 3 months after the release date. " | ||
"Instead, index or iterate through the Clifford.tableau attribute." | ||
) | ||
def __getitem__(self, key): | ||
"""Return a stabilizer Pauli row""" | ||
return self._table.__getitem__(key) | ||
return self.table.__getitem__(key) |
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.
The tableau
attribute is new in this release, so we shouldn't really be issuing a DeprecationWarning
telling users to use it unless there's already been a previous release with tableau
in it. (See top review comment, though - I'm prepared to accept this PR despite breaking the deprecation policy, on somewhat pragmatic grounds of us having pushed this and held up development on the Clifford
class for too long now.)
def __setitem__(self, key, value): | ||
"""Set a stabilizer Pauli row""" | ||
self._table.__setitem__(key, value) | ||
self.tableau.__setitem__(key, value) |
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.
Is this going to do the right thing? I'm not 100% sure, but I didn't think the tableau representation was exactly the same.
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.
Thanks, it was wrong...
OK, then let's stop deprecation. It follows the deprecation policy. In any case, the deprecation of PauliTable will not be ready in time for 0.22, and I would like to deprecate PauliTable and StabilizerTable at the same time. |
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.
Oh, I wasn't expecting you to actually swap them all over! Thank you! This does make me feel happier about the whole thing - I know it's a bit longer til we can fully remove StabilizerTable
, but we still maintain our deprecation policy. Thanks a lot!
Summary
Clifford does not use StabilizerTable as internal data and PendingDeprecation of PauliTable and StabilizerTable.
Details and comments
Performance regression occurs due to stacking of x and z and tracking of phase.We need to check the regression is acceptable or not.
=> Performance check: small regression for small qubits (acceptable?)
I updated the code not to use
PauliList
.We don't have the performance regression now.
This is new benchmark result: