-
Notifications
You must be signed in to change notification settings - Fork 1k
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
PauliString class sorts qubits by default, which results in confusing semantics #4270
Labels
area/paulis
kind/design-issue
A conversation around design
needs agreed design
We want to do this, but it needs an agreed upon design before implementation
Comments
Adding |
tanujkhattar
added
triage/discuss
Needs decision / discussion, bring these up during Cirq Cynque
needs agreed design
We want to do this, but it needs an agreed upon design before implementation
and removed
triage/discuss
Needs decision / discussion, bring these up during Cirq Cynque
labels
Aug 16, 2021
This should be done, let's figure out how to do it. |
CirqBot
pushed a commit
that referenced
this issue
Aug 20, 2021
…with pauli_string.gate (#4446) Fixes #4270 Note that the fix relies on the fact that python dicts maintain insertion order from python 3.6+ [[link](https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6)]
rht
pushed a commit
to rht/Cirq
that referenced
this issue
May 1, 2023
…with pauli_string.gate (quantumlib#4446) Fixes quantumlib#4270 Note that the fix relies on the fact that python dicts maintain insertion order from python 3.6+ [[link](https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6)]
harry-phasecraft
pushed a commit
to PhaseCraft/Cirq
that referenced
this issue
Oct 31, 2024
…with pauli_string.gate (quantumlib#4446) Fixes quantumlib#4270 Note that the fix relies on the fact that python dicts maintain insertion order from python 3.6+ [[link](https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6)]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/paulis
kind/design-issue
A conversation around design
needs agreed design
We want to do this, but it needs an agreed upon design before implementation
Description
PauliString
represents a collection of pauli's applied on different qubits. Since pauli operators applied to different qubits commute with each other, the class sorts all the qubits by default. Eg:Sorting qubits is not common in other operations (eg:
ControlledOperations
,GateOperations
etc.), and has some confusing semantics as shown below:Conversion to/from
DensePauliString
results in different gatesgate_instance == gate_instance.on().gate()
should generally be true for all gates, but this is not the case withDensePauliString
. Eg:with_qubits
returns a different gate applied on different qubits.with_qubits
function is supposed to return thesame operations applied to different qubits
but the underlying gate also changes with qubit ordering, similar to the same issue as above. Eg:Need for a
matrix()
protocol.Since changing the ordering of the qubits (which happens implicitly) changes the underlying "gate" represented by the operation, the unitary matrix of the operation is not necessarily the same as what one would expect. To get the expected representation, one needs to use
.matrix()
, which makes a case for matrix protocol propsoed in #3099. Eg:Proposal
Maybe we should store an explicit
QubitOrder
as well to improve consistency between the operator and underlying gate's representations?Update: Note that
QubitOrder
is not serializable and hence it might make more sense to use anOrderedDict
forqubit_pauli_map
or an explicitIterable[raw_types.Qid]
for storing thequbit_order
.Upd: This is part of organizing gate relationships #3242
The text was updated successfully, but these errors were encountered: