This project simulates quantum error correction using a BP-OSD (Belief Propagation with Ordered Statistics Decoding) decoder for a surface code. The simulation generates tasks to test different physical error rates, code distances, and OSD orders, then visualizes the results in the form of logical error rate plots.
- Task Generation: Creates tasks for different physical error rates (
pvalues) and code distances (dvalues). These tasks simulate different levels of noise and quantum error-correcting code strength. - Decoder Simulation: Runs simulations using the BP-OSD decoder, allowing customization of the OSD method and order. The decoder tests the logical error rates against varying parameters.
- Error Model: Uses
stimto generate a surface code circuit and applies detection events and observable flips for the quantum error correction tasks. - Results Visualization: Plots the logical error rate as a function of the physical error rate, with different curves for varying code distances and OSD orders.
-
Task Generation: The program first generates example tasks, which vary by:
- Physical error rate (
p) - Code distance (
d) - Number of rounds (
rounds)
- Physical error rate (
-
Decoding: For each task, the
BpOsdDecoderis applied using the provided circuit data. This simulates the performance of quantum error correction and calculates the logical error rate. -
Data Logging: Simulation results are saved to CSV files to allow reloading data without rerunning the simulations.
-
Visualization: Plots are generated showing the logical error rates for various configurations of the OSD method and order. The x-axis represents the physical error rate, and the y-axis shows the logical error rate on a log-log scale.
decoder_type: Specifies the type of decoder used (default isBpOsd).osd_method: Chooses the OSD method for decoding (e.g.,osd_E).osd_order: Specifies the OSD order used in the decoding process (e.g., 0, 5, 15).load_from_file: A boolean parameter to either load precomputed results from a CSV file or run the simulation from scratch.
- CSV Files: The simulation results, including the physical error rate, code distance, rounds, and logical error rates, are saved to CSV files.
- Plots: Logical error rate vs physical error rate plots are generated for each OSD method and order, with different curves for different code distances.
To run the simulation and generate plots, simply execute the script. You can modify the OSD methods or orders and decide whether to load previous results from CSV or run the simulation from scratch.
