Skip to content

🐛 Lower nested modifiers in controlled composites - #2594

Merged
burgholzer merged 3 commits into
codex/bench-controlled-gatesfrom
codex/nested-controlled-modifiers
Sep 25, 2026
Merged

burgholzer merged 3 commits into
codex/bench-controlled-gatesfrom
codex/nested-controlled-modifiers

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Fixes #2588. Stacked on #2565 (codex/bench-controlled-gates).

Target compilation and synthesis currently reject a controlled composite when an inverse or power modifier wraps its body. Reuse the existing inverse and power-unrolling helpers inside eligible controls, then simplify the resulting modifiers in the existing multi-control decomposition pass.

The shared unrolling helpers require verified linear QCO IR. This avoids rebuilding wire identities, copying inverse bodies, and maintaining a separate control wrapper. Inverse bodies retain reverse gate order. Constant integer powers are distributed only when body operations act on disjoint wires. Width thresholds and native-target support remain respected. No new pipeline pass, early rotation merging, dependencies, or frontend-specific handling are added.

Usage and limitations

The existing compile_for_target(...) and synthesize_for_target(...) APIs now accept supported nested forms such as ctrl @ inv @ composite and integer powers of disjoint composite bodies.

Fractional powers, runtime exponents, and powers of overlapping body operations are not distributed. Such inputs still need an existing simplification or native synthesis path; this does not add arbitrary large-unitary synthesis or repeated expansion of circuit bodies.

Validation

  • Rebased onto upstream main c92ffa7a6 and reviewed together with the stacked PR.
  • Combined-stack validation passes: 1,524 native tests (compiler 233, decomposition 315, MQT transforms 31, QC IR 368, QCO IR 575, and two native-synthesis checks) and all 428 Qiskit translation tests.
  • Consolidated pipeline tests compare full unitaries for plain, inverse, and positive/negative integer-power bodies through both target APIs. Retained boundary cases cover width, native support, control scope, unsupported powers, and failed unrolling.
  • Removed 203 net lines of test code across the stack: MCMT cases reduced from 36 to 6 and unsupported-power combinations from 7 to 3. No production code changed in this test/documentation cleanup.
  • Before consolidation, twelve additional Qiskit-to-target exact-unitary checks passed for nested modifiers and open MCMT inverses.
  • Clang 23/ThinLTO native build, repository lint, and full changed-file C++ lint pass. Python validation uses Qiskit 2.5.2.

Hosted checks for the updated heads are pending.

Codex assisted with implementation, tests, documentation, 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.
  • 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.

@simon1hofmann simon1hofmann added fix Fix for something that isn't working c++ Anything related to C++ code MLIR Anything related to MLIR labels Sep 21, 2026
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@simon1hofmann
simon1hofmann added this pull request to stack #2596 September 21, 2026 09:54
@simon1hofmann simon1hofmann self-assigned this Sep 21, 2026
@simon1hofmann
simon1hofmann marked this pull request as ready for review September 21, 2026 11:43
@burgholzer
burgholzer force-pushed the codex/nested-controlled-modifiers branch from e8cb4cc to c756dfd Compare September 25, 2026 21:03
simon1hofmann and others added 3 commits September 25, 2026 22:28
🤖 *AI text below* 🤖

Reuse inverse and disjoint integer-power unrolling inside eligible
controlled composites. Preserve width and native-target guards without
adding a pipeline pass or early rotation merging.

Cover both target pipelines, the OpenQASM reproducer, phase, wire order,
and unsupported powers. Stack on #2565 to address #2588.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Use verified linear QCO inputs to detect overlapping body wires without
reconstructing wire IDs. Iterate inverse bodies without a temporary vector
and use one unrollModifier overload family with a consistent no-match result.

Preserve the integer-power limit, native target guards, and wire mappings.

Assisted-by: GPT-6 via Codex
🤖 *AI text below* 🤖

Share the OpenQASM matrix cases across both target pipelines and keep one
case for each unsupported-power boundary. Permit constant hoisting instead
of freezing incidental IR layout; native synthesis owns rotation cost checks.

Retain phase, wire order, inverse ordering, control scope, and target limits.

Assisted-by: GPT-6 via Codex
@burgholzer
burgholzer force-pushed the codex/nested-controlled-modifiers branch from c756dfd to 7ae617f Compare September 25, 2026 22:43

@burgholzer burgholzer 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 one also looks good! Just trimmed down tests and docs again. Let's get this in. Two more PRs merged, one more issue closed :shipit:

@burgholzer
burgholzer merged commit 6ad2b65 into main Sep 25, 2026
36 of 38 checks passed
@burgholzer
burgholzer deleted the codex/nested-controlled-modifiers branch September 25, 2026 23:42
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 fix Fix for something that isn't working MLIR Anything related to MLIR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Lower nested modifiers in controlled composites

2 participants