Skip to content

[Feat] KVShard: Integrate GLM DSA/MTP with PD and CPU HiCache - #42973

Merged
hzh0425 merged 18 commits into
sgl-project:mainfrom
HZY-Wade:codex/kvshard-dsa-hicache
Oct 27, 2026
Merged

hzh0425 merged 18 commits into
sgl-project:mainfrom
HZY-Wade:codex/kvshard-dsa-hicache

Conversation

@HZY-Wade

@HZY-Wade HZY-Wade commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Co-author: @Shunkangz

Connect GLM DSA/MTP serving to page-sharded KV caches so prefill, P/D transfer and CPU HiCache preserve the same ownership for target/draft latent KV and DSA indexer keys/scales.

Dependencies and review scope

Base: upstream main 5987ec82ed. Current head: 346068aaa329cf1692fbb6031f60469fdac77dcb.

DSA attention/indexer support (#44280), MTP pool/scratch support (#40929), and the control-plane/pool/basic-PD prerequisites are already merged.

The remaining unmerged prerequisite is #43778, pinned at 6d1e510b2429a36fe499943ff075472d995d8457. Its three implementation commits are rebased onto this main base with Shunkang's author attribution preserved. The dependency snapshot is 152e93348ad825449c484fbee2068fc614116c67.

Review the integration increment: HZY-Wade/sglang@codex/kvshard-glm-dependencies-20261026-clean...codex/kvshard-dsa-hicache

GitHub's main-based Files changed view also includes #43778. Rust support is separate in #46445; this PR contains no Rust implementation and selects Python for sharded launches when the tree backend is unset.

Modifications

  • Select page-sharded DSA target and single-layer GLM NextN draft pools. Validate matching cache geometry and budget latent/indexer scratch for both runners.
  • Preserve the shared sender lifecycle. Pair source/destination DSA pages before owner filtering, transfer every owner's target/draft state, retain empty-final-chunk completion, and account for physical transfer bytes.
  • Compose a standalone sharded allocation facade with native host pools. Reuse HybridCacheController and L2TransferEngine; resolve owner-local indices through existing preparation hooks before the H2D start event. Preserve logical queue indices and ACK counts.
  • Scope scratch bookkeeping to sharding, cache the controller's sharding flag, retain ordinary transfer descriptor builders, and remove the redundant FULL eviction retry.
  • Pass start_owner to backups only when the tree node has a shard owner. Preserve owner zero and the non-sharded controller's existing call signature.
  • Add a four-GPU GLM P2/D2 E2E with CP2, EAGLE MTP and CPU HiCache. Use fabric NVLink with Mooncake's exportable KV allocator, matching the existing P2/D2 test on the same GB300 runner. CPU tests follow the registered CustomTestCase convention.

Supported configuration: CUDA PD-prefill, interleave CP > 1, PP1, TRTLLM DSA prefill/decode, FP8 E4M3/page64, Mooncake, and uncompressed index_kpool=1. Optional MTP is single-layer GLM NextN EAGLE with topk=1. CPU HiCache uses cache mode, kernel I/O and layer_first/page_first. L3, external linkers, DSA layer splitting, HiSparse and two-batch overlap are outside this combination. Decode remains unsharded.

Configuration requirements, paired launch example and validation guidance

Accuracy Tests

  • Runtime regression on f01f901a6a (runtime source unchanged by the following documentation/fixture commits): 200 tests and 140 subtests passed, 2 skipped, 1 deselected. This covers owner-aware PD transfer, allocator/rotation invariants, scratch sizing, scheduler admission, host-transfer dispatch, launch compatibility and controller event ordering.
  • Both new CPU test files also pass when executed directly with fail-fast, as CI invokes them: 4 PD transfer tests and 2 controller tests.
  • The unsharded host-prefix backup setup independently reproduces the published head's unexpected keyword argument 'start_owner' failure and passes with 8620dbdaa1.
  • Local CPU runs bypass only the Mac Torch/MPS version preflight. A platform-specific NPU host-pool test is deselected because the local host-memory reserve cannot be met; GPU-dependent tests are skipped. These runs do not validate CUDA/NCCL or physical host transfers.
  • Pre-commit and git diff --check pass. Mintlify 4.2.559 reports no broken links with anchor/redirect checks. Both documented launch commands pass the CLI parser and their shell block passes bash -n.

Hardware E2E status

Passed on current head 346068aaa329cf1692fbb6031f60469fdac77dcb, Base attempt 2.

  • Four-GB300 hardware job: test_dsa_glm52_pd_kv_shard_hicache.py actually ran and passed, with a 273-second suite duration. The test method completed with Ran 1 test ... OK; this was not a collection-only or skipped result.
  • The test retains P2/D2, CP2, EAGLE MTP and all cold/device-hit/host-reloaded answer, speculative-verification, host-hit and rank-specific H2D assertions. Two 6,144-token pressure requests exceed the 8,192 logical GPU slots while fitting with the target prefix in the larger host cache.
  • CPU partition 17: all 52 files passed, including test_decode_hicache_l2.py (36 seconds), which previously exposed the non-sharded backup signature regression.
  • The existing AARCH64 P2/D2 accuracy test also passed in the same GB300 job (89 seconds). This fixture uses its supported fabric configuration: MC_FORCE_MNNVL=true and SGLANG_MOONCAKE_CUSTOM_MEM_POOL=NVLINK. The NVLink allocator supplies exportable KV buffers; the runner's wheel does not provide nvlink_intra.

The launch example has separate prefill/decode commands with one option per line, addressing review comment 4379290548. CLI arguments are unchanged; both examples match the E2E transport settings. Shell syntax, CLI parsing, allocator selection equivalence, pre-commit and Mintlify anchor/link checks pass.

The separate existing GLM-5.2 layer-split accuracy rerun passed at 0.9422632794457275, above the unchanged 0.935 GSM8K threshold; the full job passed 2/2 test files. The previous attempt scored 0.9345650500384911. Both attempts tested merge e79b8b8c52735038eb60edcacff7a3e6f24ea69e with KV sharding disabled, and no code or threshold changes were made between them. The successful rerun does not establish the cause of the score variation.

On current head, Base attempt 3 and Extra attempt 3 are both successful. Arm64 and Xeon retain separately investigated failures in unchanged CPU-operator/parser paths; the complete platform matrix is not all green.

Speed Tests and Profiling

A controlled production replay is still pending; no throughput or latency speedup is claimed.

For the requested comparison, use the same model revision, hardware, runtime, P/D topology, memory budget, request order, concurrency and warm-up policy. Report device/host hit tokens, TTFT percentiles, throughput, peak memory and answer correctness for replicated/deduplicated KV and KV sharding. CPU unit-test counts and increased logical capacity are not performance measurements.

Checklist

  • Format and pre-commit checks.
  • Focused regression coverage and CI registration.
  • Configuration, launch and validation documentation.
  • Preserve non-sharded call paths and follow composition/preparation-hook review feedback.
  • Pass the corrected full-model P/D + MTP + HiCache E2E on hardware.
  • Provide controlled production accuracy/performance replay results.
  • Pass the separate GLM layer-split accuracy evaluation at the unchanged 0.935 threshold.
  • Resolve the remaining [Feat] KVShard: Support HiCache with KV Cache Sharding #43778 dependency and required CI/maintainer approvals.

CI States

Latest PR Test (Base): ✅ Run #40354128180
Latest PR Test (Extra): ✅ Run #40354126514
Latest PR Test (AMD ROCm 10): ⏳ Run #40354127190

@mintlify

mintlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 346068a.

Approve preview

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 26, 2026
@HZY-Wade

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

--enable-metrics --enable-cache-report
)

python3 -m sglang.launch_server "${COMMON_ARGS[@]}" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should optimize this command's style, like:

DeepSeek Multi-Node

# prefill 0
python -m sglang.launch_server \
  --model-path deepseek-ai/DeepSeek-V3-0324 \
  --disaggregation-ib-device ${device_name} \
  --disaggregation-mode prefill \
  --host ${local_ip} \
  --port 30000 \
  --trust-remote-code \
  --dist-init-addr ${prefill_master_ip}:5000 \
  --nnodes 2 \
  --node-rank 0 \
  --tp-size 16 \
  --attn-dp-size 8 \
  --moe-a2a-backend deepep \
  --mem-fraction-static 0.8
# prefill 1
python -m sglang.launch_server \
  --model-path deepseek-ai/DeepSeek-V3-0324 \
  --disaggregation-ib-device ${device_name} \
  --disaggregation-mode prefill \
  --host ${local_ip} \
  --port 30000 \
  --trust-remote-code \
  --dist-init-addr ${prefill_master_ip}:5000 \
  --nnodes 2 \
  --node-rank 1 \
  --tp-size 16 \
  --attn-dp-size 8 \
  --moe-a2a-backend deepep \
  --mem-fraction-static 0.8

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

1 similar comment

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

Copy link
Copy Markdown
Contributor Author

Additional GLM-5.3 accuracy evaluation results from my run, using the RadixArk/GLM-5.3-NVFP4 weights:

Benchmark Score
agentic3-TB-2-1 88.76
aime_AIME2025 95.56

@hzh0425

hzh0425 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

/rerun-test test/registered/unit/disaggregation/test_dsa_sharded_pd_transfer.py

@hzh0425

hzh0425 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator
image

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/disaggregation/test_dsa_sharded_pd_transfer.py

@hzh0425

hzh0425 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

/rerun-test -c

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 4-gpu-gb300 (1 test): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_dsa_glm52_pd_kv_shard_hicache.py

🚀 ubuntu-latest (6 tests): ✅ View workflow run

cd test/ && python3 registered/unit/disaggregation/test_dsa_sharded_pd_transfer.py
cd test/ && python3 registered/unit/managers/test_prefill_adder.py
cd test/ && python3 registered/unit/mem_cache/test_hicache_staged_write_back_dispatch.py
cd test/ && python3 registered/unit/mem_cache/test_page_interleave_shard.py
cd test/ && python3 registered/unit/mem_cache/test_sharded_dsa_hicache.py
cd test/ && python3 registered/unit/server_args/test_server_args.py

@hzh0425

hzh0425 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

thanks @HZY-Wade
need to add a accuracy hicache + sharding e2e test in next pr

@hzh0425
hzh0425 merged commit 8136cbc into sgl-project:main Oct 27, 2026
427 of 459 checks passed
jambow0320 added a commit to jambow0320/sglang that referenced this pull request Oct 27, 2026
The test from sgl-project#42973 replaced _transfer_data, which the Mooncake transport
extraction removed. Attach a real MooncakeTransport over a memory-copy engine
instead; the byte-level checks are unchanged.
Venkat2811 added a commit to datacrunch-research/sglang that referenced this pull request Oct 30, 2026
…attach check

sgl-project#42973 made StorageAttachment ask page_interleave_shard_size() about
cache.token_to_kv_pool_allocator before attaching a storage backend. The
role-local DCP attach tests (ported with sgl-project#41695) build their cache as a
SimpleNamespace without that attribute, so 14 of them stopped at an
AttributeError. Give the fake a plain namespace there: a stock allocator,
shard size 1, which is what those tests mean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
…nchors -- entries 244/247-era surfaces, 301, sgl-project#44842, sgl-project#42973

Battery damage classes re-derived per-file POST-MERGE (CVD=9, prod venv,
PYTHONPATH=python) with the B5-3/B5-4 code state:

(1) test_modelopt_nvfp4_moe_scales 2F (SUBFAILED pair): merge took
  upstream's sgl-project#45289 test file and DROPPED the fork's entry-244 stub block
  (the small-M workspace gate reads placement attrs in
  process_weights_after_loading regardless of kernel support -- kwargs
  evaluate first). Stub block re-planted VERBATIM from the 309 tip.
  20P/44sub (>= the pre-merge 20P/42sub: upstream grew two subtests).
(2) test_fp4_gemm_backend_sm120 3F: upstream sgl-project#44842 (in-range) grew the
  autotune gate with get_parallel().enable_kv_cache_sharding (sgl-project#42973) +
  the FP8->MXFP8 module-tree pre-check; the gate tests' stubs predate
  both. Test re-anchored (get_parallel stub + empty module tree); the
  three beliefs (b12x keeps the pass, cutlass autotunes, marlin doesn't)
  unchanged. 12P/0F.
(3) test_mem_pool_ep_unit 1F: the DOCUMENTED tip-era class, now attributed
  exactly: the test's id-contract predates entry-247 -- dispatcher skip
  TRUE for b12x vs the stale expected-False. Set re-pinned:
  dispatcher_global_ids += FLASHINFER_B12X_W4A16 (its expert_map contract,
  the very arm B5-3 re-planted into _keeps_global_expert_ids) and the LoRA
  subtraction gains b12x (no LoRA path). EXPERIMENTAL_SGL_TRTLLM verified
  HARMLESS without its removed arm: is_flashinfer_trtllm() covers the
  value by design (utils.py:212-217), confirming B5-3's
  upstream-churn verdict on that branch. 49P/0F/4sub -- class CLOSED, one
  fewer env-class than the pre-merge baseline.

ENV CLASSES CONFIRMED (not new, not fixable here):
  trtllm_gen 8F == documented 8F; moe_fused_gate 52F == documented ~52F
  ALL 'No CUDA GPUs are available'; triton_fused_moe 96F == documented
  ~96F; round_robin 38F (documented 37 + 1 upstream-grown CUDA case, ALL
  'No CUDA GPUs'); mega_moe_deepgemm 1F == documented 1F (test's deep_gemm
  fake vs mxfp4.py's in-range wrapper import -- NOT my redirect: fails
  identically at b3207c7 with mega_moe pre-B5-3; B2 marker :905 covers
  the test-side fix).

GATE RE-CHECK: standard_dispatcher 21P (grew again, green),
runner_backend 16P, fold probe 9P, overrides 121P/1S/210sub.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek dependencies Pull requests that update a dependency file diffusion SGLang Diffusion documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed jit-kernel memory-pool mooncake run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants