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 [2], 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────Z────X^-0.5──────I───Y────@───────────────────Y────@──────────────────────────X────@─────────Y────Y^0.5─────X^0.5───Y^0.5───I────Y─────I───I────@──────────────Z────────────@─────X───I────Y─────X───Y^-0.5───X^-0.5────Y^-0.5─────Y────────@─────I──────────────────────@───────────Y─────────────@──────────Y───I────X^0.5──────Y───Y^-0.5───X^-0.5───
                                                  │                        │                               │                                                            │                           │                                                               │                            │                         │
1: ───X^0.5────Y^-0.5───X────@───────────────X────┼─────@─────────────Y────┼@─────────────────────────I────X─────────I────@─────────────────────────Z────@─────────X────X──────────────Y────────────X─────Y────────@─────I──────────────────────@──────────Z────────X─────Z──────────────────────┼@──────────I─────────────┼────@─────Y────────@──────────I───Y^0.5────X^-0.5───
                             │                    │     │                  ││                                             │                              │                                                         │                            │                                                ││                        │    │              │
2: ───Y^-0.5───X^-0.5───I────┼─────@─────────X────┼─────┼@────────────I────┼┼Y^0.5────X^0.5───Y^0.5───X────@─────────Y────┼────@────────────────────Y────┼@────────X────@──────────────I────────────@─────I────────┼@────X──────────────────────┼─────@────Z────────@─────X───Y^-0.5───X^-0.5────┼┼Y^-0.5────Z─────────────┼────┼@────X────────┼────@─────Y───X^0.5────Y^0.5────
                             │     │              │     ││                 ││                              │              │    │                         ││             │                           │              ││                           │     │             │                            ││                        │    ││             │    │
3: ───X^0.5────Y^0.5────X────┼─────┼@────────X────┼─────┼X────────────I────┼┼@────────────────────────I────┼@────────X────┼────X────────────────────Y────X┼────────Y────┼Y────X^-0.5───Z───X^0.5────┼Y────I────────X┼────X──────────────────────┼─────X────Z────────┼@────I──────────────────────┼┼@─────────Y─────────────┼────┼X────I────────┼────┼@────Z───Y^-0.5───X^-0.5───
                             │     ││             │     │                  │││                             ││             │                               │             │                           │               │                           │                   ││                           │││                       │    │              │    ││
4: ───Y^0.5────I────────I────┼─────X┼────────Z────X─────┼─────────────I────┼┼X────────────────────────I────X┼────────I────X─────────────────────────I────@┼────────Y────┼@─────────────X────────────┼@────I────────@┼────I──────────────────────X──────────X────────X┼────I──────────────────────┼┼X─────────X─────────────X────┼─────Y────────┼────X┼────Y───I────────Y^-0.5───
                             │      │                   │                  ││                               │                                            ││             ││                          ││             ││                                                │                           ││                             │              │     │
5: ───Y^0.5────X^0.5────Y────X──────┼────────I────Y^-0.5┼─────X^0.5───I────X┼─────────────────────────Z────Y┼────X───I────@─────────────────────────I────X┼────────X────┼X─────────────I────────────┼X────Z────────X┼────Z──────────────────────@──────────Y───X────Y┼────Z──────────────────────X┼──────────Y───X^-0.5────Y^0.5┼─────Y────────X─────┼────I───X^-0.5───Y^-0.5───
                                    │                   │                   │                               │             │                               │             │                           │               │                           │                    │                            │                             │                    │
6: ───Y^-0.5───I────────X───────────X────────X──────────X─────────────X─────X─────────────────────────Z─────X────────X────X─────────────────────────Z─────X────────X────X──────────────Z────────────X─────Z─────────X────Y──────────────────────X──────────Z─────────X────Z───────────────────────X──────────X──────────────────X─────Y──────────────X────Z───I────────Y^0.5────
                            └────────┘           └────────┘               └───────┘                       └──┘           └──────┘                       └──┘           └──┘                        └──┘           └──┘                         └───────┘           └──┘                         └────────┘                └───────┘           └───────┘

Quantum Volume Circuits#

