✨ Synthesize two-qubit blocks in the native basis - #2537
Open
burgholzer wants to merge 2 commits into
Open
Conversation
burgholzer
force-pushed
the
codex/initial-placement
branch
from
September 11, 2026 19:57
7337dda to
ab5625d
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
burgholzer
force-pushed
the
codex/initial-placement
branch
from
September 11, 2026 20:30
ab5625d to
a9da95e
Compare
Resynthesize constant two-wire runs in the shared native-synthesis pass, so both target APIs compare blocks with native-preserving individual lowering. Stop cost evaluation once the block is cheaper and retain the existing direction, phase, and numerical reconstruction constraints. Optimize unrestricted targets too, preserve cheaper native operations, and keep standalone target-independent fusion available. Moving fusion after placement trades some long-block CZ compilation time for correct native-basis decisions. Assisted-by: GPT-6 via Codex
burgholzer
force-pushed
the
codex/initial-placement
branch
from
September 11, 2026 21:24
a9da95e to
1f89f27
Compare
Run target-aware fusion before placement in both target pipelines, only when it reduces the two-qubit operation count and native cost. This removes cancelled interactions before routing without expanding compact native blocks. Keep physical-site cost decisions in the later synthesis pass. Cover cancellation with full-unitary equivalence and preserve compact native pairs. Document the early and late synthesis contracts. Assisted-by: GPT-6 via Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Description
Both
compile_for_targetandsynthesize_for_targetnow resynthesize constant two-qubit blocks in the selected native basis while preserving cheaper native operations. For example, non-nativeRZZ(0.3); RXX(0.4)needs two CZ gates together instead of four individually; a native SWAP/RZZ pair stays at two gates when block synthesis would need three. Unrestricted targets also optimize their blocks.Both pipelines reuse the existing fusion implementation at two stages:
Run scanning, Weyl decomposition, phase handling, and emission remain shared. Numerical block failures fall back to individual lowering; the standalone target-independent fusion factory remains available. The selected synthesis basis uses one entangler family and does not search arbitrary native mixtures or calibration costs. No new dependencies or block IR are added.
Validation and measurements
Release CTest: 3,537 passed, with one existing QDMI skip. All 90 Python MLIR tests, whole-file C++ lint, repository lint, and complete executable documentation/internal link checks passed. The final target-synthesis suite passes all 61 tests. Coverage includes full-unitary and phase preservation, pre-routing cancellation, native preservation, reversed connectivity, unrestricted optimization, numerical fallback, and routed measurement results.
Benchpress Small compares upstream main
8d9bcfb03with this change: 42 circuits across four abstract topologies, five alternating samples per version and case (1,680 successful samples). Both builds use GCC 13.3, LLVM/MLIR 23.1.0, the release preset with LTO disabled, CPU 0 affinity, one routing trial, and seed 42. Targets use theid/sx/x/rz/czbasis with measurement, reset, and global phase. Timing includes the compiler pipeline, QC/QCO conversion, cleanup, and OpenQASM export; file import and target construction are excluded.Changes are geometric means of paired ratios, using median compile times; lower is better. Native count improves in 41 cases, ties in 127, and never regresses. Depth improves in 38 of 152 comparable cases and never regresses; structured-control-flow cases have no depth metric. Zero values are excluded only from geometric means. Output hashes and quality metrics are deterministic within each version.
Runtime is broadly unchanged: summed case medians increase 0.86%, and the largest per-case median slowdown is 3.60% (
adder_n10, all-to-all, 17.916 to 18.562 ms). Separate long-block probes preserve full matrices, including phase, and reduce 1,024-gate RZZ/RXX synthesis from 2,048 native entanglers to two. These results cover the stated workloads and settings, not a general speedup or global synthesis optimum. The benchmark drivers, exact build metadata, raw measurements, and PNG/PDF plots remain in the local experiment archive.Codex assisted with implementation, review, validation, and this description.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).