✨ Add reusable quantum functions to QC and QCO - #2336
Conversation
7773ec8 to
4982de2
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
4982de2 to
30ea067
Compare
|
@MatthiasReumann @DRovara I haven't looked through all the details here yet, but this PR may be interesting for the both of you. |
81fda33 to
6f4c34b
Compare
ad32279 to
d2e592b
Compare
|
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 |
DRovara
left a comment
There was a problem hiding this comment.
Awesome, this looks pretty cool. I like the idea of the unitary marker for unitary functions.
I have to admit I am a bit behind and still haven't fully grasped the idea behind the MQT dialect here (unitary functions aren't necessarily MQT-exclusive), but I also understand just having that as a joint source to avoid duplication.
I have a few minor comments and one major concern regarding the IPO passes, where we will have to think of some solution.
Assisted-by: GPT-5.6 via Codex
Adopt a trailing positional qubit-result ABI for reusable QCO functions. Add direct unitary calls, builder support, and loss-minimizing QC/QCO conversion in both directions. Treat generic calls as local wire-analysis boundaries and remove the speculative interprocedural qubit and tensor mapping caches. Assisted-by: GPT-5.6 via Codex
Resolve the hosted clang-tidy findings and exercise the unitary function, call, trace, and conversion rejection contracts missing from patch coverage. Assisted-by: GPT-5.6 via Codex
Resolve the entry function through mqt.entry_point so both builders can finalize modules whose entry symbol was renamed. Assisted-by: GPT-5.6 via Codex
Reuse the QC-to-QCO register materialization path for unitary and generic calls, including calls nested in converted modifier regions. Assisted-by: GPT-5.6 via Codex
Add verified source-name metadata for function symbols that must be uniquified, and preserve it across QC/QCO conversion. Assisted-by: GPT-5.6 via Codex
Follow the current C++ naming and comment guidance, add reusable function programs to compiler and QC/QCO round-trip coverage, and keep local C++ lint diagnostics visible. Assisted-by: GPT-5.6 via Codex
Drop trivial qubit predicates and document that iterator clients own callee traversal. Keep the recursion guard because straight-line unitary call cycles remain possible. Verify nested operations before querying their interfaces, reject empty unitary bodies and cyclic SSA qubit flow, and cover malformed downstream calls with regression tests. Assisted-by: GPT-5.6 via Codex
d2e592b to
1a68140
Compare
Preserve gate documentation in continued macros, trailing Doxygen member comments, file summaries, and inline unused parameter names. Clarify the comment policy without changing program behavior. Assisted-by: Codex
|
Alright, I believe this is as clean as it gets for now. Tagging this for auto-merge so that the other depending PRs can be updated over night. |
🤖 AI text below 🤖
Description
Add a frontend-neutral function model for reusable quantum helpers:
func.funcdefinitions withmqt.unitaryand represent their calls withqc.callorqco.call;func.calloperations as local wire-analysis boundaries, avoiding speculative interprocedural mapping and caches.The deliberately narrow unitary contract covers gate definitions needed by future OpenQASM, Qiskit, and jeff integrations without result annotations, recursive matrix synthesis, or a new function abstraction. This branch is based directly on
mainand is independent of #2196 and its stack.Validation
uvx nox -s cpp-lint,uvx nox -s lint, andgit diff --checkpassed.main. The@filesummary is retained.Build and C++ lint validation used #2352's dependency and test-RPATH fixes as a temporary local overlay. That overlay was removed afterward and is not part of this PR; both PRs remain based on
main.Codex assisted with implementation, documentation restoration, and local validation.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).