-
Notifications
You must be signed in to change notification settings - Fork 56
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
Interleaved RB #468
Conversation
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.
#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 |
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.
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)): |
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.
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.
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.
Thanks for catching these sorts of Windows oddities!
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.
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)): |
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.
Thanks for catching these sorts of Windows oddities!
result = proto.run(self.data_noisy) | ||
|
||
|
||
class TestInterleavedRBProtocol(BaseCase): |
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.
Thanks as always for writing tests!
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:
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 ofCombinedExperimentDesign
which allows for use to index into each of the subdesigns as well as interact with them jointly (getting the combinedall_circuits_needing_data
value at data collection time, for example).InterleavedRandomizedBenchmarking
: This is a new protocol class which farms off the RB estimation for each of the subexperiments toRandomizedBenchmarking
and then extracts the relevant results for calculating the IRB numbers and bounds. This returns aProtocolResultsDir
containing the IRB specific results along with the full results for each of the subexperiments.InterleavedRandomizedBenchmarkingResults
: This is a simple (mostly data) class for storing the IRB results at the top node of the aforementionedProtocolResultsDir
.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.