Skip to content

✨ Synthesize native parameterized gate sets - #2578

Merged
burgholzer merged 40 commits into
mainfrom
codex/native-ion-gate-targets
Oct 5, 2026
Merged

burgholzer merged 40 commits into
mainfrom
codex/native-ion-gate-targets

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Compile native parameterized gate sets through existing R and Pauli rotation operations. This builds on #2575 and supplies the compiler support for munich-quantum-toolkit/bench#1027.

Numeric and runtime synthesis share Euler plans and analytical Pauli decompositions. RX/RY/RZ, RXX/RYY/RZX/RZZ, single-controlled Pauli rotations, and controlled phase retain runtime parameters. A two-qubit Pauli rotation needs one unrestricted native entangler or two fixed entanglers, including square-root iSWAP. Commuting symbolic rotations combine before lowering; two independent commuting products share a Clifford-entangler pair, and three products reuse the analytic three-entangler template. Equal diagonal interactions merge across pair boundaries before lowering. Constant resynthesis uses the same average gate fidelity floor of 1 - 1e-12 across direct Pauli, fractional, and fixed-entangler paths. Small nonlocal angles may disappear; this is a per-decomposition bound, not a whole-circuit budget. Unbound angles remain exact. Cost estimation and emission share the decomposition choices.

IQM's R/CZ basis uses at most two R gates per single-qubit unitary. Z frames propagate through diagonal entanglers on both equatorial and native RZ targets, and enter R axes where available; measurement and reset discard their incoming frames. Other boundaries preserve frames and phase. Propagation follows local fusion so merging virtual Z gates does not add physical rotations. Isolated native RZ parameters remain unchanged. RX/RZ targets prefer ZXZ, while fixed RX/RY/R quarter-turn targets emit native gates directly and use available half turns. Same-generator composition shares inverse cancellation and balanced angle sums. Generated phases and rotation terms are normalized before accumulation to preserve small corrections beside large finite angles.

Operation capabilities retain inclusive parameter bounds alongside fixed values. Pauli entanglers covering [0, pi/2] use local corrections for numeric angles; unknown runtime angles use two supported pi/2 rotations. Binding before compilation enables fractional gates directly. Bounds survive target import, MLIR serialization, export, and submission checks. Qiskit's public predicates conservatively identify the supported interval. CompilerTarget.NativeOperations.from_qiskit imports capabilities independently of placement; the ordinary target constructor supplies topology.

Qiskit import/export preserves the radian aliases GPI(phi) = i R(pi, phi) and GPI2(phi) = R(pi/2, phi). They remain fixed-R capabilities inside Core. Targets advertise virtual RZ explicitly; providers own hardware phase tracking. No new ion-specific IR gates, MS operation, or provider dependency is needed. Core's native bridge requires Qiskit 2.5.x. Export preserves used parameter identities, permits unused top-level inputs to disappear, and retains expression-budget and custom-gate formal-parameter checks.

Bundled SC compilation models include mqt.sc.ibm.heron (156 qubits) and mqt.sc.ibm.nighthawk (120 qubits, 12-by-10 grid), using IBM Runtime topology snapshots without calibration data. Fractional Heron is exercised through Qiskit targets because QDMI v1 cannot encode RZZ bounds.

The remaining work from #2649 is integrated, with credit to @simon1hofmann. Target capabilities determine fusion behavior without a separate policy or runtime-entangler field. Classical loads and known branch conditions use a scoped scan before cleanup. Tensor-chain normalization and control-flow scalarization process all eligible slots together; modifier rewrites index wire mappings once. Top-down cleanup avoids repeated scans after value forwarding. Target liveness cleanup runs once after placement. Euler emission uses matrix precision for numerical shortcuts; fixed target capability checks retain their stricter tolerance. Redundant fusion entry points, overlapping tests, and superseded design records have been removed.

Closes #2614.

Validation

  • Local checks pass: 3,925 CTest entries with one existing optional job-ID skip, 985 Python MLIR/Qiskit tests, repository lint, whole-file C++ lint, and generated MLIR documentation. Oracles cover phase, native bounds, wire order, memory invalidation, branch scope, tensor-loop signatures, scalar dominance, and parameter identity.
  • The full frozen comparison reruns 400 smaller and 398 large cases on each revision. All 798 PR cases export and validate; main has 271 validated smaller exports and 267 larger exports. Smaller cases use semantic checks; large cases check native gate and angle conformance only.
  • On common large cases, median synthesis time is 21% lower for IQM, 22% lower for IBM CZ, and 35% lower for IBM CX. Two-qubit counts, two-qubit depth, and physical single-qubit counts never increase. Some QPE/QFT-adder cases retain greater depth excluding RZ, up to 17.3%; that tradeoff predates this round. The symbolic three-CZ Cartan kernel also trades additional local gates for one fewer entangler.
  • Results, plots, raw samples, and reproduction archive. Release LLVM/MLIR 23.1, Qiskit 2.5.2, one pinned CPU, five samples, and all-to-all connectivity. Synthesis timing excludes import/export; routing, calibration fidelity, and hardware execution are outside scope. Hosted CI is reported separately.

Assisted by GPT-6 via Codex.

Checklist

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

If PR contains AI-assisted content:

  • Any agent that created, edited, or submitted GitHub content was explicitly authorized for that scope, as required by our AI Usage Guidelines.
  • Every agent-authored or agent-edited public text body begins with the visible disclosure 🤖 *AI text below* 🤖 (titles are exempt).
  • I have disclosed AI assistance in the PR description.
  • I confirm that I have personally reviewed and understood all AI-generated content, and accept full responsibility for it.

@simon1hofmann simon1hofmann added feature New feature or request c++ Anything related to C++ code python Anything related to Python code MLIR Anything related to MLIR QIR Anything related to QIR OpenQASM Anything related to OpenQASM labels Sep 18, 2026
@simon1hofmann
simon1hofmann added this pull request to stack #2579 September 18, 2026 10:43
@simon1hofmann simon1hofmann self-assigned this Sep 18, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/native-ion-gate-targets branch 3 times, most recently from b645256 to b0e5e64 Compare September 21, 2026 12:28
@simon1hofmann
simon1hofmann force-pushed the codex/native-ion-gate-targets branch from b0e5e64 to 3882f97 Compare September 21, 2026 13:36
@simon1hofmann
simon1hofmann marked this pull request as ready for review September 21, 2026 15:01
@simon1hofmann
simon1hofmann removed this pull request from stack #2579 September 25, 2026 11:47
@simon1hofmann
simon1hofmann changed the base branch from codex/fixed-parameter-targets to main September 25, 2026 11:47
@simon1hofmann
simon1hofmann changed the base branch from main to codex/fixed-parameter-targets September 25, 2026 11:47
@simon1hofmann
simon1hofmann added this pull request to stack #2628 September 25, 2026 11:47
@simon1hofmann
simon1hofmann force-pushed the codex/native-ion-gate-targets branch from 6e9c79b to a98fa36 Compare September 25, 2026 11:49
@simon1hofmann
simon1hofmann force-pushed the codex/native-ion-gate-targets branch 2 times, most recently from 4b5c952 to 8a98480 Compare September 29, 2026 08:54
@simon1hofmann
simon1hofmann force-pushed the codex/native-ion-gate-targets branch 3 times, most recently from 997d943 to 999ab53 Compare September 29, 2026 12:08
Share angle cancellation and bounded sums across single- and two-qubit
rotations. Combine commuting symbolic Pauli generators through native
Clifford frames, preserve generated phases at large finite angles, and
remove unobservable measurement frames. Shorten native half turns.

Reuse target capability checks, remove a redundant fusion entry point,
permit erased top-level Qiskit inputs, and trim overlapping tests and
superseded design records. Keep constant-led runs with numerical fusion.

Assisted-by: GPT-6 via Codex
Use the existing MLIR evaluator for asin, atan, and atan2 produced by
symbolic compilation. This fixes QASM3 submission of controlled
fractional powers. Cover signed zero and atan2 quadrants in the scalar
evaluation test.

Check commuting Pauli composition with full matrices, reversed native
placements, phase corrections, and bounded RZZ angles in the C++ suite.
These paths were previously exercised only by Python integration tests.

Assisted-by: GPT-6 via Codex
@burgholzer

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

The latest synthesis evaluation compares upstream main 32f1b3314 with the implementation published in a5c029272. Measurements were taken on 2026-10-03. Current PR head a00a2d8c0 adds the DD evaluator fix and tests; synthesis is unchanged. These are the measured results, not a rerun of the later commit.

400/400 circuit/target combinations produce validated native exports, versus 271/400 on main. Main cannot represent the bounded IBM contract, cannot synthesize the fixed-R IonQ contract or some symbolic Pauli cases, and has one export failure. Unsupported cases are excluded from ratios.

