description
Guide

Debiasing and Sharpening

Last updated: January 18, 2024
IonQ Staff

Debiasing, also called symmetrization in the arXiv preprint published earlier this year by members of the IonQ team, is a quantum error mitigation (QEM) strategy that helps maximize the algorithmic performance of our world-class hardware. While previously only available to preferred partners and our Applications Services team, we have now integrated it into our core quantum platform, available to all customers on all systems they have access to as of API v0.3 

Unlike quantum error correction (QEC), QEM methods like debiasing do not completely eliminate the errors inherent to all quantum computing hardware, but can greatly suppress them without the large gate and qubit overhead that QEC methods require.

Content

How does debiasing work?
Debiased mapping
Debiased Circuit Execution
Average Aggregation
Sharpening via Plurality voting
Which one to use?
A visual example
Results
Using Debiasing and Sharpening with the direct IonQ REST API calls
Using Debiasing and Sharpening in Qiskit
Using Debiasing and Sharpening in Cirq
Summary
Contact Us

How does debiasing work?


Debiasing is a compiler-level error mitigation strategy that works by creating and running many symmetric variations of a given circuit, and then cleverly aggregating the measured outcomes to mitigate noise and improve the performance of quantum computers without incurring any additional qubit or gate overhead. We call this process sharpening.

Sharpening over the symmetrization variants while debiasing reduces the overall impact of stochastic noise on the computed result — the deterministic inaccuracies largely cancel out while random noise does not get amplified. This approach effectively mitigates the impact of hardware control errors and qubit decoherence, which are major sources of imperfection in modern quantum technologies. By minimizing the impact of these imperfections, debiasing enables quantum computers to produce results at a much higher level of accuracy.

Let’s break each of these steps down and explain them in the order they happen — first debiased mapping, circuit execution of symmetric variants, then sharpening.

Debiased mapping

Debiased mapping relies on identifying certain symmetries that arise at multiple levels of quantum computer hardware and using them to generate variant circuit implementations. That is, we identify and create variations of a circuit that should be identical on a noiseless machine, but in practice are not due to stochastic error. Different qubit assignments, gate decompositions, and pulse solutions can all be used to create variant implementations. 

For example, general symmetries can be found by creating conjugations (in group-action sense) of gate-level circuits by qubit permutations. The initial state is replaced by its permutation, the gates are applied on permuted qubits, and the measurement results are permuted back. Other computation-specific symmetries include gate decompositions — how we translate submitted gates into native ones — permutations of commuting gates, the addition of gates that preserve a given state (e.g., before measurement), and other changes of gates and measurements that can be compensated by changes in post-processing. Even at the laser pulse level, pulse sequences can be replaced with physically equivalent (symmetric) ones. 

Debiased Circuit Execution

Next, we run these symmetrical variants on-system, by simply splitting the number of requested shots across all variants equally. As long as there are enough total shots — we’ve found that 500 is the minimum to be able to consistently produce adequate variants and adequate runs within each variant for meaningful error mitigation — we do not need to add additional shot or qubit overhead to the circuit.  

When running these symmetrical variants as part of the debiasing process, our expected or “ideal” output remains unchanged, but the actual error profile is reflective of the specific variant implementation. This is where sharpening, our third step, comes in. We can aggregate the results from many implementations in a way that allows us to suppress the effect of these variant-specific errors and increase our confidence in the expected result.

Very simply, aggregation is how one decides to combine the output of multiple runs (“shots”) of the same circuit on a quantum computer. When running quantum algorithms on real hardware, we have an output that we want, but often get outputs we don't want due to the noisy nature of NISQ hardware. 

The simplest form of aggregation is a histogram: we group the outputs by occurrence into individual buckets, and report the aggregate statistics. While running many shots of a circuit and building a histogram is often thought of as a technique for projecting a complex statevector into the measurement basis, it is also a very rudimentary form of error mitigation: by including more shots than we strictly need, we increase our confidence that our measured outputs are indeed a correct representation of our statevector, and not just the byproduct of computational or statistical noise.  That is, it helps us get more accurate and reliable information by using lots of different tries of the same thing. The law of large numbers — one of the fundamental theorems of probability — states that the sample mean of a random variable converges to its expected value as the sample size increases.

Aggregating the results of our symmetrized circuit into a simple average histogram does not provide much benefit, though. Instead, we use sharpening, a different aggregation technique that helps us coerce arbitrary statistics to statistics of a desired type, namely one that helps us amplify our expected answer while minimizing our variant-based noise.

There are currently two aggregation strategies provided as part of the debiasing toolchain: “component-wise averaging” (“averaging” for short) and “plurality voting” (or “sharpening”). We’ll describe each in turn before making some general recommendations on which to choose in a given scenario.

Average Aggregation

Component-wise averaging is a technique for combining multiple estimates of a vector quantity, such as a parameter vector or a state vector, by taking the average of each component separately. For example, suppose we have three estimates of a parameter vector x = [x1, x2, x3], denoted by x1 = [x11, x12, x13], x2 = [x21, x22, x23], and x3 = [x31, x32, x33]. The component-wise average of these estimates is given by x_avg = [(x11 + x21 + x31) / 3, (x12 + x22 + x32) / 3, (x13 + x23 + x33) / 3]. In the case of debiasing toolchain we are averaging over symmetric variants.

Average aggregation computes the mean value over variants. For histogram output building, this means that the average aggregation takes the output probabilities of each quantum circuit symmetric variant and calculates the average probability for each possible outcome. This way, the average aggregation can produce a histogram that represents the average distribution of the all symmetric variant quantum circuits' outputs.

Sharpening via Plurality voting

Plurality voting is a method of electing a single winner from a set of candidates. In plurality voting, each voter casts one vote for their observed result. The candidate with the most votes wins, regardless of whether they have a majority (more than half) of the votes or not. Plurality voting is also known as first-past-the-post or winner-take-all voting.

If we expect from the ideal noseless result to observe only a few particular peaks in the aggregated histogram then sharpening will amplify these results by using plurality voting over debiased symmetric variants and will damp down these erroneous results observed due to quantum hardware imperfections.

Which one to use?


The recommended aggregation strategy — sharpening or averaging — is determined by the type of output probability distribution of the given quantum algorithm: for quantum algorithms with ideal measurement statistics consisting of ℓ outputs with equiprobable frequencies 1/ℓ — that is, a limited number of peaked outputs with equal or near-equal probability— the recommended aggregation strategy is sharpening implemented via plurality voting. This is because such algorithms have zero-frequency outputs and a subset of target outputs that needs to be determined. 

On the other hand, for algorithms with different measurement statistics, aggregation by averaging should be used to avoid distortion. This is because component-wise averaging is trivially stable for statistics of any type, but sharpening - voting-based aggregation may not be stable for some types of statistics. For example, sharpening may bring the true probability distribution (1-ε, ε) closer to (1,0) for small ε (< ½). 

So, component-wise averaging is reliable for all types of statistics, but plurality voting may not always be reliable. Plurality voting or sharpening can result in a distribution that is closer to the desired outcome, but it can also introduce undesired artifacts. That said, sharpening is so effective at identifying small numbers of peaked outputs, it is often worth attempting to redesign algorithms in a way that allows it to be used as an aggregation strategy.

Note also that in practice, we return the aggregated statistics under both aggregation methods for every debiased job, so you can qualitatively compare the impact on your own circuit without having to run it twice.

Let’s summarize. To get the best results, we can group together similar outputs and count how many times they occur. This is called "aggregation". The AVERAGED aggregation used in building a histogram - counting number of occurrences of the result assigned to a particular bin. Alternatively, if all the outputs we want for symmetrized variants occur the same number of times, for each variant we can just pick the one that appears the most. This is called SHARPENING via plurality voting. It amplifies the results common to all symmetrization variants and suppresses the ones that are less common (i.e. attributable to noise). However, if the outputs occur different numbers of times (e.g. not a single or few peaks, but various distribution of outcomes), we should take an average to avoid giving too much weight to less common outputs.

A visual example

Figure below (Fig. 1 in https://arxiv.org/pdf/2301.07233.pdf) shows the debiasing and sharpening of symmetrized circuit execution. The idea of creating symmetrized variants involves executing the quantum circuit in slightly different ways by varying qubit assignments, as illustrated in the figure (a). Each of the four selected qubit pairs in the circuit produces a superposition state (|00⟩ + |11⟩)/√2 in a variant of the circuit, with the target qubits highlighted in orange. The output state corresponding to each qubit pair is recreated and measured in the computational basis five times (b). Each measurement result is affected by individual inaccuracies. 

https://images.ctfassets.net/hqm865gc1xfs/25238GykB1S5qZPVJ3YmZ1/0a2c7b79e4dfc9ab1554e357871191c8/debias.png

When the measurement results are grouped per mapping and their statistics are aggregated, there is a significant deviation from the ideal outcome. However, this deviation is reduced when the measurement results are averaged. The residual erroneous counts are shown as red circles and crosses, while the all-zero states are represented by green triangles, and all-one states are represented by blue diamonds (c). 

In (d), the difference between the results obtained through component-wise averaging and plurality voting is compared. When sharpened – aggregated with plurality voting across the variants, the erroneous counts are filtered out, resulting in a distribution closer to the ideal case. On the other hand, component-wise averaging preserves all the counts, including the erroneous ones. Therefore, while component-wise averaging may be more stable for all types of statistics, plurality voting can be a better option for reducing errors in the multiple equally-probable peaks or single peak distributions.

Results

Figure below illustrates the effect of debiasing on a 13-qubit single-output QFT-based adder circuit. It compares the results without debiasing to those with debiasing using either component-wise averaging or sharpening with plurality voting. The blue squares represent the un-symmetrized results obtained from a single realization with 2500 repeated measurements. The orange diamonds and green circles show the debiased results using 25 realizations and 100 repetitions per variant. The debiased histogram generated with component-wise averaging is represented by the orange diamonds, while the green circles represent the debiased histogram generated with sharpening. Plurality voting improves the probability of the target outcome by filtering out unmatched outcomes between the variants. The debiased results continue to improve until approximately 80 repetitions per variant, as shown in (b).

https://images.ctfassets.net/hqm865gc1xfs/2CtO6dwgMKnCF2kGoO92Eo/a71a358d0699851783a9a7a54bc4be71/Screenshot_2023-05-17_at_9.52.51_AM.png

Let us also provide a comparison of fidelity improvement for different algorithms. In (a), algorithms with a single output state such as quantum Fourier transform-based adders, phase estimation, and amplitude estimation are evaluated. Debiasing with sharpening via plurality voting significantly increases Hellinger fidelity, while debiased runs with componentwise averaging show no improvement. Hellinger fidelity is defined as a statistical overlap FH=(ipiqi)2F_H = (\sum_i\sqrt{p_i q_i})^2 between the actual output statistics pi and the ideal result qi is computed via an error-free simulator.

In (b), results for amplitude estimation and Monte Carlo sampling circuits are compared before tracing out the ancillary qubits. Debiasing with sharpening via plurality voting demonstrates the strongest improvement in Hellinger fidelity, but componentwise averaging also performs better than no symmetrization by evening out errors across the four target states.

In (c), debiasing is evaluated on variational quantum eigensolvers (VQE) and quantum machine learning (QML) circuits. These circuits have broader and irregular output distributions. Debiasing with componentwise averaging shows the best improvement in this case, while sharpening via plurality voting can skew the results.

https://images.ctfassets.net/hqm865gc1xfs/79B9ITW8Uv3xcldVdSu4Wk/764e7df982de9c74fd65df6a63ecba0c/Screenshot_2023-05-17_at_11.01.40_AM.png

The figure displays Hellinger fidelity as a function of circuit depth, represented by the number of two-qubit MS (Mølmer-Sørensen) gates. The green circles represent unsymmetrized (biased) results, while the blue squares and orange diamonds represent results debiased and sharpened — aggregated with plurality voting and componentwise averaging, respectively. The unsymmetrized and debiased results are obtained from the same set of experiments, with 25 realizations and 100 repetitions per variant. For algorithms with one output state, the unsymmetrized fidelities match exactly with the debiased results aggregated with componentwise averaging (a).

Using Debiasing and Sharpening with the direct IonQ REST API calls

Let's demonstrate how debiasing and sharpening works using direct IonQ cloud API calls for job assignment and status check. First, you'll need to authenticate your requests using an API key. You can get your API key by signing up for an IonQ account and generating an API key in the dashboard. We will use Python to generate HTTP requests to the API endpoint. Alternatively, `curl` can be used for that as well. You can submit a job by sending a POST request to the `/jobs` endpoint with a JSON payload containing the necessary information, such as the job name, the circuit to be executed, and the number of shots to be taken. For more details and examples, you can refer to the IonQ API documentation at the following link: https://docs.ionq.com/#tag/jobs/operation/createJob.

import requests
headers = {'Authorization': 'apiKey {}'.format(api_key),
          'Content-Type': 'application/json'}
base_url = "https://api.ionq.co"
jobs_url = "/v0.3/jobs"
data = {
 "name": "debias_test",
 "shots": 1024, # minimum 500 shots should be used for debias
 "target": "qpu.aria-1",
 "error_mitigation": { "debias": True },
 "lang": "json",
 "body": {
   "qubits": 2,
   "circuit": [
     {"gate": "h", "target": 0},
     {"gate": "cnot", "control": 0, "target": 1}
   ]
 }
}
response = requests.post(base_url+jobs_url, headers=headers, json = data)

We recommend using a simulator first before submitting jobs to QPUs (`harmony` or `aria-1`, at the moment of writing this guide). Using a simulator first can help you test and debug your code before submitting it to a real quantum computer. Additionally, it can save you time and credits, as simulators are usually faster and less expensive than QPUs. Please be aware that the current version of the simulator incorporates the noise model of `harmony` or `aria-1` QPUs, but it does not employ debiasing and sharpening. In this context, the simulator should be utilized to verify the correctness of the circuit.

Job submission will return status code 200 if the job was successfully submitted, and also provide JSON with “id”, “status”, and “request” fields. “Id” field corresponds to UUID (jobID) and can be used for status tracking and retrieval of the job results later on.

Current job status and information about the job submission can be checked by submitting HTTP GET request using `/jobs/{UUID}` endpoint:

base_url = "https://api.ionq.co"
jobs_url = "/v0.3/jobs"
response = requests.get(base_url+jobs_url+'/'+jobID, headers=headers)

If the job has the “status” : "completed" the response from the server will provide “results_url” JSON field, which can be used to retrieve both type of aggregated results by specifying if sharpening should be used or not:

res_dict = response.json() # returns python dictionary
#params = {"sharpen": "false"} # default - averaging
params = {"sharpen": "true"} # plural voting aggregation
results = requests.get(base_url+res_dict["results_url"], 
        headers=headers, params=params)

For more details and examples, you can refer to the IonQ API Documentation.

Using Debiasing and Sharpening in Qiskit

To enable Debiasing in Qiskit you will need to provide an additional argument to the `run` function call. `error_mitigation` parameter should be set to `ErrorMitigation.DEBIASING` constant value. If you explicitly would like to disable debiasing - `ErrorMitigation.NO_DEBIASING` constant value should be used instead. For more information and examples please refer to https://github.com/Qiskit-Partners/qiskit-ionq.

# pip install qiskit qiskit_ionq getpass

from qiskit import QuantumCircuit
from qiskit_ionq import IonQProvider, ErrorMitigation

from getpass import getpass

# Get your API key from https://cloud.ionq.com/settings/keys
api_key = os.getenv('IONQ_API_KEY') or getpass('Enter your IonQ API key: ')
provider = IonQProvider(api_key)
backend = provider.get_backend("ionq_qpu.harmony") 
                           # ⬆️ or 'ionq_simulator' to check a circuit

# Create a basic Bell State circuit:
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])

# Run the circuit on IonQ's platform with error mitigation:
job = backend.run(qc, error_mitigation = ErrorMitigation.DEBIASING)

# Print the results.
print(job.result().get_counts())

# Get results with a different aggregation method  (Sharpening) when debiasing
# is applied as an error mitigation strategy
print(job.result(sharpen=True).get_counts())

# The simulator specifically provides the the ideal probabilities and creates
# counts by sampling from these probabilities. The raw probabilities are also 
# accessible:
print(job.result().get_probabilities())

If debiasing was used during the job run you will have an option to collect both versions of the aggregated results by providing `sharpen=True` argument to the `result` function call to see plurality voting aggregation results; or setting this parameter to `False` to see result of average aggregation. If argument is not provided the average aggregation will be used by default.

Using Debiasing and Sharpening in Cirq

To enable debiasing and sharpening in cirq you can provide additional parameters to the `run` function call with specifying `error_mitigation` parameter as dictionary `{ “debias” : True}`. `sharpen` parameter takes boolean values.

import cirq
import cirq_ionq as ionq

# A circuit that applies a square root of NOT and then a measurement.
qubit = cirq.LineQubit(0)
circuit = cirq.Circuit(
    cirq.X(qubit)**0.5,            # Square root of NOT.
    cirq.measure(qubit, key='x')   # Measurement store in key 'x'
)

# Create a ionq.Service object.
# Replace API_KEY with your api key.
# Alternatively, if you have the IONQ_API_KEY environment
# variable set, you can omit specifying this api_key parameters.
service = ionq.Service(api_key=API_KEY)

result = service.run( circuit=circuit, 
    repetitions=100, 
    target='qpu', 
    error_mitigation={"debias": True}, 
    sharpen=True)

If you would like to have the results of both cases with sharpening and without it – you can use `create_job` function call instead:

job = service.create_job(circuit=circuit, 
    repetitions=100, 
    target='qpu',
    error_mitigation={"debias": True})
sharpened_results = job.results(sharpen=True)
averaged_results = job.results(sharpen=False)

Summary

Debiasing is a quantum error mitigation strategy that reduces the impact of errors in quantum computing hardware by creating and running symmetric variations of a circuit and aggregating the outcomes. It does not eliminate errors completely but suppresses them without requiring additional qubits or gates like quantum error correction methods.

Debiased mapping is the process of creating variant circuit implementations by exploiting symmetries at different levels of quantum hardware. These variations can include qubit assignments, gate decompositions, and pulse sequences.

Debiased circuit execution involves running these symmetrical variants on the quantum computer, splitting the requested shots equally among them. This process provides variant-specific error profiles while preserving the expected output.

Aggregating the results of these symmetrical variants can be done through averaging or sharpening. Averaging calculates the average probability for each possible outcome, producing a histogram that represents the average distribution of all symmetric variants' outputs. Sharpening, implemented through plurality voting, amplifies the common results while reducing erroneous results due to hardware imperfections.

The choice between averaging and sharpening depends on the output probability distribution of the quantum algorithm. For algorithms with limited or equal probabilities among a few peaked outputs, sharpening is recommended. For algorithms with different measurement statistics, averaging should be used to avoid distortion.

Contact Us

Having trouble? Seeing something you don’t expect? Have other questions? Reach out to [email protected].