-
Notifications
You must be signed in to change notification settings - Fork 139
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 Heavy hex code to generators #293
Conversation
Added firs implementation for heavy hex, it only implements 1 1 heavy hex and has some hardcoded parts that will be worked on.
Pull Request Test Coverage Report for Build 1159775214
💛 - Coveralls |
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 as in #313 : no comment on the Rust, quantum stuff all looks good, and I left a few notes on clarifying intent.
src/generators.rs
Outdated
); | ||
} else if i % 2 == 1 { | ||
graph.add_edge( | ||
nodes_data[(i + 1) * d - 1], |
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 comment as in #313 : I'd prefer this to be written i * d + (d - 1)
.
src/generators.rs
Outdated
); | ||
graph.add_edge( | ||
syndrome_chunk[syndrome_chunk.len() - 1], | ||
nodes_data[(i + 2) * d - 1], |
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 comment as above.
src/generators.rs
Outdated
@@ -983,6 +983,139 @@ pub fn directed_grid_graph( | |||
}) | |||
} | |||
|
|||
/// Generate an undirected heavy hex graph. |
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.
A useful reference here is Fig 2 of https://arxiv.org/pdf/1907.09528.pdf , and here's some ASCII art:
... D-S-D D ...
| | |
...-F F-S-F ...
| | |
... D D D ...
| | |
... F-S-F F-...
| | |
.........
| | |
... D D D ...
| | |
...-F F-S-F ...
| | |
... D D D ...
| | |
... F-S-F F-...
| | |
.........
| | |
... D D D ...
| | |
...-F F-S-F ...
| | |
... D D D ...
| | |
... F-S-F F-...
| | |
... D D-S-D ...
One other note for onlookers, not really germane to the PR: it's easier to understand these lattices as perfect square grids with holes poked in them, rather than assembling the pieces from scratch. |
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
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.
LGTM, thanks for doing this. The only question I have before merging is do you think it makes sense to add a directed version too? If so I think that would be useful to have.
Good catch, and up to y'all. It's ambiguous what directionality is preferred by the circuit embodiments of the stabilizer checks, so I don't think it'd be punting to skip this — but I also think that "flag qubits are targets of edges" is the maxim that's compatible with device engineering. |
I'll implement the directed version of the heavy hex code in order to be used on the |
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.
LGTM, thanks for adding the directed variant. I do wonder if we can de-duplicate the implementation since the code is mostly identical but we can do that in a follow up (as it also applies to most of the generators).
Just one inline comment on the edge direction based on @ecpeterson's comment: #293 (comment) and the figures in the paper about the hardware implementation. Once that's fixed I think this is good to go
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.
Looking at figure 10 more closely for #313 I think the direction for the data-> syndrome edges:
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.
With @mtreinish's amendments, this LGTM.
Co-authored-by: Eric Peterson <peterson.eric.c@gmail.com>
LGTM, I just went ahead and applied the suggestions to get this in for the release. Thanks for doing this @nahumsa and sticking with it for so long |
Thanks both @mtreinish and @ecpeterson for the review. |
Added implementation of heavy hex, the input is the code distance, d. In the implementation I chose to add nodes referring to each type of qubit used in the Heavy Hex Code (data, syndrome, and flag) which may cause the node order to be confusing, but that was the best way that I figure out how to implement. Now I will explain the way that I implemented the code, which could be better for people without experience with the heavy hex code.
In the heavy hex code, there are
d ** 2
data qubits,(d + 1) * (d - 1) / 2
syndrome qubits, andd * (d - 1)
flag qubits. In order to implement I follow 3 steps:d
.In steps (ii) and (iii), there are two patterns depending on the eve (odd) columns of syndrome qubits, which are treated accordingly using an
if
statement. It was also required to use.chunk()
forVectors
in order to represent them in a column.Related to #150