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

PauliString.after() crashes for Clifford gate PhXZ(a=0.25,x=-1,z=0) in _decompose_into_cliffords #6946

Open
babacry opened this issue Jan 13, 2025 · 6 comments
Assignees
Labels
area/gates good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@babacry
Copy link
Collaborator

babacry commented Jan 13, 2025

Description of the issue

PauliString.after() should be able to return a PauliString with Clifford ops input, but failed for the Clifford gate PhasedXZGate(axis_phase_exponent=0.25, x_exponent=-1,z_exponent=0).

How to reproduce the issue

>>> a = cirq.NamedQubit('a')
>>> ps = cirq.PauliString() * cirq.Y(a)
>>> phxz = cirq.PhasedXZGate(axis_phase_exponent=0.25, x_exponent=-1,z_exponent=0)
>>> ps.after(phxz.on(a))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/google/home/renyichen/miniconda3/envs/cirq-conda/lib/python3.10/site-packages/cirq/ops/pauli_string.py", line 1008, in after
    return self.conjugated_by(protocols.inverse(ops))
  File "/usr/local/google/home/renyichen/miniconda3/envs/cirq-conda/lib/python3.10/site-packages/cirq/ops/pauli_string.py", line 987, in conjugated_by
    for clifford_op in _decompose_into_cliffords(op)[::-1]:
  File "/usr/local/google/home/renyichen/miniconda3/envs/cirq-conda/lib/python3.10/site-packages/cirq/ops/pauli_string.py", line 1606, in _decompose_into_cliffords
    return [out for sub_op in decomposed for out in _decompose_into_cliffords(sub_op)]
  File "/usr/local/google/home/renyichen/miniconda3/envs/cirq-conda/lib/python3.10/site-packages/cirq/ops/pauli_string.py", line 1606, in <listcomp>
    return [out for sub_op in decomposed for out in _decompose_into_cliffords(sub_op)]
  File "/usr/local/google/home/renyichen/miniconda3/envs/cirq-conda/lib/python3.10/site-packages/cirq/ops/pauli_string.py", line 1608, in _decompose_into_cliffords
    raise TypeError(
TypeError: Operation is not a known Clifford and did not decompose into known Cliffords: (cirq.T**-1).on(cirq.NamedQubit('a'))

Cirq version

1.5.0.dev20250109234340
@babacry babacry added the kind/bug-report Something doesn't seem to work. label Jan 13, 2025
@NoureldinYosri NoureldinYosri added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Jan 14, 2025
@mhucka mhucka added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on area/gates and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Jan 22, 2025
@NoureldinYosri
Copy link
Collaborator

cirq-sync: convert the gate to a Clifford and detect global phase (Which the clifford gate will ignore)

@NoureldinYosri NoureldinYosri added the good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. label Jan 22, 2025
@babacry babacry self-assigned this Jan 23, 2025
@babacry
Copy link
Collaborator Author

babacry commented Jan 23, 2025

Interested in investigating and trying to fix this.

@NoureldinYosri
Copy link
Collaborator

@babacry thanks Renyi, the fix we suggest is the same as you did in your PR + preserving the global phase

@babacry
Copy link
Collaborator Author

babacry commented Jan 24, 2025

Thanks for the info, noted!

@babacry
Copy link
Collaborator Author

babacry commented Jan 28, 2025

Global phases in the Clifford gate won't affect the conjugate_by(), after(), before() results as global phase commute with other gates,

$$ (GC) \cdot P \cdot (GC)^\dagger = C \cdot P \cdot C^\dagger $$

where $\mathrm{G}=k\mathrm{I}$ is the global phase gate, $C$ is Clifford gate, $P$ is Pauli gate.

Directly using cirq.CliffordGate.from_op_list() before calling _decompose_into_cliffords works for the phxz gate mentioned above, but doesn't work for all the use cases.

Investigating the recursive decomposition logic and trying to sort things out with a clean solution.

@NoureldinYosri
Copy link
Collaborator

Global phases in the Clifford gate won't affect the conjugate_by(), after(), before()

good observation .. I forgot we were conjugating.

but doesn't work for all the use cases

which cases break it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gates good first issue This issue can be resolved by someone who is not familiar with the codebase. A good starting issue. kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
Status: No status
Development

No branches or pull requests

3 participants