r/LocalLLaMA • • Oct 12 '26

Tutorial | Guide Bit-exact speculative decoding on Qwen3.8-27B: 106 t/s on one RTX PRO 6000

Follow-up to my earlier post on Qwen3.8-27B decode speed: https://www.reddit.com/r/LocalLLaMA/comments/1vuli3h/

Some people asked for the recipe, it's at the bottom.

That post said "lossless". I meant BF16 weights and BF16 KV, and that part holds. The outputs didn't match no speculation, though. I checked token ids, not text.

vLLM nightly, DFlash2 k=9 + XQA, BF16, temp 0, one request at a time, a LoRA loaded but not used, 24 prompts, 10,496 tokens:

  • speculation on vs off: 15 of 24 prompts differ
  • --max-num-seqs 1 vs 32, no speculation: 21 of 24 differ
  • a different attention backend: 20 of 24 differ

So a capacity setting moved more outputs than speculation did. I haven't found why.

On SGLang, deterministic mode alone isn't enough. With speculation on, 19 of 24 prompts still gave different tokens and all 24 had different logprobs. Two changes to verify fixed it:

  1. Verify runs the GDN recurrence through the decode kernel. The old verify kernel tiled the state in a different order and kept beta in fp32.
  2. Verify attention runs as decode rows, one per draft position.

With both, 24 of 24 prompts match no speculation, every token id and every logprob. Same with every draft forced to reject (24 of 24), with 8 requests in flight (24 of 24), and on 3 long prompts up to 128k (3 of 3).

To get the same result run after run you also need a DeepGEMM fix. Without it, 25 of 1,200 requests sent in batches of 8 came out different, and single prompts of 560 to 740 tokens did in 5 to 15% of runs.

Deterministic mode was also slow: 18.0 t/s without speculation, against 26.4 stock. DeepGEMM's sm120 bf16 kernel reads the weights at about a third of DRAM bandwidth at small batch. My PR sends those GEMMs to a Triton tile that gives the same bits: https://github.com/sgl-project/sglang/pull/42145. With it, exact decode without speculation is 27.7 t/s.

Decode t/s, single stream, temp 0, one RTX PRO 6000 Blackwell Max-Q:

setupshort prompts2.2k tokens128k tokens
SGLang, no speculation26.426.623.2
vLLM, DFlash2 k=9 + XQA (not exact)109.867.456.1
SGLang deterministic + DFlash 8 + patches + my PR (exact)106.673.942.6

Exact is 3% behind vLLM on short prompts, ahead at 2k, 24% behind at 128k. Prefill is slower too: 68.5 s to first token on a 128k prompt, vs 44.3 s on vLLM.

I need this because I compare quants and engines on task quality. If the engine drifts by itself, I can't tell that apart from the change I'm testing.

Recipe:

Launch:

python -m sglang.launch_server --model-path Qwen/Qwen3.8-27B \
  --enable-deterministic-inference --attention-backend triton \
  --speculative-algorithm DFLASH --speculative-draft-model-path incoai/Qwen3.8-27B-DFlash2 \
  --speculative-num-draft-tokens 8 --mamba-ssm-dtype float32 \
  --max-running-requests 8 --chunked-prefill-size 8192 --mem-fraction-static 0.88 \
  --context-length 262144 --disable-radix-cache
0 Upvotes

6 comments sorted by

1

u/stargate425 Oct 13 '26

Patches, measurements and limits also in a repo: https://github.com/bill-h-lin/sglang-exact-spec-decode

1

u/Aimfish Oct 12 '26

Have you seen this before?  https://github.com/jpezzulli/sglang-rtxpro6000

Might also have some tweaks to speed up yours as well (it's similar, but your stuff plus things here might add up?).

1

u/stargate425 Oct 12 '26

Yeah, saw it a couple of days ago. Their 27B profile runs FP8 weights and FP8 KV. That's a fine trade for serving, but I need BF16 here, since the point is a reference I can compare quants against. FR-Spec and the adaptive draft width are on their Flash-Next profile, not on 27B with DFlash2.

Draft-side changes should stack with this. With the two verify changes the output doesn't depend on what the draft proposes: with every draft forced to reject it still matched 24 of 24. So a better draft only changes speed. I haven't tried a different draft width.

FP8 with the same verify changes might still match FP8 without speculation. I haven't measured that, and the FP8 GEMMs would need the same batch-invariance check the BF16 ones needed.

1

u/geoffreybyers vLLM Oct 15 '26

Determinism at the hardware level is a myth. A capacity setting like max-num-seqs moves more bits than the speculative mechanism itself. The software layer can't fix what the hardware won't promise.

1

u/stargate425 Oct 15 '26

The patched stack is a counterexample. 0 of 1,200 batched requests differed run to run, and speculation on vs off matched on every token id and logprob.

The GPU gives the same result for the same instructions in the same order. What a setting changes is which instructions run: a different batch shape can pick a different GEMM tile or split, so the same sums get added in a different order. That's software, and it's what batch-invariant kernels pin down.

The one run-to-run difference I found wasn't the hardware either. DeepGEMM's sm120 kernel handed a shared-memory buffer back to the loader before its reads of it had finished. A four-line fence fixed it: 25 of 1,200 differed without it, 0 with it.

And the counts don't rank the changes by size. In the vLLM runs every divergence was at a near-tie (top two tokens within 0.25 logprob), and on 15 of 24 prompts two unrelated changes first diverged at the same token. Almost any change to rounding flips the same tokens. I still don't know what max-num-seqs changes inside vLLM.