Skip to main content

View on GitHub

Open this notebook in GitHub to run it yourself
This notebook is based on the original contribution by Georgiy Zemlevskiy (ee57b988, 1c8085e4, 5e26a4be).

Overview

Classical shadow tomography [1], introduced by Huang, Kueng, and Preskill (2020), is a measurement protocol for predicting many properties of an unknown quantum state from a small number of measurements. Rather than reconstructing the full density matrix, it builds a compact classical estimator, the classical shadow, that supports efficient prediction of a large set of observables. The algorithm treats the following problem:
  • Input: Access to copies of an unknown nn-qubit state ρ\rho, and a target set of MM observables {O1,,OM}\{O_1, \dots, O_M\}.
  • Output: Estimates o^iOi=tr(Oiρ)\hat{o}_i \approx \langle O_i \rangle = \mathrm{tr}(O_i \rho) for every ii, to additive error ε\varepsilon, with a probability of at least 1δ1-\delta.
Complexity: The sample cost, which is the number of required measurements (or copies of ρ\rho), scales as O(log(M/δ)maxiOishadow2/ϵ2)\mathcal{O}(\log(M/\delta) \max_i ||O_i ||^2_{\text{shadow}}/\epsilon^2). This scaling is logarithmic in the number of target observables, MM. Here Oishadow||O_i ||_{\text{shadow}} is the shadow norm which depends on both the specific method used to construct the classical shadow and the observables of interest, {Oi}\{O_i\}. When Pauli measurements are utilized to build the classical shadow it scales as O(4k)\mathcal{O}(4^k), for kk-local Pauli observables, while, when the algorithm involves random-Clifford measurements, the classical shadow scales as the Hilbert-Schmidt norm O(OHS2)\mathcal{O}(\|O\|_\mathrm{HS}^2). In comparison, the naive approach of measuring each time a different observable, would require (using Hoeffding inequality) O(Mlog(M/δ)/ϵ2)\mathcal{O}(M\log(M/\delta)/\epsilon^2) measurements.
Keywords: Quantum state tomography, Randomized measurements, Shadow norm, Median-of-means estimator.

Introduction

\renewcommand{\ket}[1]{\left|{#1}\right\rangle} \renewcommand{\bra}[1]{\left\langle{#1}\right|} Predicting properties of unknown quantum states is an essential task in quantum computing. By conducting many measurements in different bases on copies of the state a method called Quantum State Tomography [1] fully reconstructs the quantum state. Naturally, such complete characterization requires a number of state copies which scales exponentially, with the number of qubits nn and quadratically with the error, O(22n/ϵ2)\mathcal{O}(2^{2n}/\epsilon^2). As a result, this procedure is unfeasible for a system of more than a few qubits. Nevertheless, for many applications a complete characterization of the state, or equivalently, evaluation of the expectation value of an exponential number of observables is unnecessary. When restricting to MM observables, one can characterize only a part of the Hilbert space and achieve better complexity. Aaronson introduced shadow tomography [2] which constructs a compact classical representation of the quantum state, coined as classical shadow. The shadow allows predicting observables simultaneously without completely reconstructing the state. This could be done using O~(ε4log4Mn)\widetilde{\mathcal{O}}\left(\varepsilon^{-4} \cdot \log^4 M \cdot n\right) copies of the state. However, this approach still requires a lot of quantum memory to store the copies and long circuits to make the predictions. Based on this idea Huang, et al. introduced classical shadow tomography [3], a procedure that required only O(log(M))\mathcal{O}(\log(M)) copies of the state and independent of the dimension of the system to approximate the classical shadow. The copies could also be stored efficiently in classical memory. Meaning that one can estimate exponentially many observables using only logarithmically many measurements in the number of observables. These can be used to estimate fidelity, the entanglement entropy, or find entanglement witnesses. The procedure consists of two steps:
  1. Data acquisition - constructing snapshots of the quantum state, and construction of a classical representation of the quantum state, i.e, the classical shadow.
  2. Prediction
  • Given MM observables O1,,OMO_1, \dots, O_M, estimate their expectation values Oi=tr(Oiρ)\langle O_i \rangle = \text{tr}(O_i\rho).
The Classical Shadow Procedure (from Ref. [1]):
Classical-shadow tomography pipeline: random unitaries, measurements, classical representation, prediction

Procedure

Data Acquisition

One step of the data acquisition procedure consists of the following:
  • Select a random unitary, UU, transformation from a predefined, tomographically complete ensemble.
  • Apply the transformation to the quantum state of interest:
ρUρU\rho \rightarrow U\rho U^\dagger
  • Measure the transformed quantum state in the computational basis and obtain a bit string of measurements b{0,1}n|b\rangle \in \{0, 1\}^n.
  • Store the classical snapshot\textit{classical snapshot} of the state by classically performing the reverse operation UbbUU^\dagger |b\rangle \langle b| U and storing (efficiently) it in classical memory.
The average mapping (in terms of unitary choice and measurement result) from ρ\rho to its snapshot can be viewed as a measurement channel: M(ρ)=E[UbbU]=EUUb{0,1}nbUρUbUbbU  ,\mathcal{M}(\rho) = \mathbb{E}[U^\dagger |b\rangle \langle b| U] = \mathbb{E}_{U\sim{\cal{U}}}\sum_{b\in \{0,1 \}^n} \langle b| U \rho U^\dagger|b \rangle U^\dagger |b\rangle \langle b|U ~~, ‘Average mapping’, means that the true state is obtained from the estimated state in expectation: E[ρ^]=ρ  .\mathbb{E}[\hat{\rho}] = \rho~~. When the unitary ensemble (which is averaged over) is tomographically complete, so the quantum state can be fully reconstructed from the measurements, the measurement channel can be inverted. This allows obtaining the original state: ρ=E[M1(UbbU)]  .\rho = \mathbb{E}[\mathcal{M}^{-1}(U^\dagger |b \rangle \langle b| U)]~~. To take advantage of this, this procedure is repeated NN times, yielding an array of classical shadow\textit{classical shadow} of ρ\rho: S(ρ;N)={ρ^1,,ρ^N}  ,\textbf{S}(\rho; N) = \{\hat{\rho}_1,\dots, \hat{\rho}_N \}~~, where ρ^i=M1(UibibiUi)  ,  for all  i[1,N]  .\hat{\rho}_i = \mathcal{M}^{-1}(U_i^\dagger |b_i\rangle \langle b_i| U_i)~~,~~\text{for all} ~~i\in[1,N]~~.

Prediction

Although the observables can be predicted using an empirical mean, the authors use a median-of-means approach in order to mitigate outliers:
  • Divide the shadow into KK equally sized parts, and take the mean of each one to construct KK estimators of ρ\rho
ρ^(k)=1N/Ki=(k1)N/K+1kN/Kρ^i(1)\hat{\rho}_{(k)} = \frac{1}{\left\lfloor N / K \right\rfloor} \sum_{i=(k-1)\left\lfloor N / K \right\rfloor + 1}^{k \left\lfloor N / K \right\rfloor} \hat{\rho}_i \tag{1}
  • Then, for each observable (for i=1i =1 to MM), take the median of the means, where Oi^\hat{O_i} is the estimation of the observable:
Oi^(N,K)=median{tr(Oiρ^1),...,tr(Oiρ^K)}(2)\hat{O_i}(N, K) = \text{median}\{\text{tr} (O_i \hat{\rho}_1), ..., \text{tr} (O_i \hat{\rho}_K)\} \tag{2} Huang et al. proved that the classical shadow protocol allows predicting MM target functions tr(Oiρ)\text{tr}(O_i \rho) within error ϵ\epsilon with O(log(M)maxiOishadow2/ϵ2)  ,(3)\mathcal{O}(\log(M) \max_i ||O_i ||^2_{\text{shadow}}/\epsilon^2)~~, \tag{3} where the shadow norm Oishadow2\|O_i \|^2_{\text{shadow}} affects the sample complexity and the accuracy of prediction. An important ingredient in the protocol is the ability to sample random unitaries UU. Formally, one needs to sample from the Haar measure. However, sampling exactly from this measure requires exponential circuit size in the number of qubits. So in practice, one often uses other unitary ensembles, such as the Clifford group, which efficiently reproduces the first (mean) and second (variance) moments of Haar randomness (formally, the Clifford group forms an exact unitary 3-design). We consider two ensembles:
  1. Random Pauli measurements: each qubit is rotated by an independently sampled single-qubit Clifford gate, U=U1UnU = U_1 \otimes \dots \otimes U_n.
This is equivalent to random Pauli measurements on each qubit. In this case the inverse measurement channel factorizes across the qubits and reads \mathcal\{M\}^\{-1\}\!\bigl(U^\{\dagger\}\,|\hat b\rangle\!\langle\hat b|\,U\bigr) \;=\; \bigotimes_\{j=1\}^\{n\} \Bigl(\, 3\,U_j^\{\dagger\}\,|\hat b_j\rangle\!\langle\hat b_j|\,U_j \;-\; \mathbb\{I\}\,\Bigr)~~ , \tag\{4\} and the shadow norm of a kk-local observable scales as O{{shadow}}{2}  =  3{k},{(boundedby}4{k}O{}{2}{ingeneral)}  , \|O\|_\{\mathrm\{shadow\}\}^\{2\} \;=\; 3^\{\,k\}\,, \qquad \text\{(bounded by \} 4^\{k\}\,\|O\|_\{\infty\}^\{2\}\text\{ in general)\}~~, i.e., it scales exponentially with the locality (weight) of the observable. This channel can be implemented with a circuit of depth one, but the sample complexity (number of measurements) scales exponentially with the weight of the observables.
  1. The nn-qubit Clifford group Cl(2n)\mathrm{Cl}(2^n).
Here the average measurement channel is the depolarizing channel [4] M(ρ)=D1/(2n+1)(ρ)\mathcal{M}(\rho) = \mathcal{D}_{1/(2^n+1)}(\rho), and the inverse of the measurement channel reads {M}{1} ⁣(U{}b^ ⁣b^U)  =  (2{n}+1)U{}b^ ⁣b^U    {I}  .\mathcal\{M\}^\{-1\}\!\bigl(U^\{\dagger\}\,|\hat b\rangle\!\langle\hat b|\,U\bigr) \;=\; (2^\{n\}+1)\,U^\{\dagger\}\,|\hat b\rangle\!\langle\hat b|\,U \;-\; \mathbb\{I\}~~. The shadow norm is equivalent to the Hilbert-Schmidt norm of the traceless part of the observable, O0=Otr(O)I/2nO_0 = O - \mathrm{tr}(O)\,\mathbb{I}/2^{n}, with the two-sided bound {tr} ⁣(O0{2})    O0{{shadow}}{2}    3{tr} ⁣(O0{2})  ,\mathrm\{tr\}\!\bigl(O_0^\{2\}\bigr) \;\le\; \|O_0\|_\{\mathrm\{shadow\}\}^\{2\} \;\le\; 3\,\mathrm\{tr\}\!\bigl(O_0^\{2\}\bigr)~~, so the shadow norm is independent of the system size nn (up to the constant 3) - efficient for global observables such as fidelity. Implementation of random nn-qubit Clifford circuits scales well and estimates global observables efficiently, but requires many more (n2/log(n)n^2/\log(n)) entangling gates to implement. In both cases, the snapshots can be stored efficiently using the stabilizer formalism. For pedagogical clarity this notebook represents Clifford unitaries as dense 2n×2n2^{n}\times 2^{n} matrices, so the inverse-channel application and observable estimator cost O(22n)\mathcal{O}(2^{2n}) per snapshot (after the row-of-UU optimization used below). The same transformations can be carried out in O(n2)\mathcal{O}(n^{2}) per snapshot via the symplectic-tableau representation of Clifford circuits due to Aaronson and Gottesman [5] - the regime in which the protocol’s O(logM)\mathcal{O}(\log M) sample-complexity advantage becomes a real wall-clock speedup. To demonstrate the classical shadow procedure, we will build a classical shadow, fully reconstruct a state, and predict an observable.

Building a Classical Shadow with Classiq

In this example, we will construct a classical shadow of the Φ\Phi^- bell state, utilizing the random Pauli and random Clifford measurement channels. We begin by describing the random Pauli measurement channel in the first section and continue by analyzing the Clifford measurement channel. For each measurement channel, we first introduce the quantum functions required to implement the quantum part of the shadow protocol. Then we present the classical processing functions, which construct the classical shadow. Utilizing the shadows, the full state is constructed and compared to the ground truth. Generally, state construction even with the classical shadow is inefficient, nevertheless, the construction demonstrates the strength of the method. Following, we utilize the classical shadow representation to estimate the expectation value of O=ZZO = Z\otimes Z, and finally, we evaluate the error bound, lower bounding the number of measurements (sample complexity) required to achieve an accurate estimation with high probability. The Pauli measurement channel (with 400400 samples) produced a closer state reconstruction, but did not achieve an accurate estimation of the expectation value of ZZZ\otimes Z. In contrast, the Clifford measurement channel (with only 5050 samples) achieved machine precision for the expectation value estimation, but produced a state with larger distance from the target Bell state (this result is not coincidental but stems from the fact that the Bell state is a stabilizer state and ZZZ\otimes Z is one of its +1+1 stabilizers).

Classical Shadow with Pauli Measurement Channel

We begin by preparing the Φ\Phi^{-} Bell state and then rotating each qubit so that it corresponds to a randomly chosen Pauli measurement basis. The tomographically complete set {H,HS,I}\{H,\,HS,\,I\} corresponds to measurements in the XX, YY, ZZ bases respectively. A unitary ensemble of tensor products of single-qubit Clifford circuits is easy to implement on NISQ hardware, performs well when estimating local observables, but scales poorly (see discussion above). Rather than baking each random basis choice into a fresh circuit at synthesis time, which forces one synthesis per snapshot and dominates the wall-clock time, we express the per-qubit rotation as RY(θ)RZ(ϕ)R_Y(\theta)\,R_Z(\phi) and pass (θj,ϕj)(\theta_j,\phi_j) as classical execution-time parameters. The program is then synthesized once and executed in a single ExecutionSession.batch_sample call that submits all snapshots together. The mapping from basis index to angles is: The angles ϕ\phi and θ\theta are chosen from this set. The mapping is encoded by the BASIS_ANGLES numpy array.
Below, calculate_shadow_pauli() synthesizes the parametric program once, samples the random measurement bases, and submits all snapshots in a single sample call. The snapshots contain the measurement results (bits) and unitary operations are stored as basis identifiers, in ids list.
Output:
Output:
This is the end of the quantum part of the procedure - the snapshots are all we need to extract information about the state. We will now demonstrate the following uses of these snapshots:
  • Full Tomography: reconstruct the state completely (not just certain pieces of information) as an instructive example.
This application doesn’t offer an advantage over quantum state tomography, requiring exponential resources.
  • Estimating Observables: estimating the expectation values of observables by reconstructing only parts of the state.
This is one of the applications where classical shadow offers an advantage.

State Reconstruction

The two functions below perform a full state reconstruction, given enough snapshots. To reconstruct the state, we take the measurement results in snapshots and apply the inverse of the operations stored in ids. It turns out that since each of our possible unitaries is a tensor product of randomly selected single-qubit Clifford gates, we can apply inverse of the channel Eq. (4) ρ^=j=1n(3UjbjbjUjI)  .\begin{equation} \hat{\rho} = \bigotimes_{j=1}^{n} ( 3 U_j^\dagger |b_j\rangle \langle b_j| U_j - \mathbb{I})~~. \end{equation} In snapshot_reconstruction_pauli() below, we apply this equation to get the density matrix of the reconstructed state. reconstruction_pauli() averages these density matrices to get an accurate estimation of the initial state ρ\rho.
Output:
With 200 snapshots the output density matrix looks similar to the Φ\Phi^- bell state density matrix. To quantitatively compare the reconstructed state to the true state, we will use the cell below to compute the ‘distance’ (the Frobenius norm) between the two states.
Output:
The accuracy of the reconstruction increases with the number of snapshots. Test different values for num_snapshots to see for yourself. The execution time scales linearly with the number of snapshots. Although completely reconstructing a state using the classical shadow procedure is an instructive example, the procedure doesn’t offer much advantage when doing so. Classical shadow shine when estimating many observables.

Estimating Observables

In this example, we will assume that our observables are only made up of Pauli I,X,Y,ZI, X, Y, Z operators. That is, O=jnσjO = \bigotimes_j^n \sigma_j, where nn is the number of qubits. Recall that to estimate an observable, we compute the median of observable estimators. Each estimator is the product of the observable and the mean of the estimated states in the median-of-means division (Eq. (2)). For each of tr(Oρ^i)\text{tr} (O \hat{\rho}_i), we must compute the estimated states from the snapshots in the shadow. For this, we will apply Eq. (4) tr(Oρ^i)=tr(n=1jσj(3Ujb^jb^jUjI))\text{tr}(O \hat{\rho}_i) = \text{tr}\left(\bigotimes_{n=1}^{j} \sigma_j (3 U_j^\dagger |\hat{b}_j\rangle \langle \hat{b}_j| U_j - \mathbb{I})\right) =j=1n tr(σj(3Ujb^jb^jUjI))  .=\prod_{j=1}^{n} \ \text{tr}\left( \sigma_j (3 U_j^\dagger |\hat{b}_j\rangle \langle \hat{b}_j| U_j - \mathbb{I})\right)~~. When the basis matches the observable, e.g. σj=X\sigma_j = X, and we measured in the XX basis (applied HH in the circuit), the trace evaluates to 33 when b^j=0|\hat{b}_j\rangle = |0\rangle and 3-3 when b^j=1|\hat{b}_j\rangle = |1\rangle. If σj=I\sigma_j = I, the trace evaluates to 11. Otherwise, the trace evaluates to 00, making the product 00.
In this example, we will estimate the expectation value of the observable ZZZ \otimes Z. Due to the low number of snapshots (as we will see in the next section), the estimation may not be very accurate, and will vary with different sets of snapshots.
Output:
To compute the number of snapshots we need to accurately predict MM observables with probability 1δ1-\delta that the error is ϵ\epsilon, we use Eq. S13 from Ref. 3: K=2log(2Mδ) and N=34ϵ2max1iMOitr(Oi)2nIshadow2  .\begin{equation} \tag{5} K = 2\log(\frac{2M}{\delta}) \ \text{and} \ N = \frac{34}{\epsilon^2} \max_{1\le i \le M} \| O_i - {\frac{\text{tr} (O_i)} {2^n}}\mathbb{I} \| _{\text{shadow}}^2 ~~.\end{equation} For the random-Pauli ensemble, the shadow norm of a kk-local Pauli string PP is Pshadow2  =  3k,(bounded by 4kP2 in general),\|P\|_{\text{shadow}}^2 \;=\; 3^{\,k}\,, \qquad \text{(bounded by } 4^{k}\,\|P\|_\infty^2 \text{ in general),} so the locality factor 3k3^{\,k} dominates the sample cost. For a sum of Pauli terms O=acaPaO = \sum_a c_a P_a, the triangle inequality gives the upper bound Oshadow    aca3weight(Pa)/2  .\|O\|_{\text{shadow}} \;\le\; \sum_a |c_a|\,3^{\,\text{weight}(P_a)/2}~~. NKNK snapshots are sufficient to accurately predict MM observables, using the median-of-means algorithm with KK divisions such that oi^(N,K)tr(Oiρ)ϵ    1iM   with probability1δ  .|\hat{o_i}(N, K) - \text{tr} (O_i \rho)| \le \epsilon \ \ \forall \ \ 1 \le i \le M \ \ \text{ with probability} \ge 1-\delta~~. The error_bound_pauli() function below implements this equation for the case of an ensemble consisting of Pauli basis measurements: it computes the per-term locality kk and uses the shadow-norm bound 3k3^{\,k} above. For other ensembles the shadow norm has a different form (e.g. the Hilbert-Schmidt bound for the random-Clifford ensemble).
Output:
The error bound predicts that to estimate ZZZ \otimes Z with error 0.20.2 and failure probability 0.010.01 we need on the order of 8×104\sim 8 \times 10^{4} snapshots: the locality factor 32=93^{2}=9 multiplies the per-observable sample count compared to the operator-norm-only bound. With only 400400 snapshots split into div=2 chunks of 200 shots each, the standard error is 32/4000.15\sqrt{3^{2}/400}\approx 0.15.

Classical Shadow with Random Clifford Measurements

We now repeat the protocol with the second ensemble described in the introduction: the full nn-qubit Clifford group Cl(2n)\mathrm{Cl}(2^n). Instead of applying an independent single-qubit Clifford on each qubit, we sample a single uniformly-random Cl(2n)\mathrm{Cl}(2^n) element UU and apply it globally to the bell state, then measure in the computational basis. As discussed earlier, the average measurement channel is the depolarizing channel M(ρ)=D1/(2n+1)(ρ)\mathcal{M}(\rho) = \mathcal{D}_{1/(2^n+1)}(\rho), and the inverse-channel snapshot reads ρ^  =  M1 ⁣(Ub^ ⁣b^U)  =  (2n+1)Ub^ ⁣b^U    I.\hat{\rho} \;=\; \mathcal{M}^{-1}\!\bigl(U^\dagger\,|\hat b\rangle\!\langle\hat b|\,U\bigr) \;=\; (2^{\,n} + 1)\,U^\dagger\,|\hat b\rangle\!\langle\hat b|\,U \;-\; \mathbb{I}. This Clifford track is independent of the Pauli-shadow workflow above. Two practical changes from the Pauli protocol:
  1. We sample the random Clifford classically as a depth-2020 sequence of the generator set {H, S, CNOT}\{H,\ S,\ \mathrm{CNOT}\} (applied to randomly chosen qubits).
This depth is past the 3-design mixing time (the circuit depth required to approximate a random Clifford unitary). The same gate sequence is then traced into the Classiq circuit using the native H, S, and CX qfuncs.
  1. We record only the sampled gate sequence per snapshot in clifford_sequences - a list of (label, q1, q2) tuples.
The matrix UU is built on demand inside the reconstruction / observable-estimator routines via sequence_to_unitary. Note: As mentioned in the beginning, in contrast to the present implementation, there is no need to create the unitary matrices, corresponding to the random Clifford circuits, explicitly (see sequence_to_unitary). The unitary operations can be calculated efficiently (O(n2)\mathcal{O}(n^2)) employing the stabilizer formalism [5].
Output:
Output:
Output:
Output:

Reconstruction with the Clifford Shadow

The inverse-channel snapshot for the Clifford ensemble is given by: ρ^t  =  (2n+1)Utb^t ⁣b^tUt    I.\hat\rho_t \;=\; (2^{\,n} + 1)\, U_t^{\dagger}\, |\hat b_t\rangle\!\langle\hat b_t|\,U_t \;-\; \mathbb{I}. Here, UtU_t is a 2n×2n2^n \times 2^n unitary which generally does not factorize to nn single qubit gates. So we build b^t ⁣b^t|\hat b_t\rangle\!\langle\hat b_t| in the full 2n2^n-dimensional Hilbert space, and perform the inverse channel. Averaging across the snapshots than reconstructs ρ\rho.
Output:

Estimation of Observables

For the random nn-qubit Clifford measurement channel the inverse channel does not factorize across qubits, and the per-snapshot estimator reads ρ^i  =  (2n+1)Uib^i ⁣b^iUi    I.\hat{\rho}_{i} \;=\; (2^{n}+1)\, U_{i}^{\dagger}\,|\hat{b}_{i}\rangle\!\langle\hat{b}_{i}|\,U_{i} \;-\; \mathbb{I}. Substituting into tr(Oρ^i)\text{tr}(O\hat{\rho}_{i}) gives tr(Oρ^i)  =  (2n+1)(UiOUi)b^i,b^i    tr(O),\text{tr}(O\,\hat{\rho}_{i}) \;=\; (2^{n}+1)\, \bigl(U_{i}\, O\, U_{i}^{\dagger}\bigr)_{\hat b_{i},\,\hat b_{i}} \;-\; \text{tr}(O), so each snapshot’s contribution is a single diagonal entry of the rotated observable. As before, we average within each median-of-means chunk and take the median across the KK chunks (Eqs. (1)-(2)).
Output:
We achieve machine precision in estimating the expectation value.

Error Bound — Clifford Ensemble

The sample-complexity bound (Eq. (5)) holds with the Clifford-ensemble shadow norm. Using the upper bound from the introduction, Otr(O)2nIshadow2    3tr ⁣(O02),O0=Otr(O)2nI,\| O - {\textstyle\frac{\text{tr}(O)}{2^{n}}}\,\mathbb{I} \|^{2}_{\text{shadow}} \;\le\; 3\,\text{tr}\!\left( O_{0}^{\,2}\right), \qquad O_{0} = O - \tfrac{\text{tr}(O)}{2^{n}}\,\mathbb{I}, we obtain a sufficient sample count N  =  34ϵ2max1iM3tr ⁣(O0,i2),K  =  2log ⁣(2Mδ).N \;=\; \frac{34}{\epsilon^{2}}\,\max_{1\le i\le M}\, 3\,\text{tr}\!\left( O_{0,i}^{\,2}\right), \qquad K \;=\; 2\log\!\Bigl(\tfrac{2M}{\delta}\Bigr). Unlike the Pauli ensemble, this does not scale with the locality of the observable, only with the Hilbert-Schmidt norm of its traceless part, so global observables (e.g. fidelities) are tractable.
Output:
In practice, for the Bell state and chosen observable, we obtain an excellent estimation of the observables with much fewer samples than the error bound predicts.

Summary

We have reconstructed full states and estimated observables using the classical shadow procedure on Classiq. However, the procedure can accomplish much more, such as estimating fidelity, finding entanglement witnesses, and estimating entanglement entropy, as shown in Ref. [3].

References

[1] J. Haah, A. W. Harrow, Z. Ji, X. Wu and N. Yu, “Sample-Optimal Tomography of Quantum States,” in IEEE Transactions on Information Theory, vol. 63, no. 9, pp. 5628-5641, Sept. 2017, doi: 10.1109/TIT.2017.2719044 arXiv. [2] Aaronson, S. (2018). Shadow tomography of quantum states. arXiv. [3] Huang, HY., Kueng, R. & Preskill, J. Predicting many properties of a quantum system from very few measurements. Nat. Phys. 16, 1050–1057 (2020). https://doi.org/10.1038/s41567-020-0932-7. arXiv. [4] Quantum depolarizing channel. Wikipedia. https://en.wikipedia.org/wiki/Quantum_depolarizing_channel [5] Aaronson, S., & Gottesman, D. (2004). Improved Simulation of Stabilizer Circuits. Physical Review A, 70(5),
  1. https://doi.org/10.1103/PhysRevA.70.052328. arXiv.
[6] Wiersema, R., & Doolittle, B. (2021, June). Classical shadows. PennyLane Demos. Xanadu. https://pennylane.ai/qml/demos/tutorial_classical_shadows