|
251 | 251 | "outputs": [],
|
252 | 252 | "source": [
|
253 | 253 | "# We will truncate to these lengths\n",
|
254 |
| - "cycle_depths = np.arange(3, MAX_DEPTH, 9)\n", |
| 254 | + "cycle_depths = np.arange(1, MAX_DEPTH + 1, 9)\n", |
255 | 255 | "cycle_depths"
|
256 | 256 | ]
|
257 | 257 | },
|
|
275 | 275 | "source": [
|
276 | 276 | "pure_sim = cirq.Simulator()\n",
|
277 | 277 | "\n",
|
278 |
| - "P_DEPOL = 5e-3\n", |
279 |
| - "noisy_sim = cirq.DensityMatrixSimulator(noise=cirq.depolarize(P_DEPOL))\n", |
| 278 | + "# Pauli Error. If there is an error, it is either X, Y, or Z\n", |
| 279 | + "# with probability E_PAULI / 3\n", |
| 280 | + "E_PAULI = 5e-3\n", |
| 281 | + "noisy_sim = cirq.DensityMatrixSimulator(noise=cirq.depolarize(E_PAULI))\n", |
280 | 282 | "\n",
|
281 | 283 | "# These two qubit circuits have 2^2 = 4 probabilities\n",
|
282 | 284 | "DIM = 4\n",
|
|
386 | 388 | "$$\n",
|
387 | 389 | "\n",
|
388 | 390 | "We estimate f by performing least squares\n",
|
389 |
| - "minimization of the quantity\n", |
| 391 | + "minimization of the sum of squared residuals\n", |
390 | 392 | "\n",
|
391 | 393 | "$$\n",
|
392 |
| - " f (e_U - u_U) - (m_U - u_U)\n", |
| 394 | + " \\sum_U \\left(f (e_U - u_U) - (m_U - u_U)\\right)^2\n", |
393 | 395 | "$$\n",
|
394 | 396 | "\n",
|
395 | 397 | "over different random circuits. The solution to the\n",
|
|
456 | 458 | " \n",
|
457 | 459 | " global _lines\n",
|
458 | 460 | " _lines += [l] # for legend\n",
|
459 |
| - " return pd.Series({'fid_lsq': fid_lsq})\n", |
| 461 | + " return pd.Series({'fidelity': fid_lsq})\n", |
460 | 462 | "\n",
|
461 | 463 | "fids = df.groupby('cycle_depth').apply(per_cycle_depth).reset_index()\n",
|
462 | 464 | "plt.xlabel(r'$e_U - u_U$', fontsize=18)\n",
|
|
483 | 485 | },
|
484 | 486 | "outputs": [],
|
485 | 487 | "source": [
|
486 |
| - "plt.plot(fids['cycle_depth'], fids['fid_lsq'], label='LSq')\n", |
| 488 | + "plt.plot(\n", |
| 489 | + " fids['cycle_depth'], \n", |
| 490 | + " fids['fidelity'],\n", |
| 491 | + " marker='o',\n", |
| 492 | + " label='Least Squares')\n", |
487 | 493 | "\n",
|
488 | 494 | "xx = np.linspace(0, fids['cycle_depth'].max())\n",
|
489 |
| - "plt.plot(xx, (1-P_DEPOL)**(4*xx), label=r'$(1-\\mathrm{depol})^{4d}$')\n", |
| 495 | + "\n", |
| 496 | + "# In XEB, we extract the depolarizing fidelity, which is\n", |
| 497 | + "# related to (but not equal to) the Pauli error.\n", |
| 498 | + "# For the latter, an error involves doing X, Y, or Z with E_PAULI/3\n", |
| 499 | + "# but for the former, an error involves doing I, X, Y, or Z with e_depol/4\n", |
| 500 | + "e_depol = E_PAULI / (1 - 1/DIM**2)\n", |
| 501 | + "\n", |
| 502 | + "# The additional factor of four in the exponent is because each layer\n", |
| 503 | + "# involves two moments of two qubits (so each layer has four applications\n", |
| 504 | + "# of a single-qubit single-moment depolarizing channel).\n", |
| 505 | + "plt.plot(xx, (1-e_depol)**(4*xx), label=r'$(1-\\mathrm{e\\_depol})^{4d}$')\n", |
490 | 506 | "\n",
|
491 | 507 | "plt.ylabel('Circuit fidelity', fontsize=18)\n",
|
492 | 508 | "plt.xlabel('Cycle Depth $d$', fontsize=18)\n",
|
493 | 509 | "plt.legend(loc='best')\n",
|
| 510 | + "plt.yscale('log')\n", |
494 | 511 | "plt.tight_layout()"
|
495 | 512 | ]
|
| 513 | + }, |
| 514 | + { |
| 515 | + "cell_type": "code", |
| 516 | + "execution_count": null, |
| 517 | + "metadata": { |
| 518 | + "id": "e931726da2af" |
| 519 | + }, |
| 520 | + "outputs": [], |
| 521 | + "source": [ |
| 522 | + "from cirq.experiments.xeb_fitting import fit_exponential_decays\n", |
| 523 | + "\n", |
| 524 | + "# Ordinarily, we'd use this function to fit curves for multiple pairs.\n", |
| 525 | + "# We add our qubit pair as a column.\n", |
| 526 | + "fids['pair'] = [(q0, q1)] * len(fids)\n", |
| 527 | + "\n", |
| 528 | + "fit_df = fit_exponential_decays(fids)\n", |
| 529 | + "fit_row = fit_df.iloc[0]\n", |
| 530 | + "print(f\"Noise model fidelity: {(1-e_depol)**4:.3e}\")\n", |
| 531 | + "print(f\"XEB layer fidelity: {fit_row['layer_fid']:.3e} +- {fit_row['layer_fid_std']:.2e}\")" |
| 532 | + ] |
496 | 533 | }
|
497 | 534 | ],
|
498 | 535 | "metadata": {
|
|
0 commit comments