Skip to content

Commit 30aba7b

Browse files
tanujkhattartonybruguier
authored andcommitted
Cleanup docs/noise.ipynb in preparation for Cirq 1.0 launch (quantumlib#5147)
1 parent e994b89 commit 30aba7b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

docs/noise.ipynb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"id": "708b5b720a74"
117117
},
118118
"source": [
119-
"Cirq defines many commonly used quantum channels in [`ops/common_channels.py`](https://github.com/quantumlib/Cirq/blob/master/cirq/ops/common_channels.py). For example, the single-qubit bit-flip channel\n",
119+
"Cirq defines many commonly used quantum channels in [`ops/common_channels.py`](https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/ops/common_channels.py). For example, the single-qubit bit-flip channel\n",
120120
"\n",
121121
"$$\n",
122122
"\\rho \\rightarrow (1 - p) \\rho + p X \\rho X\n",
@@ -145,7 +145,7 @@
145145
"id": "f1f501177e53"
146146
},
147147
"source": [
148-
"To see the Kraus operators of a channel, the `cirq.channel` protocol can be used. (See the [protocols guide](./protocols.ipynb).)"
148+
"To see the Kraus operators of a channel, the `cirq.kraus` protocol can be used. (See the [protocols guide](./protocols.ipynb).)"
149149
]
150150
},
151151
{
@@ -282,7 +282,7 @@
282282
"id": "ddbc622c98da"
283283
},
284284
"source": [
285-
"## The `channel` and `mixture` protocols"
285+
"## The `kraus` and `mixture` protocols"
286286
]
287287
},
288288
{
@@ -291,7 +291,7 @@
291291
"id": "2dee355d2ae8"
292292
},
293293
"source": [
294-
"We have seen the `cirq.channel` protocol which returns the Kraus operators of a channel. Some channels have the interpretation of randomly applying a single unitary Kraus operator $U_k$ with probability $p_k$, namely\n",
294+
"We have seen the `cirq.kraus` protocol which returns the Kraus operators of a channel. Some channels have the interpretation of randomly applying a single unitary Kraus operator $U_k$ with probability $p_k$, namely\n",
295295
"\n",
296296
"$$\n",
297297
"\\rho \\rightarrow \\sum_k p_k U_k \\rho U_k^\\dagger {\\rm ~where~} \\sum_k p_k =1 {\\rm ~and~ U_k U_k^\\dagger= I}.\n",
@@ -361,9 +361,9 @@
361361
"source": [
362362
"To summarize:\n",
363363
"\n",
364-
"* Every `Gate` in Cirq supports the `cirq.channel` protocol.\n",
365-
" - If magic method `_kraus_` is not defined, `cirq.channel` looks for `_mixture_` then for `_unitary_`.\n",
366-
"* A subset of channels which support `cirq.channel` also support the `cirq.mixture` protocol.\n",
364+
"* Every `Gate` in Cirq supports the `cirq.kraus` protocol.\n",
365+
" - If magic method `_kraus_` is not defined, `cirq.kraus` looks for `_mixture_` then for `_unitary_`.\n",
366+
"* A subset of channels which support `cirq.kraus` also support the `cirq.mixture` protocol.\n",
367367
" - If magic method `_mixture_` is not defined, `cirq.mixture` looks for `_unitary_`.\n",
368368
"* A subset of channels which support `cirq.mixture` also support the `cirq.unitary` protocol."
369369
]
@@ -377,11 +377,11 @@
377377
"For concrete examples, consider `cirq.X`, `cirq.BitFlipChannel`, and `cirq.AmplitudeDampingChannel` which are all subclasses of `cirq.Gate`.\n",
378378
"\n",
379379
"* `cirq.X` defines the `_unitary_` method. \n",
380-
" - As a result, it supports the `cirq.unitary` protocol, the `cirq.mixture` protocol, and the `cirq.channel` protocol.\n",
380+
" - As a result, it supports the `cirq.unitary` protocol, the `cirq.mixture` protocol, and the `cirq.kraus` protocol.\n",
381381
"* `cirq.BitFlipChannel` defines the `_mixture_` method but not the `_unitary_` method.\n",
382-
" - As a result, it only supports the `cirq.mixture` protocol and the `cirq.channel` protocol.\n",
382+
" - As a result, it only supports the `cirq.mixture` protocol and the `cirq.kraus` protocol.\n",
383383
"* `cirq.AmplitudeDampingChannel` defines the `_kraus_` method, but not the `_mixture_` method or the `_unitary_` method.\n",
384-
" - As a result, it only supports the `cirq.channel` protocol."
384+
" - As a result, it only supports the `cirq.kraus` protocol."
385385
]
386386
},
387387
{
@@ -425,7 +425,7 @@
425425
" (0.9, np.array([[1, 0], [0, 1]], dtype=np.complex64)),\n",
426426
" (0.1, np.array([[0, 1], [1, 0]], dtype=np.complex64)),\n",
427427
"]\n",
428-
"bit_flip = cirq.MixedUnitaryChannel(mix)\n",
428+
"bit_flip_mix = cirq.MixedUnitaryChannel(mix)\n",
429429
"\n",
430430
"# This is equivalent to an X-basis measurement.\n",
431431
"ops = [\n",
@@ -436,7 +436,7 @@
436436
"\n",
437437
"# These circuits have the same behavior.\n",
438438
"circuit = cirq.Circuit(\n",
439-
" bit_flip.on(q0),\n",
439+
" bit_flip_mix.on(q0),\n",
440440
" cirq.H(q0),\n",
441441
" x_meas.on(q0),\n",
442442
")\n",
@@ -531,7 +531,7 @@
531531
"id": "72486a155131"
532532
},
533533
"source": [
534-
"Note: Since `_mixture_` is defined, the `cirq.channel` protocol can also be used."
534+
"Note: Since `_mixture_` is defined, the `cirq.kraus` protocol can also be used."
535535
]
536536
},
537537
{
@@ -890,7 +890,7 @@
890890
"id": "11b18c640767"
891891
},
892892
"source": [
893-
"Another technique is to pass a noise channel to the density matrix simulator as shown below."
893+
"Another technique is to directly pass a `cirq.NoiseModel`, or a value that can be trivially converted into one, to the density matrix simulator as shown below."
894894
]
895895
},
896896
{
@@ -901,7 +901,8 @@
901901
},
902902
"outputs": [],
903903
"source": [
904-
"\"\"\"Define a density matrix simulator with a noise model.\"\"\"\n",
904+
"\"\"\"Define a density matrix simulator with a `cirq.NOISE_MODEL_LIKE` object.\"\"\"\n",
905+
"\n",
905906
"noisy_dsim = cirq.DensityMatrixSimulator(\n",
906907
" noise=cirq.generalized_amplitude_damp(p=0.1, gamma=0.5)\n",
907908
")"

0 commit comments

Comments
 (0)