-
Notifications
You must be signed in to change notification settings - Fork 292
Adding reset after measure if qubit is to be reused #3450
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
base: main
Are you sure you want to change the base?
Adding reset after measure if qubit is to be reused #3450
Conversation
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
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.
Will look at this more...
Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]>
Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]>
Co-authored-by: Eric Schweitz <[email protected]> Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
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.
This pass should be written when the IR is in explicit linear use form (aka, value semantics), as it will be much simpler to understand, write, etc.
It actually becomes trivial. A measurement op must produce 1 or more wires. If those wires are used by anything that is not a sink operation, they are reused. In those case, if the reuse is not a reset operation, then insert a reset operation. Done.
} | ||
|
||
// No next use is found, check if this is an extracted qubit. | ||
if (isa<quake::RefType>(qubit.getType())) { |
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.
In reference semantics, you will have to account for every possible case of aliasing. References can alias.
So it's not as simple as looking at alloca and extract_ref. Correctness here means you have to consider calls, block arguments, various arithmetic operations, dynamic qubit refreences, and so on.
On the other hand, value semantics has already been built and makes all of this much, much easier.
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.
Left a few comments.
runtime/cudaq/platform/default/rest/helpers/quantinuum/quantinuum.yml
Outdated
Show resolved
Hide resolved
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Thien Nguyen <[email protected]>
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Description
A pass to detect if qubit is to be reused after measurement. If so, insert a
reset
and conditionalx
gate based on measurement result in order to bring the qubit into the |0> or |1> state consistent with the measurement.Add the pass to
quantinuum
target pipeline config.Add tests.
Modify the resource counting pre-process pass: move it down the JIT pipeline as the removal of gates in that pass may interfere with the program flow detection (i.e., whether a qubit is reused or not).