-
Notifications
You must be signed in to change notification settings - Fork 211
Tutorial: Decoding Quantum Errors on the Steane code with Belief Propagation & Catalyst #1371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…f Propagation & Catalyst"
…d preview images check-jsonschema \ --schemafile metadata_schemas/demo.metadata.schema.0.1.5.json \ demonstrations/tutorial_bp_catalyst.metadata.json fails but does not return any error messages
Co-authored-by: Paul Finlay <50180049+doctorperceptron@users.noreply.github.com>
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great demo! Excellent work.
I left comments to clarify a few points and suggestions to make it cleaner.
# | ||
# In the final section of this demo we will compute the average performance of our Steane code error | ||
# correction circuit for a range of possible error rates. We’ll define logical error rates by | ||
# comparing the state vector from our noisy simulation to with the clean state vector ``sv_clean`` of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# comparing the state vector from our noisy simulation to with the clean state vector ``sv_clean`` of | |
# comparing the state vector from our noisy simulation with the clean state vector ``sv_clean`` of |
|
||
|
||
###################################################################### | ||
# Simulate 1000x noisy shots for several noise levels, we’ll use ``jax.vmap`` to efficiently map our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do we mean by 1000x noisy? can it be written in plain words or more clearly?
# In this tutorial, we’ve successfully built, simulated, and decoded a simple quantum error correction | ||
# cycle using the Steane code. We’ve demonstrated encoding a logical qubit, introduced errors through | ||
# noise simulation, and performed error correction using stabilizer measurements combined with | ||
# classical decoding. The performance was benchmarked by measuring the logical versus physical error | ||
# rates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# In this tutorial, we’ve successfully built, simulated, and decoded a simple quantum error correction | |
# cycle using the Steane code. We’ve demonstrated encoding a logical qubit, introduced errors through | |
# noise simulation, and performed error correction using stabilizer measurements combined with | |
# classical decoding. The performance was benchmarked by measuring the logical versus physical error | |
# rates. | |
# In this tutorial, we successfully built, simulated, and decoded a simple quantum error correction | |
# cycle using the Steane code. We demonstrated encoding a logical qubit, introduced errors through | |
# noise simulation, and performed error correction using stabilizer measurements combined with | |
# classical decoding. Performance was benchmarked by measuring the logical versus physical error | |
# rates. |
# However, our approach had a significant simplifying assumption known as the code capacity model, | ||
# where errors are assumed to occur at only one stage of the circuit, with perfect encoding and | ||
# syndrome extraction otherwise. A more realistic approach—called circuit-level noise—accounts for | ||
# potential errors at every gate and measurement within the circuit. This model significantly | ||
# complicates decoding because it requires mapping every possible error location not only in space but | ||
# also across multiple syndrome measurement rounds, forming a complex space-time hypergraph. Decoding | ||
# then involves interpreting error events over both spatial and temporal dimensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# However, our approach had a significant simplifying assumption known as the code capacity model, | |
# where errors are assumed to occur at only one stage of the circuit, with perfect encoding and | |
# syndrome extraction otherwise. A more realistic approach—called circuit-level noise—accounts for | |
# potential errors at every gate and measurement within the circuit. This model significantly | |
# complicates decoding because it requires mapping every possible error location not only in space but | |
# also across multiple syndrome measurement rounds, forming a complex space-time hypergraph. Decoding | |
# then involves interpreting error events over both spatial and temporal dimensions. | |
# However, our approach relied on a significant simplifying assumption known as the code capacity model, | |
# where errors are assumed to occur at only one stage of the circuit, with otherwise perfect encoding and | |
# syndrome extraction. A more realistic approach—called circuit-level noise—accounts for | |
# potential errors at every gate and measurement within the circuit. This model significantly | |
# complicates decoding, as it requires mapping every possible error location not only in space but | |
# also across multiple syndrome measurement rounds, forming a complex space-time hypergraph. Decoding | |
# then involves interpreting error events over both spatial and temporal dimensions. |
# Nevertheless, the fundamental decoding principles explored here, particularly the Belief Propagation | ||
# (BP) algorithm, remain highly relevant. BP is flexible enough to operate effectively on more full | ||
# circuit level decoding hypergraphs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Nevertheless, the fundamental decoding principles explored here, particularly the Belief Propagation | |
# (BP) algorithm, remain highly relevant. BP is flexible enough to operate effectively on more full | |
# circuit level decoding hypergraphs. | |
# Nevertheless, the fundamental decoding principles explored here, particularly the Belief Propagation | |
# algorithm, remain highly relevant. BP is flexible enough to operate effectively on more comprehensive | |
# circuit-level decoding hypergraphs. |
Thank you for the detailed comments @daniela-angulo I'll start addressing these tomorrow. |
Co-authored-by: Daniela Angulo <42325731+daniela-angulo@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on dependancies/utility code.
from typing import Optional | ||
|
||
|
||
def state_vector_to_dict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvaro-at-xanadu this is unrelated utility code for displaying state vectors that ideally could be moved to a resource file if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniela-angulo is there a way to extract utility code or should we just keep it inline to keep things self contained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great question. There is no utility codes. However, the function is quite long and can distract people from the core content of the demo.
The function is to pretty print the state vector, isn't it? Could it be possible to just print it using a simpler function. I know yours renders beautifully, but I am wondering if there is a way in which we can keep things self contained without having a long piece of code that might be distracting. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, this is a cool feature and if you would like this to be added to PL, you can request a new feature. See here in How can I contribute? to see the Feature request form.
# the Steane code logical zero state. | ||
# | ||
|
||
import pandas as pd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few dependencies not part of the core qml deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniela-angulo not sure where to include extra deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is short enough for us to leave it there, I believe.
###################################################################### | ||
# A simple utility function to display the state | ||
# | ||
# @TODO can we move this to a utility file (or better yet make it part of pennylane 😁) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to remove this
Everything looks good here please make the changes. |
Hi @beitom |
Title: Decoding Quantum Errors on the Steane code with Belief Propagation & Catalyst
Summary:$[[7,1,3]]$
This tutorial walks you through a simplified error correction cycle using the Steane
code. You’ll encode a logical qubit, introduce noise, extract syndromes, and apply decoding using
two different strategies: a simple lookup table and a belief propagation (BP) decoder. Both decoders
are implemented in JAX and JIT-compiled by Catalyst, allowing everything to run inside a single
@qml.qjit
circuit.Relevant references:
Possible Drawbacks:
The tutorial uses a simplified noise model (code capacity) where errors occur only once. Real-world quantum computers have errors at every step (circuit-level noise), which creates a much more complex decoding challenge involving errors in space and time.
Related GitHub Issues:
N/A
If you are writing a demonstration, please answer these questions to facilitate the marketing process.
GOALS — Why are we working on this now?
I work on fault tolerant compilation of quantum circuits which involves making classical decoding algorithms run alongside quantum circuit with measurements and feedforward operations. Catalyst is a great new technology to enable these kinds of high performance hybrid quantum-classical workflows essential for quantum error correction.
AUDIENCE — Who is this for?
KEYWORDS — What words should be included in the marketing post?
quantum error correction
,css code
,hybrid quantum-classical
,belief propagation decoding
,JAX
,Catalyst
(more details here note this requires a Xanadu email to view)
Notes:
suggested thumbail is to make a graphic of the Steane code in it's usual triangle layout

The hero image should have some theme of quantum/classical QEC circuits my idea is roughly this where S is the syndrome and R is the recovery operator:
[sc-93094]