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

Feature parity benchmarking #532

Merged
merged 17 commits into from
Mar 18, 2025
Merged

Feature parity benchmarking #532

merged 17 commits into from
Mar 18, 2025

Conversation

sserita
Copy link
Contributor

@sserita sserita commented Jan 23, 2025

This adds parity benchmarking features to pygsti.extras and an associated tutorial in jupyter_notebooks/Tutorials/other, where parity benchmarking refers to computing various weight-X disturbance metrics between a reference and test data set. This is a fairly standalone feature, but we would like to merge it in to prevent this functionality from getting lost on a stale branch.

WIP: There are cells in the notebook that we should turn into unit tests, but otherwise, the code seems fully functional. @enielse, this is probably a blast from the past, but you are probably the last person who touched this code in earnest. Do you remember if there are any other outstanding issues that would prevent a merge here?

Erik Nielsen and others added 16 commits May 27, 2020 15:45
Adds a new sub-package: pygsti.extras.paritybenchmarking, that
contains disturbancecalc.py - a module for computing the weight-k
disturbance metric.  A notebook demonstrating how to use the
contained functions is given in the new
jupyter_notebooks/Tutorials/other/ParityBenchmarking.ipynb notebook.

Some cosmetic cleanup has been done to disturbancecalc.py from the
initial version that was created for separate distribution - linting
errors/warnings have been fixed, and imports have been underscore-prefixed.
- guards cvxpy import in distrubancecalc.py, as cvxpy is not a required
  package.
- adds pygsti.extras.paritybenchmarking to setup.py's list, so that
  non-local installs work properly.
…tleneck.

The swell function is used to construct basis sets for a disturbance
calculation.  The initial implementation was straightforward but relied
on lots of numpy krons, etc.  This commit adds a new version that makes
use of pyGSTi's embedding logic to more efficiently embed a weight-k
transition matrix within a larger one, and should speed up disturbance
calculations significanty.

This commit leaves in a bunch of debug logic and print statements,
including a check within the swell function itself to compare its
output with the old version - so right now the new version isn't
any faster.  Once we're satisfied the new implementation is correct
we'll remove the debug apparatus.
… warnings.

This was creating problems throughout the pygsti unit tests, where warnings
are ok and should't raise exceptions.
Checks have completed and the new, fast version of `swell` seems
correct.  This commit removes the debugging apparatus used to
check the performance of partity benchmarking on 6 qubits.  It also
adds output giving the time elapsed per bootstrap run, which for 6Q is
~1min per run on Erik's old laptop.
OVD calculation appears to be non-convex though, so we'll need to do
something else.  This commit partially plumbs a "reference" argument
(for the ideal probability distribution P0), and experiments with some
code - marked with "HERE" - in the appropriate spot within
disturbancecalc.py, even though it doesn't work yet.
After much discussion, we decided to compute the Residual OVD by
simply using the 'T' matrix found from a Residual TVD calculation
in the formula for original variational distance (OVD).
…TVD point.

We settled on computing the residual-OVD by evaluating it at the best
"T" (transition) matrix for the residual-TVD (since finding the latter
is a convex program).  This additional local optimization tries to
improve the T-matrix locally to achieve a better (lower) OVD.  A
warning is printed if this local optimization improves the OVD too
much, since this may indicate that the initial point was bad and
the final result isn't a global optimum.
When self.weight == 0 (for computing the weight-0 residual-OVD) the
code still computed the TVD!  Fixed now, and preliminary tests of
disturbance using residual-OVD look as expected.
After some further testing, we have realized that the OVD doesn't
seem compatible with the foliation we used to move from TVD -> ResidualTVD.
In particular we find that the residual-OVD values, when computed
similarly to residual-TVD, can be weirdly behaved as a function of
spam error.  This is at least in part due to the fact that the "T"
(transfer mx) found by the residual-TVD computation may exactly match
the TP and Q distributions on the 0000 and 1111 bit strings, leaving
the only remaining discrepancies on bit strings without support in P0.

To fix this issue, this commit redefines the residual-OVD to just be
a scaled version of the residual-TVD (scaled by the total OVD/TVD ratio,
as the OVD is still a robust metric).
…ions.

Removes OVD computation from within ResidualTVD class, since we
currently just correct the residual TVD by an overall r=OVD/TVD
scaling factor.  Adds a function to compute this scaling factor
as well as separate ...ovd_corrected... functions for computing
disturbance quantities that are scaled by the OVD/TVD ratio.
@sserita sserita added this to the 0.9.13.1 milestone Jan 23, 2025
@sserita sserita marked this pull request as ready for review March 18, 2025 17:49
@sserita sserita requested review from a team as code owners March 18, 2025 17:49
@sserita sserita requested review from kmrudin and coreyostrove March 18, 2025 17:49
@sserita sserita changed the title WIP: Feature parity benchmarking Feature parity benchmarking Mar 18, 2025
@sserita sserita merged commit 3bce6d3 into develop Mar 18, 2025
4 checks passed
@sserita sserita deleted the feature-parity-benchmarking branch March 18, 2025 19:00
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.

1 participant