Repository navigation
fix: decompose p, phaseshift and u1 as a single rz - #470
Conversation
Argus reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
unroll expanded p/phaseshift/u1 into h; rx(theta); h. A single rz(theta) is the same gate up to a global phase, so use that instead. This also lets rebase map p(pi/4) and p(pi/2) straight to t and s under CLIFFORD_T, and shortens the csx and rccx decompositions. Signed-off-by: Tony Coder <407243179@qq.com>
fe736cd to
bb6b3b4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary of changes
Fixes #469
phaseshift_gateexpandedp,phaseshiftandu1intoh; rx(θ); h. A singlerz(θ)is the same gate up to a global phase, so it now emits that. A user-writtenp(pi/4)then rebases to a singletunderCLIFFORD_T, andp(pi/2)tos, instead of five gates.Changes:
src/pyqasm/maps/gates.py:phaseshift_gatereturns onerz(theta). This also shortenscsxandrccx, which call it.docs/gate_decompositions.md: updated the Phaseshift section and its source link.p/phaseshift/u1, QASM 2p/u1, Clifford+T rebase ofp(pi/4)/p(pi/2)/phaseshift/u1, and fullcsx/rccxunitaries. Updated the expectations intest_depth.py,test_device_qubits.pyand the_check_phase_shift_gate_ophelper that hardcoded the old three-gate form.CHANGELOG.mdentry.On the global phase: controlled phase gates don't go through this function.
ctrl @ pandcp/cphaseshift/cu1usecphaseshift_gate. Controlled custom gates pass their controls down to each body statement.ctrl @ gphasewith two or more controls becomescp. So the dropped phase stays global. Thecsxandrccxunitaries are checked exactly in the new tests.Test plan
main(12 failures on currentmain, which includes Decompose ccx, id and p when rebasing to ROTATIONAL_CX / CLIFFORD_T #468) and pass with the change.pytest tests: 1033 passed, 3 skipped.modules/base.pythat's already onmain.