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───────Y^-0.5───I────@──────────────Y────@──────────────────Y────Y^0.5──────X^0.5───Y^0.5───I────@─────────────────────────Y────@──────────────────Z────@───────────────────Y────@──────────Y────────@──────Z────────────@───────────Z────────────@──────────X──────────────────────@──────────I───Y^-0.5───X^-0.5────Y^-0.5──────Z─────────────@───────────Y─────────────@──────X───Y^0.5────X────────
                            │                   │                                                       │                              │                       │                        │                   │                   │                        │                                 │                                                           │                         │
1: ───I────────────────Z────┼@─────────────I────┼Y^0.5─────X^0.5───Z────@──────────────────────────X────┼Y^0.5────X^0.5───Y^0.5───Y────┼Y^0.5────X^-0.5───Z────┼@──────────────────X────X──────────X────────X──────Y────────────┼@──────────X───X^0.5────┼Y^-0.5────X───Y^-0.5───X^-0.5────┼Y^-0.5────Z──────────────────────@───────────Z───X^-0.5────┼Y^-0.5─────X─────────────┼@─────Y────────────I────────
                            ││                  │                       │                               │                              │                       ││                                                               ││                       │                                 │                                 │                         │                         ││
2: ───X───────Y^0.5────Y────┼┼X────Y^0.5───I────┼@─────────────────X────┼────@─────────────────────I────┼@────────────────────────Z────┼@─────────────────Z────┼┼Y^0.5────X^-0.5───Z────@──────────Z────────@──────I───X^0.5────┼┼Y^-0.5────X────────────┼@─────────Y──────────────────────┼@─────────X──────────────────────┼─────@─────I─────────────┼@──────────Y───Y^-0.5────┼┼X────X───Y^-0.5───X────────
                            ││                  ││                      │    │                          ││                             ││                      ││                       │                   │                   ││                       ││                                ││                                │     │                   ││                        ││
3: ───Y^0.5───X^-0.5───Y────┼┼@────────────Z────┼┼────@────────────Z────┼────┼@────────────────────Y────┼X────────────────────────I────┼X─────────────────X────┼X──────────────────Y────┼@─────────Z────────┼@─────Y────────────┼X──────────Z────────────┼X─────────Y──────────────────────┼X─────────Z──────────────────────┼─────┼@────Z─────────────┼┼─────@────X─────────────┼┼@────I───X^0.5────Y^-0.5───
                            │││                 ││    │                 │    ││                         │                              │                       │                        ││                  ││                  │                        │                                 │                                 │     ││                  ││     │                  │││
4: ───X───────I────────X────┼┼X────────────X────┼X────┼────────────Z────┼────X┼────────────────────Y────┼@────────────────────────Z────X──────────────────Y────X───────────────────Z────┼┼X────I───I───I────┼┼X────Y────────────X───────────Y────────────X──────────X──────────────────────┼@─────────X──────────────────────┼─────X┼────Z─────────────┼X─────┼────X─────────────┼┼X────I───I────────X────────
                            ││                  │     │                 │     │                         ││                                                                              ││                  ││                                                                             ││                                │      │                  │      │                  ││
5: ───Y───────X^-0.5───Z────X┼─────────────Z────┼─────X────────────X────┼─────X────────────────────X────X┼────────────────────────X────@──────────────────Z────@───────────────────I────┼X─────────Z────────┼X─────Z────────────@───────────X────────────@──────────Y──────────────────────X┼─────────Z──────────────────────┼──────X────Z─────────────┼──────X────Y─────────────X┼─────X───X^0.5────Y────────
                             │                  │                       │                                │                             │                       │                        │                   │                   │                        │                                  │                                │                         │                          │
6: ───Y^0.5───X^0.5────Y─────X─────────────I────X──────────────────Y────X──────────────────────────Y─────X────────────────────────Y────X──────────────────X────X───────────────────Z────X──────────X────────X──────I────────────X───────────Y────────────X──────────X───────────────────────X─────────Z──────────────────────X───────────I─────────────X───────────X──────────────X─────I───X^-0.5───Y^-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.27 +0.61j  -0.324-0.359j -0.005+0.472j  0.313+0.027j│     │-0.502+0.112j  0.278+0.459j -0.386-0.517j -0.16 -0.08j │                                                             │ 0.184+0.175j -0.065+0.021j -0.314-0.106j -0.132+0.896j│
0: ────#2──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.083-0.488j  0.035-0.325j  0.206+0.523j -0.285+0.501j│─────│-0.221-0.136j  0.095-0.168j  0.143+0.282j -0.699-0.554j│─────────────────────────────────────────────────────────────│ 0.325+0.031j -0.279+0.718j  0.226-0.483j  0.104-0.072j│─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────
       │                                                                                                                                                                               │-0.356-0.289j -0.025+0.33j  -0.227+0.619j  0.319-0.379j│     │-0.006-0.343j  0.741+0.257j  0.4  +0.197j  0.068+0.253j│                                                             │ 0.616+0.259j  0.455+0.043j  0.408+0.385j -0.171+0.019j│                                                             │                                                            │                                                           │
       │                                                                                                                                                                               │-0.081-0.305j -0.086-0.737j -0.005-0.163j  0.025-0.568j│     │ 0.338+0.661j  0.158+0.188j  0.477-0.237j -0.002-0.323j│                                                             │ 0.277-0.553j -0.396+0.191j -0.246+0.48j  -0.36 -0.065j│                                                             │                                                            │                                                           │
       │                                                                                                                                                                               └                                                       ┘     └                                                       ┘                                                             └                                                       ┘                                                             │                                                            │                                                           │
       │                                                                                                                                                                               │                                                             │                                                                                                                     │                                                                                                                     │                                                            │                                                           │
       │                                                        ┌                                                       ┐     ┌                                                       ┐│                                                             │                                                                                                                     │                                                                                                                     │                                                            ┌                                                       ┐   ┌                                                       ┐
       │                                                        │ 0.527-0.319j  0.424+0.283j -0.078-0.458j  0.373+0.081j│     │ 0.34 +0.576j -0.593+0.386j  0.101-0.12j  -0.002+0.164j││                                                             │                                                                                                                     │                                                                                                                     │                                                            │-0.429-0.j     0.237-0.41j   0.684+0.161j  0.257+0.178j│   │-0.181+0.212j -0.717-0.195j -0.513-0.168j -0.239+0.149j│
1: ────┼────────────────────────────────────────────────────────│ 0.477-0.072j -0.666-0.122j -0.312-0.227j -0.15 -0.371j│─────│-0.101-0.49j  -0.272+0.211j  0.174-0.105j -0.723+0.259j│┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────│-0.433+0.127j  0.554-0.062j -0.352-0.477j -0.267+0.25j │───│-0.248+0.358j  0.383-0.425j -0.401+0.54j   0.175-0.013j│───
       │                                                        │ 0.122-0.357j  0.133-0.087j  0.717-0.064j -0.411-0.382j│     │-0.125+0.394j  0.41 +0.325j  0.172+0.612j -0.382-0.072j││                                                             │                                                        │                                                                                                                         │                                                        │                                                            │-0.499+0.144j -0.217+0.552j -0.178+0.071j  0.561+0.165j│   │ 0.333-0.511j -0.106-0.035j -0.434+0.184j  0.052-0.625j│
       │                                                        │ 0.348+0.352j  0.493-0.121j -0.331+0.092j -0.616+0.007j│     │ 0.323-0.165j -0.2  -0.259j -0.354+0.636j  0.059+0.478j││                                                             │                                                        │                                                                                                                         │                                                        │                                                            │ 0.512-0.283j  0.334+0.034j  0.011-0.343j  0.587+0.288j│   │ 0.315-0.512j  0.026-0.328j -0.081+0.166j -0.008+0.704j│
       │                                                        └                                                       ┘     └                                                       ┘│                                                             │                                                        │                                                                                                                         │                                                        │                                                            └                                                       ┘   └                                                       ┘
       │                                                        │                                                             │                                                        │                                                             │                                                        │                                                                                                                         │                                                        │
       ┌                                                       ┐│                                                             │                                                        │                                                             │                                                        │                                                                                                                         │                                                        ┌                                                       ┐                                                                ┌                                                       ┐
       │-0.342-0.368j  0.087+0.44j  -0.706+0.01j   0.007+0.22j ││                                                             │                                                        │                                                             │                                                        │                                                                                                                         │                                                        │ 0.058+0.406j  0.707-0.054j  0.465-0.266j -0.2  +0.052j│                                                                │-0.459-0.162j  0.261+0.528j  0.411-0.387j -0.303-0.082j│
2: ────│-0.376+0.47j  -0.142+0.212j -0.163-0.261j -0.17 -0.67j │┼─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────│ 0.283-0.066j  0.51 -0.204j -0.331+0.704j  0.096-0.006j│────#2──────────────────────────────────────────────────────────│ 0.392-0.095j  0.155-0.476j  0.666-0.357j  0.101+0.071j│───
       │ 0.389+0.427j -0.393+0.276j -0.242+0.094j  0.595+0.123j││                                                                                                                      │                                                                                                                      │                                                            │                                                            │                                                        │ 0.051+0.463j -0.313-0.157j -0.138+0.244j -0.762-0.025j│    │                                                           │-0.679+0.097j -0.015-0.308j  0.189+0.114j  0.591-0.193j│
       │ 0.104-0.202j -0.413-0.577j -0.447+0.375j -0.106-0.306j││                                                                                                                      │                                                                                                                      │                                                            │                                                            │                                                        │-0.325-0.652j  0.271+0.j    -0.131-0.111j -0.549+0.255j│    │                                                           │-0.339+0.122j -0.46 -0.31j   0.205+0.14j  -0.519+0.48j │
       └                                                       ┘│                                                                                                                      │                                                                                                                      │                                                            │                                                            │                                                        └                                                       ┘    │                                                           └                                                       ┘
                                                                │                                                                                                                      │                                                                                                                      │                                                            │                                                            │                                                                                                                     │                                                           │
                                                                │                                                                                                                      │                                                                                                                      ┌                                                       ┐    ┌                                                       ┐    ┌                                                       ┐                                                             ┌                                                       ┐   │
                                                                │                                                                                                                      │                                                                                                                      │-0.098+0.386j -0.079+0.493j -0.589-0.257j -0.412-0.098j│    │ 0.143+0.294j -0.454+0.387j  0.269-0.259j -0.403+0.486j│    │-0.063-0.439j -0.183+0.41j   0.111-0.283j -0.155-0.697j│                                                             │ 0.233-0.355j  0.304-0.086j  0.148-0.651j  0.493-0.174j│   │
3: ─────────────────────────────────────────────────────────────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│-0.564+0.335j  0.265-0.513j  0.098-0.048j -0.39 +0.267j│────│-0.391-0.181j -0.643-0.161j -0.343-0.284j  0.402+0.124j│────│ 0.166-0.019j -0.59 +0.358j -0.627+0.238j -0.101+0.189j│─────────────────────────────────────────────────────────────│ 0.132+0.322j -0.089+0.446j  0.227-0.005j -0.049-0.786j│───#2──────────────────────────────────────────────────────────
                                                                                                                                                                                                                                                                                                              │ 0.269-0.148j -0.197-0.594j -0.4  +0.193j -0.314-0.467j│    │-0.407-0.717j  0.034+0.384j  0.138+0.269j -0.247+0.142j│    │ 0.038+0.431j -0.173+0.535j  0.366-0.499j  0.059+0.332j│                                                             │-0.054-0.028j  0.565-0.489j  0.273+0.523j  0.078-0.291j│
                                                                                                                                                                                                                                                                                                              │ 0.342-0.446j  0.105-0.119j -0.069-0.611j -0.288+0.445j│    │-0.073+0.151j  0.123-0.205j -0.676+0.337j -0.369+0.455j│    │-0.755-0.135j -0.072+0.036j -0.229-0.15j   0.568+0.092j│                                                             │ 0.649+0.523j -0.039-0.366j -0.393-0.019j  0.122-0.001j│
                                                                                                                                                                                                                                                                                                              └                                                       ┘    └                                                       ┘    └                                                       ┘                                                             └                                                       ┘
      └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘                                                               └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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.315+0.378j -0.602-0.258j  0.534-0.043j  0.188+0.085j│                                                              │-0.315-0.378j -0.248-0.526j  0.137+0.051j  0.01 +0.631j│
0: ────│-0.248+0.526j  0.287+0.513j  0.135+0.456j -0.22 +0.205j│──────────────────────────────────────────────────────────────│-0.602+0.258j  0.287-0.513j -0.129-0.169j -0.081-0.417j│─────────────────────────────────────────────────────────────
       │ 0.137-0.051j -0.129+0.169j -0.239+0.392j  0.821+0.221j│                                                              │ 0.534+0.043j  0.135-0.456j -0.239-0.392j  0.524+0.04j │
       │ 0.01 -0.631j -0.081+0.417j  0.524-0.04j  -0.069+0.374j│                                                              │ 0.188-0.085j -0.22 -0.205j  0.821-0.221j -0.069-0.374j│
       └                                                       ┘                                                              └                                                       ┘
       │                                                                                                                      │
1: ────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

3: ─────────────────────────────────────────────────────────────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────
                                                                │                                                                                                                      │
       ┌                                                       ┐│                                                             ┌                                                       ┐│
       │ 0.464-0.424j  0.216-0.076j  0.291+0.319j  0.546-0.261j││                                                             │ 0.464+0.424j -0.361+0.421j -0.44 -0.135j  0.144-0.255j││
4: ────│-0.361-0.421j  0.081+0.316j -0.691+0.272j  0.144-0.116j│┼─────────────────────────────────────────────────────────────│ 0.216+0.076j  0.081-0.316j -0.512-0.156j -0.432+0.607j│┼────────────────────────────────────────────────────────────
       │-0.44 +0.135j -0.512+0.156j  0.255-0.055j  0.65 +0.104j││                                                             │ 0.291-0.319j -0.691-0.272j  0.255+0.055j -0.405-0.172j││
       │ 0.144+0.255j -0.432-0.607j -0.405+0.172j  0.088-0.398j││                                                             │ 0.546+0.261j  0.144+0.116j  0.65 -0.104j  0.088+0.398j││
       └                                                       ┘│                                                             └                                                       ┘│
       │                                                        │                                                             │                                                        │
5: ────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────
                                                                │                                                                                                                      │
                                                                ┌                                                       ┐                                                              ┌                                                       ┐
                                                                │ 0.344-0.518j -0.255-0.033j  0.28 -0.277j -0.604+0.166j│                                                              │ 0.344+0.518j  0.261+0.036j -0.449-0.525j -0.078-0.248j│
6: ─────────────────────────────────────────────────────────────│ 0.261-0.036j  0.27 +0.354j  0.684+0.062j  0.416+0.296j│──────────────────────────────────────────────────────────────│-0.255+0.033j  0.27 -0.354j -0.011-0.277j -0.43 +0.689j│────
                                                                │-0.449+0.525j -0.011+0.277j  0.377-0.372j -0.397-0.095j│                                                              │ 0.28 +0.277j  0.684-0.062j  0.377+0.372j  0.281+0.122j│
                                                                │-0.078+0.248j -0.43 -0.689j  0.281-0.122j  0.244+0.347j│                                                              │-0.604-0.166j  0.416-0.296j -0.397+0.095j  0.244-0.347j│
                                                                └                                                       ┘                                                              └                                                       ┘
      └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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───X^0.5───Y^-0.5───I───Y───X^-0.5───Y^-0.5───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───X^0.5───Y^-0.5───X───Rz(0.826π)───Y^0.5───X^-0.5───Y^0.5───Y^-0.5───I───Z^-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)
      ┌──┐
1: ─────@────────────
        │
2: ─────┼────@───S───
        │    │
3: ────T┼────@───────
        │
4: ────T┼────────────
        │
6: ─────X────H───────
      └──┘

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)