mindquantum.algorithm.error_mitigation.virtual_distillation

View Source On Gitee
mindquantum.algorithm.error_mitigation.virtual_distillation(circ: Circuit, executor: Callable[[Circuit], Dict[str, int]], little_endian: bool = True, **kwargs)[source]

Error mitigation algorithm based on virtual distillation (arXiv:2011.07064).

The algorithm calculates error-mitigated expectation values of Z_i Pauli operators for each qubit i. To measure expectation values of other Pauli operators (X_i or Y_i), appropriate basis rotation gates should be added at the end of the input circuit:

  • For X_i measurements: Add H gate on qubit i

  • For Y_i measurements: Add RX(π/2) gate on qubit i

Parameters
  • circ (Circuit) – The quantum circuit to be executed

  • executor (Callable[[Circuit], dict[str, int]]) – A callable object that executes quantum circuits and returns a dictionary mapping measurement result bitstrings to their counts. Note: executor must be able to handle twice the number of qubits as the input circuit

  • little_endian (bool) – Whether the bitstring returned by executor is little-endian. Default: True

  • **kwargs – Additional arguments to be passed to the executor.

Returns

np.ndarray, Error-mitigated expectation values <Z_i> for each qubit i. To obtain expectation values of other Pauli operators, add appropriate basis rotation gates to the input circuit before calling this function.

Examples

>>> circ = Circuit([X.on(0), RY(1).on(1)])
>>> sim = Simulator('mqvector', 4)  # Double number of qubits
>>> def executor(circ):
...     res_dict = sim.sampling(circ, shots=10000).data
...     return res_dict
>>> result = virtual_distillation(circ, executor)  # Returns <Z_i>
>>> # To measure <X_1>:
>>> circ_x = circ + H.on(1)
>>> result_x = virtual_distillation(circ_x, executor)