-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add Surface Code #7
base: main
Are you sure you want to change the base?
Conversation
/ok to test |
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.
Thanks, Justin. I have a few comments/questions below.
|
||
/// @brief enumerates the role of a grid site in the surface codes stabilizer | ||
/// grid | ||
enum surface_role { amx, amz, empty }; |
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.
Just curious: is this "a measure x" and "a measure z", or something else?
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.
That is a fine interpretation, although in my head I was thinking "ancilla for mx/z".
stabilizer(patch p, const std::vector<std::size_t> &x_stabilizers, | ||
const std::vector<std::size_t> &z_stabilizers); |
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 didn't think we supported pass-by-reference going into a __qpu__
function?
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 is the expected behavior of passing a ref in? This seems to work here as well as in the Steane code.
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 case, either pass by value or pass by ref get you the same thing - a subtlety of the ASTBridge MLIR generation. No matter what the signature is, if you pass a std::vector it is modeled as a cc.stdvec which lowers to a span-like type (a pointer and a size). You are always passing by reference no matter what. Eric can elaborate more if needed.
cudaqx::tensor<uint8_t> Lz = surf_code->get_observables_z(); | ||
|
||
{ | ||
// This is just a regression check, this has not been hand tested |
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 exactly does this comment mean? Where did the data come from?
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.
The data is only generated from itself, just scraped from the terminal and put into a vector here. Other instances of checking against hardcoded bit strings were hand checked to be correct. This one was not, as there are not printed instances of surface code PCMs I could find.
This comment is to make us aware that these are not magic numbers that we must always match. Various permutations would all be valid PCMs of the surface code.
EXPECT_EQ(t.at({i, j}), parity.at({i, j})); | ||
} | ||
{ | ||
// This is just a regression check, this has not been hand tested |
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.
Same question here.
EXPECT_EQ(t.at({i, j}), parity_x.at({i, j})); | ||
} | ||
{ | ||
// This is just a regression check, this has not been hand tested |
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.
Same question here.
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.
Notes from our meeting today.
|
||
/// @brief Generates and keeps track of the 2d grid of stabilizers in the | ||
/// rotated surface code | ||
// Grid layout is arranged from left to right, top to bottom (row major storage) |
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.
We need to double check that the docs are rendering as desired for //
vs ///
.
// The grid length of 4 corresponds to a distance 3 surface code, which results | ||
// in: e(0,0) e(0,1) Z(0,2) e(0,3) X(1,0) Z(1,1) X(1,2) e(1,3) e(2,0) | ||
// X(2,1) Z(2,2) X(2,3) e(3,0) Z(3,1) e(3,2) e(3,3) |
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.
Double-check formatting.
// | ||
// The data qubits are located at the four corners of each of the weight-4 | ||
// stabilizers. They are also organized with index increasing from left to | ||
// right, top to bottom: d0 d1 d2 d3 d4 d5 d6 d7 d8 |
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.
Double check formatting (two spaces vs single spac)
bool operator<(const vec2d &lhs, const vec2d &rhs); | ||
|
||
/// @brief Generates and keeps track of the 2d grid of stabilizers in the | ||
/// rotated surface code |
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.
Perhaps consider adding link to a reference paper who's convention you're following w.r.t. the grid.
libs/qec/lib/codes/surface_code.cpp
Outdated
@@ -0,0 +1,396 @@ | |||
/****************************************************************-*- C++ -*-**** |
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.
Nit:
/****************************************************************-*- C++ -*-**** | |
/******************************************************************************* |
@@ -0,0 +1,87 @@ | |||
/****************************************************************-*- C++ -*-**** |
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.
Nit:
/****************************************************************-*- C++ -*-**** | |
/******************************************************************************* |
554227b
to
dc2b76e
Compare
/ok to test |
9242136
to
1f64a53
Compare
/ok to test |
I don't know if you're seeing this in your local builds or not, but the CI is reporting some potentially relevant warnings: E.g., this is repeated many times:
|
I do not see this locally, but I build with |
It turns out this warning is only coming from the |
/ok to test |
This PR adds the
cudaq::qec::surface_code
namespace which includes thesurface_code
type and thestabilizer_grid
helper class. Thestabilizer_grid
generates the 2d layout of the stabilizers, and which data qubits each stabilizer has support on. Lastly it generates the stabilizers and observables as vectors ofcudaq::spin_op
which theqec::code
expects.