Randomized Compiling (RC)


“I couldn’t imagine building a quantum computer without this.”

— John Martinis, Google AI

Randomized compilinga,b (RC) takes a circuit and randomizes its gates using virtual twirling groups while preserving the overall ideal unitary of the circuit (see [5]). This has the effect of converting coherent and non-Markovian error sources into stochastic errors, resulting in dramatically improved run-time performance and overall stability for quantum algorithms. Actual experimental data illustrating these dramatic improvements is available upon request.

More concretely, randomized compilinga,b inserts virtual random gates into a circuit and compiles them as shown in the figure below so that:

  1. The logical circuit is unchanged

  2. The depth of the circuit is unchanged

  3. The probability of obtaining a correct output for an algorithm run on noisy quantum hardware is significantly increased

  4. The error prone quantum hardware can solve a given problem instance with greater accuracy and precision

  5. The error prone quantum hardware can solve bigger problem instances with the same cumulative error budget

  6. Algorithm output errors are more stable and predictable

../_images/circuit_diagram.png

These improvements arise because coherent errors are suppressed (converted into stochastic errors) and many non-Markovian errors are eliminated. The main benefits of suppressing coherent and non-Markovian errors through randomized compilinga,b include:

  1. Dramatically improved run-time performance and overall performance stability for quantum algorithms

  2. Closing the gap between the standard performance assessment data, as obtained under methods such as Streamlined Randomized Benchmarking (SRB) and Cycle Benchmarking (CB), and the predictable performance of quantum algorithms based on the assessment data

These technical features imply the above performance improvements because of the following theoretical considerations. Norm-based quantities that quantify the impact of errors determine (i) the overall success probability with which noisy quantum hardware can execute a quantum algorithm of interest and (ii) the error threshold for fault-tolerance quantum error correction are both bounded by the diamond norm, defined by:

\[\epsilon_\diamond = ||\mathcal{E} - \mathcal{I}||_\diamond\]

The relationship between randomized benchmarking error rates and the diamond norm is very loose in the presence of coherent errors [8][9] :

\[r(\mathcal{E})(1 + 2^{-N}) \leq \frac{1}{2}\epsilon_\diamond(\mathcal{E}) \leq 2^N \sqrt{r(\mathcal{E})}\sqrt{1 + 2^{-N}}\]

In particular, the exponential scaling with the number \(N\) of qubits and the \(\sqrt{r(\mathcal{E})}\) scaling is tight. Crucially, the \(\sqrt{r(\mathcal{E})}\) scaling increases reported error rates \(10^{-6}\) to \(10^{-3}\). The diamond norm also bounds the increase in the TVD due to an error in a gate [10] for both worst-case and typical circuits.

a U.S. Patent 10,360,088 B2.
b U.S. Patent 10,031,791 B2.

Example

The below example will take the following circuit and generate 30 randomly compiled circuits that implement the same unitary as the original circuit.

../_images/rc_pre_compile_example.png

Note

Randomized compiling produces a new circuit collection on each call, so the output of the below program will be different if run again.

Here is one example of a circuit that might be generated as part of the circuit collection output by True-Qᵀᴹ’s trueq.randomly_compile() function.

../_images/rc_post_compile_example.png

Note

Cycles containing multi-qubit gates are assigned to be immutable by default, while single-qubit gates are mutable by default. Randomized compiling will not attempt to compile new gates into immutable cycles.

#
# Randomized compiling (RC) example.
# Copyright 2019 Quantum Benchmark Inc.
#

import trueq as tq

# Define a circuit which applies alternating cycles, with an X gate on qubit 0
# in one cycle and a controlled-Z gate on qubits 0 and 1 in the other cycle.
cycle1 = tq.Cycle({(0,): tq.Gate.x})
cycle2 = tq.Cycle({(0, 1): tq.Gate.cz})
circuit = tq.Circuit([cycle1, cycle2, cycle1, cycle2, cycle1])

# Run randomized compiling on the circuit.
compiled_circuit = tq.randomly_compile(circuit)

# Print one of the randomly compiled circuits.
print(compiled_circuit[0])
trueq.Circuit
     (0,): Gate.id                             (1,): Gate.z                             
Imm  (0, 1): Gate.cz                          
     (0,): Gate.id                             (1,): Gate.z                             
Imm  (0, 1): Gate.cz                          
     (0,): Gate.x                              (1,): Gate.z

Example

Below is an example similar to the one presented above, but where one of the single-qubit gates is immutable. Note that the circuit depth increases in this instance because the random gates cannot be compiled into an immutable cycle. One possible output circuit is:

../_images/rc_post_compile_example2.png
#
# Randomized compiling (RC) example 2.
# Copyright 2019 Quantum Benchmark Inc.
#

import trueq as tq

# Define a circuit which applies alternating cycles, with an X gate on qubit 0
# in one cycle and a controlled-Z gate on qubits 0 and 1 in the other cycle, and
# where the middle cycle with an X gate is immutable.
cycle1 = tq.Cycle({(0,): tq.Gate.x})
cycle2 = tq.Cycle({(0, 1): tq.Gate.cz})
cycle3 = tq.Cycle({(0,): tq.Gate.x}, immutable=True)
circuit = tq.Circuit([cycle1, cycle2, cycle3, cycle2, cycle1])

# Run randomized compiling on the circuit.
compiled_circuit = tq.randomly_compile(circuit)

# Print one of the randomly compiled circuits.
print(compiled_circuit[0])
trueq.Circuit
     (0,): Gate.z                              (1,): Gate.z                             
Imm  (0, 1): Gate.cz                          
     (0,): Gate.x                              (1,): Gate.id                            
Imm  (0,): Gate.x                             
     (0,): Gate.id                             (1,): Gate.id                            
Imm  (0, 1): Gate.cz                          
     (0,): Gate.y                              (1,): Gate.id