[FEATURE] Decompose `p`, `phaseshift` and `u1` as `rz` instead of `h; rx; h`
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #470 di @tonycoder-hub — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start with phaseshift_gate and ONE_QUBIT_ROTATION_MAP in src/pyqasm/maps/gates.py, then read the phaseshift-gate section of docs/gate_decompositions.md and inspect the existing decomposition tests. Verify single-gate unrolling and the CLIFFORD_T rebases for p(pi/4) and p(pi/2). Run the unitary checks for the changed decomposition, including csx and rccx, and confirm they match up to global phase.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Feature Description
unroll decomposes p, phaseshift and u1 into three gates, h; rx(θ); h. A single rz(θ) gives the same gate up to a global phase. The longer form then grows during rebase, because each h expands again:
| Input | Basis | Output on main |
Output for the same gate written as rz |
|---|---|---|---|
p(0.3) q[0]; |
ROTATIONAL_CX |
5 gates: ry(π/2); rx(π); rx(0.3); ry(π/2); rx(π) |
rz(0.3) |
p(pi/4) q[0]; |
CLIFFORD_T |
5 gates: h; h; t; h; h |
t |
p(pi/2) q[0]; |
CLIFFORD_T |
5 gates: h; h; s; h; h |
s |
Reproduction on main at a742796, Python 3.12:
import pyqasm
from pyqasm.elements import BasisSet
src = 'OPENQASM 3.0;\ninclude "stdgates.inc";\nqubit[1] q;\np(pi/4) q[0];\n'
m = pyqasm.loads(src)
m.rebase(BasisSet.CLIFFORD_T)
print(pyqasm.dumps(m)) # h q[0]; h q[0]; t q[0]; h q[0]; h q[0];
OpenQASM 2 programs that use qelib1.inc unroll p and u1 the same way.
The decomposition is phaseshift_gate. ONE_QUBIT_ROTATION_MAP maps u1, U1, phaseshift and p to it. The csx and rccx decompositions also call it seven times in total.
A related point: #468 adds a p rule to rebase. Unroll rewrites a p gate written by the user before rebase sees it, so that rule only applies to the p gates that pyqasm generates itself.
Done when:
- A single
p(θ),phaseshift(θ)oru1(θ)unrolls to one gate. - Under
CLIFFORD_T,p(pi/4)rebases totandp(pi/2)rebases tos. - The unitary of each changed decomposition, including
csxandrccx, still matches the original up to a global phase.
Implementation (Optional)
One option is to make phaseshift_gate emit rz(θ). gate_decompositions.md documents the current form and needs the same update. rz(θ) and p(θ) differ only by a global phase. That should be safe here, because ctrl @ p resolves to cp before this decomposition runs. This reasoning is not verified against the full test suite.
- Lingua principale
- Python
- Stelle
- 29
- Fork
- 33
- Merge medio
- 1g 22h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di qBraid/pyqasm
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement error-handling program-validation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyForse già presa @danielgaskins l’ha presa 17 giorni fa. Apertaenhancement qasm2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
qBraid/pyqasm#447 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASMForse già presa @Jah-yee l’ha presa 25 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
qBraid/pyqasm#438 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostForse già presa @tonycoder-hub l’ha presa 19 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
qBraid/pyqasm#436 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di qBraid/pyqasm
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
NousResearch/hermes-agent#147104 ·
I maintainer di solito rispondono entro 1 giorno
-
[oblt-aw][autodoc] Document new required `shared-org-key` input for `obs-aw-dependency-review`Forse già presa @github-actions l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
bot-triaged module: inductor oncall: pt2 topic: fuzzer triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
getchaintips leaves out the active tip once a header is staged on it, where Core always lists itAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
btclib-org/btclib-node#2158 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
patrick-hudson/put.gd-desktop#979 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno