Skip to content

Add ReedMullerCSSCode: self-orthogonal CSS(RM(r,m),RM(r,m)) codes with closed-form distance - #567

Merged
perlinm merged 3 commits into
qLDPCOrg:mainfrom
sdoygb:reed-muller-css
Aug 19, 2026
Merged

Add ReedMullerCSSCode: self-orthogonal CSS(RM(r,m),RM(r,m)) codes with closed-form distance#567
perlinm merged 3 commits into
qLDPCOrg:mainfrom
sdoygb:reed-muller-css

Conversation

@sdoygb

@sdoygb sdoygb commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Closes #566

Adds ReedMullerCSSCode(order, size), the self-orthogonal CSS code family CSS(RM(r,m), RM(r,m)) with parameters

[[2**m, 2**m - 2*sum_{j=0}^{r} C(m,j), 2**(r+1)]]   for  2r < m-1.

Construction. Stabilizer generators are the rows of the RM(r,m) generator matrix. When 2r < m-1, RM(r,m) is strictly self-orthogonal (RM(r,m) ⊆ RM(r,m)^⊥ = RM(m-r-1,m)), so the generators are pairwise orthogonal and the CSS construction is valid. The quantum dimension 2**m - 2*dim(RM(r,m)) follows automatically from the matrix ranks.

Closed-form distance. Both X- and Z-distance equal 2**(r+1), the minimum weight of a vector in RM(m-r-1,m) \ RM(r,m), attained by the indicator vector of an affine (r+1)-flat in AG(m,2) (MacWilliams & Sloane, Ch. 13). _get_distance_exact returns this value in O(1), replacing the exponential enumeration in the general distance algorithm. promise_equal_distance_xz=True since X- and Z-distances provably coincide.

Cross-validation. The weight-4 X-logical counts for [[32,20,4]] (1240) and [[64,50,4]] (10416) match the anchors independently verified in the qec-distance-certificates package.

Tests. Parameter table ((0,2)→[[4,2,2]], (1,4)→[[16,6,4]], (1,5)→[[32,20,4]], (2,6)→[[64,20,8]], (2,7)→[[128,70,8]], (3,8)→[[256,70,16]], (2,10)→[[1024,912,8]]), self-orthogonality H_x H_z^T = 0, closed-form vs brute-force distance agreement on small codes, and invalid-parameter rejection (2r ≥ m-1 cases, incl. the k=0 boundaries (1,3), (2,5), (3,7)).

Related to #434 (logical error rates): this family is "directionally complete" — every single-qubit Pauli has a distinct syndrome — so logical operator error rates admit closed forms.

References:

Self-orthogonal CSS code family CSS(RM(r,m), RM(r,m)) with parameters
[[2^m, 2^m - 2*sum_{j<=r} C(m,j), 2^(r+1)]] for 2r < m-1.

- Stabilizer generators: rows of the RM(r,m) generator matrix
  (pairwise orthogonal since RM(r,m) is strictly self-orthogonal)
- Closed-form distance 2^(r+1) via Reed-Muller minimum-weight theorem,
  making distance evaluation O(1) instead of exponential in block length
- X/Z distances equal; promise_equal_distance_xz=True
- Closes qLDPCOrg#566
@perlinm

perlinm commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the contribution! I'll try to review soon. Meanwhile, could you please change the name to QuantumReedMullerCode for consistency with conventions elsewhere in the library (such as HammingCode/QuantumHammingCode)?

@sdoygb

sdoygb commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Done — renamed to QuantumReedMullerCode, following the HammingCode/QuantumHammingCode convention. The rename covers the class definition, the qldpc.codes export, the unit tests, and the usage in the example notebook on the other PR branch. The three reed-muller tests pass locally. Thanks for the review!

@perlinm perlinm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just one nit, otherwise looks good to me!

Please just run ./checks/format_.py --fix and ./checks/lint_.py --fix to fix the formatting/lint checks before merging 🙂

Comment thread src/qldpc/codes/quantum.py Outdated
self._order = order
self._size = size
generator = np.atleast_2d(ReedMullerCode.get_generator(order, size))
super().__init__(generator, generator, is_subsystem_code=False, promise_equal_distance_xz=True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: if you pass the same generator matrix for X and Z, there's no need to explicitly set promise_equal_distance_xz=True

Suggested change
super().__init__(generator, generator, is_subsystem_code=False, promise_equal_distance_xz=True)
super().__init__(generator, generator, is_subsystem_code=False)

@sdoygb

sdoygb commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the lint failures from the previous CI run (all were introduced by this PR):

  • ruff check: 4x W605 invalid escape sequences in the QuantumReedMullerCode docstring (\R etc.) -> switched to a raw docstring
  • ruff format: wrapped the super().__init__(...) call to fit line length + isort ordering of __all__ (QuantumReedMullerCode before QuditCode)
  • mypy was already green on the previous run ("no issues found in 80 source files")

The new CI run for daa9ac1 is sitting in action_required state (awaiting workflow approval for this new head commit). Could you approve it so the checks can run?

@perlinm

perlinm commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Done. Feel free to merge if+when the checks pass.

@perlinm
perlinm merged commit 6e1c4cd into qLDPCOrg:main Aug 19, 2026
6 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.

Feature: directionally complete self-orthogonal CSS(RM(r,m), RM(r,m)) code family with closed-form distance

2 participants