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

naive_encoding_circuit failes when rank(parity_checks) < length(parity_checks) #190

Open
amicciche opened this issue Sep 27, 2023 · 8 comments
Labels
better error messages bug Something isn't working good first issue Good for newcomers

Comments

@amicciche
Copy link
Member

When trying to generate encoding circuits for some LDPC codes, I'm getting a bounds error:
Below is me trying this with three different codes:

image

I don't think the problem is with how I'm constructing the tableaux, but for thoroughness, here is my personal function stab_from_cxcz()

image

@Krastanov
Copy link
Member

Could you upload the two npz files from the first two lines of the REPL screenshot?

It seems there is a problem with this line

if phases(S)[i]!=0

@Krastanov
Copy link
Member

Actually, this happens almost certainly due to redundant rows in the parity check matrix you are using. Presumably, there are 300 parity checks. However, probably only 296 of them are actually independent. That does not matter too much for the syndrome measurement circuit -- we happen to perform 4 redundant measurements, big deal. But it would matter to the encoding circuit. To verify that this is indeed the case, check what the rank(MixedDestabilizer(stab)) is. Probably it is smaller than length(stab). So, just for the encoding circuit (not for the syndrome measurement circuits) try the following modification stab = stabilizerview(MixedDestabilizer(stab)). I think that would be enough to fix the issue

@Krastanov
Copy link
Member

MixedDestabilizer basically does the Gaussian elimination necessary to remove redundant rows:

julia> S"XXX ZZI IZZ ZIZ" |> MixedDestabilizer |> stabilizerview
+ XXX
+ ZZ_
+ Z_Z

@amicciche
Copy link
Member Author

You were right about the rank being 296, but I'm now having trouble with the type of the tableau returned by that:
image

@Krastanov
Copy link
Member

this seems to be separate issue (I reported it just now in #191)

As a temporary workaround just do reduced_checks = copy(reduced_checks) # in order to collect the array so it is not a view into another array

@amicciche
Copy link
Member Author

amicciche commented Sep 27, 2023

I think it's working now, but the logical error versus physical error plots for LDPC codes look terrible with my way of decoding. I think this is probably due to the lookup table only working with single qubit errors, but now that the number of qubits is around 300, that almost never is going to happen. I guess it's time to talk to Krishna about us combining our work?

image

@Krastanov
Copy link
Member

Yup, this is almost certainly due to the lookup table decoder. I messaged on zulip about it.

I will change the name of this issue to track more carefully the particular bug that was initially reported.

@Krastanov Krastanov changed the title Bounds error generating encoding circuits with LDPC codes naive_encoding_circuit failes when rank(parity_checks) < length(parity_checks) Sep 27, 2023
@Krastanov Krastanov added bug Something isn't working good first issue Good for newcomers better error messages labels Sep 27, 2023
@Krastanov
Copy link
Member

All we need to do here is to double check that we do not have over-determined system. Basically check length(parity_checks) (i.e. code_c = code_n - code_k) versus the rank of the MixedDestabilizer that is already constructed. If they match everything is fine, and if they do not, raise an error with a clear descriptive message (instead of the current indexing error).

S"IZZ ZZI ZIZ" can be used when adding tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better error messages bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants