ThreeQubitDiagonalGate decomposition changes the unitary for some qubit orders
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- quantum-computing
Research direction
Start by locating ThreeQubitDiagonalGate and its decomposition, then run the reproduction with cirq.testing.assert_decompose_is_consistent_with_unitary. Compare the direct and decomposed unitaries across the six qubit orders; done means all orders pass the consistency check.
Written by the indexing model from the issue text.
Description
Describe the issue
For some permutations of three LineQubits, decomposing a ThreeQubitDiagonalGate gives a different unitary. The direct and decomposed unitaries differ even when evaluated in the same operation-qubit order and compared up to global phase. Cirq's built-in consistency check detects this mismatch.
Explain how to reproduce the bug or problem
import cirq
q = cirq.LineQubit.range(3)
gate = cirq.ThreeQubitDiagonalGate([2, 3, 5, 7, 11, 13, 17, 19])
op = gate.on(q[1], q[0], q[2])
cirq.testing.assert_decompose_is_consistent_with_unitary(op)
AssertionError:
Not equal to tolerance rtol=1e-07, atol=1e-08
Mismatched elements: 4 / 64 (6.25%)
Mismatch at indices:
[2, 2]: (0.004425697988050765-0.9999902065507034j) (ACTUAL), (0.28366218546322625-0.9589242746631385j) (DESIRED)
[3, 3]: (0.907446781450196+0.4201670368266412j) (ACTUAL), (0.7539022543433046+0.6569865987187891j) (DESIRED)
[4, 4]: (0.28366218546322625-0.9589242746631385j) (ACTUAL), (0.004425697988050785-0.9999902065507035j) (DESIRED)
[5, 5]: (0.7539022543433045+0.6569865987187893j) (ACTUAL), (0.9074467814501962+0.4201670368266409j) (DESIRED)
The same check passes for gate.on(q[0], q[1], q[2]) and gate.on(q[2], q[1], q[0]). It fails for the other four orderings of the three qubits.
Tell us the version of Cirq where this happens
Cirq 1.7.0 and prerelease 1.8.0.dev20261121043546, Python 3.12.8, macOS 27.2 (arm64), NumPy 2.5.5.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 48
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from quantumlib/Cirq
-
Potential missed optimization: `drop_diagonal_before_measurement` leaves an identity `PhasedXZGate` that blocks further removalPossibly taken @jangyoujin0917 claimed this 22 days ago. Openarea/gates area/optimization kind/feature-request triage/accepted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
quantumlib/Cirq#8523 · 1 comment ·
Maintainers usually reply within 1 day
-
`defer_measurements` ignores `BitMaskKeyCondition.index` and changes circuit behaviorMay be free again @Tejendra-06 claimed this 54 days ago, and no pull request is open. Opengood for learning help wanted kind/bug-report skill/experienced triage/accepted triage/wont-fix
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
quantumlib/Cirq#8361 · 8 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
kind/feature-request triage/discuss
quantumlib/Cirq#8598 ·
Maintainers usually reply within 1 day
-
area/docstrings area/google kind/bug-report triage/discuss
Difficulty 1/5 1-3 hours Newbie friendliness 91/100
quantumlib/Cirq#8587 ·
Maintainers usually reply within 1 day
-
kind/bug-report triage/discuss
Difficulty 2/5 1-3 hours Newbie friendliness 57/100
quantumlib/Cirq#8580 ·
Maintainers usually reply within 1 day
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day