Skip to content

✨ Add MQT Core compilation and QIR export - #1027

Draft
simon1hofmann wants to merge 35 commits into
mainfrom
feat/mqt-core-compiler
Draft

simon1hofmann wants to merge 35 commits into
mainfrom
feat/mqt-core-compiler

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Description

Add optional MQT Core compilation with compiler="mqt" or --compiler mqt, plus QIR export as LLVM text or bitcode. Qiskit remains the default compiler; both paths return QuantumCircuit. Native compilation ignores placement and uses the input circuit width. Mapped compilation enforces connectivity, ordered gate placements, and device width.

The mqt extra installs MQT Core 4.1.1 from PyPI and requires Qiskit 2.5.x. Core wheels include the compiler runtime, so wheel installations and the integration CI no longer need a separate LLVM/MLIR setup. Base Bench retains Qiskit 2.1.2 support. uv keeps both dependency selections in one lockfile; the minimums group conflicts with the mqt extra so minimum-version CI cannot silently upgrade to 2.5.

python -m pip install -e ".[mqt]"
mqt-bench --compiler mqt --algorithm ghz --num-qubits 3 \
  --level mapped --target iqm_crystal_5 --save

Core owns gate identity, native aliases, parameter constraints, and synthesis. Native compilation imports CompilerTarget.NativeOperations, retaining bounds independently of hardware placement, then uses the ordinary Core target constructor. Runtime Pauli rotations, single-controlled Pauli rotations, and controlled phase use Core's shared synthesis. IQM compilation benefits from direct two-R synthesis and Z-frame propagation through CZ, with compact symbolic angles and shared Qiskit expression conversion. Native RZ targets also merge Z frames through diagonal entanglers. Constant resynthesis shares Core's local average-fidelity floor of 1 - 1e-12; unbound angles remain exact. Unsupported constraints fail explicitly; there is no fallback transpiler or approximate Clifford+T synthesis. Multi-qubit devices require an entangling capability; one-qubit benchmarks remain supported.

Native targets

  • Add ibm_nighthawk_120 and the shared CZ-based ibm_nighthawk gate set. Its 12-by-10 grid matches all 436 directed edges in IBM Runtime's FakeNighthawk snapshot. IBM's current Nighthawk has 120 programmable qubits; Heron has 156. Nighthawk fractional gates are not advertised. Test mapped compilation for Nighthawk, Heron, and fractional Heron.
  • Add ibm_heron_fractional and ibm_heron_156_fractional, with arbitrary RX and bounded RZZ. Both compilers fold numeric RZZ angles into [0, pi/2] with exact local and phase corrections. Core uses two RZZ(pi/2) gates for unknown runtime angles; bind parameters before Qiskit compilation to enforce the interval. Qiskit uses its existing wrapping pass with local registry copies, preserving the global registry. Fractional models are available with Qiskit 2.2 or newer. Calibration is synthetic.
  • IonQ GPI/GPI2 use radians, standard RZZ replaces the custom ZZ gate, and Forte retains arbitrary virtual RZ. Provider submission must perform any required GPI phase tracking. Core uses fixed-parameter R capabilities; no MS operation or ion-specific IR gates are needed.
  • Rigetti exposes standard RX instances named rxpi, rxpidg, rxpi2, and rxpi2dg, plus RZ/CZ. IonQ and Rigetti optimize through standard Qiskit gates and lower native names with a local equivalence library. Global phase is preserved, including when results are controlled and recompiled. Alias translation preserves angle bounds on other gates; native and mapped regression tests cover bounded RZZ combined with both IonQ and Rigetti aliases.
  • Replace obsolete Aria, Falcon, Eagle, Heron-133, and Braket Ankaa models. Add rigetti_cepheus_107 with explicit physical labels and aqt_ibex_12 using R/RZ/RXX. Keep Forte, Heron-156, IQM architecture models, and Quantinuum H2. Models have documented provenance and calibration limitations; benchmark generation makes no cloud queries.

Compilation and output

Core uses its fixed optimization pipeline; leave opt_level=2. Seed 10 and four mapping trials are the defaults; compiler_options=CompilationOptions(...) overrides them, including for mirror recompilation. Native results retain logical layout metadata; use Operator.from_circuit to interpret them. Mapped results use physical wires and preserve measurement destinations. Qiskit mirror recompilation preserves the original layout. Exports record compiler provenance.

The extra enables qir/llvm text and qir-bitcode output for either compiler, with Base or Adaptive profiles. Parameters must be bound. Export lowers the supplied circuit without another compilation pipeline; execution requires a compatible QIR runtime. The parameter guide, upgrade guide, and target catalogue describe options, migrations, and device evidence. Broader compiler pipeline changes remain deferred.

Validation

  • Rebased on upstream main fcc5b3cb, preserving Python 3.15 support and the mirror fixes.
  • Full suite with the Core 4.1.1 PyPI wheel on Python 3.14: 578 passed, including all 180 Core integration tests and QIR execution. Core adapter coverage is 100%; overall coverage is 99.5%.
  • Minimum-dependency session with Qiskit 2.1.2: 377 passed, 22 skipped. All 20 fractional-angle and native-alias checks also pass on Qiskit 2.2.
  • Core's released compiler API works with the existing adapter. QIR execution tests now import open_device from mqt.core.qdmi.builtin_driver.
  • Repository lint, type checking, documentation with warnings treated as errors, and uv lock validation passed. The documentation Markdown build reuses executed notebooks to avoid concurrent file-writing examples. 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.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • 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.

@codecov

codecov Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.92761% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mqt/bench/targets/gatesets/ibm.py 94.3% 3 Missing ⚠️
src/mqt/bench/targets/gatesets/_compilation.py 98.1% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@simon1hofmann simon1hofmann changed the title ✨ Add MQT Core as an optional compiler ✨ Add MQT Core compilation and QIR export Sep 12, 2026
@simon1hofmann simon1hofmann added feature New feature or request python Pull requests that update Python code mqt.bench Issues that affect mqt.bench labels Sep 17, 2026
@simon1hofmann simon1hofmann self-assigned this Sep 24, 2026
@simon1hofmann
simon1hofmann force-pushed the feat/mqt-core-compiler branch from a51d1ac to 91949dd Compare October 2, 2026 11:21
@burgholzer
burgholzer force-pushed the feat/mqt-core-compiler branch from 91949dd to 68d4f2a Compare October 2, 2026 14:06
@burgholzer burgholzer self-assigned this Oct 2, 2026
@burgholzer
burgholzer force-pushed the feat/mqt-core-compiler branch 3 times, most recently from 93867e1 to 3c3ab51 Compare October 4, 2026 15:09
@simon1hofmann

Copy link
Copy Markdown
Collaborator Author

🤖 AI text below 🤖

[P2] Preserve angle bounds when translating native aliases

In prepare_target(), the temporary target copies instructions without their angle_bounds. When alias translation is needed, this silently removes constraints on other gates and prevents the fractional-angle wrapper from being configured.

Reproduced on 2972a1e84 with Qiskit 2.5.2:

from math import pi
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.circuit.library import RZGate, RZZGate
from qiskit.transpiler import Target
from mqt.bench import get_benchmark_native_gates, get_benchmark_mapped
from mqt.bench.targets.gatesets.ionq import GPIGate, GPI2Gate

target = Target(num_qubits=2)
target.add_instruction(GPIGate(Parameter("gpi")))
target.add_instruction(GPI2Gate(Parameter("gpi2")))
target.add_instruction(RZGate(Parameter("rz")))
target.add_instruction(RZZGate(Parameter("zz")), angle_bounds=[(0, pi / 2)])

source = QuantumCircuit(2)
source.rzz(-0.37, 0, 1)
for compile_circuit in (get_benchmark_native_gates, get_benchmark_mapped):
    result = compile_circuit(source, None, target, compiler="qiskit")
    invalid = [
        item.operation.params
        for item in result.data
        if item.operation.name == "rzz"
        and not target.supported_angle_bound("rzz", item.operation.params)
    ]
    print(invalid)  # [[-0.37]] for both compilation levels

Both outputs preserve the unitary but violate the requested target. Core compilation handles the same input correctly.

Please preserve angle bounds when constructing the temporary target and add a regression test combining native aliases with a bounded entangler, covering both native and mapped compilation.

Assisted-by: GPT-6 via Codex
Assisted-by: GPT-6 via Codex
Assisted-by: GPT-6 via Codex
Include the MQT Core coverage report in the combined CI upload.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Pin Core main plus the controlled-composite fix and expose CompilationOptions
with a fixed seed and mapping trial count, including mirror recompilation.
Remove circuit preprocessing and parameter remapping now handled by Core.

Configure MLIR for CI source builds and cover option forwarding,
reproducibility, and parameter-vector identity.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Use the Core fix that handles composite controls within the existing
decomposition pass and avoids extra single-qubit merging.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

The reusable lint job configures sccache without installing it when stub
checks are disabled, so building Core for ty fails. Run the existing ty hook
in the Core job, which already provides MLIR and builds the dependency.
Require that job whenever either tests or lint are requested.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Pin the integrated Core changes for native trapped-ion gates and generic
fixed RX/RY/RZ capabilities while preserving controlled-composite support.
Restore Rigetti pulse names during target validation and cover symbolic
parameters, native semantics, and rejected target definitions.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Use canonical native definitions so Core preserves numeric and symbolic
pulses through repeated compilation. Omit capabilities wider than the
input circuit at the native-gate level. Pin Core with the matching import
and fixed-parameter compatibility fixes.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Pin the rebased integration branch with the fixed-parameter and native-gate CI tests. Keep the dependency lockfile and documented revision aligned.

Assisted-by: GPT-6 via Codex
simon1hofmann and others added 25 commits October 15, 2026 00:22
Convert provider turns and ZZ names at the Core boundary, preserve physical-wire recompilation, and align fixed-target tests with supported synthesis bases.

Assisted-by: GPT-6 via Codex
Delegate target semantics to Core, preserve virtual RZ, and use standard
fixed RX aliases shared with Qiskit. Replace retired device models with
current Cepheus and AQT snapshots and repair exact native equivalences.

Cover strict constraints, native placement policy, phase, aliases, and
both compiler paths. Resolve documentation warnings.

Assisted-by: GPT-6 via Codex
Use Core 0ceb14003 with canonical ion gates, aliases, and jeff support.
Require an entangling capability for multi-qubit targets, removing the
single-qubit-only device workaround while retaining narrow benchmarks.

Require Qiskit 2.5 to avoid the obsolete post-layout pass path. Document
hardware feedback limits and refresh the dependency lockfile.

Assisted-by: GPT-6 via Codex
Use a conflicting uv minimums group so CI tests Qiskit 2.1.2 while
the optional Core extra retains its 2.5.x native bridge requirement.

Make IonQ and Rigetti equivalence registration idempotent with stable
parameters and copied recipe comparisons. Preserve global phase and
parameter binding across repeated compilation.

Update the Core pin and compatibility documentation.

Assisted-by: GPT-6 via Codex
Use Qiskit's single-qubit circuit constructor for GPI/GPI2 definitions.
Pin Core's matching explicit pulse export signatures.

Assisted-by: GPT-6 via Codex
Compile through a private standard-gate target and a local equivalence
library. Preserve native RX aliases and full phase without changing the
session library, so results remain reusable under control and recompilation.

Reuse the pipeline for mirrors, preserve their complete layout metadata,
and retain logical layout in Core's native compilation results. Pin the
matching Core synthesis update.

Assisted-by: GPT-6 via Codex
Use gate terminology for fixed-angle RX and IonQ operations in source,
tests, and documentation. Describe virtual Z using native gate phases
and reserve pulse terminology for physical control and Qiskit timing.

Update the Core pin to its matching terminology cleanup.

Assisted-by: GPT-6 via Codex
Compile IonQ and Rigetti aliases through standard Qiskit gates and local
phase-correct equivalences. Select supported native capabilities instead
of provider descriptions and leave the session equivalence library alone.

Pin the simplified Core synthesis implementation and retain independent
uv selections for minimum Qiskit and the optional Core integration.

Assisted-by: GPT-6 via Codex
Pin Core's integrated parametric synthesis and check runtime Pauli and
controlled rotations against IonQ, AQT, and Rigetti native targets.
Verify parameter identity, global phase, and native entangler counts.

Assisted-by: GPT-6 via Codex
Use the simplified synthesis capabilities and cost analysis from Core
PR #2578. Validate the optional integration against the exact revision.

Assisted-by: GPT-6 via Codex
Use Core's native Clifford conjugation and shared numerical Euler
synthesis. Keep the optional dependency and uv lockfile on the exact
validated revision.

Assisted-by: GPT-6 via Codex
Pin the optional MQT compiler to the integrated one-qubit fusion work
and the large symbolic-expression import/export fixes from Core #2578.
Refresh the uv lockfile without changing the base Qiskit requirement.

Assisted-by: GPT-6 via Codex
Pin the optional compiler to the audited symbolic synthesis fixes in
Core #2578, including balanced RZ runs, unchanged runtime Euler angles,
and collective input metadata validation. Refresh the uv lockfile.

Assisted-by: GPT-6 via Codex
Expose arbitrary RX and bounded RZZ on the existing Heron models. Use
Qiskit's angle wrapping with local registry copies and retain phase when
folding negative or large angles. Keep these models conditional on Qiskit
2.2 support without raising the base dependency minimum.

Pin Core's equatorial and fractional synthesis update. Import native gate
sets directly through Core while preserving parameter bounds. Cover both
compilers, mapped and native compilation, and safe runtime fallback.

Assisted-by: GPT-6 via Codex
Model the 120-qubit Nighthawk grid from IBM Runtime's device snapshot.
Share Heron's conventional CZ basis and validate mapped compilation for
Nighthawk, Heron, and fractional Heron. Document the model's provenance.

Pin the optional compiler to Core's synthesis CI and IBM mock fixes.

Assisted-by: GPT-6 via Codex
Use the final IBM mock catalogue and QDMI discovery fixes from Core #2578.

Assisted-by: GPT-6 via Codex
Build native compilation targets from NativeOperations and the circuit width.
Keep physical import for mapped compilation. Update fractional-gate tests and
documentation for the supported RZZ(pi/2) endpoint decomposition.

Pin the matching Core revision and refresh uv's lockfile. All 553 tests and
180 optional compiler checks pass against this pin, along with lint and docs.

Assisted-by: GPT-6 via Codex
Use the rebased native-synthesis branch with direct equatorial frame
absorption, commuting RZ cancellation, and shared Qiskit expressions.
Refresh uv's optional-dependency resolution for the exact compiler commit.

Assisted-by: GPT-6 via Codex
Use the native rotation composition and synthesis cleanup from Core #2578.
Retain the separate Qiskit dependency selections in the uv lockfile.

Assisted-by: GPT-6 via Codex
Refresh the optional compiler dependency and uv lockfile to include
inverse-trigonometric evaluation in DDSIM.

Assisted-by: GPT-6 via Codex
Pin the compiler extra to the shared approximation and Z-frame update.
Retain the separate minimum-Qiskit dependency selection in uv.lock.
Preserve the ML-QAE test helpers when rebasing onto upstream main.

Assisted-by: GPT-6 via Codex
Pin the native compiler to its validated tensor-chain cleanup and
numerically stable Euler emission. Refresh the optional dependency lock.

Assisted-by: GPT-6 via Codex
Pin the optional compiler dependency and lock file to the final Core
revision. The exact revision passes all 180 MQT integration tests.

Assisted-by: GPT-6 via Codex
Use the released PyPI wheel and its builtin QDMI driver API. Preserve bounded gates when translating native aliases, retain main’s mirror fixes, and serialize documentation builds that share generated files.

Assisted-by: GPT-6 via Codex
@simon1hofmann
simon1hofmann force-pushed the feat/mqt-core-compiler branch from 2972a1e to 1e1eba6 Compare October 14, 2026 22:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request mqt.bench Issues that affect mqt.bench python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants