Skip to content

👷 Lower reusable functions with standard MLIR passes - #2344

Open
burgholzer wants to merge 1 commit into
codex/qiskit-reusable-gatesfrom
codex/reusable-function-lowering
Open

👷 Lower reusable functions with standard MLIR passes#2344
burgholzer wants to merge 1 commit into
codex/qiskit-reusable-gatesfrom
codex/reusable-function-lowering

Conversation

@burgholzer

@burgholzer burgholzer commented Sep 3, 2026

Copy link
Copy Markdown
Member

🤖 AI text below 🤖

Description

Use standard MLIR passes to lower reusable functions for compiler targets. Entry points are public, defined func.func operations, giving symbol liveness an explicit root. Target compilation inlines before decomposition, mapping, synthesis, and conformance checks; a target-selected QIR route avoids duplicate early inlining.

This PR is stacked on #2342. Explicit QC and QCO cleanup run symbol DCE after canonicalization, including when folding erases a helper's last call. The QC export pipeline deliberately preserves unused gate declarations that structured formats can represent. Signature-changing dead-value removal stays out of function-preserving cleanup.

No custom IPO framework or interprocedural WireIterator state is added. qco.call already exposes positional wire correspondence through UnitaryOpInterface; generic func.call remains an intentional boundary. Codex implemented and tested the changes with independent MLIR/compiler specialist review.

Integrated-stack validation: release build; all 3,916 registered CTest cases with one expected skip; all 294 Qiskit translation tests; whole-file C++ lint and repository lint. Stub generation passed without tracked changes. Hosted CI is separate evidence and has not been claimed as passed.

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 Core Anything related to the Core library and IR c++ Anything related to C++ code MLIR Anything related to MLIR labels Sep 3, 2026
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@burgholzer
burgholzer force-pushed the codex/qiskit-reusable-gates branch from afd7d4c to 7fdb302 Compare September 3, 2026 23:12
@burgholzer
burgholzer force-pushed the codex/reusable-function-lowering branch from 4007906 to dd9ae18 Compare September 3, 2026 23:12
Require a public, defined func.func program entry so standard symbol DCE can
prune unreachable private helpers during explicit QC and QCO cleanup. Preserve
unused gate declarations during structured QC export.

Inline reusable calls once at the target-compilation boundary before mapping,
synthesis, and conformance checks. Keep the typed and CLI QIR paths from
scheduling a redundant inliner when target compilation owns the lowering.

Assisted-by: GPT-5.6 via Codex
@burgholzer
burgholzer force-pushed the codex/qiskit-reusable-gates branch from 7fdb302 to 6328d48 Compare September 4, 2026 21:59
@burgholzer
burgholzer force-pushed the codex/reusable-function-lowering branch from dd9ae18 to d1b21bd Compare September 4, 2026 21:59
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 Core Anything related to the Core library and IR feature New feature or request MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant