Skip to content

[Perf] [AMD] dsa: Allow retaining GLM kv_b BF16 under DCP - #46828

Closed
dorado269 wants to merge 1 commit into
sgl-project:mainfrom
dorado269:yihou/dsa-dcp-keep-kvb-bf16-20261027
Closed

dorado269 wants to merge 1 commit into
sgl-project:mainfrom
dorado269:yihou/dsa-dcp-keep-kvb-bf16-20261027

Conversation

@dorado269

@dorado269 dorado269 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem and fix

On gfx950, GLM's BF16 kv_b_proj is automatically converted to FP8. The replicated-Q preparation accepts BF16/FP16 weights, so that conversion prevents --dcp-replicate-q-proj from preparing full-head Q weights and avoiding its per-layer Q all-gather.

Add opt-in SGLANG_DSA_DCP_KEEP_KV_B_BF16=1 to retain BF16 only for GLM target weights on DCP ranks. Default behavior, DCP1 prefill, other architectures, non-BF16 weights and non-gfx95 paths stay on their existing policy. Rebased D22 (636cc68dd0) onto main 8a455f1.

Evidence

Historical isolated benchrun T10, 34K context, recorded step-time reductions of 0.4/1.6/1.7/1.7 ms at N=8/16/24/32, at a cost of about 0.34 GB/GPU in weights. This is the archived combined DCP implementation, not a new benchmark of this main-based revision. No stack throughput is attributed to this flag. Historical serving throughput used simulated MTP acceptance and is not model-correctness evidence.

Validation

PYTHONPATH=python python -m pytest -q test/registered/unit/models/test_glm_dcp_kv_b_dtype.py
pre-commit run --hook-stage pre-commit --files python/sglang/srt/environ.py python/sglang/srt/models/deepseek_common/deepseek_weight_loader.py test/registered/unit/models/test_glm_dcp_kv_b_dtype.py

CPU policy matrix: 1 passed, 72 subtests passed, covering platform, architecture, dtype, DCP width and flag state. This tests dispatch policy, not numerical equivalence or serving performance.

Draft blockers


CI States

Latest PR Test (Base): ❌ Run #40493973640
Latest PR Test (Extra): ❌ Run #40493973621
Latest PR Test (AMD ROCm 10): ❌ Run #40493973643

All applicable local pre-commit hooks and the new-head upstream lint passed. Upstream test execution is still gated by the maintainer-controlled run-ci label; latest PR title check passed.

@dorado269 dorado269 changed the title [Perf] [AMD] Allow retaining GLM kv_b BF16 under DCP [Perf] [AMD] dsa: Allow retaining GLM kv_b BF16 under DCP Oct 27, 2026
@dorado269

dorado269 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing this proposal because the reason for the opt-in has been superseded by #47180 (merged as b50d4394945d3dcacea05ee4afd334a9b225cbdc on November 1).

At current main acd6f5570, ModelRunner._prepare_replicated_q_proj() accepts per-tensor FP8 w_kc / w_vc, applies the rank-local scale in BF16 before the gather, and prepares replicated Q without disabling the default GLM weight quantization. This removes the original need for SGLANG_DSA_DCP_KEEP_KV_B_BF16 to activate replicated Q.

I checked the merged implementation and completed 13 CPU probes against its unchanged helper and loader quantizer: both FP8 formats, scalar and one-element scales, unsupported per-channel scales, BF16/FP16/FP32 controls, and two actual input_to_float8 → absorb-conversion cases. The GLM quantizer returns a zero-dimensional scale; these two production-shape cases return BF16 and match the explicit dequantization reference.

Correction to the initial validation wording: the first probe assumed that a one-element FP32 vector scale also preserves BF16; PyTorch instead promotes that result to FP32. The final probe records this distinction and verifies the loader's actual scalar scale separately. This is CPU conversion coverage only, not distributed gather, GPU, or model-accuracy qualification. #47180 provides its own separately attributed hardware evidence.

Keeping original BF16 weights is numerically different from dequantizing the FP8 weights, so this is not a claim that #47180 implements this flag verbatim. There is no isolated current-main evidence justifying that additional memory/precision option after #47180. Historical T10 measurements cannot establish an incremental benefit over this new baseline. We will not add a redundant option on that basis. The original patch and T10 archive remain preserved for reference.

The trial rebase was stopped after discovering this change; the PR head is unchanged. No replacement PR is needed. The separate PD transport/enablement work remains #46824 and #46826.

@dorado269 dorado269 closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant