|
116 | 116 | "id": "708b5b720a74"
|
117 | 117 | },
|
118 | 118 | "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", |
120 | 120 | "\n",
|
121 | 121 | "$$\n",
|
122 | 122 | "\\rho \\rightarrow (1 - p) \\rho + p X \\rho X\n",
|
|
145 | 145 | "id": "f1f501177e53"
|
146 | 146 | },
|
147 | 147 | "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).)" |
149 | 149 | ]
|
150 | 150 | },
|
151 | 151 | {
|
|
282 | 282 | "id": "ddbc622c98da"
|
283 | 283 | },
|
284 | 284 | "source": [
|
285 |
| - "## The `channel` and `mixture` protocols" |
| 285 | + "## The `kraus` and `mixture` protocols" |
286 | 286 | ]
|
287 | 287 | },
|
288 | 288 | {
|
|
291 | 291 | "id": "2dee355d2ae8"
|
292 | 292 | },
|
293 | 293 | "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", |
295 | 295 | "\n",
|
296 | 296 | "$$\n",
|
297 | 297 | "\\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 | 361 | "source": [
|
362 | 362 | "To summarize:\n",
|
363 | 363 | "\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", |
367 | 367 | " - If magic method `_mixture_` is not defined, `cirq.mixture` looks for `_unitary_`.\n",
|
368 | 368 | "* A subset of channels which support `cirq.mixture` also support the `cirq.unitary` protocol."
|
369 | 369 | ]
|
|
377 | 377 | "For concrete examples, consider `cirq.X`, `cirq.BitFlipChannel`, and `cirq.AmplitudeDampingChannel` which are all subclasses of `cirq.Gate`.\n",
|
378 | 378 | "\n",
|
379 | 379 | "* `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", |
381 | 381 | "* `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", |
383 | 383 | "* `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." |
385 | 385 | ]
|
386 | 386 | },
|
387 | 387 | {
|
|
425 | 425 | " (0.9, np.array([[1, 0], [0, 1]], dtype=np.complex64)),\n",
|
426 | 426 | " (0.1, np.array([[0, 1], [1, 0]], dtype=np.complex64)),\n",
|
427 | 427 | "]\n",
|
428 |
| - "bit_flip = cirq.MixedUnitaryChannel(mix)\n", |
| 428 | + "bit_flip_mix = cirq.MixedUnitaryChannel(mix)\n", |
429 | 429 | "\n",
|
430 | 430 | "# This is equivalent to an X-basis measurement.\n",
|
431 | 431 | "ops = [\n",
|
|
436 | 436 | "\n",
|
437 | 437 | "# These circuits have the same behavior.\n",
|
438 | 438 | "circuit = cirq.Circuit(\n",
|
439 |
| - " bit_flip.on(q0),\n", |
| 439 | + " bit_flip_mix.on(q0),\n", |
440 | 440 | " cirq.H(q0),\n",
|
441 | 441 | " x_meas.on(q0),\n",
|
442 | 442 | ")\n",
|
|
531 | 531 | "id": "72486a155131"
|
532 | 532 | },
|
533 | 533 | "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." |
535 | 535 | ]
|
536 | 536 | },
|
537 | 537 | {
|
|
890 | 890 | "id": "11b18c640767"
|
891 | 891 | },
|
892 | 892 | "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." |
894 | 894 | ]
|
895 | 895 | },
|
896 | 896 | {
|
|
901 | 901 | },
|
902 | 902 | "outputs": [],
|
903 | 903 | "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", |
905 | 906 | "noisy_dsim = cirq.DensityMatrixSimulator(\n",
|
906 | 907 | " noise=cirq.generalized_amplitude_damp(p=0.1, gamma=0.5)\n",
|
907 | 908 | ")"
|
|
0 commit comments