Skip to content
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

Fixing segfault crashes when using measure/reset ops. #217

Merged
merged 2 commits into from
Jun 1, 2023

Conversation

1tnguyen
Copy link
Collaborator

@1tnguyen 1tnguyen commented Jun 1, 2023

Description

This is probably a regression since #167

Specifically, flushRequestedAllocations() is not called when handling measurement at the concrete ExecutionManager implementation (i.e., QIRExecutionManager) with the assumption that it has been called during executeInstruction().
This will lead to a Segfault in this case (no gates)

{
        cudaq::qvector q(2);
        mz(q);
 }

For reset gate, there is a subtle issue w.r.t. gate ordering (leading to segfault eventually):
ExecutionManager::resetQudit is skipped by the middle BasicExecutionManager (where instruction batching occurs) and only implemented by the concrete subclass QIRExecutionManager -> reset op could be dispatched out of order due to no synchronize() call (-> segfault due to no flushRequestedAllocations call).

Changes

  • Rename ExecutionManager::resetQudit -> ExecutionManager::reset and use BasicExecutionManager::resetQudit as the pure virtual method for sub-class implementation. This is to make it consistent with how measure is handled.

  • Add flushRequestedAllocations() call to measureQudit/measureSpinOp/resetQudit implementations.

  • Add unit test cases.

Signed-off-by: Thien Nguyen <thien.md.nguyen@gmail.com>
Signed-off-by: Thien Nguyen <thien.md.nguyen@gmail.com>
Copy link
Collaborator

@amccaskey amccaskey left a comment

Choose a reason for hiding this comment

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

Thanks Thien!

@amccaskey amccaskey merged commit 9a7cd77 into NVIDIA:main Jun 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 2023
@bettinaheim bettinaheim added the bug fix To be listed under Bug Fixes in the release notes label Jun 28, 2023
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.

3 participants