Skip to content

[Perf] sampling: JIT softmax and argmax kernels for the sampler and speculative verify - #44752

Closed
DarkSharpness wants to merge 1 commit into
sgl-project:mainfrom
DarkSharpness:sampling-jit-softmax-argmax
Closed

DarkSharpness wants to merge 1 commit into
sgl-project:mainfrom
DarkSharpness:sampling-jit-softmax-argmax

Conversation

@DarkSharpness

@DarkSharpness DarkSharpness commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

(auto generated by Claude)

What

  • New JIT fp32 softmax (sglang.kernels.ops.sampling.softmax): row cached in registers (one read, one write), one row per runtime-sized cluster, per-request temperature fused, safe in place. Used on SM100-family GPUs; other platforms keep Triton (ROCm) / torch.
  • New JIT split-vocab argmax (sglang.kernels.ops.sampling.argmax): ties take the lowest index, NaN never wins.
  • Sampler: temperature + softmax run in place on the logits buffer (drops the div_ and the logits[:] = ... copy); greedy rows use the JIT argmax.
  • EAGLE / DFlash / UNO / DSpark verify use the same ops; EAGLE passes rows_per_request instead of repeat_interleave-ing temperatures.
  • Removes the Cake softmax dispatch, DSpark's fused_argmax switch and the Triton row_argmax (kept in bench_argmax.py as a baseline).

Validation (GB300)

  • Kernel tests, sampler / EAGLE / UNO / DSpark unit tests, and DSpark greedy accept captured in a CUDA graph vs a torch.argmax reference: all pass.
  • bench_softmax.py (fp32, per-row temperature, cold L2), us:
vocab batch ours Cake (FlashInfer 0.7.1) torch
32000 1 2.19 2.93 12.1
163840 1 3.14 4.42 45.7
163840 64 16.7 26.2 77.9
163840 1024 194.1 412.0 867.9
262144 4096 1220 1740 5370
  • bench_argmax.py (vocab 129280), us:
batch ours Triton row_argmax torch
1 2.49 3.46 43.6
64 7.53 9.76 43.5
1024 74.4 97.0 113.5

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ✅ Run #39610288367
Latest PR Test (Extra): ❌ Run #39610288299
Latest PR Test (AMD ROCm 10): ❌ Run #39610288322

@github-actions

This comment has been minimized.

@DarkSharpness DarkSharpness added the run-ci CI: run the baseline test suite on this PR label Oct 16, 2026
@DarkSharpness DarkSharpness changed the title [Sampling] JIT softmax and argmax kernels for the sampler and speculative verify [Perf] sampling: JIT softmax and argmax kernels for the sampler and speculative verify Oct 17, 2026
@DarkSharpness
DarkSharpness force-pushed the sampling-jit-softmax-argmax branch 4 times, most recently from 621ce1f to 9c48977 Compare October 19, 2026 12:39
@DarkSharpness DarkSharpness added the bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) label Oct 19, 2026
@DarkSharpness
DarkSharpness force-pushed the sampling-jit-softmax-argmax branch 4 times, most recently from 2b5d04a to 6cb09dc Compare October 21, 2026 12:39
@github-actions

This comment has been minimized.

…tive verify

- Add JIT fp32 softmax (fused per-request temperature, in place) and split-vocab argmax kernels under `sglang.kernels.ops.sampling`.
- `Sampler` fuses the temperature into an in-place softmax and uses the JIT argmax for greedy rows; EAGLE / DFlash / UNO / DSpark verify use the same ops.
- Drop the Cake softmax dispatch and DSpark's Triton `row_argmax` (kept as a benchmark baseline).
- Add softmax / argmax benchmarks and an argmax test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DarkSharpness
DarkSharpness force-pushed the sampling-jit-softmax-argmax branch from 6cb09dc to eea9a0c Compare October 21, 2026 13:42
DarkSharpness added a commit to DarkSharpness/sglang that referenced this pull request Oct 31, 2026
…ve verify

Add a JIT row softmax (fp32 / bf16 / fp16 logits to fp32 probs, fused per-request temperature, one row per thread-block cluster held in registers, config chosen from the compiled candidates' real occupancy) and a JIT row argmax (int64, ties to the lowest index, NaN never selected). Wire them into the sampler (fused temperature, in-place probs, greedy argmax) and the speculative verify paths (EAGLE rows_per_request, EAGLE / DFlash / UNO / fast_sample / DSpark argmax); drop the DSpark per-model fused_argmax opt-in. Rename temperature_softmax.py to softmax_triton.py.

Supersedes sgl-project#44752.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant