mindquantum.algorithm.error_mitigation.virtual_distillation
- mindquantum.algorithm.error_mitigation.virtual_distillation(circ: Circuit, executor: Callable[[Circuit], Dict[str, int]], little_endian: bool = True, **kwargs)[源代码]
基于虚拟蒸馏的误差缓解算法(arXiv:2011.07064)。
该算法用于计算每个量子比特i上 \(Z_i\) 泡利算符的误差缓解期望值。要测量其他泡利算符( \(X_i\) 或 \(Y_i\) )的期望值,需要在输入电路末尾添加适当的基矢旋转门:
对于 \(X_i\) 测量:在量子比特i上添加H门
对于 \(Y_i\) 测量:在量子比特i上添加RX(π/2)门
- 参数:
- 返回:
numpy.ndarray,每个量子比特i的误差缓解期望值 \(\langle Z_i\rangle\) 。要获取其他泡利算符的期望值,需要在调用此函数之前向输入线路添加适当的基矢旋转门。
样例:
>>> 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)