|
32 | 32 | "source": [ |
33 | 33 | "Let's first briefly review the classical shadows in Pauli basis. For an $n$-qubit quantum state $\\rho$, we randomly perform Pauli projection measurement on each qubit and obtain a snapshot like $\\{1,-1,-1,1,\\cdots,1,-1\\}$. This process is equivalent to apply a random unitary $U$ to $\\rho$ and measure in computational basis to obtain $|b\\rangle=|s_1\\cdots s_n\\rangle,\\ s_j\\in\\{0,1\\}$:\n", |
34 | 34 | "$$\n", |
35 | | - "\\begin{equation}\n", |
36 | | - " \\rho\\rightarrow U\\rho U^{\\dagger}\\xrightarrow{measure}|b\\rangle\\langle b|,\n", |
37 | | - "\\end{equation}\n", |
| 35 | + "\\rho\\rightarrow U\\rho U^{\\dagger}\\xrightarrow{measure}|b\\rangle\\langle b|,\n", |
38 | 36 | "$$\n", |
39 | 37 | "where $U=\\bigotimes_{j=1}^{n}u_j$, $u_i\\in\\{H, HS^{\\dagger}, \\mathbb{I}\\}$ correspond to the projection measurements of Pauli $X$, $Y$, $Z$ respectively. Then we reverse the operation to get the equivalent measurement result on $\\rho$:\n", |
40 | 38 | "$$\n", |
41 | | - "\\begin{equation}\n", |
42 | | - " \\rho\\xrightarrow{measure}U^{\\dagger}|b\\rangle\\langle b| U.\n", |
43 | | - "\\end{equation}\n", |
| 39 | + "\\rho\\xrightarrow{measure}U^{\\dagger}|b\\rangle\\langle b| U.\n", |
44 | 40 | "$$\n", |
45 | 41 | "Moreover, we perform $N$ random measurements and view their average as a quantum channel:\n", |
46 | 42 | "$$\n", |
47 | | - "\\begin{equation}\n", |
48 | | - " \\mathbb{E}\\left[U^{\\dagger}|b\\rangle\\langle b|U\\right]=\\mathcal{M}(\\rho),\n", |
49 | | - "\\end{equation}\n", |
| 43 | + "\\mathbb{E}\\left[U^{\\dagger}|b\\rangle\\langle b|U\\right]=\\mathcal{M}(\\rho),\n", |
50 | 44 | "$$\n", |
51 | 45 | "we can invert the channel to get the approximation of $\\rho$:\n", |
52 | 46 | "$$\n", |
53 | | - "\\begin{equation}\n", |
54 | | - " \\rho=\\mathbb{E}\\left[\\mathcal{M}^{-1}(U^{\\dagger}|b\\rangle\\langle b|U)\\right].\n", |
55 | | - "\\end{equation}\n", |
| 47 | + "\\rho=\\mathbb{E}\\left[\\mathcal{M}^{-1}(U^{\\dagger}|b\\rangle\\langle b|U)\\right].\n", |
56 | 48 | "$$\n", |
57 | 49 | "We call each $\\rho_i=\\mathcal{M}^{-1}(U_i^{\\dagger}|b_i\\rangle\\langle b_i|U_i)$ a shadow snapshot state and their ensemble $S(\\rho;N)=\\{\\rho_i|i=1,\\cdots,N\\}$ classical shadows." |
58 | 50 | ], |
|
65 | 57 | "source": [ |
66 | 58 | "In Pauli basis, we have a simple expression of $\\mathcal{M}^{-1}$:\n", |
67 | 59 | "$$\n", |
68 | | - "\\begin{eqnarray}\n", |
69 | | - " \\rho_i&=&\\mathcal{M}^{-1}(U_i^{\\dagger}|b_i\\rangle\\langle b_i|U_i)=\\bigotimes_{j=1}^{n}3u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}-\\mathbb{I},\\\\\n", |
70 | | - " \\rho&=&\\frac{1}{N}\\sum_{i=1}^{N}\\rho_i\\ .\n", |
71 | | - "\\end{eqnarray}\n", |
| 60 | + "\\begin{split}\n", |
| 61 | + " \\rho_i&=\\mathcal{M}^{-1}(U_i^{\\dagger}|b_i\\rangle\\langle b_i|U_i)=\\bigotimes_{j=1}^{n}3u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}-\\mathbb{I},\\\\\n", |
| 62 | + " \\rho&=\\frac{1}{N}\\sum_{i=1}^{N}\\rho_i\\ .\n", |
| 63 | + "\\end{split}\n", |
72 | 64 | "$$\n", |
73 | 65 | "For an observable Pauli string $O=\\bigotimes_{j=1}^{n}P_j,\\ P_j\\in\\{\\mathbb{I}, X, Y, Z\\}$, we can directly use $\\rho$ to calculate $\\langle O\\rangle=\\text{Tr}(O\\rho)$. In practice, we will divide the classical shadows into $K$ parts to calculate the expectation values independently and take the median to avoid the influence of outliers:\n", |
74 | 66 | "$$\n", |
75 | | - "\\begin{equation}\n", |
76 | | - " \\langle O\\rangle=\\text{median}\\{\\langle O_{(1)}\\rangle\\cdots\\langle O_{(K)}\\rangle\\},\n", |
77 | | - "\\end{equation}\n", |
| 67 | + "\\langle O\\rangle=\\text{median}\\{\\langle O_{(1)}\\rangle\\cdots\\langle O_{(K)}\\rangle\\},\n", |
78 | 68 | "$$\n", |
79 | 69 | "where\n", |
80 | 70 | "$$\n", |
81 | | - "\\begin{eqnarray}\n", |
82 | | - " \\langle O_{(k)}\\rangle&=&\\frac{1}{\\lceil N/K\\rceil}\\sum_{i=(k-1)\\lceil N/K\\rceil+1}^{k\\lceil N/K\\rceil}\\text{Tr}\\left[\\bigotimes_{j=1}^{n}P_j(3u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}-\\mathbb{I})\\right]\\\\\n", |
83 | | - " &=&\\frac{1}{\\lceil N/K\\rceil}\\sum_{i=(k-1)\\lceil N/K\\rceil+1}^{k\\lceil N/K\\rceil}\\prod_{j=1}^n\\text{Tr}\\left[3P_j u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}\\right].\n", |
84 | | - "\\end{eqnarray}\n", |
| 71 | + "\\begin{split}\n", |
| 72 | + " \\langle O_{(k)}\\rangle&=\\frac{1}{\\lceil N/K\\rceil}\\sum_{i=(k-1)\\lceil N/K\\rceil+1}^{k\\lceil N/K\\rceil}\\text{Tr}\\left[\\bigotimes_{j=1}^{n}P_j(3u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}-\\mathbb{I})\\right]\\\\\n", |
| 73 | + " &=\\frac{1}{\\lceil N/K\\rceil}\\sum_{i=(k-1)\\lceil N/K\\rceil+1}^{k\\lceil N/K\\rceil}\\prod_{j=1}^n\\text{Tr}\\left[3P_j u_{ij}^{\\dagger}|s_{ij}\\rangle\\langle s_{ij}|u_{ij}\\right].\n", |
| 74 | + "\\end{split}\n", |
85 | 75 | "$$" |
86 | 76 | ], |
87 | 77 | "metadata": { |
|
143 | 133 | "source": [ |
144 | 134 | "We first set the number of qubits $n$ and the number of repeated measurements $r$ on each Pauli string. Then from the target observable Pauli strings $\\{O_i|i=1,\\cdots,M\\}$ (0, 1, 2, and 3 correspond to $\\mathbb{I}$, $X$, $Y$, and $Z$, respectively), the error $\\epsilon$ and the rate of failure $\\delta$, we can use ``shadow_bound`` function to get the total number of snapshots $N$ and the number of equal parts $K$ to split the shadow snapshot states to compute the median of means:\n", |
145 | 135 | "$$\n", |
146 | | - "\\begin{eqnarray}\n", |
147 | | - " K&=&2\\log(2M/\\delta),\\\\\n", |
148 | | - " N&=&K\\frac{34}{\\epsilon^2}\\max_{1\\le i\\le M}\\left\\|O_i-\\frac{\\text{Tr}(O_i)}{2^n}\\mathbb{I}\\right\\|^2_{\\text{shadow}}=K\\frac{34}{\\epsilon^2}3^{\\max_{1\\le i\\le M}k_i},\n", |
149 | | - "\\end{eqnarray}\n", |
| 136 | + "\\begin{split}\n", |
| 137 | + " K&=2\\log(2M/\\delta),\\\\\n", |
| 138 | + " N&=K\\frac{34}{\\epsilon^2}\\max_{1\\le i\\le M}\\left\\|O_i-\\frac{\\text{Tr}(O_i)}{2^n}\\mathbb{I}\\right\\|^2_{\\text{shadow}}=K\\frac{34}{\\epsilon^2}3^{\\max_{1\\le i\\le M}k_i},\n", |
| 139 | + "\\end{split}\n", |
150 | 140 | "$$\n", |
151 | 141 | "where $k_i$ is the number of nontrivial Pauli matrices in $O_i$. Please refer to the Theorem S1 and Lemma S3 in [Huang, Kueng and Preskill (2020)](https://www.nature.com/articles/s41567-020-0932-7) for the details of proof. It should be noted that ``shadow_bound`` has a certain degree of overestimation of $N$, and so many measurements are not really needed in practice. Moreover, ``shadow_bound`` is not jitable and no need to jit." |
152 | 142 | ], |
|
596 | 586 | "source": [ |
597 | 587 | "On the other hand, for the second order Renyi entropy, we have another method to calculate it in polynomial time by random measurements:\n", |
598 | 588 | "$$\n", |
599 | | - "\\begin{eqnarray}\n", |
600 | | - " R_A^2&=&-\\log\\left(\\text{Tr}(\\rho_A^2)\\right),\\\\\n", |
601 | | - " \\text{Tr}(\\rho_A^2)&=&2^k\\sum_{b,b'\\in\\{0,1\\}^k}(-2)^{-H(b,b')}\\overline{P(b)P(b')},\n", |
602 | | - "\\end{eqnarray}\n", |
| 589 | + "\\begin{split}\n", |
| 590 | + " R_A^2&=-\\log\\left(\\text{Tr}(\\rho_A^2)\\right),\\\\\n", |
| 591 | + " \\text{Tr}(\\rho_A^2)&=2^k\\sum_{b,b'\\in\\{0,1\\}^k}(-2)^{-H(b,b')}\\overline{P(b)P(b')},\n", |
| 592 | + "\\end{split}\n", |
603 | 593 | "$$\n", |
604 | 594 | "where $A$ is the $k$-d reduced system, $H(b,b')$ is the Hamming distance between $b$ and $b'$, $P(b)$ is the probability for measuring $\\rho_A$ and obtaining the outcomes $b$ thus we need a larger $r$ to obtain a good enough priori probability, and the overline means the average on all random selected Pauli strings. Please refer to [Brydges, et al. (2019)](https://www.science.org/doi/full/10.1126/science.aau4963) for more details. We can use ``renyi_entropy_2`` to implement this method, but it is not jitable because we need to build the dictionary based on the bit strings obtained by measurements, which is a dynamical process. Compared with ``entropy_shadow``, it cannot filter out non-negative eigenvalues, so the accuracy is slightly worse." |
605 | 595 | ], |
|
0 commit comments