Skip to content

About

Requant Network research: MSM bucket accumulation over BN254 via exact INT8-limb tensor-core GEMM (Blackwell SM120)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

gpu-msm-tensorcore

MSM bucket accumulation over BN254 G1 via exact INT8-limb tensor-core GEMM.

Status: COMPLETE — bounded spike, all correctness checks pass. A prover-side windowed-MSM bucket-accumulation sub-phase is expressed as an exact INT8-limb GEMM and run on native Blackwell (SM120) INT8 tensor cores, then compared against a SIMT scatter-add baseline. This is not a full GPU MSM.

Direct answer to the research question

Can the bucket-accumulation phase of windowed MSM over BN254 G1 be expressed as exact INT8-limb tensor-core GEMMs, and how does it compare to a SIMT scatter-add baseline?

  • Yes, exactly — for the linear coordinate-limb accumulation sub-step. Bucket coordinate sums are C = U × L with a 0/1 one-hot bucket-indicator U and a base-128 coordinate-limb matrix L. Because U is 0/1, every GEMM output is a plain sum of ≤ N limbs (each ≤ 127), exact in INT32 whenever N·127 < 2^31. Verified bit-exact against an independent pure-Python oracle: 36/36 cases, both coordinates, plus every bucket limb-sum; 3/3 negative controls detected.
  • Faster than SIMT scatter-add on that sub-phase: cuBLAS IGEMM (native SM120 INT8 tensor cores) is ~10×–47× faster at c=4 and ~1.3×–3× faster at c=8.
  • Important scope limit (honest negative): a sum of point coordinates is a linear aggregate, not the elliptic-curve group bucket sum. The nonlinear bucket group additions + window aggregation stay on the CPU in this spike and dominate total cost (0.26–17.8 s vs sub-ms GPU accumulation). So the GEMM speedup does not, by itself, accelerate a full MSM here.

What has actually run (measured, not extrapolated)

Item Result
GPU NVIDIA GeForce RTX 5060 Ti (GPU 0), SM120 / compute cap 12.0, driver 13030, cuBLAS 130600
Build nvcc -arch=sm_120 (CUDA 13.3); CMP 50HX (Turing) never used
Native INT8 TC proof cuBLAS dispatches nvjet_sm120_bii_mma_..._tmaAB_... (nsys); WMMA SASS = IMMA.16816.S8.S8 (cuobjdump)
Correctness 36/36 PASS (N∈{64,1024,4096} × c∈{4,8} × seeds{11,29} × 3 paths)
Negative controls corrupted limb + wrong bucket detected on all 3 paths
Timing 24 resident-median cases, N∈{1024,4096,16384,65536} × c∈{4,8}, 3 paths
Peak VRAM < 4 GB (largest one-hot buffer 512 MiB; see results/vram_probe.txt)
CPU costs recombination + group additions measured separately (8 cases)

Headline accumulation timings (median ms, cuBLAS IGEMM vs SIMT scatter):

N c=4 cuBLAS / SIMT c=8 cuBLAS / SIMT
1024 0.0178 / 0.1802 (10.1×) 0.0293 / 0.0876 (3.0×)
4096 0.0277 / 0.7309 (26.4×) 0.1260 / 0.3131 (2.5×)
16384 0.0893 / 4.1924 (46.9×) 0.9032 / 1.2091 (1.3×)
65536 0.7573 / 14.3776 (19.0×) 3.7560 / 4.8706 (1.3×)

Full tables: RESULTS.md. Method + math: METHODS.md. Conclusions + next steps: FINAL_REPORT.md.

Scope and limitations (read this)

  1. Accumulation phase only. The GPU computes per-bucket coordinate-limb sums (a linear aggregate). It does not compute group bucket sums or do the window/bucket point additions — those are CPU-side here.
  2. Coordinate sums ≠ group sums. Σ x_i (mod p) is not the x-coordinate of Σ P_i on the curve. The hybrid pipeline recombines limbs mod p and then does the real group additions on CPU; only then does it equal the oracle MSM point.
  3. Dense one-hot GEMM. U has density 1/2^c; the GEMM does 2^c× more MACs than strictly needed. It still wins (tensor cores are fast; SIMT atomics contend), but a sparse-aware kernel is an open improvement.
  4. WMMA path is untuned. The hand-written WMMA kernel is SASS-verified native but slower than the tuned cuBLAS nvjet kernel (and slower than SIMT at large N, c=8). cuBLAS IGEMM is the headline tensor-core result.

Related work (cited, not re-run)

  • requant-network/Abacus — candidate C: MSM/KZG verifier-side GPU work only; no prover GPU work. This study is prover-side and distinct.
  • requant-network/gpu-exact-tensorcore: INT8-limb GEMM technique for wide moduli. This study reuses that exact-limb idea but applies it to a new construction (one-hot bucket accumulation) and a new phase (prover MSM).

Repository layout

bn254.py                 BN254 F_p / G1 arithmetic + base-128 limbs (pure stdlib)
msm.py                   unsigned-window bucket MSM oracle + limb reference
gpu_accum.py             ctypes driver for libmsmaccum.so
cuda/msm_accum.cu        3 paths: cuBLAS IGEMM / WMMA s8 / SIMT scatter + resident timing
cuda/build.sh            nvcc sm_120 build + SASS census
run.py                   full bounded campaign -> results/campaign.json
experiments/smoke.py     quick 3-path exactness smoke
experiments/probe_vram.py resident VRAM footprint probe
experiments/make_report.py  regenerate RESULTS.md from campaign.json
tests/test_msm.py        stdlib CPU tests (oracle, limbs, negative controls)
results/campaign.json    pinned measurements + GPU identity + source SHA-256
results/vram_probe.txt   VRAM probe output
evidence/                SASS dump + nsys kernel summary + cuBLAS kernel name

Reproduce

# CPU tests (anywhere, no GPU/numpy):
python3 -m unittest discover -s tests -v

# On the server (GPU 0, Blackwell), under the shared lock:
bash cuda/build.sh                       # nvcc -arch=sm_120 -> libmsmaccum.so + SASS census
CUDA_VISIBLE_DEVICES=0 PYTHONPATH=. \
  flock /tmp/requant-new-studies-gpu.lock python3 run.py ./libmsmaccum.so
python3 experiments/make_report.py       # RESULTS.md from results/campaign.json

All GPU work is pinned to GPU 0 (CUDA_VISIBLE_DEVICES=0) and serialized with flock /tmp/requant-new-studies-gpu.lock. The CMP 50HX (GPU 1, Turing) is never used.

About

Requant Network research: MSM bucket accumulation over BN254 via exact INT8-limb tensor-core GEMM (Blackwell SM120)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages