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

Ldpc v2 #18

Merged
merged 0 commits into from
Oct 23, 2024
Merged

Ldpc v2 #18

merged 0 commits into from
Oct 23, 2024

Conversation

quantumgizmos
Copy link
Owner

Complete rewrite. Should be backwards compatible with LDPCv1. Please test this on old scripts.

Copy link
Collaborator

@lucasberent lucasberent left a comment

Choose a reason for hiding this comment

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

Checked the most important parts hopefully and added a few comments. I guess more hands on testing would be valuable.

@@ -0,0 +1,13 @@
#include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this file needed?


cout<<endl;

for(int i = 2; i<8; i++){
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe for indexing std::size_t is best to use as loop variable type


auto decoding = flipD->decode(syndrome);

cout<<"Error: ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we leave in all cout statements in the release?

return csr_matrix;
}

// TEST(gf2dense, hamming_code){
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about all this outcommented code?


}

double sparsity = 0.01;
Copy link
Collaborator

Choose a reason for hiding this comment

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

unsure if blobal variables adhere to the best practices here.

#include "osd.hpp"

using namespace std;

Copy link
Collaborator

Choose a reason for hiding this comment

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

lots of code commented out here

using namespace ldpc::uf;

// TEST(UfDecoder, single_bit_error) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

commented out code

print(csv_string, file=output_file)


if __name__ == "__main__":
Copy link
Collaborator

Choose a reason for hiding this comment

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

is a main function needed here?




if __name__ == "__main__":
Copy link
Collaborator

Choose a reason for hiding this comment

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

needed?


for i in range(3,10):

H = hamming_code(i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess using pytest.fixture would be the best practice to generate test objects used (also those used across different tests)

Copy link
Collaborator

@lucasberent lucasberent left a comment

Choose a reason for hiding this comment

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

some minor comments and potential improvements on the sinter integration.

@@ -29,23 +63,33 @@ def decode_via_files(
) -> None:
self.dem = stim.DetectorErrorModel.from_file(dem_path)
self.matrices = detector_error_model_to_check_matrices(self.dem)
self.bposd = BpOsdDecoder(self.matrices.check_matrix, error_channel=list(self.matrices.priors), max_iter=5, bp_method="ms", ms_scaling_factor = 0.625, schedule="parallel", osd_method = "osd0")
self.bposd = BpOsdDecoder(self.matrices.check_matrix,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we might save some time and use a common base class instead of a specific decoder here. Making this more general allows to simply reuse and not require a separate sinter_[decoder name]_ for every decoder.
Something like a SinterDecoderBase would probably be the best solution?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I don't make a separate sinter_[decoder_name]_ for every decoder, then someone using Sinter in python can't see the the parameters the sinter_[decoder_name]_ excepts in their editor. Do you know what I mean? For a Sinter user (who I'm targeting) I think this solution is the cleanest.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you used named arguments that should work, no?

src_python/ldpc/sinter_decoders/sinter_bposd_decoder.py Outdated Show resolved Hide resolved
src_python/ldpc/sinter_decoders/sinter_bposd_decoder.py Outdated Show resolved Hide resolved
stim.write_shot_data_file(
data=predictions,
path=obs_predictions_b8_out_path,
format="b8",
num_observables=self.dem.num_observables,
)


def decode(self, syndrome: np.ndarray) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

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

having this at hand, writing a full simulator that only takes a code and a decoder/-name would be helpful. this is also more or less the same and boilerplate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes agreed, I made an example in sinter_example.py. Can you let me know what you think? To be clear, I don't want to write code that replaces Sinter and Stim, I simply want to use the BPOSD and BeliefFind as a plugin. Sinter and Stim have a full simulator that only takes a code and a decoder/-name.

@peter-janderks
Copy link
Collaborator

@lucasberent Thanks for the quick review 😃 . There are two comments left which I didn't resolve yet but I did comment on.

@lucasberent
Copy link
Collaborator

@lucasberent Thanks for the quick review 😃 . There are two comments left which I didn't resolve yet but I did comment on.

haven't tried it out myself yet but looks good! thanks

@quantumgizmos quantumgizmos merged commit 33c2cd6 into main Oct 23, 2024
18 checks passed
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.

3 participants