Benchmarking Circuits#

Mitiq benchmarks error mitigation techniques by evaluating improvements in metrics such as state fidelity (the closeness of the mitigated quantum state to the ideal state), output probability distributions, and logical error rates. The benchmarking process involves running diverse circuit types—such as GHZ, Mirror, Quantum Volume, and Randomized Benchmarking circuits—and comparing mitigated results against ideal theoretical outcomes. Additionally, Mitiq evaluates the overhead associated with each error mitigation technique, such as the increase in circuit depth or the number of samples required, as seen in methods like Zero Noise Extrapolation (ZNE) and Probabilistic Error Cancellation (PEC).

GHZ Circuits#

The generate_ghz_circuit() create the GHZ states that are highly sensitive to noise. A GHZ (Greenberger–Horne–Zeilinger) state is a maximally entangled quantum state involving multiple qubits. Thus, they make it easy to test error rates in entanglement creation and preservation, which is central for many quantum algorithms.

from mitiq.benchmarks import generate_ghz_circuit

circuit = generate_ghz_circuit(n_qubits=7)

print(circuit)
0: ───H───@───────────────────────
          │
1: ───────X───@───────────────────
              │
2: ───────────X───@───────────────
                  │
3: ───────────────X───@───────────
                      │
4: ───────────────────X───@───────
                          │
5: ───────────────────────X───@───
                              │
6: ───────────────────────────X───

Mirror Circuits#

The generate_mirror_circuit(), as defined in [1], involves running a quantum circuit forward and then “mirroring” it (applying the reverse operations). Ideally, this results in returning the system to the initial state, so they’re great for testing if the noise mitigation is effective in preserving information through complex sequences.

from mitiq.benchmarks import generate_mirror_circuit
import networkx as nx

topology = nx.complete_graph(7) # Provide appropriate topology
circuit, correct_bitstring = generate_mirror_circuit(nlayers=7, two_qubit_gate_prob=1.0, connectivity_graph=topology, return_type="cirq")

print(circuit)
                            ┌──────┐           ┌──┐           ┌──────┐                ┌───────┐               ┌───────┐                                                                                                   ┌──────┐                ┌──────┐               ┌───────┐           ┌──┐           ┌───────┐
0: ───X^-0.5───Y^0.5────X────@─────────────X────@─────────Y────Y^0.5─────X^-0.5───Y────@──────────────────X────@──────────────────X───@─────────────────I───Y^-0.5───I───Y───I───Y^0.5───Y───────────@───────Z─────────────@─────────I─────────────@─────────Z───X^0.5────Y^-0.5─────Y────────@─────X────────@──────────Z───Y^-0.5───X^0.5────
                             │                  │                                      │                       │                      │                                                              │                     │                       │                                          │              │
1: ───X^-0.5───Y^-0.5───Z────┼────@────────X────X─────────Z────@──────────────────Y────X──────────────────Z────X──────────────────X───X─────────────────X───@────────────Y───────@───────Z───────────X───────I─────────────X─────────I─────────────X─────────Z────────────@──────────I────────X─────I────────┼─────@────X───Y^0.5────X^0.5────
                             │    │                            │                                                                                            │                    │                                                                                        │                                  │     │
2: ───X────────Y^-0.5───I────X────┼────────Y────@─────────X────X──────────────────Z────X^-0.5─────Y^0.5───X────@──────────────────Y───Y^-0.5───X^-0.5───I───X────────────X───────X───────Z───X^0.5───Y^0.5───Z─────────────@─────────Z───Y^-0.5────X^0.5─────Z────────────X──────────X────────@─────X────────X─────┼────I───Y^0.5────X────────
                                  │             │                                                              │                                                                                                           │                                                                  │                    │
3: ───X────────Y^-0.5───I────Y^0.5┼────I───Z────┼Y────X───X────@──────────────────Y────@──────────────────X────┼X^-0.5────Y^0.5───Z───@─────────────────I───@────────────Z───────@───────X───────────@───────Z───Y^-0.5────┼X^0.5────Z─────────────@─────────I────────────@──────────X───X────┼Y────Y───I────Y^-0.5┼────X───Y^0.5────X────────
                                  │             │              │                       │                       │                      │                     │                    │                   │                     │                       │                      │                   │                    │
4: ───Y────────X^0.5────Z────@────┼────────Z────┼@────────Z────┼────@─────────────Y────┼─────@────────────X────┼@─────────────────I───X─────────────────Z───X────────────I───────X───────X───────────X───────Z─────────────┼@────────X─────────────┼────@────Y────────────┼─────@────Z────────┼@────X────────@─────┼────I───X^-0.5───Y────────
                             │    │             ││             │    │                  │     │                 ││                                                                                                          ││                      │    │                 │     │             ││             │     │
5: ───Y────────X────────X────X────┼────────I────┼X────────I────┼────X─────────────X────┼─────X────────────Z────X┼─────────────────X───@─────────────────X───@────────────I───────@───────X───────────@───────Y─────────────X┼────────Z─────────────┼────X────X────────────┼─────X────Y────────┼X────Y────────X─────┼────Z───X────────Y────────
                                  │             │              │                       │                        │                     │                     │                    │                   │                      │                      │                      │                   │                    │
6: ───X^0.5────Y^0.5────I─────────X────────I────X─────────Z────X──────────────────Y────X──────────────────Z─────X─────────────────X───X─────────────────I───X────────────I───────X───────I───────────X───────I──────────────X────────X─────────────X─────────Y────────────X──────────Y────────X─────Z──────────────X────X───Y^-0.5───X^-0.5───
                            └──────┘           └──┘           └──────┘                └───────┘               └───────┘                                                                                                   └──────┘                └──────┘               └───────┘           └──┘           └───────┘

Quantum Volume Circuits#

The generate_quantum_volume_circuit(), as defined in [2], tests the maximum achievable “volume” or computational capacity of a quantum processor. Running these circuits with error mitigation tests if mitiq’s techniques improve the effective quantum volume.

from mitiq.benchmarks import generate_quantum_volume_circuit

circuit,_ = generate_quantum_volume_circuit(num_qubits=4, depth=7)

print(circuit)
      ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐                                                               ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐   ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐   ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐   ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
                                                                ┌                                                       ┐                                                                                                                          ┌                                                       ┐                                                              ┌                                                       ┐                                                              ┌                                                       ┐
                                                                │-0.044-0.123j -0.402-0.504j  0.725+0.2j   -0.036-0.004j│                                                                                                                          │ 0.65 -0.407j  0.028+0.163j -0.274-0.153j  0.259+0.468j│                                                              │ 0.011+0.102j -0.269-0.635j -0.136+0.248j -0.61 -0.25j │                                                              │ 0.499-0.135j -0.022-0.341j -0.494+0.322j  0.506+0.106j│
0: ─────────────────────────────────────────────────────────────│ 0.099-0.66j  -0.335+0.371j -0.119+0.362j  0.28 +0.286j│────#2────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.296+0.26j   0.78 -0.032j -0.313+0.166j -0.036-0.33j │──────────────────────────────────────────────────────────────│-0.181+0.426j -0.171+0.643j -0.312+0.107j -0.241-0.42j │──────────────────────────────────────────────────────────────│-0.194+0.008j  0.193+0.513j -0.579-0.135j  0.178-0.526j│──────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────
                                                                │-0.009+0.545j -0.257-0.082j -0.108+0.138j  0.769+0.093j│    │                                                                                                                     │ 0.298-0.402j -0.005+0.434j  0.414-0.091j -0.361-0.502j│                                                              │ 0.568-0.431j -0.152+0.203j  0.258-0.322j -0.202-0.466j│                                                              │-0.207-0.053j -0.638+0.006j -0.516+0.12j  -0.462+0.23j │                                                              │                                                            │
                                                                │-0.402-0.281j -0.319-0.399j -0.497-0.11j   0.054-0.486j│    │                                                                                                                     │ 0.019+0.074j  0.409-0.09j   0.763-0.121j  0.415+0.222j│                                                              │-0.019-0.517j -0.046+0.124j -0.083+0.796j  0.214-0.165j│                                                              │ 0.584-0.555j  0.144+0.393j  0.009-0.132j -0.383+0.107j│                                                              │                                                            │
                                                                └                                                       ┘    │                                                                                                                     └                                                       ┘                                                              └                                                       ┘                                                              └                                                       ┘                                                              │                                                            │
                                                                │                                                            │                                                                                                                     │                                                                                                                      │                                                                                                                      │                                                                                                                      │                                                            │
                                                                │                                                            ┌                                                       ┐                                                             │                                                             ┌                                                       ┐│                                                                                                                      │                                                                                                                      │                                                            ┌                                                       ┐
                                                                │                                                            │ 0.362+0.43j  -0.171+0.061j  0.216+0.606j  0.486+0.042j│                                                             │                                                             │-0.273-0.252j -0.039+0.009j -0.838-0.158j  0.183+0.315j││                                                                                                                      │                                                                                                                      │                                                            │-0.068-0.438j  0.123+0.647j  0.359-0.139j -0.369+0.293j│
1: ────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────│ 0.557-0.031j -0.518-0.547j -0.226-0.145j -0.222+0.021j│────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────│-0.382+0.177j -0.398-0.376j -0.183-0.083j -0.532-0.447j│┼─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────│-0.015-0.501j -0.002-0.025j  0.01 -0.525j  0.253-0.639j│───
       │                                                        │                                                            │-0.393-0.092j -0.293-0.235j -0.234-0.01j   0.473-0.646j│    │                                                        │                                                             │-0.156+0.345j  0.761-0.297j -0.068+0.018j -0.336+0.266j││                                                             │                                                        │                                                             │                                                        │                                                            │-0.111-0.284j -0.451+0.308j -0.561+0.065j  0.432+0.323j│
       │                                                        │                                                            │-0.24 +0.391j -0.49 +0.136j  0.392-0.552j  0.137+0.23j │    │                                                        │                                                             │-0.641+0.361j -0.16 +0.068j  0.348-0.326j  0.364+0.262j││                                                             │                                                        │                                                             │                                                        │                                                            │-0.624+0.266j -0.517-0.024j  0.473-0.181j  0.124+0.014j│
       │                                                        │                                                            └                                                       ┘    │                                                        │                                                             └                                                       ┘│                                                             │                                                        │                                                             │                                                        │                                                            └                                                       ┘
       │                                                        │                                                                                                                         │                                                        │                                                             │                                                        │                                                             │                                                        │                                                             │                                                        │
       ┌                                                       ┐│                                                                                                                         │                                                        │                                                             │                                                        │                                                             │                                                        │                                                             ┌                                                       ┐│
       │-0.283-0.441j -0.453-0.544j  0.016+0.421j  0.149-0.155j││                                                                                                                         │                                                        │                                                             │                                                        │                                                             │                                                        │                                                             │ 0.112-0.176j  0.422+0.802j -0.009+0.343j -0.132-0.011j││
2: ────│-0.344+0.643j  0.082-0.564j -0.099-0.007j -0.278+0.237j│┼────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────│-0.705-0.143j  0.035+0.198j -0.383-0.238j  0.284+0.396j│┼────────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────
       │ 0.257-0.203j  0.048-0.354j  0.746-0.36j  -0.28 +0.038j││                                                            │                                                            │                                                                                                                      │                                                                                                                      │                                                                                                                      │-0.35 -0.059j -0.183+0.244j  0.698-0.124j  0.345-0.398j││                                                            │
       │ 0.292+0.023j -0.207-0.065j -0.349-0.073j -0.62 -0.596j││                                                            │                                                            │                                                                                                                      │                                                                                                                      │                                                                                                                      │ 0.029-0.558j  0.129-0.168j -0.419-0.011j  0.218-0.648j││                                                            │
       └                                                       ┘│                                                            │                                                            │                                                                                                                      │                                                                                                                      │                                                                                                                      └                                                       ┘│                                                            │
                                                                │                                                            │                                                            │                                                                                                                      │                                                                                                                      │                                                                                                                                                                               │                                                            │
                                                                │                                                            ┌                                                       ┐    ┌                                                       ┐                                                              │                                                                                                                      ┌                                                       ┐                                                                                                                       ┌                                                       ┐    ┌                                                       ┐
                                                                │                                                            │ 0.518-0.217j -0.125+0.221j  0.287+0.63j   0.372+0.044j│    │-0.382-0.405j -0.202-0.48j   0.158+0.349j  0.368-0.369j│                                                              │                                                                                                                      │ 0.14 +0.407j  0.111-0.15j   0.246+0.571j  0.596-0.198j│                                                                                                                       │-0.095-0.059j  0.324-0.766j  0.123-0.427j  0.192-0.249j│    │ 0.111+0.779j  0.284+0.058j  0.136+0.167j -0.493-0.089j│
3: ─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────│ 0.01 +0.047j -0.453+0.401j -0.343-0.258j  0.388-0.544j│────│-0.105-0.714j -0.033+0.56j  -0.019+0.184j -0.36 -0.01j │──────────────────────────────────────────────────────────────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.285+0.676j  0.353-0.154j -0.303-0.113j -0.441-0.122j│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.252+0.446j  0.04 -0.013j -0.406-0.303j  0.433+0.541j│────│ 0.236-0.281j -0.404-0.287j -0.103+0.362j -0.472-0.505j│───
                                                                                                                             │-0.58 -0.328j -0.567+0.109j -0.013+0.359j -0.258+0.167j│    │ 0.174+0.182j  0.372+0.502j  0.284+0.211j  0.441-0.476j│                                                                                                                                                                                     │-0.01 +0.039j -0.011-0.61j  -0.129-0.609j  0.484+0.068j│                                                                                                                       │-0.015-0.246j -0.352-0.4j    0.391+0.384j  0.231+0.549j│    │ 0.024-0.485j  0.748+0.152j  0.18 -0.098j -0.245-0.282j│
                                                                                                                             │ 0.479-0.095j -0.336+0.351j  0.154-0.429j -0.473+0.307j│    │-0.165-0.28j  -0.053+0.144j -0.071-0.83j   0.412-0.084j│                                                                                                                                                                                     │ 0.431-0.298j  0.486+0.457j -0.306-0.169j  0.353-0.183j│                                                                                                                       │ 0.7  -0.419j -0.123+0.087j  0.188-0.46j  -0.236+0.103j│    │-0.101+0.004j  0.055-0.291j  0.721+0.501j  0.359-0.053j│
                                                                                                                             └                                                       ┘    └                                                       ┘                                                                                                                                                                                     └                                                       ┘                                                                                                                       └                                                       ┘    └                                                       ┘
      └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘                                                               └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Mirror Quantum Volume Circuits#

The generate_mirror_qv_circuit(), as defined in [3], is designed to test Quantum Volume, a metric combining circuit depth, number of qubits, and fidelity. These circuits run a quantum circuit forward and then “mirroring” it to check whether error mitigation techniques help achieve higher effective quantum volumes on noisy devices.

from mitiq.benchmarks import generate_mirror_qv_circuit

circuit = generate_mirror_qv_circuit(num_qubits=7, depth=2)

print(circuit)
      ┌                                                       ┐   ┌                                                       ┐
      │-0.362+0.115j -0.102-0.47j   0.318-0.106j  0.675+0.238j│   │-0.362-0.115j -0.189+0.337j -0.104-0.714j  0.233+0.362j│
0: ───│-0.189-0.337j -0.359-0.23j  -0.586+0.541j  0.143-0.111j│───│-0.102+0.47j  -0.359+0.23j   0.081+0.491j  0.101+0.574j│───
      │-0.104+0.714j  0.081-0.491j -0.196+0.158j -0.407+0.047j│   │ 0.318+0.106j -0.586-0.541j -0.196-0.158j  0.423-0.091j│
      │ 0.233-0.362j  0.101-0.574j  0.423+0.091j -0.209-0.494j│   │ 0.675-0.238j  0.143+0.111j -0.407-0.047j -0.209+0.494j│
      └                                                       ┘   └                                                       ┘
      │                                                           │
1: ───#2──────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────

2: ───#2──────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────
      │                                                           │
      ┌                                                       ┐   ┌                                                       ┐
      │ 0.246+0.349j  0.551+0.323j -0.2  -0.039j -0.294+0.531j│   │ 0.246-0.349j  0.392-0.45j  -0.309-0.5j    0.319+0.121j│
3: ───│ 0.392+0.45j  -0.388-0.111j  0.161+0.653j -0.167+0.01j │───│ 0.551-0.323j -0.388+0.111j -0.274+0.073j -0.443+0.39j │───
      │-0.309+0.5j   -0.274-0.073j  0.309-0.312j  0.409+0.463j│   │-0.2  +0.039j  0.161-0.653j  0.309+0.312j -0.312+0.465j│
      │ 0.319-0.121j -0.443-0.39j  -0.312-0.465j -0.392+0.261j│   │-0.294-0.531j -0.167-0.01j   0.409-0.463j -0.392-0.261j│
      └                                                       ┘   └                                                       ┘

5: ───#2──────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────
      │                                                           │
      ┌                                                       ┐   ┌                                                       ┐
      │-0.266+0.187j  0.564-0.523j  0.024+0.163j -0.164+0.499j│   │-0.266-0.187j -0.537-0.496j  0.04 +0.518j -0.119+0.275j│
6: ───│-0.537+0.496j -0.103+0.004j -0.071-0.636j -0.116-0.179j│───│ 0.564+0.523j -0.103-0.004j -0.128+0.021j -0.293+0.544j│───
      │ 0.04 -0.518j -0.128-0.021j -0.379-0.53j   0.025+0.537j│   │ 0.024-0.163j -0.071+0.636j -0.379+0.53j  -0.333-0.167j│
      │-0.119-0.275j -0.293-0.544j -0.333+0.167j -0.482-0.397j│   │-0.164-0.499j -0.116+0.179j  0.025-0.537j -0.482+0.397j│
      └                                                       ┘   └                                                       ┘

Quantum Phase Estimation Circuits#

The generate_qpe_circuit(), as defined in Quantum phase estimation algorithm is used to the measure eigenvalues of unitary operators. Since accurate phase estimation requires precise control over operations, these circuits test the mitigation techniques’ ability to handle small noise effects over multiple gate sequences.

from mitiq.benchmarks import generate_qpe_circuit

circuit = generate_qpe_circuit(evalue_reg=7)

print(circuit)
0: ───H──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────×───────────H───@─────────────@───────────────────────@─────────────────────────────────@───────────────────────────────────────────@─────────────────────────────────────────────────────@───────────────────────────────────────────────────────────────
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │               │             │                       │                                 │                                           │                                                     │
1: ───H──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼───×───────────@^-0.25───H───┼─────────@─────────────┼─────────@───────────────────────┼─────────@─────────────────────────────────┼─────────@───────────────────────────────────────────┼─────────@─────────────────────────────────────────────────────
                                                                                                                                                                                                                                                                                                 │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │   │                         │         │             │         │                       │         │                                 │         │                                           │         │
2: ───H──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼───┼───×─────────────────────@^-0.25───@^-0.25───H───┼─────────┼─────────@─────────────┼─────────┼─────────@───────────────────────┼─────────┼─────────@─────────────────────────────────┼─────────┼─────────@───────────────────────────────────────────
                                                                                                                                                 │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │   │   │                                             │         │         │             │         │         │                       │         │         │                                 │         │         │
3: ───H──────────────────────────────────────────────────────────────────@────────@────────@────────@────────@────────@────────@────────@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼───┼───┼─────────────────────────────────────────────@^-0.25───@^-0.25───@^-0.25───H───┼─────────┼─────────┼─────────@─────────────┼─────────┼─────────┼─────────@───────────────────────┼─────────┼─────────┼─────────@─────────────────────────────────
                                                                         │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │   │   │                                                                               │         │         │         │             │         │         │         │                       │         │         │         │
4: ───H──────────────────────────────@────────@────────@────────@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼───┼───×───────────────────────────────────────────────────────────────────────────────@^-0.25───@^-0.25───@^-0.25───@^-0.25───H───┼─────────┼─────────┼─────────┼─────────@─────────────┼─────────┼─────────┼─────────┼─────────@───────────────────────
                                     │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │   │                                                                                                                               │         │         │         │         │             │         │         │         │         │
5: ───H────────────@────────@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼───×───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@^-0.25───@^-0.25───@^-0.25───@^-0.25───@^-0.25───H───┼─────────┼─────────┼─────────┼─────────┼─────────@─────────────
                   │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │                                                                                                                                                                                         │         │         │         │         │         │
6: ───H───@────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────×─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────@^-0.25───@^-0.25───@^-0.25───@^-0.25───@^-0.25───@^-0.25───H───
          │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │        │
