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

Swap register order, removing need to pass num_qpd_bits #434

Merged
merged 4 commits into from
Oct 26, 2023

Conversation

garrison
Copy link
Member

@garrison garrison commented Oct 4, 2023

This swaps the order of the registers such that qpd_measurements now comes last. The motivation here is two-fold:

  1. To be consistent with the natural register order when reconstructing probability distributions (Draft support for reconstructing a probability distribution #428)
  2. To remove the need to pass around num_qpd_bits

@garrison garrison added the cutting QPD-based circuit cutting code label Oct 4, 2023
@garrison garrison added this to the 0.5.0 milestone Oct 4, 2023
@github-actions
Copy link

Pull Request Test Coverage Report for Build 6463654179

  • 32 of 32 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 92.382%

Totals Coverage Status
Change from base Build 6463570000: 0.02%
Covered Lines: 2959
Relevant Lines: 3203

💛 - Coveralls

Copy link
Collaborator

@caleb-johnson caleb-johnson left a 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:
Copy link
Collaborator

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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

niiiiice

caleb-johnson
caleb-johnson previously approved these changes Oct 23, 2023
Copy link
Collaborator

@caleb-johnson caleb-johnson left a 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)
Copy link
Member Author

@garrison garrison Oct 24, 2023

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

Suggested change
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) using ExactSampler

@garrison
Copy link
Member Author

@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!

Copy link
Collaborator

@ibrahim-shehzad ibrahim-shehzad left a 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!

@garrison garrison merged commit 26845aa into main Oct 26, 2023
11 checks passed
@garrison garrison deleted the swap-register-order branch October 26, 2023 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cutting QPD-based circuit cutting code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants