👷 Lower reusable functions with standard MLIR passes - #2344
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
burgholzer
force-pushed
the
codex/qiskit-reusable-gates
branch
from
September 3, 2026 23:12
afd7d4c to
7fdb302
Compare
burgholzer
force-pushed
the
codex/reusable-function-lowering
branch
from
September 3, 2026 23:12
4007906 to
dd9ae18
Compare
burgholzer
force-pushed
the
codex/qiskit-reusable-gates
branch
from
September 4, 2026 21:59
7fdb302 to
6328d48
Compare
burgholzer
force-pushed
the
codex/reusable-function-lowering
branch
2 times, most recently
from
September 5, 2026 13:09
d1b21bd to
e5b20d2
Compare
burgholzer
force-pushed
the
codex/qiskit-reusable-gates
branch
from
September 5, 2026 13:09
6328d48 to
26e83a0
Compare
burgholzer
force-pushed
the
codex/reusable-function-lowering
branch
from
September 5, 2026 15:00
e5b20d2 to
d3fda6b
Compare
burgholzer
force-pushed
the
codex/qiskit-reusable-gates
branch
2 times, most recently
from
September 6, 2026 12:06
d2688e6 to
1e71124
Compare
12 tasks
burgholzer
force-pushed
the
codex/reusable-function-lowering
branch
from
September 6, 2026 20:12
d3fda6b to
05abf45
Compare
Require a public, defined func.func program entry so symbol DCE can prune unreachable private helpers during QC export and QC/QCO cleanup. Let structured exporters omit unreachable gate declarations. Use MLIR dead-value removal in explicit cleanup so unused unitary parameters and qubits are removed with their matching call operands. Inline reusable calls once at the target-compilation boundary before mapping, synthesis, and conformance checks. Avoid redundant inlining in typed and CLI QIR paths. Assisted-by: GPT-5.6 via Codex
burgholzer
force-pushed
the
codex/reusable-function-lowering
branch
from
September 6, 2026 21:14
05abf45 to
33dbc84
Compare
burgholzer
commented
Sep 6, 2026
burgholzer
left a comment
Member
Author
There was a problem hiding this comment.
This now also looks decent and like a workable solution for now.
Custom gates will simply be inlined now as part of the target compilation. This is definitely an aspect to improve in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This marks the end of the first stack or PRs to add multiple function support.
Fixes #1659
🤖 AI text below 🤖
Description
Use standard MLIR passes to lower reusable functions for compiler targets. Program entry points are public, defined
func.funcoperations, which gives symbol liveness an explicit root. Target compilation inlines reusable calls before decomposition, mapping, synthesis, and conformance checks. Target-selected QIR compilation avoids redundant early inlining.QC export and explicit QC/QCO cleanup remove unreachable private functions. The OpenQASM and Qiskit exporters emit only gates reachable from the entry point, so unused gate declarations are dropped. Explicit cleanup also uses MLIR dead-value removal to prune unused unitary parameters and qubits together with the corresponding call operands.
No custom interprocedural framework or
WireIteratorstate is added.qco.callalready exposes positional wire correspondence throughUnitaryOpInterface; genericfunc.callremains an intentional wire boundary.The prerequisite structured-export changes in #2338, #2339, #2340, and #2342 are merged. This branch is rebased onto current
mainand requires no additional dependency.Final-head local validation passed: release configuration and build; all 3,918 registered CTest cases with one expected skip; all 294 Qiskit translation tests; C++ lint; and repository lint. Hosted CI for the rebased commit is still running.
Codex implemented and tested the changes with independent MLIR/compiler specialist review.
Checklist
If PR contains AI-assisted content:
🤖 *AI text below* 🤖(titles are exempt).