♻️ Generalize MLIR compiler target facts - #2218
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
burgholzer
left a comment
There was a problem hiding this comment.
This one feels close to ready.
|
Important Approval pendingCodeRabbit 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.
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. Comment |
9b961b2 to
8fafa97
Compare
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
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
8fafa97 to
a6f7fd1
Compare
denialhaag
left a comment
There was a problem hiding this comment.
I just had a free minute to go through this, and it looks really clean to me! ![]()
simon1hofmann
left a comment
There was a problem hiding this comment.
This also looks quite good, just a few comments about the documentation and two concerns flagged by another LLM review run.
| ``` | ||
|
|
||
| Use `CompilerTarget.Connectivity.all_to_all()` for an all-to-all target. An | ||
| empty `CompilerTarget.NativeOperations([])` means that no operation is native. |
There was a problem hiding this comment.
Does that mean native synthesis is not called at all? Should we add an example for a target with a specific set of native operations?
There was a problem hiding this comment.
I'd rather argue that "no operation is native" is a misconfiguration as this essentially means that you cannot compile to the target (it lacks an ISA).
Maybe this part of the documentation should make this more explicit (and the code should likely fail early on such targets)
| target = CompilerTarget( | ||
| device.qubits_num(), | ||
| connectivity=CompilerTarget.Connectivity.all_to_all(), | ||
| native_operations=CompilerTarget.NativeOperations([ |
There was a problem hiding this comment.
An example like this in target_compilation.md.
| CompilerTarget.Operation("u", 1, 3), | ||
| CompilerTarget.Operation("cx", 2, 0), | ||
| CompilerTarget.Operation("measure", 1, 0), | ||
| CompilerTarget.Operation("reset", 1, 0), |
There was a problem hiding this comment.
Is it clear/explained somewhere what the second and third argument in Operation represent?
There was a problem hiding this comment.
Likely no really. Maybe it would help to add keyword arguments here in the docs to make this more explicit.
| """ | ||
| target = CompilerTarget.from_device(ddsim_device) | ||
| target = CompilerTarget( | ||
| ddsim_device.qubits_num(), |
There was a problem hiding this comment.
Unrelated to this PR, but is there any reason why it is called qubits_num and not num_qubits?
There was a problem hiding this comment.
None that I could think of. We can happily rename consistently.
| signalPassFailure(); | ||
| return; | ||
| } | ||
| if (comp->hasTwoQubitOperations && |
There was a problem hiding this comment.
This permits unknown connectivity without two-qubit gates, but control-flow reconciliation still queries topology at Mapping.cpp:899-908, reaching the fatal branch at Target.cpp:753-758.
There was a problem hiding this comment.
Thanks for pointing that out. We should definitely fix this!
| const std::optional<uint64_t> duration, | ||
| const std::optional<double> fidelity) { | ||
| std::set<SiteId> uniqueSites; | ||
| llvm::SmallDenseSet<SiteId> uniqueSites; |
There was a problem hiding this comment.
This stores nonnegative int64_t IDs in SmallDenseSet, whose sentinel values overlap the advertised domain (INT64_MAX, and on LP64 also INT64_MAX-1)
There was a problem hiding this comment.
Thanks. I think we could be limiting the sites to 32bits. IIRC site IDs should also be non-negative (might be worth double-checking).
Reducing to 32-bits may even increase efficiency throughout the implementation.
|
Thanks @denialhaag and @simon1hofmann 🙏🏼 |
Thanks for addressing my comments, I agree with all your answers. |
Go also from my side! |
🤖 AI text below 🤖
Description
Generalize the unreleased MLIR compiler target contract before serializing it in
mqt.target_env.CompilerTargetcopies and move target metadata into immutable storage.This is the context-free target prerequisite for #2215. It deliberately does not add payload capabilities or depend on the WIP QDMI v1.4 API.
Validation:
uvx nox -s lint, andgit diff --checkpass.Implementation and pull-request text were prepared with OpenAI Codex.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).