Skip to content

Add Volta (SM70) kernels for compensated FP32 inference - #10

Open
chris-edstrom wants to merge 2 commits into
lkarlslund:mainfrom
CareHarmony:sm70-optimizations
Open

chris-edstrom wants to merge 2 commits into
lkarlslund:mainfrom
CareHarmony:sm70-optimizations

Conversation

@chris-edstrom

@chris-edstrom chris-edstrom commented Sep 23, 2026 •

Copy link
Copy Markdown

Adds Volta-specific kernels for --tensor-core-fp32 --flash-fp32, selected at runtime on compute capability 7.x (LAYA_SM70=0/1 overrides). Other GPUs keep the existing graph. The kernels are compensated FP16-WMMA flash attention with local-window tile skipping, fused residual/LayerNorm/rotary kernels, and a shape-based cuBLAS algorithm choice.

Verification (Tesla V100, CUDA 12.9): CTest passes, including extended attention tests up to 1024 keys. The CPU-only build and Python tests also pass. Acceptance at batch 1–8 and the edge cases in tests/model-requests.json pass for english and typed-decisions. HTTP/CLI parity passes for english and typed-decisions. Paired sweep: english +12–32%, typed-decisions +18–44%.

Limitations: the baseline was PyPI laya 0.3.6 with its temperature clamp removed to match native calibration, not the recorded baseline revision. Multilingual fraud-08 differs by 0.0002 at batch ≥2 in the base build too, so multilingual acceptance, the paired sweep and HTTP validation can't complete; CLI timing shows +32–47%. Not run on Blackwell or Vulkan.

🤖 Generated with Claude Code

chris-edstrom and others added 2 commits September 23, 2026 01:49
On compute capability 7.x with --tensor-core-fp32 --flash-fp32, select
dedicated kernels adapted from the Flash-V100 design:

- Flash attention with FP16 WMMA, FP32 accumulation and an FP32 online
  softmax. Both operands are compensated (hi*hi + hi*lo + lo*hi), and
  local layers visit only key tiles inside the +/-64 window. This replaces
  the FP32 SGEMM/softmax/SGEMM path used for sequences over 128 tokens.
- Fused residual merge, LayerNorm split and merged rotary packing, so
  compensated products stay unmerged until their consumer.
- Per-shape GEMM tuning over cuBLAS tensor-op algorithms and cuBLASLt
  candidates, timed from a flushed L2 on the first eager run and pinned
  before CUDA graph capture.

Selection happens at runtime; other GPUs keep the existing graph.
LAYA_SM70=0/1 overrides the selection and LAYA_SM70_GEMM_TUNE=0 keeps the
default GEMM algorithm. The attention test covers the new kernel up to
1024 keys in global and local modes.

Tesla V100, all three models pass validation at batch sizes 1-8 (the
multilingual fraud-08 difference is pre-existing). Throughput improves
12-56% on the acceptance corpus, and 8 x 1024-token batches run 29-42%
faster.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Timed per-process tuning could pin different cuBLAS algorithms in the HTTP
server and the CLI, breaking exact HTTP/CLI parity in
benchmarks/http_validate.py (multilingual, batch 1). Select the algorithm
from the shape instead: CUBLAS_GEMM_ALGO3_TENSOR_OP for 2048+ columns when
M <= 4096, where the default choice regresses by up to 50% on V100, and the
default algorithm otherwise. Timed tuning remains available with
LAYA_SM70_GEMM_TUNE=1 and is documented as reproducible only within one
process.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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