perf(ds4): default mixed ROCmFP MMQ prefill on gfx1151

Merged
DA
1mo ago
+2121-143

Summary

Builds on the now-merged #667 and targets main. This makes its registry-aware mixed ROCmFP MMQ prefill path the default on gfx1151 when DS4 uses dense or sparse approximate prefill.

The old path dequantized mixed expert weights and then called BLAS. The direct MMQ path removes that round trip and reduces the 8K trace from 325,841 to 73,165 GPU dispatches.

Exact prefill and non-gfx1151 devices keep their existing behavior. An explicit DFLASH_DS4_MIX_MMQ_PREFILL=0 remains the kill switch.

Historical Strix Halo results

DeepSeek-V4-Flash-0731 ROCmFPX MIX, six routed experts, chunk 3072, sparse prefill, DSpark enabled, cold cache:

PromptBeforeAfterGain
8,192147.9 tok/s (55.4s)209.0 tok/s (39.2s)+41.3%
32,768139.5 tok/s (234.9s)185.8 tok/s (176.4s)+33.2%
122,879105.7 tok/s (1162.7s)129.35 tok/s (950.0s)+22.4%

The historical 8K result was a matched same-code kill-switch A/B. The longer comparisons used the same model, service flags, tokenizer-built prompt, and HTTP workload from the pre-change #667 captures. All measured contexts in that sweep produced the same response SHA-256: 16fbd7d1f18d2fedb247d73edc3bc6aa040f5ab99bd3b48c35b79e543d22179b. These are not fresh results for the current head.

The gain narrows with context length because sparse attention becomes the remaining dominant cost. This does not claim Vulkan parity yet.

Reuse and safety

  • The optimized loaders remain generic mixed-ROCmFP qtype MMQ code; this PR only adds a qualified DS4/gfx1151 default policy.
  • Future model backends can select the same path after model/device qualification.
  • Exact mode is not enabled automatically because MMQ changes reduction and codebook-quantization topology.
  • Explicit environment policy is preserved, including the value 0 kill switch.

Historical verification

  • HIP dflash_server and test_deepseek4_unit build
  • test_deepseek4_unit on gfx1151
  • test_inference_profile
  • test_observability
  • test_qwen35_roctx
  • test_seq_engine_contract
  • test_deepseek4_roctx
  • test_server_unit: 431 passed, 0 failed
  • Clean full API context sweep at 8K, 32K, and 122,879 tokens

September 8 fix verification

The fixes through ed09c8682 make automatic mixed-MMQ selection model/graph-local, remove the Windows HIP environment mutation, reconcile this PR with current main, and propagate the policy through cached/hash-routed and single-token fallback graphs. The streaming-attention tests now verify actual kernel launches. The optimized kernels and explicit disable switch are retained.

Fresh lucebox8 gfx1151 validation: 494/494 CTest entries passed (489 server-unit entries plus affected DS4/MMQ/grouped-MMID/fused-combine and negative-option tests). HIP server and test builds passed.

Matched 8K prose-task regression check, old PR head 710315f44 versus final head ed09c8682: two cold requests per build/mode, identical input token IDs, six routed experts, 256 output tokens, sparse approximate prefill, chunk 3072, caches disabled. Throughput is total tokens divided by total API-reported stage time.

Mode / stageBefore (tok/s)Fixed head (tok/s)Change
AR prefill208.99219.38+5.0%
AR decode20.1020.83+3.6%
Adaptive DSpark prefill208.27218.98+5.1%
Adaptive DSpark decode17.5719.05+8.4%

Adaptive runs use confidence-driven width (cap 4), fused verification and F16 KV in both builds. These results show no slowdown in this small regression sample; they do not isolate the policy fix from other changes brought in from main. Outputs are not byte-identical between builds, and adaptive decode remains slower than AR on this task. No fresh 128K or Vulkan comparison was performed.

Still draft pending fresh CI/Cubic review, broader output-quality and long-duration stability qualification.