-
Notifications
You must be signed in to change notification settings - Fork 189
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
[Hardware path] cudaq.observe()
incorrectly returns 0.0 when there is only a single spin op term
#2382
Comments
Adds a check to see if the execution context is observe to avoid the bug mentioned in issue NVIDIA#2382. The issue mentions "bugs", so there may be others. Add the test case provided. Signed-off-by: Eric Schweitz <[email protected]>
Adds a check to see if the execution context is observe to avoid the bug mentioned in issue NVIDIA#2382. The issue mentions "bugs", so there may be others. Add the test case provided. Signed-off-by: Eric Schweitz <[email protected]>
Adds a check to see if the execution context is observe to avoid the bug mentioned in issue NVIDIA#2382. The issue mentions "bugs", so there may be others. Add the test case provided. Signed-off-by: Eric Schweitz <[email protected]>
* Fix issue #2382. Adds a check to see if the execution context is observe to avoid the bug mentioned in issue #2382. The issue mentions "bugs", so there may be others. Add the test case provided. * Coding convention. * Review comments. --------- Signed-off-by: Eric Schweitz <[email protected]>
Thank you for the fix, @schweitzpgi ! $ export OQC_URL="https://cloud.oqc.app" |
Thank you very much @bmhowe23 , the above C++ code work fine with your fix! |
Required prerequisites
Describe the bug
When using a single spin-op term, running
cudaq::observe()
from C++ (orcudaq.observe()
from Python) returns incorrect results when running with--emulate
for C++ (oremulate=True
for Python). It returns0.0
instead of a true expectation calculation.Steps to reproduce the bug
Starting with the targettests/execution/cudaq_observe.cpp test already in the repo, if one were to modify
h
to a single term (e.g.cudaq::spin_op h = i(0) * z(1);
), the resulting energy is 0.0 when running with--emulate
and it is non-zero when running without--emulate
.For example, generate this test file (test.cpp):
And then run the following two tests, you will see different answers. The answers should be the same.
Expected behavior
The answers should match.
Note that the example provided in this bug report only deals with the
--emulate
path, but based on partner feedback, I believe the bug exists when using real hardware as well.Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
Suggestions
I have tracked down at least one of the problems to this section of code:
cuda-quantum/runtime/common/BaseRemoteRESTQPU.h
Line 692 in 3300b12
That section of code is assuming that if there is a single circuit that was run (like for a single spin op), that it was not actually an observe calculation. This needs to be updated to be correctly ascertain whether the parent request originated from an observe call rather than just inferring it.
The text was updated successfully, but these errors were encountered: