quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

Utilities for measurement error mitigation using confusion matrix (aka calibration matrix) #4800

Closed tanujkhattar closed 2 years ago

tanujkhattar commented 2 years ago

Is your feature request related to a use case or problem? Please describe. Measurement error is one of the major sources of error when running circuits on the device. A common technique to compensate for the measurement error is to first compute a confusion matrix (aka calibration matrix) by running 2 ** n circuits to prepare all basis. Measurement outcomes from the i'th circuit becomes the i'th row of the matrix.

The resulting confusion matrix would be the transpose of a stochastic map from final states to measurement outcomes, s.t. M_obs = CM.T @ M_act. For 2 qubits, this corresponds to:

[ 00o ]         ⎡ Pr(00o|00a) Pr(01o|00a) Pr(10o|00a) Pr(11o|00a) ⎤T      [ 00a ] 
[ 01o ]         ⎢ Pr(00o|01a) Pr(01o|01a) Pr(10o|01a) Pr(11o|01a) ⎥       [ 01a ]
[ 10o ]    =    ⎢ Pr(00o|10a) Pr(01o|10a) Pr(10o|10a) Pr(11o|10a) ⎥  @    [ 10a ] 
[ 11o ]         ⎣ Pr(00o|11a) Pr(01o|11a) Pr(10o|11a) Pr(11o|11a) ⎦       [ 11a ]

We can then use the computed confusion matrix to calibrate the measurement results of another experiment on the same qubits as:

M_compensated = Inv(CM.T) @ M_obs

Describe the solution you'd like We should have utility methods / classes to

What is the urgency from your perspective for this issue? Is it blocking important work? P2 - we should do it in the next couple of quarters

crazy4pi314 commented 2 years ago

Folks on the Mitiq project are also working on implementing measurement error mitigation: https://github.com/unitaryfund/mitiq/issues/815 that might be a helpful example

tanujkhattar commented 2 years ago

We should add this to cirq/experiments. Look at potential collaboration opportunities with Unitary Fund.