-
-
Notifications
You must be signed in to change notification settings - Fork 38
Add Dynamic QFT benchmark #918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gshaowei6
wants to merge
4
commits into
munich-quantum-toolkit:main
Choose a base branch
from
gshaowei6:unitaryhack/dynamic-qft-798
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+114
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Copyright (c) 2023 - 2026 Chair for Design Automation, TUM | ||
| # Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Licensed under the MIT License | ||
|
|
||
| """Dynamic QFT benchmark definition.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import math | ||
|
|
||
| from qiskit.circuit import ClassicalRegister, QuantumCircuit, QuantumRegister | ||
|
|
||
| from ._registry import register_benchmark | ||
|
|
||
|
|
||
| @register_benchmark("dynamic_qft", description="Dynamic QFT") | ||
| def create_circuit(num_qubits: int) -> QuantumCircuit: | ||
| """Return a circuit implementing the Dynamic QFT. | ||
|
|
||
| This benchmark follows the semiclassical Quantum Fourier Transform by | ||
| Griffiths and Niu. Each qubit is transformed with a Hadamard gate, measured | ||
| immediately, and then its classical result controls phase rotations on the | ||
| remaining qubits. This replaces the usual controlled-phase gates with | ||
| mid-circuit measurements and classical feed-forward while keeping the same | ||
| triangular phase-angle structure as the standard QFT. | ||
|
|
||
| Arguments: | ||
| num_qubits: number of qubits of the returned quantum circuit. | ||
|
|
||
| Returns: | ||
| QuantumCircuit: a quantum circuit implementing the Dynamic QFT. | ||
| """ | ||
| q = QuantumRegister(num_qubits, "q") | ||
| c = ClassicalRegister(num_qubits, "c") | ||
| qc = QuantumCircuit(q, c, name="dynamic_qft") | ||
|
|
||
| for measured_qubit in range(num_qubits): | ||
| measured_bit = num_qubits - measured_qubit - 1 | ||
| qc.h(q[measured_qubit]) | ||
| qc.measure(q[measured_qubit], c[measured_bit]) | ||
|
|
||
| for offset in range(1, num_qubits - measured_qubit): | ||
| with qc.if_test((c[measured_bit], 1)): | ||
| qc.p(math.pi / (2**offset), q[measured_qubit + offset]) | ||
|
|
||
| return qc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
qftbenchmark. The measured outcomes should be written to the classical bits in the reversed order.There was a problem hiding this comment.
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]intoc[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.
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
qftbenchmark 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.