Skip to content

Conversation

1tnguyen
Copy link
Collaborator

@1tnguyen 1tnguyen commented Sep 19, 2025

Description

  • A pass to detect if qubit is to be reused after measurement. If so, insert a reset and conditional x 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).

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]>
@1tnguyen 1tnguyen changed the title [WIP [WIP] Adding reset after measure if qubit is to be reused Sep 19, 2025
github-actions bot pushed a commit that referenced this pull request Sep 19, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Copy link
Collaborator

@schweitzpgi schweitzpgi left a 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...

1tnguyen and others added 5 commits September 22, 2025 14:19
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]>
github-actions bot pushed a commit that referenced this pull request Sep 22, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Sep 22, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Sep 24, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Sep 29, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Signed-off-by: Thien Nguyen <[email protected]>
github-actions bot pushed a commit that referenced this pull request Sep 29, 2025
github-actions bot pushed a commit that referenced this pull request Sep 30, 2025
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Copy link
Collaborator

@schweitzpgi schweitzpgi left a 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())) {
Copy link
Collaborator

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.

Copy link
Collaborator

@sacpis sacpis left a 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.

github-actions bot pushed a commit that referenced this pull request Oct 2, 2025
Copy link

github-actions bot commented Oct 2, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 7, 2025
Copy link

github-actions bot commented Oct 7, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Copy link

github-actions bot commented Oct 7, 2025

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants