Skip to content

HTML Report Updates #572

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

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open

HTML Report Updates #572

wants to merge 25 commits into from

Conversation

coreyostrove
Copy link
Contributor

@coreyostrove coreyostrove commented Apr 18, 2025

This PR introduces a number of changes to the display, functionality and performance of HTML report generation.

standard_report_high_depth.zip
instruments_and_CIs.zip

Visualization Changes (Existing Figures)

I will describe the changes briefly below, but it is likely most informative to see these in-situ so I have attached two demo 1Q GST reports, one with a really high maximum depth and another containing both instruments and error bars.

  1. Updated per-sequence detail plots: Also called the color box plots, these have been reworked for clarity and with some additional features. It was sometimes hard to delineate between boxes of similar colors so thin outlines have been added to each box. It was also often tricky in the context of FPR to visually place a square within its prep-fid/meas-fid row-column pair by eye for very sparse plaquettes, so there is now a toggleable overlay which adds a grid to the help guide the eye. Sizing on squares has been made more consistent and spacings have been adjusted in accordance with this. One big request we had was to address difficulties with the hover box information being challenging to use due to it often obscuring underlying boxes. The behavior of the hover boxes has been adjusted to more consistently stay off to the right or left of the object being introspected, so this should hopefully reduce the frequency of those issues. The formatting of text in the hover boxes has also been tab aligned for readability. Another big request was the addition of a new interface for accessing the per-sequence detail information where one could click on a box and have the contents of the hover information printed to the side of the figure, and this has been added as well. Both the hover boxes and the click interface can be toggled on/off individually (live) in case either is not wanted for whatever reason.
  2. Delineation between C and A error generators: There are now triangles marking which triangle is which.
  3. Less funky SPAM and Choi states: The formatting the raw estimates for the SPAM has always been confusing, since it looks like it should be a density matrix, and it was, but written in a strange way where the upper and lower triangular parts of the plotted array were used for the real and imaginary parts of the off diagonals (except this wasn't ever explained anywhere). The new version splits these off into two arrays and plots the real and imaginary parts separately (and labels them). The same issue applied to choi states that were being reported so this change was made there too.
  4. Error generator sector percentage: The text that used to accompany the error generator projections has been made more understandable. The original information is still there, but now with the clarification that it is frobenius norm, and a new line has been added with the percentage contribution to the generator infidelity (which is closer to what people have always wanted this percentage to mean).
  5. Error bars on raw estimates for gates now shows up both in the hover info and in a separate column with the CI half widths. This was a request from some users for better visibility when errors are very small.
  6. Error bars on raw estimates for SPAM now also show up as hover info.

New Stuff

Here are some new additions to the reports.

  1. There is a new plot on the model violation overview tab which gives a histogram with the distribution of the per-circuit TVDs, per a recent request from @omaupin.
  2. Raw estimates for the SPAM operations now include the target and estimated SPAM operations as Hilbert-Schmidt vectors.
  3. Generator infidelity has been added as an error metric in a few of the tables currently containing quality metrics.

Performance Changes

100% honesty, report generation will often be at least a bit slower on the whole due to the changes on this branch. A lot of that has to do with the fact that we're now drawing a lot more geometry for the per-sequence details. There are some changes to the report generation that speed certain subroutines up and ameliorate this increased time cost quite a bit, though. The biggest change is completing some plumbing for reusing MDC store objects that are generated in the course of GST's iterative optimization to accelerate the construction of certain plots which rely on them (and previously were rebuilding new ones from scratch). If my commit messages from a year ago are to be trusted then for smaller maximum circuit depths the speedup is rather modest, but for a maximum depth of 2048 with one-qubit GST this change sped up report generation by ~40%.

Bugfixes

  1. Fix for Target Eigenvalues Overwritten with Estimated in Germs Detail #569, which reported that on the second table of the germs detail tab the target eigenvalues were being pulled in from the wrong model. The underlying bug was just that the wrong model was being passed in from the switchboard, and it turns out the other table on this page had the exact same issue.
  2. The predicted RB number table that had been previous disabled (years ago) is now enabled again and the code it points to has been updated to the current home of that RB theory code. This issue was originally report in HTML Reports (Parent Issue) #426.

Corey Ostrove added 24 commits April 17, 2024 23:55
This adds thin borders around squares in the color box plots used for per-sequence detail plots in reports. Also adds a small gap between squares, tweaks to the spacing of plaquettes, and grid lines delineating between plaquettes for increased visbility.
Updates the version number in readme and adds information about one possible way to cite pygsti in publications.
This commit adds a few new options for finer grained control of the per-sequence detail visualizations.
1. This adds intra-plaquette grids for easier reading of FPRed experiment designs. These can be toggled on and off with a button.
2. The option to toggle on and off hover labels on boxes.
3. A new visualization option that enables click-to-display of the hover label information in an area off to the side of the figures plot area. This can also be toggled on and off.

Additionally there is some clean up for long since out of data code. This also adds a copy of the open sans true type file to the repo as this seemed to be the most portable solution to the problem of having a font handy and readily findable by pillow for estimating the rendered size of the hover labels (needed to ensure we have enough margin included so that the text doesn't get cut off).
Default behavior is now to have the clickable hover labels on by default.
Adds the generator infidelity to reports, and adds a helper function to optools for calculating this quantity.
Modify the error generator table text to include the generator infidelity contributions and to call out that the other norm is the frobenius norm.
This adds additional annotations to the C and A project plot to more clearly label which triangle is which, and to make the figure more clear generally.
Initial attempt at making the information in the hover labels and click labels for per-sequence-detail-like plots easier to read by making by using f-string alignment jutsu.
This commit overhauls the presentation of the SPAM estimate table and the choi matrix table. This includes the following changes:
1. SPAM and choi matrices are now split into their real and imaginary parts in separate subplots (when complex valued), rather than having their real and imaginary off-diagonals arranged on the upper and lower triangles of a matrix.
2. The HS vector is not included by default, and there is now plotted as a box plot whenever the states and effects are.
3. A bunch of changes to the reporting code to enable support for these changes, including new plot classes meant to wrap together multiple matrix plots, as well as changes to the existing matrix plots to properly support non-square data.
4. Bug fix for the error bars on the HS vector for POVM effects.
This plumbs in errorbars into the plotting routines for SPAM raw estimates and enables viewing them via hovering over boxes.
This commit adds in additional plumbing for the MDC stores generated during the course of GST estimation so that these can be accessed by the report generation, side-stepping the need to rebuild them from scratch when creating ColorBoxPlots. This only provides a small speedup for relatively small max Ls, but a fairly significant one for large max Ls. e.g. report generation for one-qubit and a maximum depth of 2048 is sped up by ~40% with these changes. Even longer max Ls should be sped up by an even larger fraction.
Adds plumbing for using pre-computed MDC store objects in more places in the reports, and fixes the artifacting of these during the GST protocol. This results in a notable performance for report generation.
Minor tweaks to improve report generation performance by switching to using dictionaries for annotation creation, and inlining some numpy functions.
Rework the SPAM and Gate table error bar handling, and re-implement the ability to split off real and imaginary parts for gates. Additionally, add the target HS vector as a column to the SPAM table.
A series of changes related to the rendering of the new per-sequence detail plots when using the new and improved implementation. This was tracked back to behavior related to trying to have use the aspect ratio of the figure used to rescale its size based on the dimensions of the container. This resulted in unexpected scaling behavior where really wide plots got scaled to be too small. The workaround added, since I didn't see an obvious way to address the logic, was to add the plumbing for skipping this aspect ratio locking behavior for these particular figures.
Fixes a bug in the germs details tables reported in #569. The issue was that the wrong model was being pulled from the switchboard as the target model.

Also includes and unrelated fix for the generator infidelity in reports which was accidentally pulling in the average gate infidelity.
Reenable support for the predicted RB number table in the gauge invariant error metric section of the reports. This had previously been disabled, but I believe the version of the relevant function for computing this in the pyGSTi rbtheory tools module does work, so this reenables that computation using the newest code path.
Add a new histogram of the per-circuit TVDs to the goodness of fit overview page.
Fix an issue related to not updating all of the parts of the code touched by the change to the return values from iterative GST now including MDC stores for reuse.
@@ -197,3 +197,29 @@ Questions?
----------
For help and support with pyGSTi, please contact the authors at
pygsti@sandia.gov.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot I added this, I think I did so in response to a request from @dhothem. We should probably also include the citation for Zenodo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

# (and triggers resize-script creation)
if orig_width: del fig['layout']['width']
if orig_height: del fig['layout']['height']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is related to the fix I found for the figure sizing issues I discussed live in the new per-sequence detail plots.

@@ -2461,6 +2460,9 @@ def __init__(self, ws, fn, *args):
The arguments to `fn`.
"""
super(WorkspacePlot, self).__init__(ws)
#add a plot specific option for aspect ratios
self.options['lock_aspect_ratio'] = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a handle for this option was the second half of the fix for the sizing issue I reported for per-sequence detail plots.

Set minimum version to 3.8.0
@coreyostrove coreyostrove marked this pull request as ready for review April 21, 2025 17:43
@coreyostrove coreyostrove requested review from pcwysoc, a team and rileyjmurray as code owners April 21, 2025 17:43
@coreyostrove coreyostrove requested a review from sserita April 21, 2025 17:43
@coreyostrove coreyostrove added this to the 0.9.14 milestone Apr 21, 2025
#TEMPORARILY disabled b/c RB analysis is broken
#from ..extras.rb import theory as _rbtheory
return -1.0 # _rbtheory.predicted_rb_number(model_a, model_b)
return _tools.rbtheory.predicted_rb_number(model_a, model_b)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ran this change past @tjproct and also asked him to take a look at the rest of the code for the predicted RB number table's construction and no immediate concerns were raised.

@pcwysoc
Copy link
Contributor

pcwysoc commented Apr 22, 2025

Hi @coreyostrove,

Excited to see these features getting close to the finish line! Here's a provisional list of feedback:

  • I think the new TVD histogram should be blue, in order to provide greater contrast and maintain a similar look as other TVD figures.
  • In the raw estimates, the instrument error bars are asymmetric as they are calculated using deriv_wrt_params which due to the parameterization of TPInstrument gives overly conservative error bars. I believe the correct way to do this is either using finite difference or calculating them like a reportable quantity using the confidence regions intervals.
  • Relatedly, this pull requests does not include some features for QI that we had at one point worked to incorporate into a similar branch (feature-QI-HTML-integration). These features included rescaling the color bar for quantum instruments in Raw Estimates and adding QIs to the Choi representation table in Gate Decompositions.
  • Is the "Poisson bump" correction implemented? This correction accounts for Wilks' Theorem breaking down for small numbers of counts. The code I wrote also accounts for differing degrees of freedom for different circuits (which often crops up with experiments that include MCMs). If not, I think we should consider including those features in this pull request. This will also require thinking about how to handle the loglikelihood histogram as the expected chi^2 distribution will be different.
  • You may wish to wrap the text for the error generator metrics. They get cut off on small screens.
  • Table 6 in Gauge Invariant Error Metrics does not have error bars for the quantum instrument.

Overall, it looks great and we shouldn't let the perfect be the enemy of the good with regards to implementation.

@coreyostrove
Copy link
Contributor Author

Thanks for the feedback, @pcwysoc!

* I think the new TVD histogram should be blue, in order to provide greater contrast and maintain a similar look as other TVD figures.

That should be simple enough to change.

* In the raw estimates, the instrument error bars are asymmetric as they are calculated using deriv_wrt_params which due to the parameterization of TPInstrument gives overly conservative error bars. I believe the correct way to do this is either using finite difference or calculating them like a reportable quantity using the confidence regions intervals.

Is this an HTML report issue, or is it one that goes deeper?

* Relatedly, this pull requests does not include some features for QI that we had at one point worked to incorporate into a similar branch (feature-QI-HTML-integration). These features included rescaling the color bar for quantum instruments in Raw Estimates and adding QIs to the Choi representation table in Gate Decompositions.

* Is the "Poisson bump" correction implemented? This correction accounts for Wilks' Theorem breaking down for small numbers of counts. The code I wrote also accounts for differing degrees of freedom for different circuits (which often crops up with experiments that include MCMs). If not, I think we should consider including those features in this pull request. This will also require thinking about how to handle the loglikelihood histogram as the expected chi^2 distribution will be different.

You're correct that a number of the instrument-related updates are on the aforementioned feature-QI-HTML-integration branch and not represented here. I haven't forgotten about those, but there are some instrument related plots that are currently broken on that branch (some issues related to error bars) which will take some effort to get fixed. I don't have a timeline on that, so decided to try and get the changes that were ready integrated in the meantime.

* You may wish to wrap the text for the error generator metrics. They get cut off on small screens.

Could you share a screenshot?

* Table 6 in Gauge Invariant Error Metrics does not have error bars for the quantum instrument.

This is also on my to-do list for whenever the feature-QI-HTML-integration branch gets merged in. This was listed in one of the open issue threads so I'll make sure that line item doesn't get prematurely deleted so we can track this.

@pcwysoc
Copy link
Contributor

pcwysoc commented Apr 24, 2025

@coreyostrove here's some answers to your questions:

The blocking problem on the feature-QI-HTML branch is one and the same as the Raw Estimates error bar issue, which is as follows. Error bars on the quantum instrument process matrices are being calculated by falling back on using 'deriv_wrt_params,' since we don't know how to reshape the interval matrix. TPInstruments are parameterized as Q0 (fully parameterized) and Q0+Q1 (full TP parameterization). The error bars on Q1 are then effectively calculated summing the error bars on the Q0 and Q0+Q1 parameters. Consequently, the error bars on the second process matrix will spuriously be roughly twice those of the first process matrix as the positive covariance between the Q1 and Q0+Q1 parameters is ignored.

One way to avoid this issue is to calculate the error bars directly from the confidence region interval as one might a reportable quantity. It may also be possible to work out how the interval matrix should reshaped, which would be the optimal fix.

Here's a screenshot of the error generator metrics issue:

Screenshot 2025-04-24 at 2 17 23 PM

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.

2 participants