Skip to content

✨ Support directional compiler-target operation availability - #2285

Merged
burgholzer merged 7 commits into
mainfrom
codex/directional-gate-mapping
Sep 4, 2026
Merged

✨ Support directional compiler-target operation availability#2285
burgholzer merged 7 commits into
mainfrom
codex/directional-gate-mapping

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Adds exact ordered operation applicability to CompilerTarget and uses it to support targets with one-way CX, ECR, and RZX gates.

  • Separates operation applicability from optional calibration data, including unrestricted, explicitly empty, and explicit ordered site tuples.
  • Preserves ordered applicability through QDMI, typed MQT attributes, Python bindings, serialization, mapping, synthesis, and target conformance.
  • Wraps the immutable compiler target in a cached MappingTarget: topology traversal stays bidirectional, while mapping assigns the lower cost to the physical direction supported by the selected entangler.
  • Precomputes directional two-qubit costs in O(E), giving average O(1) lookups in the mapping hot path instead of repeated support scans.
  • Keeps the mapping pass synthesis-free; native synthesis performs any required direction repair and checks the exact emitted direction.
  • Handles symmetric operations by reordering operands only when the reversed physical tuple is the supported one.

Fixes #2132

Verification

  • Core release suites: Compiler 156/156, MQT IR 15/15, Mapping 96/96, and NativeSynthesis 37/37 passed.
  • Python MLIR tests: 49/49 passed.
  • Repository lint, C++ lint, strict documentation build, generated Python stubs, and git diff --check passed.
  • Regression tests cover ambiguous one- and two-qubit sites and maximum valid target site IDs.
  • Benchpress MQT integration: 53/53 passed, including focused one-way CX/ECR applicability and timeout round-trip tests.

AI assistance

Codex implemented, reviewed, and tested the change under explicit user authorization. Human review and acceptance remain required before merge.

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 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 c++ Anything related to C++ code feature New feature or request MLIR Anything related to MLIR python Anything related to Python code labels Aug 31, 2026
@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@MatthiasReumann Would you mind taking at first look here to see if this goes in the right direction?

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.29932% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...QCO/Transforms/NativeSynthesis/TargetSynthesis.cpp 97.0% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp Outdated
Comment thread mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp Outdated
@simon1hofmann
simon1hofmann force-pushed the codex/directional-gate-mapping branch 2 times, most recently from 91f69af to ddc67f1 Compare August 31, 2026 17:55
@mergify mergify Bot added the conflict label Aug 31, 2026
@simon1hofmann simon1hofmann self-assigned this Sep 1, 2026
Comment thread mlir/lib/Dialect/QCO/Transforms/Mapping/Mapping.cpp Outdated
@simon1hofmann
simon1hofmann force-pushed the codex/directional-gate-mapping branch from ddc67f1 to dcddb01 Compare September 3, 2026 17:02
@simon1hofmann
simon1hofmann force-pushed the codex/directional-gate-mapping branch 2 times, most recently from 893d01a to 77eb715 Compare September 3, 2026 17:59
@mergify mergify Bot added the conflict label Sep 3, 2026
@simon1hofmann
simon1hofmann force-pushed the codex/directional-gate-mapping branch from 77eb715 to a2f71f1 Compare September 3, 2026 19:54
Replace the intermediate target-cost helper with a focused mapping wrapper, keep target applicability exact, and make native synthesis direction-aware without partial rewrites. Add focused C++, Python, QDMI, and documentation coverage.

Assisted-by: OpenAI Codex
@simon1hofmann
simon1hofmann force-pushed the codex/directional-gate-mapping branch from a2f71f1 to 33710b4 Compare September 3, 2026 20:10
@mergify mergify Bot removed the conflict label Sep 3, 2026
@burgholzer

Copy link
Copy Markdown
Member

I started an iteration on this already now. Will look at it in more detail tomorrow.

@mergify mergify Bot added the conflict label Sep 4, 2026
Route by adjacency and repair operand direction during native synthesis.
Use one checked staged walk for exact static sites, with branch agreement
and site-preserving loop backedges. Remove the module clone and duplicate
synthesis planning.

Validation: 303 focused tests, strict documentation, and repository lint
pass. Direct whole-file clang-tidy finds no diagnostics in changed source
files. Full C++ lint is blocked by unrelated QIR/QTensor linking; a
locationless binding macro warning remains.

Assisted-by: OpenAI Codex
@mergify mergify Bot removed the conflict label Sep 4, 2026
@burgholzer

Copy link
Copy Markdown
Member

Still working through this one. Feels too large still, even after the simplifications.

Use one list of supported ordered placements with optional calibration.
Empty site tuples mean general applicability; omit unavailable QDMI
operations. Remove duplicate applicability metadata from C++, MLIR,
and Python.

Rewrite gates in reverse order to retain collected site facts without
an action plan or repeated matrix extraction. Keep the shared guard for
unsupported controlled-gate matrix shapes.

Validation: 305 C++ tests, 49 Python tests, regenerated stubs, strict docs,
and repository lint pass. Whole-file C++ lint reports zero findings in
all ten changed sources; its full build remains blocked by unrelated
QIR/QTensor linking.

Assisted-by: OpenAI Codex
Accept plain Python tuples and lists for uncalibrated placements, and
print positional sites in MLIR. Keep explicit SiteTuple values for
calibration.

Use LLVM 23 dense containers and one immutable tuple cache for every
arity. Remove redundant factories and lookup helpers. Fuse runs during
reverse traversal to avoid snapshots and repeated matrix extraction.

Validation: 307 focused C++ tests, 51 Python tests, regenerated stubs,
strict docs, and repository lint pass. Whole-file C++ analysis reports
zero findings across ten changed sources. The full lint build remains
blocked by unrelated QIR/QTensor linking.

Assisted-by: OpenAI Codex
@burgholzer

Copy link
Copy Markdown
Member

@simon1hofmann Alright. I think I simplified this as far as I could. Would you mind checking the current implementation and whether it fulfills all goals you had in mind?

@simon1hofmann

Copy link
Copy Markdown
Contributor Author

@simon1hofmann Alright. I think I simplified this as far as I could. Would you mind checking the current implementation and whether it fulfills all goals you had in mind?

Thanks a lot for the changes, the skipped benchpress test were successful based on this PR 🚀

@coderabbitai

coderabbitai Bot commented Sep 4, 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

Copy link
Copy Markdown
Member

I'll merge this now, given how it seems to resolve the underlying issues 🙌🏼

@burgholzer
burgholzer merged commit c4a5def into main Sep 4, 2026
26 checks passed
@burgholzer
burgholzer deleted the codex/directional-gate-mapping branch September 4, 2026 19:40
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 python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Support directional compiler-target connectivity and operation availability

3 participants