-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fix bit pack of mwpf and fusion blossom decoders under multiple logical observable #873
Merged
+39
−54
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading status checks…
…vables
Loading status checks…
Sorry about the CI breakages. Background radiation from dependencies churning beneath our feet... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixed two bugs in MWPF decoder
1. Supporting decomposed detector error model
While MWPF expects a decoding hypergraph, the input detector error model from sinter is by default decomposed. The decomposed DEM may contain the same detector or logical observable multiple times, which is not considered by the previous implementation.
The previous implementation assumes that each detector and logical observable only appears once, thus, I used
However, this no longer works if the same frame appears in multiple decomposed parts. In this case, the DEM actually means that "the hyperedge contributes to the logical observable iff count(frame) % 2 == 1". This is fixed by
2. Supporting multiple logical observables
Although a previous PR #864 has fixed the panic issue when multiple logical observables are encountered, the returned value is actually problematic and causes significantly higher logical error rate.
The previous implementation converts a . However,
int
typed bitmask to a bitpacked value usingnp.packbits(prediction, bitorder="little")
. However, this doesn't work for more than one logical observables.For example, if I define an observable using
OBSERVABLE_INCLUDE(2) ...
, supposedly the bitpacked value should be[4]
becausenp.packbits(4, bitorder="little") = [1]
, which is incorrect.The correct procedure is first generate the binary representation with
self.num_obs
bits usingnp.binary_repr(prediction, width=self.num_obs)
, in this case,'100'
, and then revert the order of the bits to['0', '0', '1']
, and then run the packbits which gives us the correct value[4]
.The full code is below: