Skip to content

Add Dynamic QFT benchmark#918

Open
gshaowei6 wants to merge 4 commits into
munich-quantum-toolkit:mainfrom
gshaowei6:unitaryhack/dynamic-qft-798
Open

Add Dynamic QFT benchmark#918
gshaowei6 wants to merge 4 commits into
munich-quantum-toolkit:mainfrom
gshaowei6:unitaryhack/dynamic-qft-798

Conversation

@gshaowei6

@gshaowei6 gshaowei6 commented Jun 6, 2026

Copy link
Copy Markdown

Description

Adds a dynamic_qft benchmark implementing the semiclassical Dynamic QFT with mid-circuit measurements and classically controlled phase rotations. The implementation follows the current benchmark registry pattern, uses the canonical Dynamic QFT naming, keeps the classical register named c, and rejects instances above 64 qubits to avoid impractically small phase shifts.

Fixes #798

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:

  • I have disclosed the use of AI tools in the PR description as per the AI Usage Guidelines.
  • AI-assisted commits include an Assisted-by: GPT-5 via Codex footer.
  • I confirm that I have personally reviewed and understood all AI-assisted content, and accept full responsibility for it.

Verification

  • python -m pytest tests\\test_bench.py -q -k dynamic_qft -p no:benchmark -n0 --basetemp .tmp-pytest -> 4 passed
  • python -m pytest tests\\test_bench.py -q -p no:benchmark -n0 --basetemp .tmp-pytest -> 199 passed
  • python -m pytest -q -p no:benchmark -n0 --basetemp .tmp-pytest -> 243 passed
  • WSL Ubuntu: python -m pytest -q -p no:benchmark -n0 --basetemp .tmp-pytest-wsl -> 243 passed
  • python -m ruff check src\\mqt\\bench\\benchmarks\\dynamic_qft.py tests\\test_bench.py
  • python -m ruff format --check src\\mqt\\bench\\benchmarks\\dynamic_qft.py tests\\test_bench.py
  • PYTHONPATH=<user-site> python -m ty check -> All checks passed
  • git diff --check

Assisted-by: GPT-5 via Codex
Assisted-by: GPT-5 via Codex
@gshaowei6 gshaowei6 force-pushed the unitaryhack/dynamic-qft-798 branch from c815dd9 to 336e71c Compare June 6, 2026 23:00
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@flowerthrower flowerthrower left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @gshaowei6, your contribution already looks good. I left only two minor comments to be addressed. Thanks for your efforts.

Comment thread src/mqt/bench/benchmarks/dynamic_qft.py Outdated

@register_benchmark("dynamic_qft", description="Dynamic QFT")
def create_circuit(num_qubits: int) -> QuantumCircuit:
"""Return a circuit implementing the Dynamic QFT.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the classical output convention with the existing qft benchmark. The measured outcomes should be written to the classical bits in the reversed order.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed measurements to write q[i] into c[num_qubits - i - 1] and kept each conditional phase controlled by that same measured classical bit. Added a structure assertion for the reversed measurement mapping.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a small misalignment between the regular qft benchmark and your version. I encourage you to (visually) inspect and compare the following two circuits. Both circuits should have a matching operation order on same qubit and measurement indices.

from mqt.bench import get_benchmark, BenchmarkLevel

# original qft benchmark
circ = get_benchmark("qft", BenchmarkLevel.ALG, circuit_size=3)
circ.draw("mpl", fold=-1)

# your solution
circ = get_benchmark("dynamic_qft", BenchmarkLevel.ALG, circuit_size=3)
circ.decompose().draw("mpl", fold=-1)

@burgholzer burgholzer added feature New feature or request unitaryHACK Issues and PRs intended for unitaryHACK labels Jun 10, 2026
Comment thread CHANGELOG.md Outdated

### Added

- Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**])

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.

Suggested change
- Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**])
- Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**])

To align with the rest of the changelog style.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the suggested changelog entry style with the prefix.

@gshaowei6

Copy link
Copy Markdown
Author

Addressed the three review comments in b8d3ff1:

  • Removed the Dynamic QFT qubit cap and added 65-qubit coverage.
  • Reversed the classical measurement mapping while keeping feed-forward conditions tied to the measured bit.
  • Applied the changelog entry style.

Local verification:

  • \python -m ruff check src\mqt\bench\benchmarks\dynamic_qft.py tests\test_bench.py\
  • \python -m ruff format --check src\mqt\bench\benchmarks\dynamic_qft.py tests\test_bench.py\
  • \python -m pytest -n0 -p no:benchmark\ -> 243 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request unitaryHACK Issues and PRs intended for unitaryHACK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Dynamical QFT

3 participants