Random unitary evolution
Performing random measurements on a state is equivalent to evolving it through random unitaries and, then, performing projective measurements on a state vector of a basis of choice. In this implementation, we take our reference state vector to be the $|0\rangle$ of the computational basis.
However, the first step is being able to randomly evolve states, for which we need to properly sample unitary operators from the Haar metric.
local
indicates whether the random unitaries act at a local (local=True
) or global (local=False
) level. Global unitaries are much more costly to implement both at a numerical and experimental level. In terms of simulation, they require the explicit computation of $N\times N$ matrices, where $N$ is the size of the Hilbert space. In contrast, the operator resulting from the combination of local unitaries is expressed as the lazy computation of their tensor product, which is a list of n_qubits
elements of size $d\times d$, where d
is the size of the local Hilbert space.
n_qubits = 2
loc = random_unitary_circuits(1, n_qubits)[0]
glob = random_unitary_circuits(1, n_qubits, local=False)[0]
print(loc)
print(glob)
In terms of actual execution on a quantum hardware, the performance of local unitaries is straightforward, whereas global unitaries must be decomposed into a series of local operations.
loc.to_circuit_op().primitive.draw('mpl')
glob.to_circuit_op().primitive.draw('mpl')
The overlap between quantum states through random measurements can be performed with either local or global unitaries setting local
accordingly. The method mainly consists on sampling a set of random unitaries $U$ and, then, evolving and measuring the states of interest. This way, the probability $P(s)$ of measuring a given state $|s\rangle$ after a random unitary evolution $U$ of our initial state $\rho$ is $P(s) = \text{Tr}\left[U\rho U^\dagger|s\rangle\langle s|\right]$ and its expected value over all possible random measurements is $\langle P(s)\rangle=1/N$.
The expectation of the probability $P(s)$ over all possible random measurements is $\langle P(s)\rangle=1/N$. Measuring higher moments of $P(s)$, i. e. $\langle P(s)^n\rangle$, we can infer the value of $\text{Tr}\left[\rho^n\right]$ [1]. In this application case, we are mostly interested in computing the second moment $\langle P(s)^2\rangle$, from which we can infer $\text{Tr}\left[\rho^2\right]$. This is not restricted to purities, as we can compute the expectation $\langle P_0(s)P_1(s)\rangle$ from statistics obtained measuring $\rho_0, \ \rho_1$ over the same set of random unitaries $U$.
With global unitaries, the computation is rather straightforward. We can choose any vector $s$ of the computational basis to compute the statstics from. For convenience we have taken the zero state as our observable ~Zero
. Then,
$$\text{Tr}\left[\rho_0\rho_1\right]=N(N+1)\langle P_0(s)P_1(s)\rangle - 1.$$
The main issue, as discussed above, is the execution of such global operators in the quantum circuits.
On the other hand, local unitaries are much easier to implement in a quantum computer. Nevertheless, the posterior analysis requires the estimation of the statistics over all the states in the computational basis, rather than just a single one. Then, as derived in [2] the overlap between two quantum states may be obtained as $$\text{Tr}\left[\rho_0\rho_1\right]=N\sum_{s,s'}(-d)^{-D[s,s']}\langle P_0(s)P_1(s')\rangle,$$ where the sum goes over all pairs of states $s,s'$ in the computational basis, $d$ is the size of the local Hilbert space and $D[s,s']$ is the Hamming distance between states $s,s'$.
Hence, both approaches present a tradeoff between overloading the quantum (global unitaries) or the classical (local unitaries) hardware. See [3] for further detail. In terms of the API, the behaviour of the function is exactly the same besides the local
optional argument .
Overlap estimators, such as randomized_measurement_overlap
, are mainly intended to work with StateFn
and ListOp
objects. However, we provide compatibility with state0
in QuantumCircuit
with the idea to cover quick purity estimations straight from the circuits.
The bread-and-butter calls and applications of these methods are all detailed in the basic usage.
In order to illustrate its behaviour, we first need to create a parameterized quantum circuit.
theta0, theta1 = Parameter('θ0'), Parameter('θ1')
qc = QuantumCircuit(2)
qc.h(0)
qc.rx(theta0, 0)
qc.rx(theta1, 1)
qc.draw('mpl')
As previously mentioned, these overlap computers operate with StateFn
so we will call CircuitStateFn
on the circuit to create our state. If a Backend
or QuantumInstance
is not provided, everything is computed analytically with operator flow. Otherwise, the resulting observables are internally converted with a CircuitSampler
built from the backend. Providing an Expectation
converts the observable prior to the CircuitSampler
.
state = CircuitStateFn(qc)
expectation = PauliExpectation()
backend = BasicAer.get_backend('qasm_simulator')
qi = QuantumInstance(backend, shots=1000)
Now we can, for instance, compare the effect of using local or global unitaries. Let's first define a set of parameters to evaluate the overlap across their respective states.
param_dict = {theta0: [0, 0.1, 0.1],
theta1: [0, 0.1, 1.5]}
overlap = randomized_measurement_overlap(state, param_dict=param_dict, n_rnd=500,
local=False, expectation=expectation, backend=qi)
overlap
overlap = randomized_measurement_overlap(state, param_dict=param_dict, n_rnd=500,
local=True, expectation=expectation, backend=qi)
overlap
In terms of the result, we do not appreciate any substantial difference between both approaches. The execution performance, however, depends strongly on the backends, as previously discussed.
state0 = state.bind_parameters({theta0: 0., theta1: 0.5})
state1 = state.bind_parameters({theta0: [0.2, 0.5], theta1: [1.5, 0.5]})
overlap = randomized_measurement_overlap(state0, state1, n_rnd=200)
overlap
purity = randomized_measurement_overlap(state0)
purity
Overlap across backends
A major advantage of the random measurement protocol is that it is device independent, so long as we find the right way to define the unitary transformations across platforms. This allows us to perform the random measurements independently in separate devices and then infer the overlap between the states from the classical statistics.
We can perform a wide range of operations with device_independent_overlap
. It has a similar behaviour to that of the other overlap computation functions with the main difference being that it does not accept parameter-dependent states.
The most basic functionality is the calculation of the purity of a state in various backends. This is done by providing a single state0
input and a collection of backends.
qc = QuantumCircuit(1)
qc.h(0)
qc.draw('mpl')
state = CircuitStateFn(qc)
backends = [QasmSimulator(), QasmSimulator.from_backend(FakeVigo())]
purities = device_independent_overlap(state, backends)
purities
The outputs follow the same phylosophy as when randomized_measurement_overlap
is provided with a param_dict
: return the overlap between everything. Hence, the diagonal always contains the purity of each state in its backend.
As an optional input, it accepts a set of states state1
with which the overlaps are computed. In this case, it distributes the provided backends in a rather intuitive way following two main principles:
- If there is no backend for
state0
it loads aStatevectorSimulator
. state0
always takes the first backend.
Therefore, we identify the following cases as function of the amount of provided backends:
- A single backend:
state0
is simulated and all statesstate1
run in the backend. - Two backends:
state0
runs on the first, allstate1
run on the second. - As many backends as
state1
:state0
is simulated andstate1
run each on the backends. state0
+state1
backends:state0
runs on the first,state1
states run on the rest.
References
[1] S. J. van Enk and C. W. J. Beenakker, Measuring $\text{Tr}\rho^n$ on single copies of $\rho$ using random measurements. PRL 108, 110503 (2012).
[2] T. Brydges et al. Probing Rényi entanglement entropy via randomized measurements Science 364, 6437, pp. 260-263 (2019).
[3] A. Elben et al., Statistical correlations between locally randomized measurements: A toolbox for probing entanglement in many-body quantum states. PRA 99, 052323 (2019).