The generate_quantum_volume_circuit(), as defined in [3], 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.401-0.274j  0.075+0.147j  0.774-0.02j  -0.002-0.372j│                                                                                                                          │-0.676-0.154j  0.115-0.095j  0.125-0.196j -0.532+0.4j  │                                                                                                                       │-0.251-0.497j -0.182-0.212j  0.461+0.444j  0.168+0.417j│     │-0.218-0.331j -0.629-0.099j -0.2  +0.12j  -0.366+0.498j│                                                                                                                                                                                     │ 0.421-0.399j  0.157+0.269j -0.53 -0.225j  0.366+0.318j│
0: ────│ 0.191-0.055j  0.37 -0.421j  0.094+0.37j  -0.624+0.333j│─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────│-0.112-0.369j -0.786-0.068j -0.466-0.08j   0.051+0.053j│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.037-0.26j  -0.007-0.22j   0.335-0.574j -0.656+0.103j│─────│-0.383+0.164j  0.083+0.461j -0.296+0.14j  -0.562-0.429j│───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────│ 0.073+0.195j -0.723-0.001j -0.347+0.518j  0.081+0.198j│─────────────────────────────────────────────────────────────
       │ 0.368-0.51j   0.297+0.462j -0.289+0.046j  0.224+0.409j│                                                             │                                                            │-0.334-0.174j  0.239-0.529j -0.194+0.63j   0.282-0.083j│                                                                                                                       │-0.124-0.708j -0.175-0.02j  -0.331-0.154j  0.163-0.541j│     │-0.524+0.232j -0.052-0.569j  0.105+0.51j   0.179-0.205j│                                                                                                                       │                                                             │ 0.358-0.388j -0.476-0.292j  0.231-0.253j  0.199-0.503j│
       │ 0.529-0.224j -0.164-0.574j -0.396-0.114j  0.162-0.343j│                                                             │                                                            │-0.108+0.466j  0.066-0.118j -0.529-0.086j -0.445-0.518j│                                                                                                                       │-0.129+0.296j -0.178-0.9j   -0.121+0.032j  0.06 -0.184j│     │-0.341-0.473j  0.203+0.086j  0.746-0.107j -0.21 -0.02j │                                                                                                                       │                                                             │ 0.525+0.257j  0.254+0.071j -0.34 +0.217j -0.388-0.525j│
       └                                                       ┘                                                             │                                                            └                                                       ┘                                                                                                                       └                                                       ┘     └                                                       ┘                                                                                                                       │                                                             └                                                       ┘
       │                                                                                                                     │                                                            │                                                                                                                                                                               │                                                             │                                                                                                                                                                               │                                                             │
       │                                                        ┌                                                       ┐    ┌                                                       ┐    │                                                        ┌                                                       ┐                                                              │                                                             │                                                        ┌                                                       ┐     ┌                                                       ┐│                                                             │
       │                                                        │-0.074+0.334j -0.445-0.398j -0.142-0.008j  0.302-0.644j│    │-0.221-0.704j  0.031-0.372j  0.045-0.527j -0.029+0.189j│    │                                                        │-0.181-0.188j -0.148-0.589j  0.617-0.409j  0.117-0.047j│                                                              │                                                             │                                                        │-0.262-0.143j  0.431-0.486j  0.158+0.336j -0.59 -0.05j │     │-0.334+0.117j  0.314-0.546j  0.55 +0.224j  0.016-0.355j││                                                             │
1: ────┼────────────────────────────────────────────────────────│-0.471+0.105j -0.398-0.059j  0.054+0.678j -0.054+0.374j│────│ 0.13 +0.295j  0.307-0.766j -0.301+0.175j -0.213+0.22j │────┼────────────────────────────────────────────────────────│ 0.589+0.63j   0.159-0.152j  0.043-0.277j  0.262+0.245j│─────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────│-0.393+0.465j  0.358-0.313j -0.482-0.3j    0.284-0.016j│─────│-0.081+0.408j -0.234+0.359j  0.519+0.337j  0.183+0.476j│┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────
       │                                                        │-0.48 +0.632j  0.277+0.211j -0.342-0.253j -0.261+0.017j│    │ 0.321+0.007j -0.175-0.223j -0.28 -0.31j   0.074-0.798j│    │                                                        │ 0.046-0.338j -0.229+0.331j  0.149-0.081j  0.167+0.815j│     │                                                        │                                                             │                                                        │ 0.401+0.406j  0.159+0.063j  0.237-0.573j -0.455-0.233j│     │-0.048+0.487j -0.052-0.425j -0.457+0.007j  0.591+0.137j││                                                             │                                                        │
       │                                                        │-0.091-0.112j  0.512+0.314j -0.073+0.575j  0.199-0.493j│    │-0.283-0.411j  0.271-0.159j  0.052+0.65j   0.295-0.375j│    │                                                        │ 0.265-0.035j  0.038+0.648j  0.534-0.244j -0.156-0.372j│     │                                                        │                                                             │                                                        │-0.312+0.343j -0.18 +0.538j -0.335+0.209j -0.508+0.221j│     │-0.673-0.101j -0.358+0.329j -0.019-0.235j  0.312-0.385j││                                                             │                                                        │
       │                                                        └                                                       ┘    └                                                       ┘    │                                                        └                                                       ┘     │                                                        │                                                             │                                                        └                                                       ┘     └                                                       ┘│                                                             │                                                        │
       │                                                        │                                                                                                                         │                                                        │                                                             │                                                        │                                                             │                                                        │                                                             │                                                        │                                                             │                                                        │
       │                                                        │                                                                                                                         │                                                        │                                                             ┌                                                       ┐│                                                             │                                                        │                                                             │                                                        │                                                             │                                                        ┌                                                       ┐
       │                                                        │                                                                                                                         │                                                        │                                                             │ 0.253+0.197j  0.255-0.501j  0.384-0.272j -0.583+0.139j││                                                             │                                                        │                                                             │                                                        │                                                             │                                                        │ 0.117-0.215j -0.693-0.036j -0.57 +0.282j -0.233-0.001j│
2: ────#2───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────│-0.149+0.351j  0.191-0.125j -0.749-0.392j -0.129-0.265j│┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────│-0.186+0.089j  0.036+0.036j -0.29 +0.26j   0.737-0.51j │────
                                                                │                                                            │                                                                                                                     │                                                             │ 0.84 -0.04j  -0.029+0.164j  0.005-0.204j  0.193-0.432j││                                                             │                                                                                                                                                                               │                                                             │                                                        │ 0.342+0.164j -0.633+0.025j  0.558-0.163j  0.338-0.051j│
                                                                │                                                            │                                                                                                                     │                                                             │-0.15 +0.148j -0.761+0.157j  0.124-0.079j -0.451-0.357j││                                                             │                                                                                                                                                                               │                                                             │                                                        │-0.513-0.7j   -0.15 -0.303j  0.318-0.07j   0.018-0.158j│
                                                                │                                                            │                                                                                                                     │                                                             └                                                       ┘│                                                             │                                                                                                                                                                               │                                                             │                                                        └                                                       ┘
                                                                │                                                            │                                                                                                                     │                                                                                                                      │                                                             │                                                                                                                                                                               │                                                             │
                                                                │                                                            ┌                                                       ┐                                                             │                                                                                                                      │                                                             │                                                                                                                                                                               ┌                                                       ┐     │
                                                                │                                                            │-0.169-0.056j -0.474-0.426j  0.278+0.493j -0.147+0.469j│                                                             │                                                                                                                      │                                                             │                                                                                                                                                                               │-0.438+0.042j -0.203+0.001j  0.427+0.203j  0.587+0.443j│     │
3: ─────────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────│-0.202-0.502j  0.188+0.167j -0.392+0.145j  0.516+0.451j│─────────────────────────────────────────────────────────────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────#2──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ 0.431+0.289j  0.686+0.159j  0.284+0.04j   0.023+0.39j │─────#2────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                                             │-0.334+0.592j  0.188+0.458j -0.205+0.246j -0.286+0.329j│                                                                                                                                                                                                                                                                                                                                                                                                                                  │-0.113+0.511j -0.088-0.235j -0.555-0.4j    0.062+0.438j│
                                                                                                                             │ 0.458+0.067j -0.456+0.278j -0.392+0.499j  0.131-0.285j│                                                                                                                                                                                                                                                                                                                                                                                                                                  │-0.102-0.503j  0.221+0.593j -0.372-0.296j  0.303+0.138j│
                                                                                                                             └                                                       ┘                                                                                                                                                                                                                                                                                                                                                                                                                                  └                                                       ┘
      └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘                                                               └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Mirror Quantum Volume Circuits#

The generate_mirror_qv_circuit(), as defined in [4], 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: ────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │                                                                                                                      │
       │                                                        ┌                                                       ┐     │                                                        ┌                                                       ┐
       │                                                        │ 0.232+0.236j -0.337-0.02j   0.272-0.133j  0.826-0.041j│     │                                                        │ 0.232-0.236j  0.388-0.657j -0.22 +0.082j -0.256+0.433j│
1: ────┼────────────────────────────────────────────────────────│ 0.388+0.657j -0.329+0.086j -0.132-0.298j -0.428+0.11j │─────┼────────────────────────────────────────────────────────│-0.337+0.02j  -0.329-0.086j -0.641+0.108j -0.511-0.292j│────
       │                                                        │-0.22 -0.082j -0.641-0.108j -0.625+0.344j  0.078-0.085j│     │                                                        │ 0.272+0.133j -0.132+0.298j -0.625-0.344j  0.322+0.435j│
       │                                                        │-0.256-0.433j -0.511+0.292j  0.322-0.435j -0.169+0.28j │     │                                                        │ 0.826+0.041j -0.428-0.11j   0.078+0.085j -0.169-0.28j │
       │                                                        └                                                       ┘     │                                                        └                                                       ┘
       │                                                        │                                                             │                                                        │
3: ────┼────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────#2───────────────────────────────────────────────────────────
       │                                                                                                                      │
       ┌                                                       ┐                                                              ┌                                                       ┐
       │ 0.574-0.14j  -0.104-0.243j -0.25 -0.235j -0.678-0.056j│                                                              │ 0.574+0.14j  -0.43 +0.133j  0.185-0.151j  0.432-0.452j│
4: ────│-0.43 -0.133j -0.303-0.391j  0.041-0.736j  0.087+0.043j│──────────────────────────────────────────────────────────────│-0.104+0.243j -0.303+0.391j -0.661+0.494j  0.024-0.066j│─────────────────────────────────────────────────────────────
       │ 0.185+0.151j -0.661-0.494j  0.198+0.428j  0.188-0.068j│                                                              │-0.25 +0.235j  0.041+0.736j  0.198-0.428j  0.154+0.305j│
       │ 0.432+0.452j  0.024+0.066j  0.154-0.305j  0.24 +0.656j│                                                              │-0.678+0.056j  0.087-0.043j  0.188+0.068j  0.24 -0.656j│
       └                                                       ┘                                                              └                                                       ┘

       ┌                                                       ┐                                                              ┌                                                       ┐
       │-0.291+0.027j  0.067-0.579j  0.032-0.267j -0.031-0.708j│                                                              │-0.291-0.027j -0.082+0.037j  0.35 +0.596j -0.133-0.641j│
5: ────│-0.082-0.037j  0.597+0.054j -0.6  +0.404j -0.308-0.121j│──────────────────────────────────────────────────────────────│ 0.067+0.579j  0.597-0.054j -0.375+0.324j -0.236+0.011j│─────────────────────────────────────────────────────────────
       │ 0.35 -0.596j -0.375-0.324j -0.425+0.168j  0.257-0.031j│                                                              │ 0.032+0.267j -0.6  -0.404j -0.425-0.168j -0.331-0.293j│
       │-0.133+0.641j -0.236-0.011j -0.331+0.293j  0.56 -0.084j│                                                              │-0.031+0.708j -0.308+0.121j  0.257+0.031j  0.56 +0.084j│
       └                                                       ┘                                                              └                                                       ┘
       │                                                                                                                      │
6: ────#2─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────#2────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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: ───X^0.5───Y^0.5───X^0.5───I───Y^-0.5───X^-0.5───Y^0.5───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: ───X^0.5───I───Y^-0.5───I───X^-0.5───Rz(1.77π)───I───Y^0.5───X^0.5───X^0.5───Y^0.5───(X-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)
      ┌──┐
0: ─────@────────────
        │
2: ────S┼────────────
        │
4: ────T┼────@───────
        │    │
5: ─────┼────@───────
        │
6: ─────@────S───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 [5]. 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)