Skip to content

compute the minimum distance of QLDPC using Mixed Integer Programming#439

Merged
Krastanov merged 55 commits intoQuantumSavory:masterfrom
Fe-r-oz:fa/MILPExt
Jun 20, 2025
Merged

compute the minimum distance of QLDPC using Mixed Integer Programming#439
Krastanov merged 55 commits intoQuantumSavory:masterfrom
Fe-r-oz:fa/MILPExt

Conversation

@Fe-r-oz
Copy link
Contributor

@Fe-r-oz Fe-r-oz commented Nov 30, 2024

This PR implements the Mixed Integer programming (MIP) approach to compute the minimum distance of QLDPC using GNU's Linear Programming Kit. This method is used by Panteleev and Kalachev and by Bravyi et. al.. The latter reference mentioned that this MIP approach was originally developed in 2011 and used in this reference

This PR allows the users to compute the minimum distance with ease and also provide the necessary documentation along with the relevant modern usecases. The tests have been conducted in #435

ILP/MILP methods: https://quantumcomputing.stackexchange.com/questions/37289/compute-the-exact-minimum-distance-of-a-qecc-with-integer-linear-programming-met

P.S. Mixed Integer Programming (MIP) or mixed integer linear program refer to same thing in the literature, in this context.

Edit:

  • The code is properly formatted and commented.
  • Substantial new functionality is documented within the docs.
  • All new functionality is tested.
  • All of the automated tests on github pass.
  • We recently started enforcing formatting checks. If formatting issues are reported in the new code you have written, please correct them.

@Fe-r-oz Fe-r-oz changed the title QuantumCliffordJuMPExt: compute the minimum distance of QLDPC using Mixed Integer Programming (MIP) QuantumCliffordJuMPExt: compute the minimum distance of QLDPC using Mixed Integer Programming (MIP) via GNU Linear Programming Kit Nov 30, 2024
@codecov
Copy link

codecov bot commented Nov 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.42%. Comparing base (6065fab) to head (e40b4b3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #439      +/-   ##
==========================================
+ Coverage   82.82%   83.42%   +0.60%     
==========================================
  Files          70       73       +3     
  Lines        4651     4808     +157     
==========================================
+ Hits         3852     4011     +159     
+ Misses        799      797       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Fe-r-oz Fe-r-oz marked this pull request as ready for review December 5, 2024 13:41
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Dec 5, 2024

Please help review this PR, thank you :)

Thanks to GNU for open-souring GLPK. I have tested all the instances of 2bga codes using distance and added other tests for correctness. Many more tests are in #435. Referring to #353 as it's related a issue. This PR aims to provide the first reasonable step. This MIP method is used by Panteleev and Kalachev and by Bravyi et. al.. This MILP method that Bravyi used was also asked on stack exchange. The end goal is to be able to compute minimum distance of QECC/QLDPC codes with n being $10^3$ or $10^4$: QDistRnd or MaxSAT solvers or upcoming algorithms appear to be helpful for that. There is a lot more work to be done in this direction. I will be happy if this PR is one of my PRs you are most excited about, along with in-place Ted's Pauli measurement algorithm PR. :)

Possible Future TODOs include:

@Fe-r-oz Fe-r-oz marked this pull request as draft December 20, 2024 10:30
@Fe-r-oz Fe-r-oz marked this pull request as ready for review December 20, 2024 10:30
@Krastanov
Copy link
Member

This is really interesting and deserving of a bounty.

Regrettably there are a few merge conflicts related to the doc fixes in an earlier PR. Could you fix those?

I also probably would suggest looking into a slightly different API, or at least some easier way to support independent solvers. But that can be discussed after the first round of review.

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

I pushed a few minor changes:

  • making sure the docs build correctly and list the new content
  • a different more idiomatic way to give hints about what needs to be imported
  • other mixed cleanup

Could you:

  • check the changes in my last commit and make sure I have not broken anything
  • fix the existing latex in the docstring you have added (if you render the docs and open the ECC_API page, you will see that your docstring is not formatted correctly (the latex in it is not formatted))
  • add a docstring to the struct where I have left a bunch of TODOs. You can used DocStringExtensions to simplify that by putting a docstring for each struct field (QuantumSavory.ProtocolZoo uses that a lot)

To build the docs locally you can do

cd QuantumClifford.jl
julia --project=docs -e '
            using Pkg
            Pkg.develop(PackageSpec(path=pwd()))
            Pkg.instantiate()';
julia --project=docs -i docs/make.jl
# and then the docs are in the build folder

If you do that you will see that currently there are a few issues:

The admonitions are note rendered correctly:
image

The latex is not rendered (just one example, make sure to correct all of the latex in your pr):

image

There is a missing citation:
image

This is a great addition! We should push it out soon and make sure the bounty for it is claimed.

@Fe-r-oz Fe-r-oz force-pushed the fa/MILPExt branch 2 times, most recently from ec8d3db to 4643f75 Compare May 25, 2025 06:42
@Fe-r-oz Fe-r-oz closed this May 25, 2025
@Fe-r-oz Fe-r-oz reopened this May 25, 2025
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented May 25, 2025

Thank you very much for the amazing improvements and suggestions on the documentation build!! Nothing appears to be broken by the changes.

Regarding LaTeX rendering: I tried building the documentation locally, but since I don’t yet have VSCode installed, I didn’t get the HTML link of documentation after processing the commands. For LaTeX, I used @doc raw""" to avoid escaping \ or $, which hopefully seems to work well.

A few other fixes to the aforementioned issues: resolved the formatting error with !!! note, added the missing citation and followed the QuantumSavory.ProtocolZoo format for the MIPDistanceAlgorithm docstring.

The CI documentation error is unrelated to this PR—it occurs because linkcheck sometimes fails when testing tutorial Jupyter notebook link. Please help review this PR, Thank you!!

@Fe-r-oz Fe-r-oz requested a review from Krastanov May 25, 2025 10:59
@Krastanov
Copy link
Member

Regarding LaTeX rendering: I tried building the documentation locally, but since I don’t yet have VSCode installed, I didn’t get the HTML link of documentation after processing the commands

Not immediately important, but just posting for future reference: VS Code should not be related or necessary for the doc building. You probably did not get the index.html and others because your doc build failed. If that is the case, it will report why it failed. You can just add exceptions to those failures in the config in main.jl, e.g. warnonly = [:some_other_reason, ...] and checklinks=false.

Copy link
Member

@Krastanov Krastanov left a comment

Choose a reason for hiding this comment

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

Thanks! This looks great. One last comment left below.

After you address that comment, please go ahead and officially claim the bounty, no need to wait for review. It would be convenient for me if you make the claim promptly, as otherwise some of the processing can be significantly delayed.

src/ecc/ECC.jl Outdated
Comment on lines 145 to 149
"""when `true` (default=`false`), computes the code distance for each logical qubit and returns the minimum value across all
logical operators of the specified type (`X` or `Z`)"""
all_logical_qubits::Bool=false
"""type of logical operator to consider (:X or :Z, defaults to :X) - both types yield identical distance results for CSS stabilizer codes."""
logical_operator_type::Symbol=:X
Copy link
Member

Choose a reason for hiding this comment

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

Probably last comment on this:

These two configuration options are not "orthogonal". Can we simplify them a bit. For instance, it looks like we can just completely drop all_logical_qubits as logical_qubit === nothing can already unambiguously mean "all logical qubits".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely agree!! Thank you very much!!

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented May 25, 2025

VS Code should not be related or necessary for the doc building.

Thank you for your amazing suggestions!! That's awesome news!!

Thank you very much for helpful suggestion!! Incorporated the code review suggestion and added remaining distance test for the remaining GB codes in (test_ecc_generalized_bicycle_codes.jl) so that the entire testset there does not take more than extra 1 minute. When I test all the GB codes there, it takes total 2 minutes to run the entire set of codes so I left one of them out so extra time < 1 min. Testing individually, it takes ≤ 60s to test distance of each of these GB codes though, within default time limit of solver. Please let me know if there’s anything else that needs to be done!! Thank you!!

@Fe-r-oz Fe-r-oz requested a review from Krastanov May 25, 2025 18:57
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented May 30, 2025

Hi Stefan, Please help review this PR when you have a moment! Once it’s pushed, I’m excited to start working on the satisfiability formulation of minimum distance problem as we discussed in the meeting! Really appreciate your very helpful suggestions in shaping this work! Thank you! 😀

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Jun 11, 2025

I have added AbstractDistanceAlg to the QECCore because the abstract ECC interfaces are now imported from there.

All the tests related to this PR pass. The failing CI JET =true/false tests fail on master CI so they are not related to this PR.

This PR is ready for review! Thank you!

@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Jun 20, 2025

Hi, @Krastanov, just a friendly bump on this PR! Thank you!

@Krastanov Krastanov merged commit da0c37a into QuantumSavory:master Jun 20, 2025
17 of 22 checks passed
@Krastanov
Copy link
Member

Thank you, this is great!

@Fe-r-oz Fe-r-oz deleted the fa/MILPExt branch June 21, 2025 03:39
@Fe-r-oz
Copy link
Contributor Author

Fe-r-oz commented Jun 21, 2025

Thank you! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bounty:400 bug bounty There is an award for solving this issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants