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

Interleaved RB #468

Merged
merged 7 commits into from
Jul 25, 2024
Merged

Interleaved RB #468

merged 7 commits into from
Jul 25, 2024

Conversation

coreyostrove
Copy link
Contributor

@coreyostrove coreyostrove commented Jul 18, 2024

This PR adds first party support for interleaved randomized benchmarking (as described in the original 2012 paper from Magesan et al. https://arxiv.org/pdf/1203.4550) to the RB codebase. The analysis for IRB is incredibly simple, so from an implementation standpoint much of what has been added is aimed at streamlining the experiment design construction process, automating this analysis, and creating data structures for keeping the two relevant subexperiments stored together.

Specifically I have added the following:

  1. InterleavedRBDesign: This class both performs the creation of the two subexperiment designs (a standard CRB experiment and one with a target gate interleaved between random cliffords) and acts as a container for these two experiment designs. This subclasses off of CombinedExperimentDesign which allows for use to index into each of the subdesigns as well as interact with them jointly (getting the combined all_circuits_needing_data value at data collection time, for example).
  2. InterleavedRandomizedBenchmarking: This is a new protocol class which farms off the RB estimation for each of the subexperiments to RandomizedBenchmarking and then extracts the relevant results for calculating the IRB numbers and bounds. This returns a ProtocolResultsDir containing the IRB specific results along with the full results for each of the subexperiments.
  3. InterleavedRandomizedBenchmarkingResults: This is a simple (mostly data) class for storing the IRB results at the top node of the aforementioned ProtocolResultsDir.

Aside from the code described above I have also added a new section to the Clifford RB tutorial notebook demonstrating the use of the new functionality. Also included are new unit tests, both for the IRB features added and for improving testing coverage on existing parts RB (particularly with regards to serialization). Lastly, there is a bug fix for a reported issue where serialization of CliffordRBDesign was failing when constructed using the (previously undocumented) interleaved_circuit kwarg.

Big thanks go out to @jordanh6 and @enielse for their valuable advice in the achitecting of these additions, and to @jordanh6 and @tjproct for their guidance on the IRB theory.

Corey Ostrove added 7 commits July 16, 2024 21:23
This commit adds new functionality for performing interleaved randomized benchmarking including functionality for building the experiment designs required as well as running the protocol and storing the results into a format that is compatible with serialization and maintains ease of access to relevant subresults. This also includes a bug fix for a serialization issue that had been impacting CliffordRBDesign when using the (previously) undocumented interleaved_circuit argument.
Patch back in support for EI type IRB numbers into the InterleavedRandomizedBenchmarking protocol.
To address an annoying warning and pickle fallback behavior.
Add a new IRB subsection to the CRB tutorial discussing the new IRB related functionality and use.
Removes the `square_mean_root` kwarg for RandomizedBenchmarking. This was an experimental option that changed the way that per-depth circuit data was used, but is no longer in use nor recommended to be used.
Previously the two CRB designs were being passed the same seed, which would mean the crb and icrb designs would likely wind up with identical random cliffords.
Add new unit tests for the IRB related additions. Also add more testing coverage for existing RB protocols and experiment designs. Finally, this also includes a couple minor bug fixes caught by testing.
@coreyostrove coreyostrove self-assigned this Jul 18, 2024
@coreyostrove coreyostrove requested review from a team as code owners July 18, 2024 05:59
#print(adj_sps)
else:
adj_sps.append(_np.nanmean(percircuitdata)) # average [adjusted] success probabilities or energies
adj_sps.append(_np.nanmean(percircuitdata)) # average [adjusted] success probabilities or energies
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The removal of the square_mean_root kwarg (and related behavior shown here) is unrelated to the IRB stuff and was done at the recommendation of @tjproct. This was added at one point as an experiment and no longer makes sense to keep as an analysis option.

@@ -88,7 +88,7 @@ def _serialize(x):
#TODO: serialize via _to_memoized_dict once we have a base class
if x is None or isinstance(x, (float, int, str)):
return x
elif isinstance(x, _np.int64):
elif isinstance(x, (_np.int64, _np.int32)):
Copy link
Contributor Author

@coreyostrove coreyostrove Jul 18, 2024

Choose a reason for hiding this comment

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

Semi-related serialization fix to address pickle fallback (I think this is a windows specific thing related to the whole 32-bit integer thing that gave us headaches a couple years ago) and a related warning when serializing some RB-related objects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for catching these sorts of Windows oddities!

Copy link
Contributor

@sserita sserita left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @coreyostrove!

@@ -88,7 +88,7 @@ def _serialize(x):
#TODO: serialize via _to_memoized_dict once we have a base class
if x is None or isinstance(x, (float, int, str)):
return x
elif isinstance(x, _np.int64):
elif isinstance(x, (_np.int64, _np.int32)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for catching these sorts of Windows oddities!

result = proto.run(self.data_noisy)


class TestInterleavedRBProtocol(BaseCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks as always for writing tests!

@sserita sserita merged commit 722053c into develop Jul 25, 2024
4 checks passed
@sserita sserita deleted the feature-irb branch July 25, 2024 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants