ring_switch: pin exact-ONE coords in build_eq_sparse (boolean points collapse to one tensor entry)#8
Draft
SipengXie2024 wants to merge 1 commit into
Conversation
build_eq_sparse already skips exact-ZERO coords (the eq factor is 0 on one branch, so the dimension's bit is pinned to 0 and dropped from the live tensor). The same argument applies symmetrically to exact-ONE coords: the factor is 0 on the c_i=0 branch and 1 on the c_i=1 branch, so the bit can be pinned to 1 and the dimension dropped. Track those bits in a forced_ones_mask that scatter_idx ORs into the reconstructed full index. PD-claim points derived from block/slot geometry are fully boolean, so their eq tensors collapse from 2^(#ones) entries to a single entry. On a workload with thousands of such claims (batched Merkle-path openings at L=23) this took the PD eq tensors from GBs to KBs and end-to-end prove from 30.5s to 13.8s. Non-boolean coords are unaffected. New test covers mixed zero/one/random coords against the dense build_eq reference. All flock-core tests pass (256).
SipengXie2024
marked this pull request as draft
July 20, 2026 06:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
build_eq_sparsealready skips exact-ZERO coords: the eq factor is 0 on one branch, so the dimension's scattered-index bit is pinned to 0 and dropped from the live tensor. The same argument applies symmetrically to exact-ONE coords — the factor isc_i(0 on thec_i=0branch, 1 on the other), so the bit can be pinned to 1 and the dimension dropped just the same.This PR tracks those bits in a
forced_ones_maskonSparseEqTensor;scatter_idxORs the mask into the reconstructed full index. Everything else (consumers, scatter paths) is unchanged.Why it matters
PackedDirectClaimpoints derived from block/slot geometry are fully boolean vectors. Under zero-only pinning their sparse tensors still materialize2^(#ones)entries; with one-pinning they collapse to a single entry.On a workload with thousands of such claims (batched SHA-256 Merkle-path openings at L=23, MHOT multiproof on our fork): PD eq tensors went from GBs to KBs of allocation, end-to-end prove 30.5 s → 13.8 s. Non-boolean coords are unaffected; proof bytes identical.
Tests
New test (
mk_coords_bool+ mixed zero/one/random cases) checks the sparse representation against the densebuild_eqreference. All flock-core tests pass (256).