Skip to content

♻️ Define target compilation with payload specifications - #2219

Open
burgholzer wants to merge 1 commit into
codex/payload-execution-environmentfrom
codex/selected-payload-environment
Open

♻️ Define target compilation with payload specifications#2219
burgholzer wants to merge 1 commit into
codex/payload-execution-environmentfrom
codex/selected-payload-environment

Conversation

@burgholzer

@burgholzer burgholzer commented Aug 23, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Make the selected hardware target and payload specification the single source of truth for target compilation.

This pull request:

  • adds a validated PayloadSpecification with an exact PayloadFormat, capabilities, and typed constraints;
  • pairs the hardware target and payload specification in one context-free TargetEnvironment;
  • materializes that pair as the typed mqt.target_env module attribute;
  • caches the reconstructed target environment through the MLIR analysis manager and invalidates it when the attribute changes;
  • makes mapping, native synthesis, and conformance consume the cached target environment;
  • derives targeted compiler output from the selected payload format in C++, Python, and mqt-cc; and
  • keeps untargeted compilation independent through its existing explicit output selection.

This PR is stacked on #2215. The focused child PRs #2226 and #2227 connect QDMI v1.4 program formats and feature records to this provider-neutral compiler interface before #2220.

Validation

  • Compiler tests: 137/137 passed.
  • Mapping tests: 84/84 passed.
  • Native-synthesis tests: 25/25 passed.
  • MQT IR tests: 16/16 passed.
  • mqt-cc QIR output test: passed.
  • Focused Python compiler, QDMI, and Qiskit tests: 471/471 passed.
  • Stub regeneration: passed.
  • MLIR documentation build: passed.
  • uvx nox --non-interactive -s lint: passed.
  • git diff --check: passed.

AI assistance: OpenAI Codex assisted with implementation, review, testing, and this description.

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 feature New feature or request c++ Anything related to C++ code python Anything related to Python code MLIR Anything related to MLIR QDMI Anything related to QDMI labels Aug 23, 2026
@burgholzer burgholzer self-assigned this Aug 23, 2026
@burgholzer
burgholzer force-pushed the codex/selected-payload-environment branch from b53e303 to c62e088 Compare August 23, 2026 19:10
@codecov

codecov Bot commented Aug 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.00346% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mlir/lib/Compiler/TargetEnvironment.cpp 92.0% 13 Missing ⚠️
mlir/tools/mqt-cc/mqt-cc.cpp 77.1% 13 Missing ⚠️

📢 Thoughts on this report? Let us know!

@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 will likely still need a bit of work to iron out the details.

Comment thread .agent/plans/selected-payload-target-environment.md
Comment thread .agent/plans/selected-payload-target-environment.md
Comment thread .agent/plans/selected-payload-target-environment.md Outdated
Comment thread bindings/mlir/register_mlir.cpp
Comment thread docs/mlir/target_compilation.md Outdated
@mergify mergify Bot added the conflict label Aug 24, 2026
@burgholzer
burgholzer force-pushed the codex/selected-payload-environment branch from ae5b72f to b0dd192 Compare August 24, 2026 13:31
@burgholzer burgholzer changed the title ✨ Select exact payload environments for target compilation ♻️ Define target compilation with payload specifications Aug 24, 2026
@burgholzer burgholzer removed QDMI Anything related to QDMI conflict labels Aug 24, 2026
@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

Copy link
Copy Markdown
Member Author

This looks much cleaner now. And should also be ready.

Represent the selected hardware target and payload specification as one validated target environment. Cache that value through the MLIR analysis manager for mapping, native synthesis, and conformance.

Derive targeted compiler output from the selected payload format in the C++, Python, and mqt-cc APIs. Keep untargeted output selection independent.

Assisted-by: GPT-5.6 Sol via Codex
@burgholzer
burgholzer force-pushed the codex/selected-payload-environment branch from bb0240b to 28284fa Compare August 24, 2026 23:47
@burgholzer

Copy link
Copy Markdown
Member Author

@simon1hofmann @denialhaag any feedback on this one from your side?
I looked through this yesterday night already and it looked pretty clean to me.

@simon1hofmann

Copy link
Copy Markdown
Contributor

@simon1hofmann @denialhaag any feedback on this one from your side? I looked through this yesterday night already and it looked pretty clean to me.

Going through this now and will provide feedback in around 15min.

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

Also went through the changes here and they look really clean 👍

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

This also looks pretty clean to me! 😌 I just have two observations and a small reminder:

Comment thread docs/mlir/target_compilation.md
Comment thread docs/mlir/target_compilation.md

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.

My earlier point about removing the MQT_ prefix will probably show up during rebasing here, but just as a reminder.

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.

Good to keep it in mind!

)

target = CompilerTarget.from_device_id("mqt.sc.iqm.garnet")
payload = PayloadSpecification(PayloadFormat("qir", "2.1.0", "base", PayloadEncoding.BINARY))

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.

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.

Not really. I was just about to argue that it is cleaner if one always specifies a full semver tripple. But one could also argue that this should actually be a version range following the python dependency specification.
That would allow to express things like "accepts OpenQASM 3" or "accepts QIR 2.1" or more. Adds a fair bit of complexity probably, but may be worth it.
Any thoughts?

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.

Hmm, I do understand the intention behind requiring a full SemVer triple, but OpenQASM and QIR really seem like prime examples where people generally don't think too much about patch (and sometimes even minor) versions. I'd say relaxing the condition could be worth it. 🤔

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.

Technically, both formats have a minor version that is kind of meaningful (OpenQASM 3.1 and QIR 2.1) but I agree with you that people typically do not care and just refer to them as OpenQASM 3 and QIR 2 (or even just QIR for the sake of it).
Let's what gpt-5.6 comes up with in plan mode later 😌

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.

3 participants