7: ───────@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25───@^0.25─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Randomized Benchmarking Circuits#

The generate_rb_circuits() are sequences of random gates (generally Clifford gates), to estimate an average error rate. They’re standard in benchmarking for evaluating how well mitiq’s error mitigation reduces this error rate across different levels of noise.

from mitiq.benchmarks import generate_rb_circuits

circuits = generate_rb_circuits(n_qubits=1, num_cliffords=5)
circuit=circuits[0]

print(circuit)
0: ───Y^0.5───X^-0.5───Y^0.5───X^0.5───Y^0.5───X───I───Y^-0.5───I───X^-0.5───Y^-0.5───(Z^0.5-X^-0.5)───

Rotated Randomized Benchmarking Circuits#

The generate_rotated_rb_circuits() are sequences of random gates similar to generate_rb_circuits(), but with rotations added, that allows assessment of errors beyond just the standard Clifford gates. They’re useful to check how well Mitiq handles noise in scenarios with more diverse gates.

from mitiq.benchmarks import generate_rotated_rb_circuits

circuits = generate_rotated_rb_circuits(n_qubits=1, num_cliffords=5)
circuit=circuits[0]

print(circuit)
0: ───Y^-0.5───X^0.5───Y^-0.5───Y^0.5───I───Y^-0.5───Rz(0.775π)───X^0.5───Y^-0.5───Y^0.5───X^0.5───X^-0.5───Y^0.5───(Y-X^0.5)───

Randomized Clifford+T Circuits#

The generate_random_clifford_t_circuit() add the T gate to the standard Clifford set, adding more complex operations to the random benchmarking. This type evaluates Mitiq’s performance with gate sets that go beyond the Clifford gates, crucial for fault-tolerant computing.

from mitiq.benchmarks import generate_random_clifford_t_circuit

circuit = generate_random_clifford_t_circuit(num_qubits=7, num_oneq_cliffords=2, num_twoq_cliffords=2, num_t_gates=2)

print(circuit)
0: ───T───────

1: ───S───────

2: ───@───────
      │
3: ───┼───@───
      │   │
4: ───@───┼───
          │
5: ───S───┼───
          │
6: ───T───@───

W State Circuits#

The generate_w_circuit() are entangled circuits that distribute the entanglement across qubits differently than GHZ states. Testing with W state circuits can help explore how well a device maintains distributed entanglement in noisy environments.

A generalized multipartite \(N\)-qubit W-state is defined in equation (1):

(1)#\[ \ket{W_N} = \frac{1}{\sqrt{N}} \left( \ket{100 \dots 0} + \ket{010 \dots 0} + \dots + \ket{0 \dots 01}\right) \]

Such a \(N\)-qubit W-state circuit can be generated through generate_w_circuit() as defined in [4]. The construction relies on an initial state \(\ket{10 \dots 0}\) and a fundamental building block \(B(p)\) such that

\[ B(p) \ket{00} = \ket{00} , \, B(p) \ket{10} = \sqrt{p} \ket{10} + \sqrt{1-p} \ket{01} \]

This building block comprises of a controlled \(G(p)\) and an inverted CNOT where \(0 < p < 1\).

\[\begin{split} G(p) = \begin{pmatrix} \sqrt{p} & -\sqrt{1-p} \\ \sqrt{1-p} & \sqrt{p} \end{pmatrix} \end{split}\]
from mitiq.benchmarks import generate_w_circuit

circuit = generate_w_circuit(n_qubits=4)

print(circuit)
0: ───@────────────X───────────────────────────────────
      │            │
1: ───Ry(0.667π)───@───@────────────X──────────────────
                       │            │
2: ────────────────────Ry(0.608π)───@───@──────────X───
                                        │          │
3: ─────────────────────────────────────Ry(0.5π)───@───

We can also verify the final state of the circuit is equivalent to \(\ket{W_4}\).

\[ \ket{W_4} = \frac{1}{\sqrt{4}} \left( \ket{1000} + \ket{0100} + \ket{0010} + \ket{0001}\right) \]
import cirq 

w4_state_vector_transpose = (
        cirq.Simulator()
        .simulate(circuit, initial_state=1000)
        .final_state_vector)