Skip to content

cuda: launch Qwen's FP8 RoPE plain under PDL, so fp8 KV tokens match PDL off (#5308) - #5353

Merged
ashhart merged 4 commits into
mainfrom
lead/qwen-fp8-rope-pdl
Nov 27, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/qwen-fp8-rope-pdl

Conversation

@ashhart

@ashhart ashhart commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Fixes #5308. Since v1.3.5, TF_QWEN_PDL is on by default on sm_12x. With --kv-cache fp8 (and the reporter's --prompt-precision int8), greedy replies changed and drafted no longer equalled plain; TF_QWEN_PDL=0 was exact.

Cause: the FP8 RoPE kernel (rope8) was launched as a programmatic dependent launch, but its body has no dependency-wait prologue. It could start while the preceding norm was still writing the K rows it reads, so the FP8 K-cache bytes depended on timing. The fix launches rope8 plain; every other launch, and the whole default bf16 path, is unchanged.

Evidence on one GB10 (sm_121), Qwen3.8-27B MLX 4-bit, the reporter's exact recipe (--context 32768 --parallel 1 --prompt-cache-gib 0), four greedy requests per arm, done shas:

Build fp8 KV + int8 prompt, PDL on fp8/int8, PDL off default flags, PDL on or off
main eb415dcbaf6e ffd8ce19a679 f28349df6aca 2c73c3410e76 (plain), ... 14c292d669bb a372f7da4806 b9f60e4f767b (drafted) eb415dcbaf6e 32770168799b 4b07984a0d32 e54a38dcef83 same as PDL off
this PR eb415dcbaf6e 32770168799b 4b07984a0d32 e54a38dcef83, plain and drafted same same

The PDL-off shas match the reporter's RTX 5090 results exactly. contract_qwen_pdl.zig adds a launch-table regression that fails on main (the FP8 RoPE launch carried the dependent attribute) and an int8-to-FP8 PDL on/off output-bytes contract for the device.

FP8 RoPE has no dependency wait, so a dependent launch can read Kn before the preceding K-head norm finishes. Keep only that launch stream-ordered; all proven-safe PDL launches stay unchanged. Add a recording host regression and a GB10 int8-prompt/FP8-KV byte-parity stress contract.
@ashhart
ashhart force-pushed the lead/qwen-fp8-rope-pdl branch from 0bae6dd to 331db47 Compare November 27, 2026 13:01
@ashhart
ashhart merged commit 0447036 into main Nov 27, 2026
1 check failed
@ashhart
ashhart deleted the lead/qwen-fp8-rope-pdl branch November 27, 2026 13:01
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.

qwen3_5 cuda: v1.3.5's default TF_QWEN_PDL changes greedy replies on an RTX 5090 (sm_120), drafted and plain; TF_QWEN_PDL=0 is exact

1 participant