Skip to content

Optimize exact-scan MPC threshold primitives - #138

Merged
philsippl merged 1 commit into
mainfrom
codex/cpu-linear-scan-primitives
Aug 24, 2026
Merged

Optimize exact-scan MPC threshold primitives#138
philsippl merged 1 commit into
mainfrom
codex/cpu-linear-scan-primitives

Conversation

@philsippl

Copy link
Copy Markdown
Contributor

Summary

  • add packed three-way MSB extraction matching the GPU threshold-ring circuit
  • add a direct 18-bit circuit for the fixed anonymous-statistics FHD threshold instead of lifting every dense comparison into the 32-bit arithmetic ring
  • fuse the independent mask-carry and threshold-expression adders into shared communication rounds
  • refresh interleaved Galois-ring dot contributions directly into packed Rep3 components and materialize scalar code/mask shares only for public candidate indices
  • preserve multi-flow session striping for batch-size-one workloads and stop clamping physical connections to the logical session count
  • remove the benchmarked-but-inferior session-affine transport path

Why

The CPU linear scanner evaluates every first-eye candidate and needs threshold checks to remain parallel across an entire chunk. The generic lift/multiply/MSB path introduced unnecessary memory traffic and sequential MPC rounds. These primitives expose the GPU-equivalent threshold circuit to the CPU implementation while preserving the existing PRF use and wire semantics.

Consumed by worldcoin/iris-mpc#2347.

Correctness and validation

  • cargo test -p ampc-actor-utils: 74 passed, 0 failed
  • deterministic generic-vs-direct FHD threshold coverage
  • randomized direct anonymous-threshold vs lifted-reference coverage
  • fused Galois-to-Rep3 path checked against the dense path
  • candidate selection checks preserve order and duplicate indices
  • git diff --check origin/main...HEAD

End-to-end performance

Measured through the dependent Iris MPC implementation with batch size 1 on three AWS r8g.24xlarge instances:

  • full TLS + MPC protocol, normal and mirror included: 5.17–5.20M logical comparisons/s
  • measured traffic: 383.67 bytes/comparison/direction
  • network demand at 5.2M/s: about 16.0 Gbit/s per direction

These are application-level results for the combined AMPC and Iris changes, not an isolated AMPC microbenchmark. Detailed benchmark context is recorded in worldcoin/iris-mpc#2347.

Comment thread ampc-actor-utils/src/protocol/binary.rs Outdated
dkales
dkales previously approved these changes Aug 17, 2026
Comment thread ampc-actor-utils/src/network/mpc/handle/session/mod.rs Outdated
Comment thread ampc-actor-utils/src/protocol/binary.rs Outdated
Comment thread ampc-actor-utils/src/protocol/binary.rs Outdated
dkales
dkales previously approved these changes Aug 17, 2026
@philsippl
philsippl enabled auto-merge (squash) August 20, 2026 11:26
* perf: optimize exact-scan MPC primitives
* perf: fuse exact-scan threshold preparation
* feat: add session-affine connection policy
* Remove inferior session-affine transport
* Remove unused threshold bit calculation
* Address PR review feedback
* chore: fix dependency security checks
@philsippl
philsippl force-pushed the codex/cpu-linear-scan-primitives branch from b1ffb57 to a558365 Compare August 24, 2026 12:48
@philsippl
philsippl merged commit 468f1e1 into main Aug 24, 2026
13 checks passed
@philsippl
philsippl deleted the codex/cpu-linear-scan-primitives branch August 24, 2026 12:56
philsippl added a commit to worldcoin/iris-mpc that referenced this pull request Aug 24, 2026
worldcoin/ampc-common#138 merged; a0b968c4 was its pre-merge head and is
not an ancestor of ampc-common main. Pin 11bcd059, the current main head,
which also carries the #140 threshold-path allocation reductions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAbAnQyfsSrWH6UGcRM1FF
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.

3 participants