KEMBAR78
Fixes and issue with sampling when kernel contains mid-circuit measurements by 1tnguyen · Pull Request #1619 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@1tnguyen
Copy link
Collaborator

@1tnguyen 1tnguyen commented May 7, 2024

Description

The current Python MidCircuitMeasurementAnalyzer visitor only supports certain expressions, e.g., if val but not if val == boolVar, where val = mz(q).

Hence, it may mis-identify some kernels as non-measurement feedback, i.e., not setting qubitMeasurementFeedback=true, causing wrong sampling mode being used.

This PR:

  • Add more handling cases: variable name or variable subscript; CompareOp; handle variables in BoolOp and UnaryOp.

  • Add IR checks and target tests.

Note: this is not an exhaustive handling of all possible scenarios.

Resolves #1618

The current Python `MidCircuitMeasurementAnalyzer` visitor only supports
certain expressions, e.g., `if val` but not `if val == True`, where `val
= mz(q)`.

Hence, it mis-identified some kernels as non-measurement feedback, i.e.,
not setting `qubitMeasurementFeedback=true`, causing wrong sampling mode
being used.

This PR:

- Add more handling cases: variable name or variable subscript;
  CompareOp; handle variables in BoolOp and UnaryOp.

- Add IR checks and target tests.

Note: this is not an exhaustive handling of all possible scenarios.
github-actions bot pushed a commit that referenced this pull request May 7, 2024
@github-actions
Copy link

github-actions bot commented May 7, 2024

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

@github-actions
Copy link

github-actions bot commented May 7, 2024

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

github-actions bot pushed a commit that referenced this pull request May 7, 2024
@github-actions
Copy link

github-actions bot commented May 7, 2024

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

github-actions bot pushed a commit that referenced this pull request May 7, 2024
Copy link
Collaborator

@bmhowe23 bmhowe23 left a comment

Choose a reason for hiding this comment

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

+1

@schweitzpgi
Copy link
Collaborator

schweitzpgi commented May 7, 2024

IMO, this analysis shouldn't really be done on the AST.

Can you create another issue to replace this ad hoc pattern matching with a dataflow analysis? (We need it for C++ as well.)

@github-actions
Copy link

github-actions bot commented May 7, 2024

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

github-actions bot pushed a commit that referenced this pull request May 7, 2024
@schweitzpgi schweitzpgi merged commit 8797d61 into NVIDIA:main May 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 7, 2024
@bettinaheim bettinaheim added the bug fix To be listed under Bug Fixes in the release notes label May 10, 2024
@bettinaheim bettinaheim added this to the release 0.7.1 milestone May 10, 2024
@bettinaheim bettinaheim changed the title Fixes for https://github.com/NVIDIA/cuda-quantum/issues/1618 Fixes and issue with sampling when kernel contains mid-circuit measurements May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug fix To be listed under Bug Fixes in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MidCircuitMeasurementAnalyzer doesn't handle all cases of measurement assigned variables

4 participants