Skip to content

Commit 78f72af

Browse files
Oseltamivirclaude
andauthored
Add DRAM KV offloading (HiCache) to GLM-5.2 NVFP4 B300 SGLang agentic recipe (#2279)
* feat: DRAM KV offloading via HiCache for all glm5.2 b300 agentic points Run 29651235293 showed the 1M-context corpus working set outgrowing the HBM KV pool past conc 8 (TP8) / conc 64 (DP8): gpu_kv_cache_usage pinned at 1.0 while the radix hit rate collapsed from a ~0.97 theoretical ceiling to 0.04-0.06, so every post-knee turn re-prefilled its whole history and throughput fell together with interactivity, leaving the frontier a single dominated cliff. Spill evicted prefixes to a per-rank pinned host pool (0.80 x node DRAM / TP) instead of recomputing them, following the qwen3.5 b300 hicache recipe; GLM-5.2 is plain GQA so there is one host pool per rank and GB-based --hicache-size works (the DSv4 ratio-based sizing is a DSv4-only workaround). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * chore: fill perf-changelog pr-link for glm5.2 b300 hicache entry Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: ratio-based HiCache sizing (0.75) for DSA-family GLM-5.2 Run 29678598595 OOM-killed both arms at scheduler init: GLM-5.2 runs attention_backend=dsa (DeepSeek-sparse family; the 169.98 GB device KV pool is replicated on every rank), so the GB-based --hicache-size of TOTAL_CPU_DRAM_GB/TP pinned the whole 0.80-DRAM budget (8 x 299 GB = 2.4 TB) on top of 465 GB of weights on a 3 TB node. Control host capacity through the host/device token-capacity ratio like the DSv4 recipe — but DSv4's ratio=2 default also OOMs here (2 x 170 GB x 8 = 2.7 TB; GLM-5.2's device pool is far larger than DSv4's), so use fractional ratio 0.75 = ~128 GB/rank = ~1.0 TB total, matching the cluster's proven host-pool envelope. Adopt DSv4's write_back / direct / page_first_direct transfer flags. Validated on-node (b300-019, 2026-07-19): both sizing regressions reproduced, ratio 0.75 boots in ~290 s and survives a 4.2M-token overflow bench that forces eviction through the DSA KV+INDEXER host pools. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent e599a0b commit 78f72af

3 files changed

Lines changed: 52 additions & 7 deletions

File tree

benchmarks/single_node/agentic/glm5.2_fp4_b300_sglang.sh

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ set -x
1313
# Required env vars:
1414
# MODEL, TP, CONC, KV_OFFLOADING, TOTAL_CPU_DRAM_GB, RESULT_DIR, DURATION,
1515
# EP_SIZE, DP_ATTENTION
16+
#
17+
# KV_OFFLOADING=dram requires KV_OFFLOAD_BACKEND=hicache.
1618

1719
source "$(dirname "$0")/../../benchmark_lib.sh"
1820

1921
check_env_vars MODEL TP CONC KV_OFFLOADING TOTAL_CPU_DRAM_GB RESULT_DIR DURATION EP_SIZE DP_ATTENTION
2022

21-
if [[ "$KV_OFFLOADING" != "none" ]]; then
22-
echo "Error: KV_OFFLOADING=$KV_OFFLOADING is not supported by this recipe" >&2
23-
exit 1
24-
fi
25-
2623
if [[ -n "${SLURM_JOB_ID:-}" ]]; then
2724
echo "JOB $SLURM_JOB_ID running on ${SLURMD_NODENAME:-unknown}"
2825
fi
@@ -46,6 +43,45 @@ install_agentic_deps
4643
SERVER_LOG="$RESULT_DIR/server.log"
4744
mkdir -p "$RESULT_DIR"
4845

46+
CACHE_ARGS=()
47+
if require_agentic_kv_offload_backend hicache; then
48+
# HiCache extends RadixAttention: prefixes evicted from the HBM KV pool
49+
# spill to a pinned host pool instead of being recomputed. On the
50+
# 1M-context agentic corpus the live working set outgrows HBM past
51+
# conc 8 (TP8) / 64 (DP8) and the radix hit rate collapses to <0.1
52+
# against a ~0.97 theoretical ceiling, so every turn re-prefills its
53+
# whole history; the host tier restores those hits at C2C bandwidth.
54+
# GLM-5.2 is DSA/MLA-family (attention_backend=dsa): every rank holds
55+
# complete per-token KV (169.98 GB device pool per rank, replicated on
56+
# all 8 ranks), so host capacity is controlled through the host/device
57+
# token-capacity ratio like the DSv4 recipe, NOT a per-rank
58+
# --hicache-size. A GB-based size of TOTAL_CPU_DRAM_GB/TP pinned the
59+
# whole 0.80-DRAM budget (8 x 299 GB) at init on top of 465 GB of
60+
# weights and OOM-killed the node (run 29678598595); DSv4's own
61+
# ratio=2 default pins 2 x 170 GB x 8 = 2.7 TB here and OOMs too
62+
# (GLM-5.2's device pool is far larger than DSv4's). Fractional 0.75
63+
# = ~128 GB/rank = ~1.0 TB total, matching the cluster's proven ~1 TB
64+
# host-pool envelope; validated on-node 2026-07-19 (boot + 4.2M-token
65+
# overflow bench forcing eviction through the DSA KV+INDEXER pools).
66+
DEFAULT_HICACHE_RATIO=0.75
67+
HICACHE_RATIO="${HICACHE_RATIO:-$DEFAULT_HICACHE_RATIO}"
68+
if awk -v r="$HICACHE_RATIO" -v cap="$DEFAULT_HICACHE_RATIO" 'BEGIN { exit !(r > cap) }'; then
69+
echo "Error: HICACHE_RATIO=$HICACHE_RATIO exceeds configured limit $DEFAULT_HICACHE_RATIO" >&2
70+
exit 1
71+
fi
72+
HICACHE_WRITE_POLICY="${HICACHE_WRITE_POLICY:-write_back}"
73+
HICACHE_IO_BACKEND="${HICACHE_IO_BACKEND:-direct}"
74+
HICACHE_MEM_LAYOUT="${HICACHE_MEM_LAYOUT:-page_first_direct}"
75+
echo "HiCache CPU tier: ratio=$HICACHE_RATIO, capacity=${TOTAL_CPU_DRAM_GB} GB, write_policy=$HICACHE_WRITE_POLICY, io_backend=$HICACHE_IO_BACKEND, mem_layout=$HICACHE_MEM_LAYOUT"
76+
CACHE_ARGS=(
77+
--enable-hierarchical-cache
78+
--hicache-ratio "$HICACHE_RATIO"
79+
--hicache-write-policy "$HICACHE_WRITE_POLICY"
80+
--hicache-io-backend "$HICACHE_IO_BACKEND"
81+
--hicache-mem-layout "$HICACHE_MEM_LAYOUT"
82+
)
83+
fi
84+
4985
# With attention-DP, front the DP ranks with sglang-router using consistent
5086
# hashing on the AIPerf correlation id so multi-turn sessions stay on the DP
5187
# rank that holds their radix-cache prefix.
@@ -136,6 +172,7 @@ SGLANG_CMD=(
136172
--mem-fraction-static 0.85
137173
--max-running-requests "$MAX_RUNNING_REQUESTS"
138174
"${GRAPH_ARGS[@]}"
175+
"${CACHE_ARGS[@]}"
139176
--watchdog-timeout 1800
140177
--enable-metrics
141178
)

configs/nvidia-master.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7873,5 +7873,5 @@ glm5.2-fp4-b300-sglang-agentic:
78737873
agentic-coding:
78747874
- dram-utilization: 0.80
78757875
search-space:
7876-
- { tp: 8, kv-offloading: none, conc-list: [1, 2, 4, 8, 16, 32] }
7877-
- { tp: 8, dp-attn: true, kv-offloading: none, conc-list: [48, 64, 96, 128, 192, 256, 512], router: { name: sglang-router, version: "0.3.2" } }
7876+
- { tp: 8, kv-offloading: dram, kv-offload-backend: { name: hicache }, conc-list: [1, 2, 4, 8, 16, 32] }
7877+
- { tp: 8, dp-attn: true, kv-offloading: dram, kv-offload-backend: { name: hicache }, conc-list: [48, 64, 96, 128, 192, 256, 512], router: { name: sglang-router, version: "0.3.2" } }

perf-changelog.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4950,3 +4950,11 @@
49504950
description:
49514951
- "Bump vLLM image to v0.25.0"
49524952
pr-link: https://github.com/SemiAnalysisAI/InferenceX/pull/2256
4953+
4954+
- config-keys:
4955+
- glm5.2-fp4-b300-sglang-agentic
4956+
description:
4957+
- "Enable DRAM KV offloading (SGLang HiCache) on all points of both arms: DSv4-style host/device token-capacity ratio, tuned to 0.75 for GLM-5.2 (DSA/MLA-family: the 169.98 GB device pool is replicated on all 8 ranks, so ratio 0.75 = ~1.0 TB pinned host pools; ratio 2 and GB-based sizing both OOM-killed 3 TB nodes), io-backend direct, mem-layout page_first_direct, write policy write_back; validated on-node with an overflow bench forcing eviction through the DSA KV+INDEXER host pools"
4958+
- "Run 29651235293 showed the 1M-context corpus working set outgrowing the HBM KV pool past conc 8 (TP8) / conc 64 (DP8): gpu_kv_cache_usage pinned at 1.0 and the radix hit rate collapsed from a ~0.97 theoretical ceiling to 0.04-0.06, so every post-knee turn re-prefilled its full history and throughput fell together with interactivity"
4959+
- "HiCache spills evicted prefixes to host DRAM and restores them at C2C bandwidth instead of recomputing; sizing follows the qwen3.5-fp8-b300-sglang-agentic-hicache recipe (GLM-5.2 is plain GQA: one host pool per rank, GB-based --hicache-size)"
4960+
pr-link: https://github.com/SemiAnalysisAI/InferenceX/pull/2279

0 commit comments

Comments
 (0)