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

Update "Compare to Calibration" tutorial into "Identifying Hardware Changes" with Simultaneous Readout and additional context #4552

Merged
merged 21 commits into from
Jan 21, 2022

Conversation

augustehirth
Copy link
Collaborator

@augustehirth augustehirth commented Oct 5, 2021

A large rework of the "Compare to Calibration" tutorial to emphasize the use of Parallel XEB and Simultaneous Readout (new) to identify if and how qubits have drifted since the previous maintenance calibration. Adds contextual information on what drift is, how it occurs, and what you can do about it once spotted.

TODO/Things I don't have answers for yet:

  • Relative linking for API reference pages
  • Need more links/references on qubit picking/mapping/routing.
  • An email address should be supplied for the quantum engine support team at the end of #Heatmap Observations
  • Edit: Renaming the file without losing the previous contributors' commit history.

More importantly, looking for any corrections, feedback or advice on improving this. Thanks!

@augustehirth augustehirth requested review from cduck, vtomole, wcourtney and a team as code owners October 5, 2021 01:17
@augustehirth augustehirth requested a review from viathor October 5, 2021 01:17
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@google-cla
Copy link

google-cla bot commented Oct 5, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@CirqBot CirqBot added the size: XL lines changed >1000 label Oct 5, 2021
@google-cla google-cla bot added the cla: no label Oct 5, 2021
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@MichaelBroughton MichaelBroughton self-assigned this Oct 5, 2021
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Thanks so much for opening the PR. This is a good first pass on an update for this tutorial, there are a few outstanding changes that need to be made before we can get closer to merging.

Also, if we are going to change the name of the tutorial, we will need to update https://github.com/quantumlib/Cirq/blob/master/docs/_book.yaml as well to update the name.

A lot of the reasoning behind some of the suggestions for changes can be found here: https://developers.google.com/style.

docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
"source": [
"# Qubit Error Metrics\n",
"\n",
"This tutorial will focus on the following two metrics for our examples:\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We do have a tutorial that lists all of the available metrics that our system can provide to a user (https://quantumai.google/cirq/tutorials/google/visualizing_calibration_metrics). Do you think it would be a good idea to link out to that tutorial and emphasize something to the effect of: "Using just these two metrics from this big list here <link> you can characterize drift" ? instead of having to spend so much time re-introducing the metrics below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've significantly shortened and simplified this section, but I still think it is valuable for there to be a short explanation of the metrics we're using in the tutorial, so that the tutorial is more or less one cohesively digestible meal of information. Going back and forth to other pages to understand core concepts seems like it would interrupt the overall understanding process, at least for me. I've cut the explanations of the other metrics.

docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
@augustehirth
Copy link
Collaborator Author

Thank you for all the detailed feedback. I'm working through the changes now.

docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
"outputId": "81b2dc67-7347-471c-c743-de870803da61"
},
"source": [
"sq_result = cirq.estimate_parallel_single_qubit_readout_errors(sampl
Copy link
Collaborator

Choose a reason for hiding this comment

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

This analysis is quite confusing and hand-wavy. Is this really our best practice? Our advice is to stare at these heatmaps and try to manually glean some information out of them? We are not going to tell them to refit bad two-qubit gates or to use any readout mitigation techniques?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The next steps section at the bottom provide links for using calibration for compensation and for other resources in the tutorial. This tutorial at the moment focuses on identifying drift and picking qubits, not how you should change your circuit to fit the qubits selected. That said, I agree with you that we need better defined best practices for how to build circuits given this data, and this tutorial may be the correct place for that. I'd greatly appreciate any information or sources to read up on information that should possibly be in this tutorial.

docs/tutorials/google/identifying_drift.ipynb Outdated Show resolved Hide resolved
"outputId": "81b2dc67-7347-471c-c743-de870803da61"
},
"source": [
"sq_result = cirq.estimate_parallel_single_qubit_readout_errors(sampl
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think each of these tutorials actually use client-side calibration techniques and not the Calibration API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an especially important point that I don't know how to immediately resolve. I attempted to use the shortest available way to collect the data, and focus the tutorial on comparison. This means using cirq.experiments.xeb_sampling.sample_2q_xeb_circuits and cirq.estimate_parallel_single_qubit_readout_errors, which, as far as I can tell, don't use the Calibration API under the hood. The alternative would be to set up and run a cirq.google.CalibrationLayer manually, or sending a large dummy circuit into prepare_characterization_for_operations. This is an option but doesn't seem to be presented the other tutorials. For now I'll fix the references to the Calibration API.

- Removed usage of "drift" outside of "thermal drift"
- Separated out "Hardware Changes" section to describe the types and
causes, as well as replacing entire section with suggestion
- Some minor wording refinement
- Renamed to "identifying hardware changes" in line with "drift" change
@augustehirth
Copy link
Collaborator Author

Version 3 has significant changes based on feedback, including removal of incorrect use of "drift", as well as addition/rework of "hardware changes" section.

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Thanks for all the changes. This is looking pretty much ready to merge after this round of feedback.

docs/tutorials/google/identifying_hardware_changes.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_hardware_changes.ipynb Outdated Show resolved Hide resolved
Comment on lines 271 to 282
"device = qcs_objects.device\n",
"sampler = qcs_objects.sampler\n",
"\n",
"# Get qubit set\n",
"qubits = device.qubit_set()\n",
"\n",
"# Limit device qubits to only those before row/column `device_limit`\n",
"device_limit = 10 #@param {type:\"integer\"}\n",
"qubits = {qb for qb in qubits if qb.row<device_limit and qb.col<device_limit}\n",
"\n",
"# Visualize the device qubits\n",
"print(cg.devices.XmonDevice(0,0,0,qubits))"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be a little more relevant if we used a Sycamore device here, since those are the ones that are most prevalent in the QCS fleet.

Copy link
Collaborator Author

@augustehirth augustehirth Oct 18, 2021

Choose a reason for hiding this comment

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

The intent is that the user puts in a QCS project_id and actual-device processor_id, and the examples reflect this. If you mean the cg.devices.XmonDevice at the bottom, it's just to show the device graph with connectivity, especially if you limit the qubit set. I don't think there's another way to do this currently, especially because print(device) here wouldn't show qubit connectivity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cg.devices.XmonDevice at the bottom, it's just to show the device graph with connectivity, especially if you limit the qubit set.

Right, but we don't host any xmon devices on QCS anymore. cg.Sycamore23 is probably a more relevant device since those are what we host. I think just changing the line to cg.Sycamore23 over cg.devices.XmonDevice(...) is all we need.

docs/tutorials/google/identifying_hardware_changes.ipynb Outdated Show resolved Hide resolved
docs/tutorials/google/identifying_hardware_changes.ipynb Outdated Show resolved Hide resolved
Comment on lines 453 to 456
"cycle_depths = np.arange(3, 100, 20)"
],
"execution_count": null,
"outputs": []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any intermediate output we could show here ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't found anything suitable yet. The closest thing I've thought of is to print combinations_by_layer or one of it's elements, but I don't think it would provide much useful insight into the tutorial's problem. That data structure is a little hard to read easily, and I think one of the XEB tutorials would be a better place to go into how cirq.experiments.random_quantum_circuit_generation.get_random_combinations_for_device works.

Comment on lines 502 to 507
"pxeb_results = {\n",
" pair: (1.0 - fidelity) / (4 / 3) #Scalar to get Pauli error\n",
" for (_, _, pair), fidelity in fidelities.layer_fid.items()\n",
"}"
],
"execution_count": null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Stylistic question: Is it worth showing all the visualizations at the end or do you think it's worth showing the baseline comparison for XEB here along with the baseline readout comparison in the readout section and then maybe the more advanced comparison (the deltas) at the end ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was how it was originally. I elected to put all three (calibration, current, deltas) graphs together shortly before the sections discussing them for easy reference, and to show the user the big picture all at once. Having the same graphs (without deltas) duplicated and printed earlier, without the explanations provided later, seems like it would unnecessarily delay getting to the important part of the tutorial (the comparisons and explanations). I'm definitely open to them being potentially useful, but I'm not sure how right off the bat.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Though along this line of reasoning the original calibration data's heatmaps should be removed, so I'm unsure what's best here.

