Skip to content

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
succinctlabs:mainfrom
SipengXie2024:pr/eq-sparse-one-pinning
Draft

ring_switch: pin exact-ONE coords in build_eq_sparse (boolean points collapse to one tensor entry)#8
SipengXie2024 wants to merge 1 commit into
succinctlabs:mainfrom
SipengXie2024:pr/eq-sparse-one-pinning

Conversation

@SipengXie2024

Copy link
Copy Markdown

What

build_eq_sparse already 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 is c_i (0 on the c_i=0 branch, 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_mask on SparseEqTensor; scatter_idx ORs the mask into the reconstructed full index. Everything else (consumers, scatter paths) is unchanged.

Why it matters

PackedDirectClaim points derived from block/slot geometry are fully boolean vectors. Under zero-only pinning their sparse tensors still materialize 2^(#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 dense build_eq reference. All flock-core tests pass (256).

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
SipengXie2024 marked this pull request as draft July 20, 2026 06:06
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.

1 participant