-
Notifications
You must be signed in to change notification settings - Fork 34
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
Swap register order, removing need to pass num_qpd_bits
#434
Conversation
Pull Request Test Coverage Report for Build 6463654179
💛 - Coveralls |
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.
Dropping a couple thoughts here. Will finish this up in a bit. Looking great!
if reg.name == "observable_measurements": | ||
obs_creg = reg | ||
break | ||
else: |
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.
Neat code here where the else sits outside the looped if ... I'll have to glance at how this works :)
@@ -111,21 +109,7 @@ def reconstruct_expectation_values( | |||
for k, cog in enumerate(so.groups): | |||
quasi_probs = results_dict[label].quasi_dists[i * len(so.groups) + k] | |||
for outcome, quasi_prob in quasi_probs.items(): | |||
try: |
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.
niiiiice
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.
Great idea, thanks for puttin this PR together. Makes thing much more straightforward :)
@@ -156,15 +136,11 @@ def _process_outcome( | |||
this vector correspond to the elements of ``cog.commuting_observables``, | |||
and each result will be either +1 or -1. | |||
""" | |||
num_meas_bits = len(cog.pauli_indices) |
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.
I realized in my final-review-before-merging that this line has a bug. It should really be
num_meas_bits = len(cog.pauli_indices) | |
num_meas_bits = len(_get_pauli_indices(cog)) |
i.e., it needs to consider the actual number of measurement bits given the workaround to #422.
I fixed this and added a test (really, a more thorough version of the existing test_sampler_with_identity_subobservable
) in f4dec60. The refactored test
- only considers a single circuit rather than all circuits given by the
example_circuit
fixture (should save execution time) - performs a smoke test with
Sampler
(as before) as well as a newly added full roundtrip test (which ensures correct expectation values) usingExactSampler
@ibrahim-shehzad: since @caleb-johnson already approved everything before f4dec60, and f4dec60 primarily updates a test that you wrote, I think it makes most sense for you to review the changes in f4dec60 and approve this PR if those changes look good to you. Thanks! |
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.
This looks good to me!
This swaps the order of the registers such that
qpd_measurements
now comes last. The motivation here is two-fold:num_qpd_bits