The corpus contains 24 Core benchmarks—GHZ, QFT, W state, QPE, Grover, multiplexer, QFT adder, and Bernstein–Vazirani at three sizes—plus 18 scalable numeric/symbolic kernels and eight identity microcases. Eight native contracts cover IQM, IBM, IonQ, Rigetti, and an exploratory fixed-RX/iSWAP basis. The latter is not a claim about an online Rigetti device. IBM fractional RX is unrestricted in the tested contract; RZZ is bounded to [0, π/2].

For each jointly supported target below, the median uses the same 39 paired Core/scalable cases, excluding microcases. Ratios are PR / main; lower is better.

Native contract Native 1Q gates Native 2Q gates Synthesis time Export time
IQM R/CZ 0.333 1.000 0.947 0.638
IBM SX/X/RZ + CX 0.818 1.000 0.876 0.823
IBM SX/X/RZ + CZ 0.883 1.000 0.973 0.912
RX/RZ + unrestricted RZZ 0.532 1.000 0.957 0.750
Rigetti fixed RX/RZ + CZ 0.881 1.000 0.964 0.903
Fixed RX/RZ + iSWAP (exploratory) 0.687 1.000 0.973 0.740

Paired native-gate quality and synthesis runtime

Some representative results:

Workload and target Main PR
IQM QFT-16: R gates 2,204 263
IQM QFT-16: synthesis 14.13 ms 13.25 ms
IQM symbolic EfficientSU2-16: R gates 496 176
IQM symbolic EfficientSU2-16: synthesis 24.32 ms 7.81 ms
Unrestricted RZZ QFT-16: 2Q gates 240 120
Unrestricted RZZ QFT-16: synthesis 11.72 ms 8.98 ms
IBM fractional QFT-16: RZZ gates Unsupported contract 120
IBM fractional QFT-16: synthesis Unsupported contract 10.11 ms

On all 271 jointly validated cases, total native one- and two-qubit gate counts never increase. There are tradeoffs: numeric IQM W-state/Pauli-layer workloads take up to about 20% longer while using roughly two-thirds fewer R gates. Seven total circuit depths increase; the largest non-micro increase is QPE-16 on CZ targets, 1,108 → 1,210 (+9.2%). Two-qubit depth never increases. Non-RZ one-qubit count increases in one exploratory iSWAP case, 98 → 99, while its total one-qubit count falls.

Algorithm-level quality and runtime graphs

Native one-qubit counts by algorithm

Native two-qubit counts by algorithm

Synthesis runtime by algorithm

Absolute results and supported workloads, including fractional IBM and IonQ

Absolute representative results

Validated native export coverage

Measurements use Release LLVM/MLIR 23.1 builds, Python 3.14.7, Qiskit 2.5.2, and NumPy 2.5.3 on DGX Spark arm64: one pinned CPU, one thread, one warm-up, and five timed repetitions. Targets have all-to-all connectivity to isolate synthesis. Import, cloning, export, and validation are outside synthesis timing. These results do not measure routing or hardware fidelity; timing differences of a few percent should not be overinterpreted.

Validation uses full complex matrices for small synthetic circuits, sampled statevectors for larger circuits, three symbolic bindings, and 512 seeded DD shots against Core benchmark reference distributions. Maximum matrix/state error is 1.49e-14. Sampled checks are weaker than full-unitary equivalence.

CI follow-up: all required hosted checks now pass at a00a2d8c0; C++ patch coverage is 92.2% against a 90% target. Local validation includes 1,906 Python tests, 336 affected C++ tests, and 180 Bench integration tests.

Raw measurements · Figure/data index · Reproduction bundle, including frozen inputs, scripts, samples, native IR, metadata, and PNG/PDF/SVG figures

burgholzer added a commit that referenced this pull request Oct 4, 2026
Record the 24–156-qubit comparison, approximation diagnostics, pass
profiles, and reproduction artifacts for PR #2578.

Assisted-by: GPT-6 via Codex
@burgholzer

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Repeated the earlier evaluation at 24, 36, 54, 104, and 156 qubits. IQM, IonQ, and fixed-RX/CZ contracts stop at 54; IBM and unrestricted RX/RZ/RZZ extend to 156. The 68 frozen inputs give 398 circuit/target combinations per revision.

PR: 398/398 native exports pass gate/angle checks. Main: 267/398. No compilation timeouts. Main has 68 unsupported bounded contracts and 63 synthesis failures. These are native-conformance checks, not full-width equivalence proofs.

Workload Main synthesis PR synthesis Quality / scaling
IQM symbolic EfficientSU2, 54 qubits 219.41 ms 30.61 ms 7.2× faster; 1Q gates 1,674 → 594
IBM CZ symbolic EfficientSU2, 156 qubits 2,006.61 ms 147.20 ms 13.6× faster; 2Q gates remain 468
IQM numeric Pauli layers, 54 qubits 27.60 ms 33.13 ms 20% slower; 1Q gates 2,036 → 727
IQM Grover, 54 qubits 2,272.55 ms 2,290.55 ms Similar runtime; 1Q gates 196,070 → 27,720
IQM QFT, 54 qubits 159.30 ms 183.80 ms 2Q gates 1,672 → 2,820
IBM CZ QFT, 156 qubits 1,298.87 ms 1,736.68 ms 2Q gates 5,548 → 12,408
IBM fractional QFT, 156 qubits Unsupported 1,278.92 ms 6,204 bounded RZZ gates
IBM fractional symbolic Pauli layers, 156 qubits Unsupported 117.87 ms 936 entanglers; bound checks pass

IQM large-circuit scaling

IBM CZ large-circuit scaling

The larger instances expose three priorities:

  1. Align approximation semantics. Main's numeric Weyl path drops entanglers for CP(pi/2^20), with maximum complex-matrix error 7.49e-7. The PR's direct Pauli path retains two CZ gates, with error 4.74e-16, and retains much smaller rotations. This explains the QFT gate-count growth: the two implementations make different accuracy choices. Across all 267 paired successful cases, 59 have more 2Q gates on the PR. A shared, explicit approximation policy should precede gate-count comparisons; silently discarding more angles would hide the issue.
  2. Extend diagonal-frame merging to native RZ/CZ bases. A separate IBM probe alternating RZ on one wire with CZ to distinct neighbors retains 155 RZ instructions at 156 qubits; one RZ suffices. The three-qubit identity is verified by full matrices. The existing frame implementation is currently invoked for the equatorial basis. Reusing its commuting-frame logic for native RZ/CZ could reduce instructions and compiler/export work. RZ is virtual; this is not a corresponding claim about physical gate duration. Full-QFT savings from this change are not yet measured.
  3. Profile cleanup as well as decomposition. On IBM CZ QFT-156, native synthesis takes about 31% of pass-manager time, inliner/nested canonicalization 31%, dead-value analysis 10%, and CSE 10%. For fractional QFT-156, native synthesis is only 17%, versus 44% for inliner/nested cleanup. IQM Grover-54 remains dominated by native synthesis (53%). These measurements support narrowing or combining repeated IR traversals, not removing correctness checks.

The metadata-verification optimization is worth keeping. It explains much of the symbolic speedup. A SymbolDCE-only diagnostic leaves the 1,248-parameter IR unchanged but takes 106.0 ms on main versus 4.16 ms on the PR. Main repeats quadratic cross-argument checks during verification; the PR consolidates them. Symbolic EfficientSU2-156 export also improves from 257.1 to 48.5 ms.

Unused device capacity is not a material bottleneck in these probes: a 24-qubit circuit takes 11.73/11.69 ms on 24-/54-qubit IQM targets, and 13.97/14.16 ms on 24-/156-qubit IBM targets. Peak worker RSS is 848 MiB main / 811 MiB PR, including Python, compilation, export, and validation.

Gate counts, approximation diagnostics, pass profiles, and export scaling

Native gate counts at the largest widths

Exact two-qubit small-angle comparison

Compiler pass profiles

Symbolic synthesis and export times

The baseline remains 32f1b3314; the measured PR synthesis implementation is a5c029272. Current head a00a2d8c0 changes DD evaluation/tests, not synthesis. This repeat uses the same Release compiler binaries, DGX Spark CPU 5, one thread, one warm-up, and five samples. Graph bands show sample min–max. Import, cloning, export, and validation are outside synthesis timing. Targets are all-to-all: routing and hardware fidelity are excluded. Grover uses two iterations and stops at 54 because Core's generator caps it at 62 qubits.

Every export is checked against native aliases, arity, fixed parameters, and bounds; symbolic circuits use three bindings. Eight additional wide DD sampling checks pass, while two 30-second simulation checks time out (IBM CZ QPE-156 and fractional QFT-adder-156). Both compile successfully. No full-width equivalence proof is claimed.

Full report and source locations · Raw measurements · Method and reproduction instructions · Reproduction bundle with frozen inputs, raw samples, diagnostics, and PNG/PDF/SVG figures

Use the Weyl fidelity floor across direct Pauli and numeric native
synthesis. Merge Z frames on native RZ targets after local fusion,
without expanding physical rotations or isolated parameter expressions.
Keep the shared constant cache informed of every rewrite.

Let module cleanup own canonicalization and dead symbols after inlining.

Assisted-by: GPT-6 via Codex
Small interactions may now be approximated away. Check the shared
fidelity floor, phase, and removal of negligible entanglers instead
of requiring exact preservation. Fold the small-angle cases into the
existing boundary test.

Assisted-by: GPT-6 via Codex
@burgholzer

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Implemented in cdf609911, with the approximation-test update in 9fcefeeac. Bench #1027 is rebased on its latest main and pins the measured synthesis implementation.

  • Direct Pauli and numerical synthesis share the existing 1 - 1e-12 average-fidelity floor. Small constant nonlocal angles can disappear; runtime angles remain exact. The bound applies per decomposition.
  • The existing frame propagation also merges native RZ through diagonal entanglers. It runs after local fusion to preserve physical-gate quality and leaves isolated RZ expressions unchanged.
  • Module cleanup owns canonicalization and dead symbols after inlining. The redundant callable cleanup is disabled; required dead-value analysis remains.

Repeated the frozen 24–156-qubit experiment: 398/398 native exports pass their gate and angle checks, versus 267 on main. Across the seven targets, median per-case synthesis times are 5–9% lower than the previous PR in this run.

Circuit / target Previous 1Q / 2Q gates Updated 1Q / 2Q gates Synthesis, previous → updated
QFT-54 / IQM 2,886 / 2,820 1,752 / 1,672 184 → 145 ms
QFT-156 / IBM CZ 67,587 / 12,408 19,458 / 5,548 1,737 → 1,171 ms
QFT-156 / IBM fractional 12,811 / 6,204 621 / 2,774 1,279 → 1,005 ms
Symbolic SU2-156 / IBM CZ 4,830 / 468 4,362 / 468 147 → 116 ms

Synthesis runtime scaling

Native gate counts, with virtual RZ separated

Two-qubit counts and two-qubit depth never increase versus the previous PR. Small regressions remain: total 1Q counts increase in 12 cases (at most 1.3%), non-RZ 1Q counts in 38 (at most 4%, from 25 to 26), and total depth in 21 (at most 2.3%). The report includes every case and timing ratio.

Pass profiles show the remaining costs: module canonicalization and dead-value analysis account for about one third and one sixth of QFT-156 pass time. Native synthesis accounts for about half of Grover-54 pass time. Broader pipeline and exporter changes remain follow-up work. Angle probes confirm the shared cutoff, and the 156-qubit CZ-star probe reduces 155 RZ gates to one.

Validation: the complete local C++ suite has 3,922 passes and one existing skip; 791 Python MLIR/Qiskit tests and 400 smaller semantic/export cases pass. Bench passes 180 optional compiler tests and 269 benchmark tests. Repository lint and whole-file C++ lint pass. The two failing CI tests with stale exact-preservation assertions were consolidated into fidelity, phase, and zero-entangler checks; the new CI run is pending.

Measurements use Release LLVM/MLIR 23.1, Qiskit 2.5.2, one pinned CPU, five timed samples, and all-to-all targets. Main was measured during this evaluation; previous-PR samples are historical. Contended runs were discarded, and three pairs with over 30% sample spread were repeated on both compilers. Large-width checks establish native conformance, not full semantic equivalence. Routing, calibration, and hardware execution are excluded.

Full report · Methods and provenance · Raw results · Reproduction bundle

Forward repeated tensor slots in one chain rewrite instead of repeatedly
commuting inserts past extracts. Defer target liveness cleanup until after
placement, while retaining it in standalone QCO cleanup.

Use matrix precision for Euler shortcuts so reconstruction roundoff does
not introduce extra native gates. Fixed target angle checks are unchanged.

Assisted-by: GPT-6 via Codex
@burgholzer

burgholzer commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Implemented the cleanup and numerical fixes in 021036520, followed by the CI-only style fix 294901223. munich-quantum-toolkit/bench#1027 pins the final revision. Measurements below use the behavior-identical implementation commit.

The easy gate regressions came from matrix-reconstruction roundoff, not virtual-RZ accounting. Euler emission now uses matrix precision while fixed target capability checks remain unchanged. For example, W-36 / IBM CX drops from 181 to 175 SX gates. Multiplexer-24 keeps the eight-CX saving and returns to 25 SX gates.

The main canonicalization hotspot was repeated tensor insert/extract shuffling: QFT-156 needed 24,178 chain rewrites and 1.29 million extract-fold attempts. The existing pattern now normalizes that chain in one rewrite. Target compilation runs dead-value analysis once, after placement. Iteration caps stay unchanged: the expensive work happened inside the worklist, and control-flow cleanup still needs convergence.

Fresh paired timings, five samples after warm-up:

Workload Previous → updated synthesis
IQM QFT-54 137.7 → 115.0 ms
IBM CZ QFT-156 1163.0 → 831.1 ms
IBM fractional QFT-156 1010.2 → 671.4 ms
Symbolic SU2-156 / IBM CZ 117.3 → 83.8 ms

Grover is essentially unchanged; its retained late liveness pass and native synthesis dominate. The report includes all ten paired cases and pass profiles.

Synthesis timings

Cleanup pass timings

All 398 large cases pass native conformance. These fixes reduce physical 1Q counts in 40 cases, increase no gate counts, and preserve all 2Q depths. Three total depths increase by one. Relative to the older pre-refinement measurements, a few symbolic SU2 cases still use three extra physical rotations; removing RZ from the depth metric does not eliminate that difference. The report separates those local-decomposition trade-offs from numerical variation.

Validation: 3,922 C++ tests passed with one existing skip; 791 Python integration tests and 400 smaller semantic/export checks passed. Repository and whole-file C++ lint passed. Bench passes 180 optional-integration tests, 269 benchmark tests, lint, and lock validation. Large-width native conformance is not a full semantic-equivalence proof; timings exclude routing and hardware execution.

Make the graph-region pointer check explicit and add the required
initializer trailing comma. Whole-file lint covers the complete cleanup
commit, including the newly changed tensor and pipeline files.

Assisted-by: GPT-6 via Codex
Reuse the analytic three-entangler template for symbolic Cartan triples and
merge equal diagonal interactions across pair boundaries before lowering.

Move classical load and condition propagation into one scoped walk. Batch
control-flow tensor scalarization, index modifier wire mappings once, and
visit definitions before users during cleanup to avoid repeated scans.

Validate phase, native bounds, wire order, classical invalidation, and loop
signatures. Repeat the complete frozen small and large benchmark suites
against upstream main; keep experiment artifacts outside the source PR.

Assisted-by: GPT-6 via Codex
@burgholzer

burgholzer commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Implemented in c9123b1: three-entangler symbolic Cartan synthesis, diagonal merging across pair boundaries, scoped classical simplification, batched tensor scalarization, indexed modifier mappings, and top-down cleanup.

Repeated the complete frozen suite against main 32f1b3314: 400 smaller + 398 large cases on each revision, five timed samples per case. All 798 PR cases export and validate; main has 538 validated exports. Large-width validation checks native gates and bounds, not full-circuit equivalence. Timing excludes parsing/export and routing.

On common large cases, median synthesis time is 21% lower for IQM, 22% lower for IBM CZ, and 35% lower for IBM CX. Two-qubit count, two-qubit depth, and single-qubit count excluding RZ never increase. The existing depth tradeoff remains: some QPE/QFT-adder cases have greater depth excluding RZ, up to 17.3%; all large-case counts and depths match the previous PR evaluation.

The new symbolic Cartan witness uses three rather than four fixed entanglers. On IQM this trades four additional R gates for one fewer CZ. The diagonal inverse witness falls from six to two CZ gates. Cleanup stress tests improve by 5.7×–70×; those are microbenchmark results, separate from synthesis timings.

Local validation: 3,925 CTest entries with one existing optional skip, 985 Python tests, repository and whole-file C++ lint, and generated MLIR documentation. Final lint-only edits were rebuilt and retested; the archive retains the exact measured patch and final source patch. Hosted CI is separate.

Full report, plots, raw samples, and reproduction archive.

Synthesis runtime

Native gate counts and depth excluding RZ

Canonicalization scaling

Counting all single-qubit gates, including RZ: the following plots give every gate unit weight. They reuse the same measurements. Total one-qubit count never increases across the 538 common cases. Depth including RZ never increases in the large suite; one small Rigetti RX/iSWAP case (pauli_merge_numeric) increases from 10 to 12. Depth is structural, excludes measurement/reset/barrier/delay, and does not represent device execution time.

Native gate counts and depth including RZ

Gate counts including RZ at 54 and 156 qubits

@burgholzer

Copy link
Copy Markdown
Member

@simon1hofmann @denialhaag
Alright. I took this for quite a spin over the last few days. This has turned into quite a large PR that touches very large parts of the synthesis code.
I steered the agents quite a bit along the process and very regularly reviewed the changes.

I believe the results pretty much speak for themselves. The code can now properly handle many cases of symbolic synthesis and is much more optimized to trim down the number of single-qubit gates, while at the same time being >20% faster.
The speed increases also has to do with a few improvements on canonicalizations and the overall pipeline.

@simon1hofmann maybe you could run this through benchpress and compare with your latest results/4.0.

Other than that, I do not think this needs an in-depth review given the extensive amount of iteration I did on this. However, it certainly can't hurt, if the two of you have a quick look.

I also made sure to update the MQT Bench PR in tandem with this PR so that we have all the right features to support the IonQ gateset, the AQT gateset, as well as the latest IBM architectures. I've come to the conclusion that it likely makes sense to refresh the available architectures in MQT Bench to reflect current architectures. I believe there is little use in maintaining architectures that are no longer in use.
Perspectively, we'll likely want to hook up all the QDMI devices we have to the live hosted version so that people get access to "real" machines. As a starter, For the Python package, I believe we should enable hooking up QDMI devices as targets. But that's likely a next-next step.

I also tried very hard to avoid adding new gates here when we already have gates that can express the respective functionality with fixed angles.

Fractional gates by IBM also add the first case of gates that have a limited angle domain. I am not quite sure yet the overall design for that is perfect (and it definitely cannot be communicated through QDMI at the moment), but I iterated on it quite a bit and it seems to be working.

I am pretty much done with this for now.
Let me know what you think! 💭

@denialhaag denialhaag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool to see these improvements! Thanks a lot, @burgholzer and @simon1hofmann! 🙂

I took some time to scroll through the changes and left a comment whenever something caught my eye. Most of the comments are inspiration for follow-up PRs. None of them are dealbrakers. Let me know what you think!

Comment thread bindings/mlir/register_mlir.cpp
Comment thread docs/qdmi/sc_device.md Outdated
Comment thread mlir/include/mqt/Dialect/MQT/IR/MQTDialect.td Outdated
Comment thread mlir/include/mqt/Dialect/MQT/Transforms/GlobalPhaseNormalization.h
Comment thread mlir/include/mqt/Dialect/QCO/Transforms/Decomposition/Pauli.h
Comment thread mlir/lib/Dialect/QC/IR/Modifiers/CtrlOp.cpp
Comment thread mlir/lib/Dialect/QCO/Transforms/Decomposition/Euler.cpp
Comment thread mlir/lib/Dialect/QCO/Transforms/Decomposition/Pauli.cpp
Comment thread mlir/lib/Dialect/QTensor/IR/QTensorCanonicalization.cpp Outdated
simon1hofmann added a commit that referenced this pull request Oct 5, 2026
Compare Core 4.0.0, main da01e39, and PR #2578 at c9123b1. Preserve the shared metric subset and slow-case timing caveat.

Assisted-by: OpenAI Codex
@simon1hofmann

Copy link
Copy Markdown
Contributor Author

🤖 AI text below 🤖

Ran the full QASMBench medium suite through Benchpress with Core 4.0.0, main da01e3991, and this PR at c9123b11e: 23 circuits × four topologies per version. All 276 cases passed, with no failures, skips, or timeouts.

QASMBench medium: Core 4.0.0, main, and PR #2578

The figure uses all 92 cases for outcomes and the same 88 nonconditional cases for both timing and CZ bars. The four cc_n12 cases passed but have no comparable CZ count in these results.

Version Passed Geomean compilation time Total CZ gates
Core 4.0.0 92/92 43.93 ms 3,782,358
Core main 92/92 46.52 ms 3,287,002
PR #2578 92/92 44.51 ms 3,283,745

PR #2578 versus main

  • 1Q gates: lower in all 92 cases, counting RZ as a gate. The geometric mean of per-case count ratios is 0.657 (34.3% fewer); the total count is 40.6% lower.
  • CZ count and depth: unchanged in 86 of the 88 comparable cases and lower in two; no increases observed.
  • Compilation time: lower in 73/92 cases. Across all 92 cases, the geometric-mean time ratio is 0.963 (3.7% lower). On the figure’s 88-case subset, it is 0.957 (4.3% lower).

There is a slow-case regression in this run: summing the per-case median compilation times gives 673.07 s on main versus 721.26 s on the PR (+7.2%), primarily from factor247_n15:

Topology Main PR #2578 Change
All-to-all 106.15 s 118.45 s +11.6%
Square 119.76 s 137.65 s +14.9%
Heavy-hex 127.40 s 134.69 s +5.7%
Linear 114.81 s 126.65 s +10.3%

These slow cases used one timed round, so the regression needs repeated measurements before attributing it to a particular change. This is a full compilation-pipeline measurement, including mapping/routing, not the synthesis-only workload in the earlier reports.

Method and limits

  • Apple M1 Pro, 10 logical CPUs; Python 3.14.3 and Qiskit 2.5.2. Sequential runs with frozen benchmark inputs and compiler defaults; no fixed seed.
  • Main and the PR use matched Release builds with AppleClang and LLVM/MLIR 23.1.0. Core 4.0.0 uses the published wheel, so its timing comparison also includes build differences.
  • Topologies: all-to-all, square, heavy-hex, linear. Target basis: id, sx, x, rz, cz, plus measurement/reset. The Core 4.0 target-construction compatibility path runs outside the timer and was checked against the current target contracts.
  • Timed: input copying, QC-to-QCO lowering, and native target compilation. Parsing, target setup, export, and output validation are outside the timer.
  • Five rounds, one iteration per round, no calibration/warmup; one round for bwt_n21 and factor247_n15. A 600 s watchdog covers each whole case.
  • Benchpress output validation is not a full circuit-equivalence proof. Small timing differences and the two improved CZ results should not be read as statistically established improvements, especially with default, unseeded mapping.

Figure and per-case comparison data

@burgholzer

Copy link
Copy Markdown
Member

@simon1hofmann looks convincing to me.
35-40% fewer single-qubit gates at the same or lower two-qubit gates is quite something.

I'd run one more Codex iteration based on Daniel's comments, creating follow-ups where reasonable, and then likely merge the PR.
Does that sound reasonable?

@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@simon1hofmann looks convincing to me. 35-40% fewer single-qubit gates at the same or lower two-qubit gates is quite something.

I'd run one more Codex iteration based on Daniel's comments, creating follow-ups where reasonable, and then likely merge the PR. Does that sound reasonable?

Sounds good to me. I will also run another sanity check in my session I originally used to work on the core and bench PR :)

@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@simon1hofmann looks convincing to me. 35-40% fewer single-qubit gates at the same or lower two-qubit gates is quite something.
I'd run one more Codex iteration based on Daniel's comments, creating follow-ups where reasonable, and then likely merge the PR. Does that sound reasonable?

Sounds good to me. I will also run another sanity check in my session I originally used to work on the core and bench PR :)

Found nothing in the core PR, just one concern in MQT Bench that I posted there: munich-quantum-toolkit/bench#1027 (comment)

@burgholzer

Copy link
Copy Markdown
Member

Found nothing in the core PR, just one concern in MQT Bench that I posted there: munich-quantum-toolkit/bench#1027 (comment)

Nice. That sounds isolated enough so that it can be fixed locally in Bench. I'll kick off my run here, and if nothing big comes up, merge :shipit:

Clarify API summaries, native-attribute documentation, and rotation formulas.
Keep modifier helpers inside their namespace and name the classical control
simplifier for its scope. Document bounded queries and Pauli return arity.

Broader follow-ups are tracked in #2671, #2672, #2673, #2674, and #2675.

Assisted-by: GPT-6 via Codex
@burgholzer

Copy link
Copy Markdown
Member

4bc6bde contains the easy fixes. Follow-ups have been created. Let's get this merge once CI is green :shipit:

@burgholzer
burgholzer merged commit 726c1ad into main Oct 5, 2026
27 checks passed
@burgholzer
burgholzer deleted the codex/native-ion-gate-targets branch October 5, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Anything related to C++ code feature New feature or request MLIR Anything related to MLIR OpenQASM Anything related to OpenQASM python Anything related to Python code QIR Anything related to QIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🧹 Unify one-qubit synthesis and clarify test ownership

4 participants