FA-91280 / Quantum circuit simulation / Member archive
Rotation merger lets rz slide past a CNOT target · case 05
rz on qubit 1 before and after cx(0,1) are merged although they do not commute.
Case contract
Input a gate list: ["rz", q, angle] (angle in units of pi as a fraction string), ["x", q], ["h", q], ["cx", c, t]. Scan left to right; a new gate looks back to the last op touching its qubit, except that rz may look past a cx whose control is that qubit. rz merges into a found rz, angles normalized to (-1, 1] and zero rotations dropped; x or h cancels a found identical gate. Return the optimized list with angles as fraction strings.
Why this case matters
Rotation merging and cancellation are the cheapest transpiler wins; commutation or normalization slips change circuit semantics.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: random peephole 7 | [["rz", 1, "-1/2"], ["cx", 2, 0], ["rz", 0, "-1/2"], ["cx", 0, 1], ["rz", 0, "1/2"], ["rz", 2, "1"]] | [["rz", 1, "-1/2"], ["cx", 2, 0], ["cx", 0, 1], ["rz", 2, "1"]] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