Skip to content

♻️ Generalize MLIR compiler target facts - #2218

Merged
simon1hofmann merged 20 commits into
mainfrom
codex/generalize-compiler-target
Sep 2, 2026
Merged

♻️ Generalize MLIR compiler target facts#2218
simon1hofmann merged 20 commits into
mainfrom
codex/generalize-compiler-target

Conversation

@burgholzer

@burgholzer burgholzer commented Aug 23, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Define a complete, immutable MLIR compiler-target contract before serializing it as a typed MQT dialect attribute.

  • Require connectivity to be all-to-all or an explicit coupling graph.
  • Require native-operation support to be unrestricted or explicitly enumerated.
  • Reject missing or unrepresentable QDMI target facts during target inference.
  • Represent operation arity as an exact width or a positive variadic minimum.
  • Represent gphase as a fixed zero-arity operation and preserve its observable phase effects during native synthesis.
  • Recognize structurally controlled QCO operations through variadic base-gate capabilities.
  • Let the bundled DDSIM device advertise arbitrary positive controls for every canonical standard gate with one or more targets, including multi-target gates, through one exact QDMI 1.3 compatibility marker.
  • Support homogeneous fixed operations above two qubits without treating format-level constructs as compiler-target operations.
  • Use deterministic placement for all-to-all targets and mapping for explicit coupling graphs.
  • Preserve the full nonnegative site-ID domain and cheap shared target snapshots.

The DDSIM custom property is private to MQT Core and can be removed when QDMI standardizes the same operation capability. Controlled aliases such as mcx and mcp remain available to existing adapters but are not enumerated as compiler-target capabilities.

This PR is the bottom layer of the stack. #2323 adds target-aware controlled-operation decomposition, and #2215 adds typed target serialization on top of it. This PR does not add payload capabilities, replaceable-driver work, or a dependency on the QDMI v1.4 development API.

Target synthesis relies on the canonical QCO cleanup pipeline to remove empty control modifiers. Doxygen comments in every C++ file touched by this PR consistently use ///.

Validation

  • Compiler unit tests: 143 passed.
  • Mapping unit tests: 86 passed.
  • Native-synthesis unit tests: 26 passed.
  • DDSIM device tests: 52 passed.
  • Focused Python MLIR and Qiskit translation tests: 279 passed with the bundled superconducting-device catalog selected explicitly.
  • Generated Python stubs are current.
  • The release build passes.
  • Full CTest reached 4,156 passes and one expected skip; its only failure was the obsolete CUSTOM1 unsupported-property probe. The corrected isolated test passes.
  • Sphinx documentation passes with warnings treated as errors.
  • uvx nox -s lint passes.
  • uvx nox -s cpp-lint -- origin/main reports no clang-format or clang-tidy findings.
  • git diff --check passes.
  • An independent final audit found no concrete issues.

All 13 commits were rebased onto current main, signed, and verified. Hosted checks for the new head are pending.

Implementation, validation, and pull-request text were prepared with OpenAI 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.

@burgholzer burgholzer added refactor Anything related to code refactoring c++ Anything related to C++ code python Anything related to Python code MLIR Anything related to MLIR labels Aug 23, 2026
@burgholzer burgholzer self-assigned this Aug 23, 2026
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.76694% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mlir/lib/Compiler/QDMIAdapter.cpp 90.1% 11 Missing ⚠️
mlir/lib/Compiler/Target.cpp 94.7% 9 Missing ⚠️
...QCO/Transforms/NativeSynthesis/TargetSynthesis.cpp 82.3% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@burgholzer burgholzer added this to the MLIR Support milestone Aug 23, 2026

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This one feels close to ready.

Comment thread docs/qdmi/ddsim_device.md Outdated
Comment thread docs/qdmi/ddsim_device.md Outdated
Comment thread mlir/include/mlir/Compiler/Target.h Outdated
Comment thread mlir/include/mlir/Compiler/Target.h Outdated
Comment thread mlir/include/mlir/Compiler/Target.h Outdated
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Important

Approval pending

CodeRabbit has no unresolved comments, but it has not reviewed the latest commit.

Use the checkbox below to review the latest commit. CodeRabbit will approve the changes if it finds no blocking issues.

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@burgholzer
burgholzer force-pushed the codex/generalize-compiler-target branch from 9b961b2 to 8fafa97 Compare August 24, 2026 13:52
@mergify mergify Bot added the conflict label Aug 24, 2026
@burgholzer
burgholzer force-pushed the codex/generalize-compiler-target branch from 8fafa97 to a6f7fd1 Compare August 24, 2026 23:47

@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.

I just had a free minute to go through this, and it looks really clean to me! :shipit:

@simon1hofmann simon1hofmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also looks quite good, just a few comments about the documentation and two concerns flagged by another LLM review run.

Comment thread docs/mlir/target_compilation.md Outdated
Comment thread docs/qdmi/ddsim_device.md Outdated
Comment thread docs/qdmi/ddsim_device.md Outdated
Comment thread test/python/qdmi/test_qdmi.py Outdated
Comment thread mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp Outdated
Comment thread mlir/lib/Compiler/Target.cpp Outdated
@burgholzer

Copy link
Copy Markdown
Member Author

Thanks @denialhaag and @simon1hofmann 🙏🏼
Given how this is at the very bottom of an 11 PR stack, I'd like to only touch this once more and freeze the implementation afterwards. Are there any further comments on the above from your side?
Quick signal would be good. Then I'll kick off the implementation and the rebase.

@simon1hofmann

Copy link
Copy Markdown
Contributor

Thanks @denialhaag and @simon1hofmann 🙏🏼

Given how this is at the very bottom of an 11 PR stack, I'd like to only touch this once more and freeze the implementation afterwards. Are there any further comments on the above from your side?

Quick signal would be good. Then I'll kick off the implementation and the rebase.

Thanks for addressing my comments, I agree with all your answers.

@denialhaag

Copy link
Copy Markdown
Member

Thanks @denialhaag and @simon1hofmann 🙏🏼
Given how this is at the very bottom of an 11 PR stack, I'd like to only touch this once more and freeze the implementation afterwards. Are there any further comments on the above from your side?
Quick signal would be good. Then I'll kick off the implementation and the rebase.

Thanks for addressing my comments, I agree with all your answers.

Go also from my side!

@mergify mergify Bot added the conflict label Aug 26, 2026
@burgholzer
burgholzer force-pushed the codex/generalize-compiler-target branch from a6f7fd1 to fe41d2a Compare September 1, 2026 06:13
@burgholzer burgholzer added fix Fix for something that isn't working and removed conflict labels Sep 1, 2026
@burgholzer
burgholzer force-pushed the codex/generalize-compiler-target branch from fe41d2a to 363f8b5 Compare September 1, 2026 08:44

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Two more things to address here before this can go in.

Comment thread mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp
Comment thread docs/qdmi/ddsim_device.md
@burgholzer

Copy link
Copy Markdown
Member Author

I believe I am happy with this now. Looking forward to what you think @simon1hofmann 😌

@simon1hofmann simon1hofmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks quite clean and I really like the changes here!
I just have two comments that should be checked before this can go in.

Comment thread mlir/lib/Compiler/Target.cpp
Comment thread mlir/lib/Dialect/QCO/Transforms/NativeSynthesis/TargetSynthesis.cpp
@simon1hofmann

Copy link
Copy Markdown
Contributor

@burgholzer I fixed the two open comments and this PR should we ready now.

@burgholzer

Copy link
Copy Markdown
Member Author

@burgholzer I fixed the two open comments and this PR should we ready now.

One (hopefully) last request for changes. Then this can go in 👍🏼

@simon1hofmann
simon1hofmann force-pushed the codex/generalize-compiler-target branch from 9355f74 to 2b887ba Compare September 2, 2026 14:19
burgholzer and others added 19 commits September 2, 2026 18:00
Represent unknown, unrestricted, and explicit connectivity and native-operation facts separately. Use site and arity vocabulary, and make target passes request facts only when needed.

Assisted-by: OpenAI Codex
Keep unavailable QDMI v1.3 properties unknown while preserving the compile-and-execute integration with explicit simulator capabilities.

Assisted-by: OpenAI Codex
Replace ordered sets with the project's LLVM containers and in-place canonicalization.

Assisted-by: OpenAI Codex
Copy public collection views into compact LLVM storage and document the explicit DDSIM synthesis basis used until QDMI v1.4 reports all-to-all connectivity.

Assisted-by: GPT-5.6 Sol via Codex
Avoid topology reconciliation when a single-site program does not need unknown connectivity, preserve the full nonnegative site-ID domain, and document explicit DDSIM capabilities.

Assisted-by: GPT-5.6 Sol via Codex
QDMI 1.3 cannot enumerate the DDSIM all-to-all topology or
homogeneous operation loci compactly. Advertise an exact custom marker
and let the compiler adapter consume it without changing the fail-closed
default for other devices.

Assisted-by: GPT-5.6 Sol via Codex
Parallel Windows CTest workers could delete each other's inputs because
the QIR and invalid-input scripts shared one output directory. Give the
invalid-input test its own scratch path.

Assisted-by: GPT-5.6 Sol via Codex
Keep the generic Python overload checks independent of DDSIM metadata now that CUSTOM1 carries compiler-target facts.

Assisted-by: GPT-5.6 Sol via Codex
Dispatch explicit connectivity to mapping and use deterministic placement for all-to-all or safe unknown-connectivity programs. Reject unknown multi-site placement before mutation.

Keep the QDMI 1.3 DDSIM metadata marker explicitly temporary until QDMI standardizes the equivalent facts.

Assisted-by: GPT-5.6 Sol via Codex
Require complete topology and native-operation facts at target construction instead of propagating unusable unknown states.

Model global phase as fixed zero arity and simulator gate families as positive variadic capabilities. DDSIM reports arbitrary controls through one exact QDMI 1.3 compatibility marker, so compiler support covers every canonical base gate without enumerating controlled aliases.

Assisted-by: GPT-5.6 Sol via Codex
Rely on the QCO cleanup pipeline to canonicalize empty control modifiers before target synthesis. Keep target documentation consistent with the current Doxygen style and query an unused custom-property slot in generic DDSIM tests.

Assisted-by: GPT-5.6 Sol via Codex
Treat variadic X and Z capabilities as CX and CZ support in the gate cache. This keeps synthesis-basis resolution consistent with controlled-operation support.

Assisted-by: GPT-5.6 Sol via Codex
Global-phase normalization can leave an empty control shell beside the lowered phase operation. Remove that shell before target support planning so the standalone synthesis pass accepts P-only targets.

Assisted-by: GPT-5.6 Sol via Codex
Use LLVM early-increment iteration to preserve reverse deletion without manual iterator bookkeeping.

Assisted-by: GPT-5.6 Sol via Codex
Keep an explicit pointer to the previous operation before erasing the current node. Reverse early-increment iteration retains a dangling base iterator after deletion.\n\nAssisted-by: GPT-5.6 Sol via Codex
Adapt the mapping test added on main to the explicit connectivity and native-operation facts required by the generalized compiler target API.\n\nAssisted-by: GPT-5.6 Sol via Codex
@simon1hofmann
simon1hofmann force-pushed the codex/generalize-compiler-target branch from 2b887ba to ba81d4b Compare September 2, 2026 16:04
Adapt the fixed-point test added on main to the explicit connectivity and native-operation facts required by the generalized compiler target API.

Assisted-by: GPT-5.6 Sol via Codex
@simon1hofmann
simon1hofmann merged commit 156921e into main Sep 2, 2026
27 checks passed
@simon1hofmann
simon1hofmann deleted the codex/generalize-compiler-target branch September 2, 2026 17:11
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 fix Fix for something that isn't working MLIR Anything related to MLIR python Anything related to Python code refactor Anything related to code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants