Add Dynamic QFT benchmark#918
Conversation
Assisted-by: GPT-5 via Codex
Assisted-by: GPT-5 via Codex
c815dd9 to
336e71c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Dear @gshaowei6, your contribution already looks good. I left only two minor comments to be addressed. Thanks for your efforts.
|
|
||
| @register_benchmark("dynamic_qft", description="Dynamic QFT") | ||
| def create_circuit(num_qubits: int) -> QuantumCircuit: | ||
| """Return a circuit implementing the Dynamic QFT. |
There was a problem hiding this comment.
Align the classical output convention with the existing qft benchmark. The measured outcomes should be written to the classical bits in the reversed order.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
|
|
||
| ### Added | ||
|
|
||
| - Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**]) |
There was a problem hiding this comment.
| - Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**]) | |
| - ✨ Add Dynamic QFT benchmark ([#918]) ([**@gshaowei6**]) |
To align with the rest of the changelog style.
There was a problem hiding this comment.
Applied the suggested changelog entry style with the ✨ prefix.
|
Addressed the three review comments in b8d3ff1:
Local verification:
|
Description
Adds a
dynamic_qftbenchmark implementing the semiclassical Dynamic QFT with mid-circuit measurements and classically controlled phase rotations. The implementation follows the current benchmark registry pattern, uses the canonicalDynamic QFTnaming, keeps the classical register namedc, and rejects instances above 64 qubits to avoid impractically small phase shifts.Fixes #798
Checklist
If PR contains AI-assisted content:
Assisted-by: GPT-5 via Codexfooter.Verification
python -m pytest tests\\test_bench.py -q -k dynamic_qft -p no:benchmark -n0 --basetemp .tmp-pytest-> 4 passedpython -m pytest tests\\test_bench.py -q -p no:benchmark -n0 --basetemp .tmp-pytest-> 199 passedpython -m pytest -q -p no:benchmark -n0 --basetemp .tmp-pytest-> 243 passedpython -m pytest -q -p no:benchmark -n0 --basetemp .tmp-pytest-wsl-> 243 passedpython -m ruff check src\\mqt\\bench\\benchmarks\\dynamic_qft.py tests\\test_bench.pypython -m ruff format --check src\\mqt\\bench\\benchmarks\\dynamic_qft.py tests\\test_bench.pyPYTHONPATH=<user-site> python -m ty check-> All checks passedgit diff --check