What is VD?#
Virtual distillation is an error mitigation technique introduced in [57, 58]. VD leverages \(M\) copies of a state \(\rho\) to suppress the error term. Virtual distillation describes the approximation of the error-free expectation value of an operator \(O\) as:
As described in the paper, the protocol makes use of the following equality:
Tip
More details about \(O^{\textbf{i}}\) and \(S^{(M)}\) can be found in What is the theory behind VD?.
This equation allows us to use \(M\) copies of \(\rho\) instead of preparing \(\rho^M\) explicitly.
How do I use VD?#
Problem setup#
The VD implementation requires:
A quantum circuit to apply error mitigation to (can be any supported frontend
mitiq.SUPPORTED_PROGRAM_TYPES)An executor function that runs the circuit and returns measurement results
Warning
Currently, VD only supports \(M=2\) copies and measurements of the Pauli-Z observable on each qubit.
Applying VD#
Below we provide an example of applying VD:
from mitiq import MeasurementResult
from mitiq.experimental import vd
import cirq
import numpy as np
# Create a simple example circuit WITHOUT measurements
# VD will add measurements
qubits = cirq.LineQubit.range(2)
circuit = cirq.Circuit([
cirq.H(qubits[0]),
cirq.CNOT(qubits[0], qubits[1])
])
def noisy_executor(circuit, noise_level=0.01, shots=1001) -> MeasurementResult:
circuit_to_run = circuit.with_noise(cirq.depolarize(noise_level))
simulator = cirq.DensityMatrixSimulator()
result = simulator.run(circuit_to_run, repetitions=shots)
bitstrings = np.column_stack(list(result.measurements.values()))
qubit_indices = tuple(
int(q[2:-1]) # Extract index from "q(index)" string
for k in result.measurements.keys()
for q in k.split(",")
)
return MeasurementResult(bitstrings, qubit_indices)
# Apply VD
mitigated_expectation_values = vd.execute_with_vd(circuit, noisy_executor)
print(f"Z expectation values for each qubit: {mitigated_expectation_values}")
/tmp/ipykernel_3282/3282667575.py:2: FutureWarning: mitiq.experimental.vd is experimental and its API may change without notice in future releases. It is not covered by mitiq's semantic versioning guarantees.
from mitiq.experimental import vd
Z expectation values for each qubit: [0.01437125748502994, -0.004790419161676647]
The function returns a list of error-mitigated expectation values \(\langle Z_i \rangle\) for each qubit \(i\) in the original circuit.