Readout error mitigation for the Sampler primitive using M3
Ang pahinang ito ay hindi pa naisalin. Nakikita mo ang orihinal na bersyon sa Ingles.
Usage estimate: under one minute on a Heron r2 processor (NOTE: This is an estimate only. Your runtime might vary.)
Background
Unlike the Estimator primitive, the Sampler primitive does not have built-in support for error mitigation. Several of the methods supported by the Estimator are specifically designed for expectation values, and hence are not applicable to the Sampler primitive. An exception is readout error mitigation, which is a highly effective method that is also applicable to the Sampler primitive.
The M3 Qiskit addon implements an efficient method for readout error mitigation. This tutorial explains how to use the M3 Qiskit addon to mitigate readout error for the Sampler primitive.
What is readout error?
Immediately before measurement, the state of a qubit register is described by a superposition of computational basis states, or by a density matrix. Measurement of the qubit register into a classical bit register then proceeds in two steps. First the quantum measurement proper is performed. This means that the state of the qubit register is projected onto a single basis state that is characterized by a string of s and s. The second step consists of reading the bitstring characterizing this basis state and writing it into classical computer memory. We call this step readout. It turns out that the second step (readout) incurs more error than the first step (projection onto basis states). This makes sense when you recall that readout requires detecting a microscopic quantum state and amplifying it to the macroscopic realm. A readout resonator is coupled to the (transmon) qubit, thereby experiencing a very small frequency shift. A microwave pulse is then bounced off of the resonator, in turn experiencing small changes in its characteristics. The reflected pulse is then amplified and analyzed. This is a delicate process and is subject to a host of errors.
The important point is that, while both quantum measurement and readout are subject to error, the latter incurs the dominant error, called readout error, which is the focus in this tutorial.
Theoretical background
If the sampled bitstring (stored in classical memory) differs from the bitstring characterizing the projected quantum state, we say that a readout error has occurred. These errors are observed to be random and uncorrelated from sample to sample. It has proven useful to model readout error as a noisy classical channel. That is, for every pair of bitstrings and , there is a fixed probability that a true value of will be incorrectly read as .
More precisely, for every pair of bitstrings , there is a (conditional) probability that is read, given that the true value is That is,
where is the number of bits in the readout register. For concreteness, we assume that is a decimal integer whose binary representation is the bitstring that labels the computational basis states. We call the matrix the assignment matrix. For fixed true value , summing the probability over all noisy outcomes must give . That is
A matrix with no negative entries that satisfies (1) is called left-stochastic. A left-stochastic matrix is also called column-stochastic because each of its columns sums to . We experimentally determine approximate values for each element by repeatedly preparing each basis state and then computing the frequencies of the occurrence of sampled bitstrings.
If an experiment involves estimating a probability distribution over output bitstrings by repeated sampling, then we can use to mitigate readout error at the level of the distribution. The first step is to repeat a fixed circuit of interest many times, creating a histogram of sampled bitstrings. The normalized histogram is the measured probability distribution over the possible bitstrings, which we denote by . The (estimated) probability of sampling bitstring is equal to the sum over all true bitstrings , each weighted by the probability that it is mistaken for . This statement in matrix form is
where is the true distribution. In words, the readout error has the effect of multiplying the ideal distribution over bitstrings by the assignment matrix to produce the observed distribution . We have measured and , but have no direct access to . In principle, we will obtain the true distribution of bitstrings for our circuit by solving equation (2) for numerically.
Before we move on, it's worth noting some important features of this naive approach.
- In practice, equation (2) is not solved by inverting . Linear algebra routines in software libraries employ methods that are more stable, accurate, and efficient.
- When estimating , we assumed that only readout errors occurred. In particular, we assume there were no state preparation and quantum measurement errors — or at least that they were otherwise mitigated. To the extent that this is a good assumption, really represents only readout error. But when we use to correct a measured distribution over bitstrings, we make no such assumption. In fact, we expect an interesting circuit to introduce noise, for instance, gate errors. The "true" distribution still includes effects from any errors that are not otherwise mitigated.
This method, while useful in some circumstances, suffers from a few limitations.
The space and time resources needed to estimate grow exponentially in :
- The estimation of and is subject to statistical error due to finite sampling. This noise can be made as small as desired at the cost of more shots (up to the timescale of drifting hardware parameters that result in systematic errors in ). However, if no assumptions are made on the bitstrings observed when performing mitigation, the number of shots required to estimate grows at least exponentially in .
- is a matrix. When , the amount of memory required to store is greater than the memory available in a powerful laptop.
Further limitations are:
- The recovered distribution may have one or more negative probabilities (while still summing to one). One solution is to minimize subject to the constraint that each entry in be non-negative. However, the runtime of such a method is orders of magnitude longer than directly solving equation (2).
- This mitigation procedure works on the level of a probability distribution over bitstrings. In particular, it cannot correct an error in an individual observed bitstring.
Qiskit M3 addon: Scaling to longer bitstrings
Solving equation (2) using standard numeric linear algebra routines is limited to bitstrings no longer than about 10 bits. M3, however, can handle much longer bitstrings. Two key properties of M3 that make this possible are:
- Correlations in readout error of order three and higher among collections of bits are assumed to be negligible and are ignored. In principle, at the cost of more shots, one could estimate higher correlations as well.
- Rather than constructing explicitly, we use a much smaller effective matrix that records probabilities only for bitstrings collected when constructing .
At a high level, the procedure works as follows.
First, we construct building blocks from which we can construct a simplified, effective, description of . Then, we repeatedly run the circuit of interest and collect bitstrings which we use to construct both and, with the help of the building blocks, an effective .
More precisely,
-
Single-qubit assignment matrices are estimated for each qubit. To do this, we repeatedly prepare the qubit register in the all-zero state and then in the all-one state , and record the probability for each qubit that it is read incorrectly.
-
Correlations of order three and higher are assumed to be negligible and are ignored.
Instead we construct a number of single-qubit assignment matrices, and a number of two-qubit assignment matrices. These one- and two-qubit assignment matrices are stored for later use.
-
After repeatedly sampling a circuit to construct , we construct an effective approximation to using only bitstrings that are sampled when constructing . This effective matrix is built using the single- and two-qubit matrices described in the previous item. The linear dimension of this matrix is at most of the order of the number of shots used in constructing , which is much smaller than the dimension of the full assignment matrix .
For technical details on M3, you can refer to Scalable Mitigation of Measurement Errors on Quantum Computers.
Application of M3 to a quantum algorithm
We'll apply M3's readout mitigation to the hidden shift problem. The hidden shift problem, and closely related problems such as the hidden subgroup problem, were originally conceived in a fault-tolerant setting (more precisely, before fault-tolerant QPUs were proved to be possible!). But they are studied with available processors as well. An example of algorithmic exponential speedup obtained for a variant of the hidden shift problem obtained on 127-qubit IBM® QPUs can be found in this paper (arXiv version).
In the following, all arithmetic is Boolean. That is, for , addition, is the logical XOR function. Furthermore, multiplication (or ) is the logical AND function. For , is defined by bitwise application of XOR. The dot product is defined by .
Hadamard operator and Fourier transform
In implementing quantum algorithms, it is very common to use the Hadamard operator as a Fourier transform. The computational basis states are sometimes called classical states. They stand in a one-to-one relation to the classical bitstrings. The -qubit Hadamard operator on classical states can be viewed as a Fourier transform on the Boolean hypercube:
Consider a state corresponding to fixed bitstring . Applying , and using