docs/tutorials/google/identifying_hardware_changes.ipynb Outdated Show resolved Hide resolved
augustehirth and others added 4 commits October 18, 2021 16:04
Removed authorization link and code
Removed try-except statement
Removed used-once function
Removed assert statement
Moved import to top of cell
Added note on project/processor_id(s)
@MichaelBroughton
Copy link
Collaborator

This looks good to me. I think after the notebook formatting fixes, changing over the entry in dev_tools/notebooks/isolated_notebook_test.py , NOTEBOOKS_DEPENDING_ON_UNRELEASED_FEATURES to the new name and switching to the Sycamore23 device we should be good to merge.

@augustehirth augustehirth changed the title Update "Compare to Calibration" tutorial into "Identifying Drift" with Simultaneous Readout and additional context Update "Compare to Calibration" tutorial into "Identifying Hardware Changes" with Simultaneous Readout and additional context Oct 22, 2021
@MichaelBroughton MichaelBroughton added cla: yes Makes googlebot stop complaining. and removed cla: no labels Nov 15, 2021
@google-cla
Copy link

google-cla bot commented Nov 15, 2021

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes Makes googlebot stop complaining. labels Nov 15, 2021
@MichaelBroughton
Copy link
Collaborator

Any updates on the CLA status here @augustehirth ?

@augustehirth
Copy link
Collaborator Author

CLA status is moving forwards, but very slowly. Thanks for your patience.

@augustehirth
Copy link
Collaborator Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Makes googlebot stop complaining. and removed cla: no labels Jan 21, 2022
@augustehirth
Copy link
Collaborator Author

@MichaelBroughton CLA should be resolved, is there anything else that needs to be changed here?

Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Nope, LGTM.

@MichaelBroughton MichaelBroughton added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jan 21, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jan 21, 2022
@CirqBot CirqBot merged commit c2b8691 into quantumlib:master Jan 21, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jan 21, 2022
MichaelBroughton pushed a commit to MichaelBroughton/Cirq that referenced this pull request Jan 22, 2022
…hanges" with Simultaneous Readout and additional context (quantumlib#4552)

A large rework of the "Compare to Calibration" tutorial to emphasize the use of Parallel XEB and Simultaneous Readout (new) to identify if and how qubits have drifted since the previous maintenance calibration. Adds contextual information on what drift is, how it occurs, and what you can do about it once spotted. 

TODO/Things I don't have answers for yet: 
- Relative linking for API reference pages
- Need more links/references on qubit picking/mapping/routing. 
- An email address should be supplied for the quantum engine support team at the end of #Heatmap Observations
- Edit: Renaming the file without losing the previous contributors' commit history. 

More importantly, looking for any corrections, feedback or advice on improving this. Thanks!
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
…hanges" with Simultaneous Readout and additional context (quantumlib#4552)

A large rework of the "Compare to Calibration" tutorial to emphasize the use of Parallel XEB and Simultaneous Readout (new) to identify if and how qubits have drifted since the previous maintenance calibration. Adds contextual information on what drift is, how it occurs, and what you can do about it once spotted. 

TODO/Things I don't have answers for yet: 
- Relative linking for API reference pages
- Need more links/references on qubit picking/mapping/routing. 
- An email address should be supplied for the quantum engine support team at the end of #Heatmap Observations
- Edit: Renaming the file without losing the previous contributors' commit history. 

More importantly, looking for any corrections, feedback or advice on improving this. Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining. size: XL lines changed >1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants