Skip to content

🐛 Preserve Clifford+T basis after synthesis - #1093

Merged
simon1hofmann merged 5 commits into
mainfrom
codex/clifford-t-post-synthesis
Oct 22, 2026
Merged

simon1hofmann merged 5 commits into
mainfrom
codex/clifford-t-post-synthesis

Conversation

@simon1hofmann

@simon1hofmann simon1hofmann commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Description

Compiling RZZ(0.3) to Clifford+T at optimization levels 2 or 3 can fail because general optimization reintroduces arbitrary gates after synthesis. Run continuous optimization, Solovay–Kitaev synthesis, and discrete cleanup in one staged Qiskit pass manager. Keep Solovay–Kitaev and the Qiskit 2.2.3 minimum unchanged; version-dependent synthesis remains in #1081.

Disable permutation elision for native Clifford+T compilation so wire permutations remain in the circuit and survive QASM export without manual layout repair. After synthesis, apply OptimizeCliffordT recursively for nonzero optimization levels and translate to the target basis. Preserve native target normalization, structured loops, loop jumps, and classical measurement destinations.

Mirrors reuse only the exact cleanup pipeline before terminal measurements. High-level synthesis receives the target and equivalence library to lower inverse gates such as iswap_dg and dcx_dg, without repeating approximate synthesis.

Validation after updating to main: 656 tests passed with four existing expected failures on Qiskit 2.6.0; 103 focused Clifford+T, mirror, and loop tests passed on Qiskit 2.2.3. All lint hooks passed, using Python 3.14 for type checking. Hosted CI is running on the updated branch.

Codex assisted with implementation, Ponytail review, regression tests, validation, 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.
  • 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.

@github-project-automation github-project-automation Bot moved this to In Progress in MQT Applications Oct 21, 2026
simon1hofmann added a commit that referenced this pull request Oct 21, 2026
Assisted-by: GPT-5 via Codex
@simon1hofmann

Copy link
Copy Markdown
Collaborator Author

@burgholzer I tried different fixed to this problem but I'm still not really happy with it.

@simon1hofmann simon1hofmann added the fix Fixes something that isn't working label Oct 21, 2026
@codecov

codecov Bot commented Oct 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 and others added 4 commits October 22, 2026 10:16
Assisted-by: GPT-5 via Codex
Pass the target and equivalence library to high-level synthesis so inverse ISWAP and DCX definitions are lowered before basis translation. Cover both gates at every optimization level and sort the changelog reference.

Assisted-by: GPT-6 via Codex
Run continuous optimization, Solovay-Kitaev synthesis, and discrete cleanup
in one staged pass manager. Disable permutation elision for native circuits
so QASM exports preserve wire ordering without manual permutation repair.
Reuse only discrete cleanup for exact mirrors and share the final run path.

Cover all optimization levels and mirror variants with QASM2/QASM3
permutation round trips. Keep Qiskit 2.2.3 and the synthesis algorithm.

Assisted-by: GPT-6 via Codex
@burgholzer
burgholzer force-pushed the codex/clifford-t-post-synthesis branch from 97f2304 to e0ab894 Compare October 22, 2026 10:17
@burgholzer burgholzer self-assigned this Oct 22, 2026
Assisted-by: GPT-6 via Codex

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

Alright. Played around with this a little. I think the solution now is pretty much fine and relatively clean 😌

@simon1hofmann
simon1hofmann enabled auto-merge (squash) October 22, 2026 10:56
@simon1hofmann
simon1hofmann merged commit 673bbbe into main Oct 22, 2026
15 checks passed
@simon1hofmann
simon1hofmann deleted the codex/clifford-t-post-synthesis branch October 22, 2026 11:49
@github-project-automation github-project-automation Bot moved this from In Progress to Done in MQT Applications Oct 22, 2026
simon1hofmann added a commit that referenced this pull request Oct 22, 2026
simon1hofmann added a commit that referenced this pull request Oct 22, 2026
simon1hofmann added a commit that referenced this pull request Oct 23, 2026
* Use version-aware Clifford+T synthesis

* Use packaging for Qiskit version comparison

* Remove prerelease-specific Clifford+T test

* Retain Clifford+T optimization after synthesis

* 🐛 Preserve Clifford+T basis after synthesis

Assisted-by: GPT-5 via Codex

* 📝 Link Clifford+T fix to #1093

Assisted-by: GPT-5 via Codex

* 🐛 Preserve Clifford+T basis after synthesis

Assisted-by: GPT-5 via Codex

* 📝 Link Clifford+T fix to #1093

Assisted-by: GPT-5 via Codex

* 🐛 Lower inverse Clifford gates in mirrors

Pass the target and equivalence library to high-level synthesis so inverse ISWAP and DCX definitions are lowered before basis translation. Cover both gates at every optimization level and sort the changelog reference.

Assisted-by: GPT-6 via Codex

* ♻️ Simplify Clifford+T compilation orchestration

Run continuous optimization, Solovay-Kitaev synthesis, and discrete cleanup
in one staged pass manager. Disable permutation elision for native circuits
so QASM exports preserve wire ordering without manual permutation repair.
Reuse only discrete cleanup for exact mirrors and share the final run path.

Cover all optimization levels and mirror variants with QASM2/QASM3
permutation round trips. Keep Qiskit 2.2.3 and the synthesis algorithm.

Assisted-by: GPT-6 via Codex

* 📝 Place #1081 changelog entry below #1087

---------

Signed-off-by: simon1hofmann <119581649+simon1hofmann@users.noreply.github.com>
Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixes something that isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants