Bypass cyclic emulator state indexing - #1505
Conversation
lballerio
left a comment
There was a problem hiding this comment.
Hi Dennis, thanks for your contribution!
For me is almost fine, I would ask you do the for loop inside the _marginalize_probability, this would be better for modularity and readability.
Also, for even more readability, maybe add some more comments especially in the more convoluted lines.
I'll move this PR to draft, but I think apart for these small suggestions I think it will be soon good to merge for me.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1505 +/- ##
==========================================
+ Coverage 39.34% 39.41% +0.06%
==========================================
Files 115 115
Lines 6145 6152 +7
==========================================
+ Hits 2418 2425 +7
Misses 3727 3727
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| [ | ||
| _marginalize_probability( | ||
| state_probs[..., measurement, :], hamiltonian.dims, qubit_index | ||
| )[..., 1:].sum(axis=-1) |
There was a problem hiding this comment.
I guess here you are summing all states >=1...I think you can also move this part in the function
|
Thanks @lballerio, this makes sense. I moved the per-measurement loop into |
|
Thanks @lballerio , I added the comment at that point. It now states that the non-ground-state sum is intentionally done before stacking because measured subsystems may have different dimensions. |
|
Hi @DennisWayo, I tested your code for a bit and everything seems working, so for me is approved and able to merge. |
Summary
This is a small follow-up to the emulator/Qibocal baseline enabled by
qiboteam/qibocal#1551.It updates cyclic emulator result extraction to marginalize probabilities directly over the measured Hilbert-space component instead of first building the full computational-state index table and masking it.
The behavior is unchanged at the result interface:
1;INTEGRATIONresults still return the expected(I, Q)shape;Context
This addresses the marginalization direction described in
qiboteam/qibolab#1216: for non-shot/cyclic result processing, there is no need to go through sampled-state machinery or full-state index conversion when probabilities can be reshaped to the system Hilbert-space dimensions and marginalized directly.I kept this separate from the local #1413 work because #1413 depends on the confusion-matrix path introduced in draft
qiboteam/qibolab#1401, which has not landed yet.Validation
pytest tests/instruments/emulator/test_results.py -qpytest tests/instruments/emulator/test_emulator.py tests/instruments/emulator/test_results.py -qpytest tests/instruments/emulator -qruff check src/qibolab/_core/instruments/emulator/results.py tests/instruments/emulator/test_results.pyruff format --check src/qibolab/_core/instruments/emulator/results.py tests/instruments/emulator/test_results.pymainplatform:qubitacquisition + fit passedmainplatform:qutritacquisition + fit passed