-
Notifications
You must be signed in to change notification settings - Fork 61
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
Fix complex samples #1414
Fix complex samples #1414
Conversation
@renatomello do you remember why the cast was introduced? Due to torch? |
While I agree with the fix, it seems a bit of a patch: in principle, I should try myself to reproduce, but since you already did it: which was the original object being cast? |
Co-authored-by: Stefano Carrazza <[email protected]>
for more information, see https://pre-commit.ci
206db01
to
c32fe97
Compare
It is a patch, it is attempting to fix the issue but may not necessarily be the best overall solution.
I don't think this is correct. If you look at the qibo/src/qibo/backends/numpy.py Lines 59 to 66 in 259380d
if a
I tried to stop with the debugger right before the I guess it only appears with qibolab because this part of the code is normally not used when simulating. It handles the case where the samples are registered externally, in qibolab's case using what was returned from the instruments. For simulation the samples are generated by the backend (using RNG) so |
You're right, I just got confused with At this point, I really wonder why it was introduced...
Yes, this was just because of my former confusion. But you should be able to reproduce this even with the
Yes, if there is a more likely way to incur in this, we should use that for testing as well. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1414 +/- ##
=======================================
Coverage 99.94% 99.94%
=======================================
Files 78 78
Lines 11225 11225
=======================================
Hits 11219 11219
Misses 6 6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Yes, it is due to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm in favor of the patch. Maybe we should add the test I was proposing above, but given the urgency, we may do it even in a different PR.
Yes, it is due to
torch
. Without thecast
, theMeasurementOutcumes.samples
breaks fortorch
because it returns a list ofnp.ndarray
s and that breaks furthertorch
functions.torch
needs it to be a list oftorch.Tensor
s. I do believe that @stavros11's patch is the easiest, most painless way to solve this.
Ok, but this problem would be better solved at the level of MeasurementOutcomes
itself, which should return a tensor of the given backend (which is then cast to NumPy explicitly, when needed).
I would open an issue to discuss it.
Btw, as soon as we'll release v0.2.11 with this patch on PyPI, we should consider yanking v0.2.10, since it's broken for Qibolab and should be avoided (if there is no critical feature in there, we could even yank immediately - but since there are more Qibo users than Qibolab users, maybe it's worth to wait for the new one) @scarrazza |
This should fix #1412, however I am not sure if it causes any other issues as I don't understand why this
cast
was introduced and the workflows are failing for other reasons.Checklist: