Skip to content

🐛 Preserve symbolic Euler chains in target synthesis - #2559

Merged
simon1hofmann merged 8 commits into
mainfrom
codex/symbolic-target-fusion
Sep 23, 2026
Merged

simon1hofmann merged 8 commits into
mainfrom
codex/symbolic-target-fusion

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Description

Compile supported symbolic Euler chains directly into the target basis so that EfficientSU2-style circuits remain bindable after Qiskit export. H/RZ pairs in either order now use one U gate or at most three gates in the other supported bases, without runtime quaternion extraction. This restores the RX/RZ, RX/RY, and R gate-count bounds and fixes the U/H–RZ export failure.

  • Reuse direct ZXZ/ZYZ and XZX/XYX identities and the existing Euler emitters. Normalize each evaluated gate operand modulo 4*pi before offsets or phase arithmetic, preserving shared scalar expressions and controlled phase.
  • Keep target-aware fusion inside native synthesis: preserve native symbolic runs, require improvement for constant native runs, and leave controlled bodies with their lowering owner. Restore canonicalized controlled U2 to native U when supported.
  • Retain the U/unrestricted optimizer until the shared synthesis contracts cover its controlled-body and singleton behavior. Unsupported symbolic shapes retain individual native lowering; this does not make arbitrary runtime Euler expressions exportable.
  • Keep numerical/basis coverage in C++ and reduce this PR's Python additions from 19 cases to seven binding/export cases. Move the 100-qubit symbolic workload to the follow-up benchmark specification.

No new dependencies or public API changes are required. Broader consolidation and the remaining Python test audit are tracked in follow-up issue #2614.

Validation

Linux AArch64, optimized release-clang-ipo build:

  • 329 focused C++ tests passed: Euler/fusion, rotation merging, native synthesis, and compiler pipelines. Includes both H/RZ orders in all seven bases, phase-sensitive controlled matrices, bounded/shared operands, native preservation, and controlled-U compilation.
  • All 97 tests in test/python/test_mlir.py passed with Qiskit and jeff available, including late parameter binding and the U/H–RZ exporter regression.
  • Repository lint and whole-file C++ lint: passed with zero findings.

Hosted CI has not been checked for this update. The earlier large-workload timings are not claimed as validation of this revision.

OpenAI Codex assisted with implementation, tests, and this description. Human review of the updated patch remains required before merging.

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.

🤖 *AI text below* 🤖

Reuse direct Euler angles and synthesize into the target basis after
placement. This avoids inverse trigonometry and cancelling U phase
corrections for symbolic circSU2 circuits while retaining classical
read sharing and the existing U-target optimizer.

Assisted-by: GPT-5 via Codex
@simon1hofmann simon1hofmann added bug Something isn't working c++ Anything related to C++ code MLIR Anything related to MLIR labels Sep 14, 2026
@simon1hofmann simon1hofmann self-assigned this Sep 14, 2026
🤖 *AI text below* 🤖

Reuse the existing Euler emitters for symbolic XZX and XYX chains in
compatible XZX, XYX, and R bases, including shortened chains. Preserve
phase and gate-count bounds without inverse trigonometry.

Cover controlled matrix equality and late-bound Qiskit export through
both target pipelines. Initialize the test fixture in its constructor.

Assisted-by: GPT-5 via Codex
@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.77419% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...QCO/Transforms/NativeSynthesis/TargetSynthesis.cpp 86.3% 3 Missing ⚠️
...ms/Optimizations/MergeSingleQubitRotationGates.cpp 98.8% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

🤖 *AI text below* 🤖

Use designated fields for the symbolic angle initializer. Exercise the
compiler-target basis overload in the existing seven-basis regression,
covering the previously missed U and ZXZ switch cases.

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

Add the trailing commas required by clang-tidy. Extend the existing symbolic Euler regression with isolated rotations to exercise the RX-to-R conversion.

Assisted-by: GPT-5 via Codex
burgholzer and others added 4 commits September 19, 2026 21:02
🤖 *AI text below* 🤖

Keep optional target fusion direct and preserve supported gate runs,
including native controlled operations. Normalize evaluated one-qubit
operands and accumulated phases modulo 4*pi before angle arithmetic so
late binding preserves the full unitary with bounded angles.

Use the existing fusion pass options and remove the redundant basis
factory. Cover native preservation, symbolic export, periodic reduction,
and shared scalar expressions with phase-sensitive regressions.

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

Direct Euler synthesis now emits math.tan when bounding symbolic angles. Register Math in the test fixture, which bypasses the pass manager and its dependent-dialect loading.

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

Reuse the direct Euler path for H/RZ pairs and preserve controlled U
lowering after canonicalization. Restore native gate-count bounds and
keep exhaustive numeric checks in C++, with seven Python consumer cases.

Assisted-by: GPT-6 via Codex
@burgholzer burgholzer added fix Fix for something that isn't working and removed bug Something isn't working labels Sep 23, 2026
@burgholzer burgholzer self-assigned this Sep 23, 2026

@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.

Thanks @simon1hofmann 🙏🏼 finally got through this. I pushed a couple of fixes and simplifications and created a follow-up issue (#2614) with further simplification opportunities I identified but did not want to put into this PR in order to not hold it up for too long.
If you are also happy with the changes here, feel free to merge.
The follow-up issue is also up for grabs 🙌🏼

@simon1hofmann

Copy link
Copy Markdown
Contributor Author

Thanks @simon1hofmann 🙏🏼 finally got through this. I pushed a couple of fixes and simplifications and created a follow-up issue (#2614) with further simplification opportunities I identified but did not want to put into this PR in order to not hold it up for too long. If you are also happy with the changes here, feel free to merge. The follow-up issue is also up for grabs 🙌🏼

Thanks a lot for the final touches, I can tackle the follow-up issue 👍

@simon1hofmann
simon1hofmann merged commit e7b37b7 into main Sep 23, 2026
26 checks passed
@simon1hofmann
simon1hofmann deleted the codex/symbolic-target-fusion branch September 23, 2026 14:00
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.

2 participants