Skip to content

[Refactor] hicache: Move shared host backing and build unified host pools from layout views - #48003

Merged
ch-wan merged 2 commits into
mainfrom
cheng/refactor/unified-kv-host-pools
Nov 4, 2026
Merged

ch-wan merged 2 commits into
mainfrom
cheng/refactor/unified-kv-host-pools

Conversation

@ch-wan

@ch-wan ch-wan commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is part of a stack (oldest at bottom):

Motivation

The unified pool's host (HiCache) side built its host pools from pool-specific knowledge inside mem_cache/pool_host/unified.py. Later PRs in this stack let the unified pool carry any number of window sub-pools and fused draft parts, which the host side must mirror without a case per pool shape. This PR moves the shared host backing next to the device memory code and builds host pools from each device layout view's own description.

Modifications

  • mem_cache/kv/memory/host_backing.py (new): _SharedPageEnvelopeHostBacking moved from mem_cache/pool_host/unified.py unchanged in behavior (a mechanical move in the first commit).
  • mem_cache/kv/layout/{base,mha,mla,state}.py: each layout view describes its host rows (host_layout() returning e.g. MHAHostLayout, MLA and state equivalents) and builds its host pool from HostPoolOptions; MHA host transfers require unsharded token ids.
  • mem_cache/hybrid_cache/hybrid_pool_assembler.py, mem_cache/pool_host/unified.py, mem_cache/kv/storage.py: unified host pools are assembled from the layout views' descriptions instead of per-pool-type code.
  • Tests: test/registered/unit/mem_cache/kv/test_host_layout.py (host rows and storage pages match the existing host layouts; a state layout accepts a KV split without splitting state), updates to test_hybrid_pool_assembler.py and test_unified_kv_storage.py.

No intended behavior change: host pool sizes, layouts and transfers are the same as before.

Accuracy Tests

Serving validation was run at the top of this 26-PR stack (the cumulative change), not at this PR's head. Software: torch 2.14.1+cu130, flashinfer 0.7.2, sglang-kernel 0.4.10. GSM8K is few-shot, 500 or 1319 questions as noted; main is the same commit the stack is based on, same flags.

Hardware Model Configuration Stack top main
2x H200 Qwen/Qwen3.8-27B TP2, --enable-unified-memory (rebased stack) 0.954 (1319 q) 0.950–0.954
1x H200 openai/gpt-oss-120b TP1, --enable-unified-memory --max-total-tokens 120000 (rebased stack) 0.842 (1319 q) 0.839
2x H200 Qwen/Qwen3.8-27B TP2, unified, MTP (EAGLE, 3 steps, topk 1, 4 draft tokens) 0.951, accept length 3.56 0.953, 3.56
2x H200 Qwen/Qwen3.8-27B TP2, unified, DFlash draft 0.951, accept length 5.42 0.952, 5.44
2x H200 Qwen/Qwen3.8-27B PD (prefill TP1 + decode TP1, mooncake), unified, repeated runs 0.952–0.960, no hang 0.954–0.958
2x H200 openai/gpt-oss-120b PD (TP1 + TP1, mooncake), unified 0.810 0.808
2x H200 Qwen/Qwen3.8-27B TP2, unified, HiCache 0.954 —
2x H200 Qwen/Qwen3.8-27B PP2, unified 0.953 0.955 (static pools)
2x B200 Qwen/Qwen3.8-27B TP2, unified (500 q) 0.958 0.960
2x B200 openai/gpt-oss-120b TP2, unified, trtllm_mha (1319 q) 0.849 0.863
2x B300 Qwen/Qwen3.8-27B / openai/gpt-oss-120b TP2, unified 0.950 / 0.849 0.954 / 0.849

On B200 and B300, 40 greedy GSM8K generations were compared with main: 35–40 of 40 are identical, and the rest first differ after at least 27 characters (near ties). The H200 runs above other than the two marked "rebased stack" were run at the stack top before it was rebased onto the current base; the code they cover is unchanged by the rebase except for conflict resolutions.

The HiCache row exercises the host pools built here.

Speed Tests and Profiling

Not expected to change speed (host pool construction only). Measured at the stack top, same flags as main (bench_serving, random 4096-in / 512-out unless noted):

Hardware Model / configuration Stack top main
1x H200 openai/gpt-oss-120b, unified, --max-total-tokens 120000 3.93–3.95 req/s 3.95 req/s
2x H200 Qwen/Qwen3.8-27B PD (TP1 + TP1), 2048-in / 256-out 5.65–6.28 req/s 6.21–6.29 req/s
2x H200 openai/gpt-oss-120b PD (TP1 + TP1) 9.39–9.45 req/s 9.21 req/s
2x H200 Qwen/Qwen3.8-27B MTP TP2 / DFlash TP2 4.26 / 4.36 req/s 4.29 / 4.35 req/s
2x B200 Qwen/Qwen3.8-27B TP2 / openai/gpt-oss-120b TP2 6.35 / 19.31 req/s 6.34 / 19.28 req/s

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): 🚫 Run #41907128175
Latest PR Test (Extra): 🚫 Run #41907128162
Latest PR Test (AMD ROCm 10): ❌ Run #41907128243

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@ch-wan
ch-wan force-pushed the cheng/hot-fix/unified-kv-cp-sharded-padded-refusal branch from 43fc645 to 5458116 Compare November 4, 2026 11:33
@ch-wan
ch-wan force-pushed the cheng/refactor/unified-kv-host-pools branch from 08378a2 to 4ce96ca Compare November 4, 2026 11:33
@ch-wan
ch-wan force-pushed the cheng/hot-fix/unified-kv-cp-sharded-padded-refusal branch from 5458116 to 0c76b4a Compare November 4, 2026 20:29
@ch-wan
ch-wan requested a review from Qiaolin-Yu as a code owner November 4, 2026 20:29
Base automatically changed from cheng/hot-fix/unified-kv-cp-sharded-padded-refusal to main November 4, 2026 20:29
@ch-wan
ch-wan force-pushed the cheng/refactor/unified-kv-host-pools branch from 4ce96ca to c9178e9 Compare November 4, 2026 20:29
@ch-wan
ch-wan merged commit 440ae6d into main Nov 4, 2026
19 of 24 checks passed
@ch-wan
ch-wan deleted the cheng/refactor/unified-kv-host-pools branch November 4, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hicache Hierarchical Caching for SGLang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant