← Back to Pull requests

Memory access optimised NTT for BN254 #174

Closed
unknown closed this pull request without merging on Sep 24, 2025 04:17 UTC
View on GitHub
unknown unknown commented on Sep 01, 2025 08:00 UTC
Author

The main addition in this PR is the BN254 NTT which is 1.5x to 2x times faster and uses half the space for the roots vector compared to the implementation in WHIR for the range 2ˆ20 to 2ˆ24. The performance increase is mainly due not fetching roots from memory during the hot loop. By storing the roots in reverse bit order the access pattern for the roots is linear.

The NTT is split into three phases all using the same general strategy (DIT NR). In the last phase the problem size fits within cache and in a future PR it will switch to an optimised strategy.

Other additions in this PR:

  • simple proptest valuetree and strategy to generate valid NTTs for use in tests.

  • Unoptimised inverse NTT
  • Follow ups to this PRs will deal with:

  • Winograd kernels for cached-sized problems

  • Incorporate the optimised block multiplier instead of ark-ff

  • further reduce the size of the roots table

  • caching engine like in WHIR

  • optimise out omega^0 = 1 multiplications
  • Measurements

    On macOS the improvement is 2.25x. When looking at the CPU resource graph there seem to be some unnecessary idles. Moving to a custom schedular instead of Rayon might allow for some extra performance improvment.

    On Raspberry Pi there is a 1.5x-2x improvement. Caveat both WHIR and this ran into thermal throttling on my Raspberry Pi as it doesn't have any heatsink or any cooling.

    Diff: 173 lines (+129 / -44) across 2 files Reviewer: recmo Review duration: 32897m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 173 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.309
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #174"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.3% (MEDIUM) · Higher = larger blast radius
    35.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.0% · Safe to merge
    14.0%