Skip to content

Commit 1f17390

Browse files
authored
Prefer load_device_noise_properties in example notebooks (#7408)
Replace calls of `noise_properties_from_calibration` with `load_device_noise_properties` so users do not need to pass the `gate_times_ns` argument. Updated notebooks need to install development cirq and be listed in `NOTEBOOKS_DEPENDING_ON_UNRELEASED_FEATURES`. Related to b/395705720
1 parent fa8d64d commit 1f17390

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

dev_tools/notebooks/isolated_notebook_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
# note that these notebooks are still tested in dev_tools/notebook_test.py
4343
# Please, always indicate in comments the feature used for easier bookkeeping.
4444

45-
NOTEBOOKS_DEPENDING_ON_UNRELEASED_FEATURES: list[str] = []
45+
NOTEBOOKS_DEPENDING_ON_UNRELEASED_FEATURES: list[str] = [
46+
# Requires `load_device_noise_properties` from #7369
47+
'docs/hardware/qubit_picking.ipynb',
48+
'docs/simulate/noisy_simulation.ipynb',
49+
'docs/simulate/quantum_virtual_machine.ipynb',
50+
'docs/simulate/qvm_basic_example.ipynb',
51+
]
4652

4753
# By default all notebooks should be tested, however, this list contains exceptions to the rule
4854
# please always add a reason for skipping.

docs/hardware/qubit_picking.ipynb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@
7171
"When running a circuit on a noisy quantum hardware device, the choice and even ordering of hardware qubits used directly affects how reliably the device measures a correct result. This notebook covers some of the available qubit error information that can be useful for picking good hardware qubits to run your circuit on."
7272
]
7373
},
74+
{
75+
"cell_type": "markdown",
76+
"metadata": {
77+
"id": "cb67ae611d34"
78+
},
79+
"source": [
80+
"## Setup\n",
81+
"\n",
82+
"Note: this notebook relies on unreleased Cirq features. If you want to try these features, make sure you install cirq via `pip install --upgrade cirq~=1.0.dev`."
83+
]
84+
},
7485
{
7586
"cell_type": "code",
7687
"execution_count": null,
@@ -85,7 +96,7 @@
8596
" import cirq\n",
8697
"except ImportError:\n",
8798
" print(\"installing cirq...\")\n",
88-
" !pip install --quiet cirq\n",
99+
" !pip install --upgrade --quiet cirq~=1.0.dev\n",
89100
" print(\"installed cirq.\")\n",
90101
" import cirq\n",
91102
"\n",
@@ -120,8 +131,7 @@
120131
"outputs": [],
121132
"source": [
122133
"processor_id = \"rainbow\"\n",
123-
"cal = cirq_google.engine.load_median_device_calibration(processor_id)\n",
124-
"noise_props = cirq_google.noise_properties_from_calibration(cal)"
134+
"noise_props = cirq_google.engine.load_device_noise_properties(processor_id)"
125135
]
126136
},
127137
{

docs/simulate/noisy_simulation.ipynb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@
6262
"</table>"
6363
]
6464
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {
68+
"id": "f9c6fb06ebbf"
69+
},
70+
"source": [
71+
"## Setup\n",
72+
"\n",
73+
"Note: this notebook relies on unreleased Cirq features. If you want to try these features, make sure you install cirq via `pip install --upgrade cirq~=1.0.dev`."
74+
]
75+
},
6576
{
6677
"cell_type": "code",
6778
"execution_count": null,
@@ -74,7 +85,7 @@
7485
" import cirq\n",
7586
"except ImportError:\n",
7687
" print(\"installing cirq...\")\n",
77-
" !pip install --quiet cirq\n",
88+
" !pip install --upgrade --quiet cirq~=1.0.dev\n",
7889
" print(\"installed cirq.\")"
7990
]
8091
},
@@ -988,10 +999,8 @@
988999
"import cirq_google\n",
9891000
"\n",
9901001
"processor_id = \"rainbow\" # or \"weber\"\n",
991-
"# Load the calibration data\n",
992-
"cal = cirq_google.engine.load_median_device_calibration(processor_id)\n",
993-
"# Turn calibration data into a noise properties object\n",
994-
"noise_props = cirq_google.noise_properties_from_calibration(cal)\n",
1002+
"# Load the noise properties for the processor\n",
1003+
"noise_props = cirq_google.engine.load_device_noise_properties(processor_id)\n",
9951004
"# Build a noise model from the noise properties\n",
9961005
"noise_model = cirq_google.NoiseModelFromGoogleNoiseProperties(noise_props)"
9971006
]

docs/simulate/quantum_virtual_machine.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
"id": "p31cCK_T1ylm"
8080
},
8181
"source": [
82-
"## Setup"
82+
"## Setup\n",
83+
"\n",
84+
"Note: this notebook relies on unreleased Cirq features. If you want to try these features, make sure you install cirq via `pip install --upgrade cirq~=1.0.dev`."
8385
]
8486
},
8587
{
@@ -98,7 +100,7 @@
98100
" import cirq_google\n",
99101
"except ImportError:\n",
100102
" print(\"installing cirq...\")\n",
101-
" !pip install --quiet cirq-google\n",
103+
" !pip install --upgrade --quiet cirq-google~=1.0.dev\n",
102104
" print(\"installed cirq.\")\n",
103105
" import cirq\n",
104106
" import cirq_google\n",
@@ -161,8 +163,8 @@
161163
"source": [
162164
"# Load the median device noise calibration for your selected processor.\n",
163165
"cal = cirq_google.engine.load_median_device_calibration(processor_id)\n",
164-
"# Create the noise properties object.\n",
165-
"noise_props = cirq_google.noise_properties_from_calibration(cal)\n",
166+
"# Load the noise properties for the processor.\n",
167+
"noise_props = cirq_google.engine.load_device_noise_properties(processor_id)\n",
166168
"# Create a noise model from the noise properties.\n",
167169
"noise_model = cirq_google.NoiseModelFromGoogleNoiseProperties(noise_props)\n",
168170
"# Prepare a qsim simulator using the noise model.\n",

docs/simulate/qvm_basic_example.ipynb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@
8080
"## **Install** Cirq and qsim"
8181
]
8282
},
83+
{
84+
"cell_type": "markdown",
85+
"metadata": {
86+
"id": "8e3ded3ff3d1"
87+
},
88+
"source": [
89+
"## Setup\n",
90+
"\n",
91+
"Note: this notebook relies on unreleased Cirq features. If you want to try these features, make sure you install cirq via `pip install --upgrade cirq~=1.0.dev`."
92+
]
93+
},
8394
{
8495
"cell_type": "code",
8596
"execution_count": null,
@@ -96,7 +107,7 @@
96107
" import cirq_google\n",
97108
"except ImportError:\n",
98109
" print(\"installing cirq...\")\n",
99-
" !pip install --quiet cirq-google\n",
110+
" !pip install --upgrade --quiet cirq-google~=1.0.dev\n",
100111
" print(\"installed cirq.\")\n",
101112
" import cirq\n",
102113
" import cirq_google\n",
@@ -145,7 +156,7 @@
145156
"\n",
146157
"# Construct a simulator with a noise model based on the specified processor.\n",
147158
"cal = cirq_google.engine.load_median_device_calibration(processor_id)\n",
148-
"noise_props = cirq_google.noise_properties_from_calibration(cal)\n",
159+
"noise_props = cirq_google.engine.load_device_noise_properties(processor_id)\n",
149160
"noise_model = cirq_google.NoiseModelFromGoogleNoiseProperties(noise_props)\n",
150161
"sim = qsimcirq.QSimSimulator(noise=noise_model)\n",
151162
"\n",

0 commit comments

Comments
 (0)