Skip to content

[NPU] Support GLM-5.2 DSpark loading - #38860

Open
yuejiat0416 wants to merge 3 commits into
sgl-project:mainfrom
yuejiat0416:feat/glm52-dspark-npu-upstream
Open

yuejiat0416 wants to merge 3 commits into
sgl-project:mainfrom
yuejiat0416:feat/glm52-dspark-npu-upstream

Conversation

@yuejiat0416

@yuejiat0416 yuejiat0416 commented Sep 10, 2026

Copy link
Copy Markdown

Motivation

Enable GLM-5.2 DSpark with a Speculators-format dense BF16 draft and a ModelSlim QuaRot target on Ascend NPU. The draft export needs configuration translation, and its original-coordinate vocabulary and target-feature projection must remain compatible with the rotated target.

This draft PR targets static DSpark. Single-node/two-node colocated validation and performance results are being completed. Full accuracy evaluation results will be added to this PR in a follow-up update. Compact mode support will be implemented in a separate follow-up PR.

Depends on sgl-kernel-npu #791 for head_dim=192. Development testing uses the candidate split_qkv_rmsnorm_rope.py through a process-local Python package overlay; the binary library and other modules remain from the image-installed sgl-kernel-npu package. A released package version or reproducible image that includes #791 for normal installation is still TODO; the existing image is not claimed to contain this change.

Modifications

  • Normalize supported nested Speculators configurations, preserve the DSpark architecture, translate capture layer IDs once, and reject conflicting aliases. Preserve native configuration and LongCat loading.
  • Add opt-in SGLANG_NPU_GLM_DSPARK_QUAROT=original for an NPU GLM DSA ModelSlim QuaRot target with an unquantized dense draft. The default remains disabled; original declares that the draft checkpoint has not already been converted.
  • Create and load the draft's own embedding/LM head through the existing loader. Use the same embedding in the proposal and model entry points.
  • At load time, fold each newly read FC block as F_i @ Q on CPU in FP32 and store the original dtype. Validate the initial vocabulary/FC inputs; retain existing loader requirements on later reloads.
  • Add regression coverage for configuration, quantization selection, loading, QuaRot conversion, vocabulary parallelism and embedding dispatch in eight CPU-registered test files.

The DFlash backbone and NPU fused-QKV call, DSpark proposal/verification/commit flow, and source checkpoints are preserved. The stored Q is not assumed to have an exact floating-point inverse. Independent vocabulary modules add device memory, and FC conversion adds startup work; both costs need measurement.

Accuracy Tests

PR head: 421ed1731176a33353b9a8a91a33bda6bb96b9b6; merge base: dc2157dcd62d5fb1bc5317fcf8765ebfcd8a8dad.

Local CPU: 117 tests and 95 subtests passed across the eight affected test files on this PR head. This includes 51 new test methods and existing tests in test_hf_transformers.py. Tests use CPU arithmetic, Gloo where applicable, and selected NPU mocks; this is not NPU execution or GitHub CI validation.

PYTHONPATH=python HF_HUB_OFFLINE=1 python -m pytest -q \
 test/registered/unit/configs/test_dspark_quantization_config.py \
 test/registered/unit/model_loader/test_dspark_npu_quarot_loading.py \
 test/registered/unit/model_loader/test_dspark_weight_loading.py \
 test/registered/unit/models/test_dflash_npu_qk_norm_rope.py \
 test/registered/unit/models/test_dspark_npu_quarot.py \
 test/registered/unit/models/test_dspark_quarot_vocab_parallel.py \
 test/registered/unit/spec/test_dspark_quarot_embedding_dispatch.py \
 test/registered/unit/utils/test_hf_transformers.py

Preliminary NPU results from development runs

Run GSM8K sample accuracy Acceptance: accepted A / proposed P Verification rounds N Requests / concurrency
Two-node colocated deployment on Ascend A3 560T servers; reported on 2026-09-10 9/10 (90%), as reported by the client scorer 7893 / 13008 = 60.678% 1626 10 successful / 1
Earlier single-node DSpark static eager run; TP16, DP1 Not scored in the available report 5211 / 8432 = 61.800% 1054 10 successful / 1

Acceptance is sum(A) / sum(P), not the mean of per-request percentages. The earlier run used the first 10 GSM8K test questions with temperature 0 and a 1024-token output limit: 8 requests stopped naturally and 2 reached the limit. Its 61.800% acceptance must not be combined with the later run's 9/10 score as if they came from one run.

For the run reported on September 10, the same-run summary with algorithm/execution mode, TP/DP settings, tested source revisions, output budget and termination details is TODO. The uncredited answer has not yet been classified as incorrect, truncated or unparsed. These are small development samples collected before the PR rebase, not full GSM8K evaluation or validation of the current PR head. Full accuracy evaluation and matched target-only results will be added in a follow-up update.

Final-version validation Status / results
Hardware/topology, public runtime image, CANN, driver, torch/torch_npu, Triton-Ascend and kernel artifact TODO
Reproducible target/draft checkpoint revisions, tokenizer, launch commands and dataset/settings TODO
Single-node colocated: DSpark eager/graph; matched target-only eager/graph and NEXTN graph TODO
Two-node colocated: the same matched modes TODO
GSM8K and GPQA-Diamond quality, separately: correct/total, failed and truncated requests TODO
Acceptance per deployment/dataset/mode: accepted A, proposed P, verification rounds N, ratio sum(A)/sum(P) TODO
Existing native/default-off, ordinary DFlash, target-only/NEXTN and non-NPU regressions in CI TODO

Full-model NPU quality, actual graph replay and broader deployment compatibility remain unverified on the final PR head. Small development smoke results are not presented as a complete quality benchmark.

Speed Tests and Profiling

Matched measurements Results
Single-node and two-node eager/graph: target-only vs DSpark TTFT/TPOT mean and P95, output throughput; NEXTN graph comparator TODO
131072-input/1024-output workload at 0%, 50%, 90% requested prefix hit: actual lengths/hits/tier, load, failures, A/P/N and latency/throughput TODO
FC conversion/total startup time, peak host memory, device memory/KV capacity, draft/operator profile TODO
Existing-path and old-kernel-dimension performance regression checks TODO

Record fixed versions, weights, topology, requests, sampling, concurrency and warmup/cache preparation. Report actual cache hits and graph execution. No speedup claim is made before these results are available.

Checklist

Targeted Ruff 0.15.1 formatting/lint, isort 7.0.0, codespell and syntax/diff checks passed on all 15 changed files without rewriting source. GitHub Lint passed on this head. A separate local full-repository pre-commit run and the remaining CPU/NPU CI are still pending.

  • Complete the final pre-commit checks.
  • Confirm tests follow the test contribution guidance, including test-base conventions.
  • Add public usage and dependency documentation.
  • Provide final-version accuracy and speed results.
  • Complete code-style review, including the frozen dataclass container convention.

Review and Merge Process

Keep this PR as a draft while validation and the kernel dependency are pending. Once ready, follow the maintainer process for code-owner review, authorized CPU/NPU CI, and merge after the required checks and dependency release.


CI States

Latest PR Test (Base): ⏳ Run #34464589708
Latest PR Test (Extra): ❌ Run #34464589499
Latest PR Test (AMD ROCm 10): ❌ Run #34464589834

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

npu quant LLM Quantization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant