Skip to content

pcs: batch sparse-PD round-0 recompute — O(n_pd·2^L) → O(Σ support + 2^L)#7

Open
SipengXie2024 wants to merge 1 commit into
succinctlabs:mainfrom
SipengXie2024:pr/sparse-pd-round0-batch
Open

pcs: batch sparse-PD round-0 recompute — O(n_pd·2^L) → O(Σ support + 2^L)#7
SipengXie2024 wants to merge 1 commit into
succinctlabs:mainfrom
SipengXie2024:pr/sparse-pd-round0-batch

Conversation

@SipengXie2024

Copy link
Copy Markdown

What

compute_combined_basis_and_target re-swept the full 2^L b_combined array to recompute the round-0 correction after each sparse PackedDirectClaim was scattered. The per-claim assignment overwrites round0_u0/round0_u2 rather than accumulating, so every sweep except the last one was dead work — with n_pd sparse claims the loop cost O(n_pd · 2^L) while only the final sweep's result survived.

This PR scatters all sparse claims first, then does the round-0 reduction once.

Why it is safe

Bit-identical output: F128 addition is commutative (the scatter order doesn't matter), and the overwritten intermediate round0_* values were never observable. Workloads with zero or one sparse PD claim produce identical bytes and identical work.

Measured

Found while profiling a batched SHA-256 Merkle-path workload (MHOT multiproof on our fork) that opens ~9k per-block sparse PD claims at L=23:

  • PCS open: 29.5 s → 0.43 s (68×)
  • end-to-end prove: 34.8 s → 2.0 s

Proof bytes identical before/after.

Tests

All flock-core tests pass (255). No behavior change, so no new tests added.

… + 2^L)

compute_combined_basis_and_target re-swept the full 2^L b_combined to
recompute the round-0 correction after EACH sparse PackedDirectClaim was
scattered. The per-claim assignment overwrites round0_u0/u2 (it does not
accumulate), so every sweep except the last was dead work: with n_pd sparse
claims the loop cost O(n_pd * 2^L) while only the final sweep's result
survived.

Scatter all sparse claims first, then reduce once. Output is bit-identical
(F128 addition is commutative; the overwritten intermediate results were
never observable).

On a workload with many per-block sparse PD claims (~9k claims, L=23,
batched SHA-256 Merkle-path openings), this cut the PCS open from 29.5s to
0.43s (68x) and end-to-end prove 34.8s -> 2.0s. Workloads with zero or few
sparse PD claims are unaffected (identical bytes out).

All flock-core tests pass (255).
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