-
Notifications
You must be signed in to change notification settings - Fork 131
Update interleaved RB fitter #52
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
Update interleaved RB fitter #52
Conversation
|
793e160 to
b47db8a
Compare
|
|
||
| # Process data | ||
| def data_processor(datum): | ||
| return level2_probability(datum, datum["metadata"]["ylabel"]) |
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.
I think having outcome label in circuit metadata is reasonable. I assumed processor option can be obtained from the metadata without extra data processing. Do you prefer having such extra data processing capability to generate data processor options?
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.
I prefer having it as part of the metadata as well, but have no strong feelings about it (note that if we change this we can remove this metadata from rb_experiment).
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.
It seemed redundant to add the measurement label in metadata for every circuit when it's always the same and only depends on the number of qubits. Maybe it needs to be added if this is later a subclassed from a generic curve fit experiment.
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.
So we naively assume all 1 probability here (if outcome is not specified in the metadata)? I'm fine with this approach.
| } | ||
|
|
||
| @classmethod | ||
| def _format_plot(cls, ax, analysis_result, add_label=True): |
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.
Do you think fit values is needed now? In old Ignis implementation this is kind of necessary because fit values are protected member. But now these values can be seen in the repr of analysis result object.
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.
I think it's nice to keep the info in the figure so you can get the main details without having to also look at the result.
|
|
||
| # Process data | ||
| def data_processor(datum): | ||
| return level2_probability(datum, datum["metadata"]["ylabel"]) |
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.
I prefer having it as part of the metadata as well, but have no strong feelings about it (note that if we change this we can remove this metadata from rb_experiment).
| The error bounds are given by | ||
| :math:`E=\min\left\{ \begin{array}{c} | ||
| \frac{\left(d-1\right)\left[\left|p-p_{\overline{\mathcal{C}}}/p\right|+\left(1-p\right)\right]}{d}\\ | ||
| \frac{\left(d-1\right)\left[\left|p-p_{\overline{\mathcal{C}}}\right|+\left(1-p\right)\right]}{d}\\ |
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.
Is the systematic error bounds calculation remain the same in this case?
Need to comment that the notation here is not the same as in the original interleaved RB paper,
namely that p_C here denotes p_C/p
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.
I'm not 100% sure, I was hoping you or @gadial could double check this.
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.
It looks OK to me, but maybe it's better to ask one of the co-authors of the original paper?
(and one should also comment that the notation is different than the original paper)
| return analysis_result, figures | ||
|
|
||
| @staticmethod | ||
| def _generate_multi_scatter_plot(series, xdata, ydata, ax): |
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.
Note that the points of the standard and interleaved data are denoted the same (green x), only the fitting curve and mean and bars have separate colors
If analysis fails include the exception raised in the returned result so it can be viewed.
* Fit directly to alpha * alpha_c in interleaved model * Use kwarg format for curve fitting * plot raw data on scatter plot * Change color of interleaved fit curve in figure and add legend.
b47db8a to
2d428b7
Compare
|
Note that now the graph of the 2-qubit interleaved Rb does not appear in the Jupyter notebook |
Change way systematic error is reported in result to be "EPC_systematic_err" and "EPC_systematic_bounds"
* Fix bug in multi_curve_fit for kwarg params * Add error message to failed analysis If analysis fails include the exception raised in the returned result so it can be viewed. * Update interleaved-rb analysis * Fit directly to alpha * alpha_c in interleaved model * Use kwarg format for curve fitting * plot raw data on scatter plot * Change color of interleaved fit curve in figure and add legend. * update notebook * unused variable * Fix alpha_c initial guess * Fix equation * Update plot colors * update notebook and systematic error Change way systematic error is reported in result to be "EPC_systematic_err" and "EPC_systematic_bounds"
Summary
This makes a couple of changes to the interleaved RB fitter.
Details and comments
This means the series fit functions are:
f_0(x, a, alpha, alpha_c, b) = a * alpha ** x + bf_1(x, a, alpha, alpha_c, b) = a * (alpha * alpha_c) ** x + band the std error in
alpha_cand EPC can then be directly calculated from the fitter covariance matrix.Fixes what I think was a bug in the scale coefficient for EPC. It was
scale = (nrb - 1) / (2 ** nrb)whernrb = 2 ** num_qubits, but I think it was supposed to be(nrb - 1) / nrb, @gadial can you double check this?The second change is to the formatting of the returned figure. The figure now plots the raw unaveraged scatter data, and uses different colour curves for the standard and interleaved fits to distinguish them. It looks like this: