K-body Noise Reconstruction (KNR)

This example illustrates how to generate k-body noise reconstruction (KNR) circuits and use them to estimate the probability distribution of stochastic Pauli errors afflicting the cycle being benchmarked. While this example uses a simulator to execute the circuits, the same procedure can be followed for hardware applications.

import trueq as tq

# Define the cycle to benchmark using KNR.
cycle = tq.Cycle({label: tq.Gate.id for label in range(4)})

# Generate KNR circuits to benchmark the cycle, targeting only single body interactions,
# and 30 circuits for each length in [4, 32, 64].
circuits = tq.make_knr(cycle, n_random_cycles=[4, 32, 64], n_circuits=30, n_bodies=1)

# Initialize a simulator with stochastic Pauli noise, with worse noise on qubit 3.
sim = tq.Simulator()
sim.add_stochastic_pauli(px=0.005, py=0.005)
sim.add_stochastic_pauli(pz=0.01, noisy_labels=3)

# Run the circuits on the simulator to populate the results.
sim.run(circuits)
# Display a table of KNR estimates:
circuits.fit()
KNR Estimates
K-body Noise Reconstruction
(0,): Gate.id, (1,): Gate.id, (2,): Gate.id, (3,): Gate.id
Cycle:
  • (0,): Gate.id
  • (1,): Gate.id
  • (2,): Gate.id
  • (3,): Gate.id
  (0,) : Gate.id
Cycle:
  • (0,): Gate.id
  • (1,): Gate.id
  • (2,): Gate.id
  • (3,): Gate.id
(1,) : Gate.id
Cycle:
  • (0,): Gate.id
  • (1,): Gate.id
  • (2,): Gate.id
  • (3,): Gate.id
(2,) : Gate.id
Cycle:
  • (0,): Gate.id
  • (1,): Gate.id
  • (2,): Gate.id
  • (3,): Gate.id
(3,) : Gate.id
Cycle:
  • (0,): Gate.id
  • (1,): Gate.id
  • (2,): Gate.id
  • (3,): Gate.id
X 1.1e-02 (9.2e-04)
Subcycle:
  • (0,): Gate.id
Error Type:
  • X
Error Probability (std):
  • 0.01075865529625547 (0.0009195397955831476)
1.0e-02 (8.4e-04)
Subcycle:
  • (1,): Gate.id
Error Type:
  • X
Error Probability (std):
  • 0.010257980966760227 (0.0008379086924513488)
8.6e-03 (6.5e-04)
Subcycle:
  • (2,): Gate.id
Error Type:
  • X
Error Probability (std):
  • 0.008622180730822132 (0.0006464793993599913)
1.1e-02 (2.0e-03)
Subcycle:
  • (3,): Gate.id
Error Type:
  • X
Error Probability (std):
  • 0.010775234194351169 (0.0019757099488570233)
Y 1.1e-02 (9.2e-04)
Subcycle:
  • (0,): Gate.id
Error Type:
  • Y
Error Probability (std):
  • 0.011021070585178705 (0.0009195397955831476)
1.0e-02 (8.4e-04)
Subcycle:
  • (1,): Gate.id
Error Type:
  • Y
Error Probability (std):
  • 0.010227300523666355 (0.0008379086924513488)
1.0e-02 (6.5e-04)
Subcycle:
  • (2,): Gate.id
Error Type:
  • Y
Error Probability (std):
  • 0.010055522003371925 (0.0006464793993599913)
1.0e-02 (2.0e-03)
Subcycle:
  • (3,): Gate.id
Error Type:
  • Y
Error Probability (std):
  • 0.010114789547798486 (0.0019757099488570233)
Z -1.2e-03 (9.2e-04)
Subcycle:
  • (0,): Gate.id
Error Type:
  • Z
Error Probability (std):
  • -0.0012019971108529481 (0.0009195397955831476)
2.0e-04 (8.4e-04)
Subcycle:
  • (1,): Gate.id
Error Type:
  • Z
Error Probability (std):
  • 0.00019872724966599198 (0.0008379086924513488)
6.2e-04 (6.5e-04)
Subcycle:
  • (2,): Gate.id
Error Type:
  • Z
Error Probability (std):
  • 0.0006210643436302121 (0.0006464793993599913)
1.7e-02 (2.0e-03)
Subcycle:
  • (3,): Gate.id
Error Type:
  • Z
Error Probability (std):
  • 0.016672005980549798 (0.0019757099488570233)


# Plot the results:
circuits.plot.knr_heatmap()
knr

From above, you can see that the largest single-qubit error is a \(Z\) error on qubit 3, whose probability is approximately twice as large as the next leading single-qubit error. The probability of a \(Z\) error on any other qubit is very low since we would have to have both an \(X\) and a \(Y\) error acting on that qubit for a \(Z\) error to arise. This is exactly as expected given the noise defined by the simulator in this example.

In the example above KNR was ran on only single body terms, below we run KNR on two body terms, for more details see KNR.

# Generate KNR circuits to benchmark the cycle, but now targeting both single and two
# body interactions, with 30 circuits for each length in [4, 12, 32].
circuits = tq.make_knr(cycle, [4, 12, 32], n_circuits=30, n_bodies=2)

# Run the circuits on the simulator to populate the results.
sim.run(circuits)

# Plot the results:
circuits.plot.knr_heatmap()
knr

As before, the Pauli error with the highest probability is a \(Z\) error on qubit 3 and the other most-likely errors are weight 1. This is as expected based on our simple simulator model used in this example.

Total running time of the script: ( 0 minutes 18.362 seconds)

Gallery generated by Sphinx-Gallery