Skip to content

Correctly distinguish measurement result and boolean variable - #1952

Merged
khalatepradnya merged 3 commits into
NVIDIA:mainfrom
khalatepradnya:fix-bool-scope
Jul 18, 2024
Merged

Correctly distinguish measurement result and boolean variable#1952
khalatepradnya merged 3 commits into
NVIDIA:mainfrom
khalatepradnya:fix-bool-scope

Conversation

@khalatepradnya

@khalatepradnya khalatepradnya commented Jul 17, 2024

Copy link
Copy Markdown
Collaborator
  • If a boolean variable is not the result of measurement then treat it as regular variable.
  • Update the value of boolean if seen in outer scope.

@khalatepradnya khalatepradnya self-assigned this Jul 17, 2024
@khalatepradnya khalatepradnya added bug fix To be listed under Bug Fixes in the release notes python bridge Involves the python bridge to quake labels Jul 17, 2024
Comment thread python/tests/mlir/bool_var_scope.py
@khalatepradnya
khalatepradnya marked this pull request as draft July 17, 2024 21:10
@github-actions

Copy link
Copy Markdown

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

github-actions Bot pushed a commit that referenced this pull request Jul 17, 2024
@khalatepradnya
khalatepradnya force-pushed the fix-bool-scope branch 2 times, most recently from 997ca6c to 5fb5e4e Compare July 17, 2024 22:34
github-actions Bot pushed a commit that referenced this pull request Jul 17, 2024
@github-actions

Copy link
Copy Markdown

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

@khalatepradnya
khalatepradnya marked this pull request as ready for review July 17, 2024 23:45

@bmhowe23 bmhowe23 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@khalatepradnya
khalatepradnya enabled auto-merge (squash) July 18, 2024 02:57
@khalatepradnya
khalatepradnya merged commit 33c279b into NVIDIA:main Jul 18, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2024
Comment thread python/tests/mlir/bool_var_scope.py
Comment on lines +59 to +60
# CHECK: %[[VAL_18:.*]] = cc.alloca !cc.stdvec<i1>
# CHECK: cc.store %[[VAL_17]], %[[VAL_18]] : !cc.ptr<!cc.stdvec<i1>>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This code doesn't create a vector, doesn't create any storage to save a vector's data, doesn't copy the vector, does potentially create a memory leak on the stack, and in the end is a dead store to a memory location that will never be read.

@khalatepradnya
khalatepradnya deleted the fix-bool-scope branch July 18, 2024 16:56
@khalatepradnya khalatepradnya added this to the release 0.8.0 milestone Jul 22, 2024
@bettinaheim bettinaheim changed the title [Python] [AST Bridge] Correctly distinguish measurement result and boolean variable Correctly distinguish measurement result and boolean variable Jul 29, 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 python bridge Involves the python bridge to quake

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope of variables is inconsistent within cudaq.kernel

3 participants