Skip to content
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 hypergraph-UF and mwpf decoder in sinter #815

Closed
wants to merge 7 commits into from

Conversation

yuewuo
Copy link
Contributor

@yuewuo yuewuo commented Aug 24, 2024

This is a simple adaptation of the mwpf' python package to sinter. Just copied the _decoding_fusion.pyand modify it accordingly to let the decoder consider hyperedges. Tested using thegetting_started.ipynb` and they run decoding without a problem.

I haven't added any test cases for this, since I didn't find a test case for fusion_blossom decoder as well. Please let me know where should I put a basic test case for the new decoders!

Copy link

google-cla bot commented Aug 24, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Collaborator

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Unfortunately, I think there's currently a bit of a showstopper. The timeout behavior needs to be replaced in order for results to be mergeable (and reproduceable) across machines. Otherwise the decoder is ill-behaved in ways that make it dangerous to collect statistics at different times and places while expecting them to be from the same distribution, which is something sinter sort of implicitly assumes.


BUILT_IN_DECODERS: Dict[str, Decoder] = {
'vacuous': VacuousDecoder(),
'pymatching': PyMatchingDecoder(),
'fusion_blossom': FusionBlossomDecoder(),
'hyper_uf': HyperUFDecoder(),
'mwpf': MwpfDecoder(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these names be more descriptive?

glue/sample/src/sinter/_decoding_mwpf.py Outdated Show resolved Hide resolved
@yuewuo
Copy link
Contributor Author

yuewuo commented Aug 26, 2024

A basic performance benchmark using the sinter jobs of getting_started.ipynb (the sinter.collect( block of repetition_code:memory)

  • pymatching: 1.7s
  • fusion_blossom: 35s
  • hypergraph_union_find: 89.5s
  • mw_parity_factor: 142.9s

By the way, I had some thoughts on the slow down of fusion_blossom compared to pymatching: it is probably coming from duplicate edges. The current implementation of sinter for fusion_blossom does not deduplicate the edges (and merge them) like pymatching would do internally when calling the add_edge function. I think there could be some functionality outside of pymatching that merges the edges. Do you think this is reasonable?

@Strilanc
Copy link
Collaborator

Having duplicate edges could certainly slow things down. Stim already dedupes most errors so there may not be a lot of dupes to start with.

@yuewuo
Copy link
Contributor Author

yuewuo commented Aug 26, 2024

Having duplicate edges could certainly slow things down. Stim already dedupes most errors so there may not be a lot of dupes to start with.

Thanks for the insight! Indeed, just printed them out and there are no duplicate edges. I've also tried to reduce the integer weight of the edges, but the decoding time remains almost unchanged. The most probably reason would then because iterating the ndarray in Python instead of in Rust. I'll investigate in this to get a better understanding.

@yuewuo
Copy link
Contributor Author

yuewuo commented Aug 26, 2024

Having duplicate edges could certainly slow things down. Stim already dedupes most errors so there may not be a lot of dupes to start with.

Thanks for the insight! Indeed, just printed them out and there are no duplicate edges. I've also tried to reduce the integer weight of the edges, but the decoding time remains almost unchanged. The most probably reason would then because iterating the ndarray in Python instead of in Rust. I'll investigate in this to get a better understanding.

Sorry I made a stupid mistake...... I installed the debug version of the fusion_blossom package which runs for 35s. Once I switch to a release version, it drops to 6.3s. This makes more sense. Similarly for mwpf package. Here is the new result:

  • pymatching: 2.3s
  • fusion_blossom: 6.3s
  • hypergraph_union_find: 9.7s
  • mw_parity_factor: 14.0s

@Strilanc
Copy link
Collaborator

I moved this to #837 so I could resolve the merge conflicts.

@Strilanc Strilanc closed this Sep 24, 2024
Strilanc added a commit that referenced this pull request Sep 24, 2024
…nter (#837)

(This PR is just a merge-conflict-resolved version of
#815)

> This is a simple adaptation of the `mwpf' python package to sinter.
Just copied the `_decoding_fusion.py` and modify it accordingly to let
the decoder consider hyperedges. Tested using the
`getting_started.ipynb` and they run decoding without a problem.

> I haven't added any test cases for this, since I didn't find a test
case for `fusion_blossom` decoder as well. Please let me know where
should I put a basic test case for the new decoders!

Editor's note: The existing unit tests automatically iterate over the defined decoders and run them through some basic sanity checks.

Authored by: Yue Wu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants