Skip to content

ling-3.2-air: keep the mma prefill PV accumulator in registers - #146

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/202611270250-ling-mla-mma-regresident
Nov 27, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/202611270250-ling-mla-mma-regresident

Conversation

@maplepaladin73

Copy link
Copy Markdown
Owner

Summary

  • Fully unroll the 16-tile PV loop in ling_mla_prefill_attn_mma so the 64-float accumulator is register-indexed instead of local-memory-indexed.
  • Add __launch_bounds__(128, 4) so the kernel keeps the four-CTA shared-memory occupancy target with only an 8-byte residual spill.
  • Update the MLA fast-path assessment with the root cause; the lane remains explicitly env-gated and is not defaulted on.

Validation

Fingerprint: f341 GB10, Ling-3.2-air-NVFP4, branch commit d76b83af0, release build, ATLAS_TARGET_HW=gb10 ATLAS_TARGET_MODEL=ling-3.2-air, serve flags --max-num-seqs 2 --max-batch-size 2 --no-tui, ATLAS_LING_PREFILL_ROWS=4096, prompt tests/fixtures/bench_prompt_4096.txt (4151 prompt tokens), greedy, max_tokens=1.

  • ptxas -v before: ling_mla_prefill_attn_mma had a 256-byte stack frame; after: 128 registers, 21,760 B smem, 8-byte residual spill.
  • mla_prefill_attn_bench medians, same process/data, preliminary single-harness kernel measurements: at seq_len 512 scalar 4254.7 us vs mma 968.0 us; at 1024 scalar 16274.2 us vs mma 3566.9 us; at 4096 scalar 250931.0 us vs mma 53693.4 us.
  • Warm serve TTFT observed under the fingerprint above: baseline scalar arm 5.122-5.188 s (n=3) vs ATLAS_LING_MLA_PREFILL_MMA=1 arm 3.668-3.705 s (n=3 warm after one JIT warmup request). This is a one-lane A/B observation, not yet a cross-validated production claim.
  • mla_layer5_prefill_fast_parity with ATLAS_LING_MLA_PREFILL_MMA=1: PASS, 25 stage checks clean.
  • cargo build --release -p spark-server --features cuda: PASS.
  • git diff --check: PASS.
  • cargo fmt --all -- --check still reports the pre-existing mla_prefill_attn_bench.rs formatting drift on main; this PR does not touch that file.

Correctness caveat for any future default flip

  • The scalar production lane passed ling-tools-e2e.py 9/9.
  • The env-gated mma lane passed 8/9 twice: the numerically sensitive multi-tool email-copy check emitted ali***@example.com instead of [email protected]. The scalar lane emitted the full address in the same harness. This is consistent with the mma lane's BF16 probability operand changing borderline greedy tokens; it predates this performance fix, but it means the lane must remain opt-in until its numerics are improved or separately acceptance-gated.

Test plan

  • GPU build
  • MLA fast-path parity with mma enabled
  • kernel microbenchmark
  • serve TTFT A/B observation
  • scalar tools e2e 9/9
  • mma tools e2e caveat documented

Generated with Devin

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@maplepaladin73 maplepaladin73 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: diff is minimal and correct — the #pragma unroll on the 16-tile PV loop makes every o_acc index compile-time constant (eliminating the 256 B local-memory frame confirmed in ptxas), and __launch_bounds__(128, 4) caps registers so the 4-CTA occupancy target holds (128 regs x 128 thr x 4 CTAs = exactly the 64K GB10 regfile, with only an 8 B residual spill). Validation evidence in the PR body is appropriately fingerprinted and the correctness caveat (mma lane stays opt-in) is the right call. Lane is env-gated off by default, so zero production risk. LGTM — merging.

@maplepaladin73
maplepaladin73 merged commit 54604f4 into main Nov 27, 2026
@maplepaladin73
maplepaladin73 deleted the devin/202611270250-ling-mla-mma-regresident branch November 27, 2026 03:05
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