Skip to content

[Blog]: Scaling GLM-5.2 on SGLang with Hierarchical KV Cache Offloading and llm-d - #490

Closed
tyuchn wants to merge 2 commits into
llm-d:mainfrom
tyuchn:blog/sglang-glm-5-2-kv-cache-offloading
Closed

tyuchn wants to merge 2 commits into
llm-d:mainfrom
tyuchn:blog/sglang-glm-5-2-kv-cache-offloading

Conversation

@tyuchn

@tyuchn tyuchn commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a blog post sharing our production evaluation of hierarchical KV cache offloading with
SGLang and llm-d
on GKE with NVIDIA B200 GPUs (a4-highgpu-8g), serving GLM-5.2-FP8 under
real multi-turn agentic coding traces. The post covers:

  • the KV cache capacity cliff on an 8× B200 node: after ~744 GB of model weights, remaining HBM
    holds only ~1.16M tokens (~14 concurrent 80k-token sessions), and eviction beyond that forces a
    ~5.4s full prefill recompute per resumed turn
  • a 3-tier memory hierarchy orchestrated by SGLang's Hierarchical Cache (HiCache): L1 GPU HBM,
    L2 Host CPU DRAM (--hicache-size=250, 2.0 TB/node), and L3 shared remote storage
    (--hicache-storage-backend=file) backed by Google Cloud Managed Lustre
  • a decision matrix of the workload profiles where hierarchical offloading pays off, and which
    storage tiers each one needs
  • benchmark results driven by the SemiAnalysis Claude Code WekaTrace dataset replayed with
    inference-perf:
    • single-node concurrency sweep (C = 2, 8, 16): P50 TTFT stays flat at 2.34s–3.74s across
      528 multi-turn requests over 68 minutes, with zero OOMs, crashes, or restarts
    • 3-phase cold retrieval from L3 Lustre: cold resumption at P50 TTFT 6.24s, and a 93.8% TTFT
      reduction (14.28s → 0.89s) on an isolated sequential 124k-token turn-2 resumption
    • multi-node fleet scaling across 5 nodes (40× B200) fronted by llm-d-router (EPP):
      871 turns at 10 QPS target load and 229.2 tok/s generation at 20 QPS peak
  • a production recipe: SGLang startup flags and the llm-d-router EndpointPickerConfig, including
    sizing lruCapacityPerServer to cover the combined HBM + Host DRAM pool

Supporting changes:

  • blog/authors.yml: add tyuchn and nishjain
  • blog/tags.yml: add the gke tag
  • docusaurus.config.js: enable remarkMath / rehypeKatex on the blog plugin so LaTeX in blog
    posts renders (they were already enabled for docs, but not for blog)

Why is this change needed?

Agentic coding workloads (65k–130k+ token prompts, dozens of turns, long tool-execution pauses)
break the assumptions behind HBM-only KV caching. This post gives platform teams the capacity math,
the measured trade-offs of each storage tier, and a reproducible configuration for SGLang HiCache
plus llm-d-router so they can size and deploy tiered prefix caching instead of paying repeated
full-prefill recomputes.

How was this tested?

  • Tests added/updated (npm test)
  • Site builds successfully (npm run build:all)
  • Check links after buildling (npm run check-links)
  • Manual testing performed (npm run serve)

Verified the rendered post on the Netlify deploy preview: KaTeX formulas, tables, Mermaid diagram,
figures, and both author cards render correctly. The link checker reports no broken links
introduced by this PR (the two remaining failures are pre-existing, in synced llm-d/llm-d docs).

Checklist

  • Commits are signed off (git commit -s) per DCO
  • Code follows project contributing guidelines
  • Tests pass locally (npm test)
  • Site builds without errors (npm run build:all)
  • No broken links after building full site (npm run check-links)
  • Documentation updated (if applicable)

Related Issues

None.

@netlify

netlify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for llm-d ready!

Name Link
🔨 Latest commit 9de3c62
🔍 Latest deploy log https://app.netlify.com/projects/llm-d/deploys/6aa8619251492400086d4a39
😎 Deploy Preview https://deploy-preview-490--llm-d.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tyuchn
tyuchn force-pushed the blog/sglang-glm-5-2-kv-cache-offloading branch from 65ba158 to d42fc8a Compare September 9, 2026 22:43
@tyuchn
tyuchn marked this pull request as ready for review September 11, 2026 19:52
@tyuchn

tyuchn commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

/assign @ahg-g

@tyuchn
tyuchn force-pushed the blog/sglang-glm-5-2-kv-cache-offloading branch from eb5cd50 to 9de3c62 Compare September 14, 2026 21:05

@ahg-g ahg-g left a comment

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.

Thanks for putting this together, I think this is good, but we should not regress from what we guided before on using wide-ep with data parallelism for GLM agentic deployments.

* 78 transformer layers
* Compressed KV latent vector: $512\text{ (kv\_lora\_rank)} + 64\text{ (qk\_rope\_head\_dim)} = 576\text{ elements/layer}$
* KV cache precision: FP8 (1 byte per element)
* **KV Footprint:** $576 \times 78 \times 1\text{ byte} = \mathbf{44.93\text{ KB per token}}$ (replicated across all 8 GPU ranks under TP=8).

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.

Using TP=8 is not ideal as demonstrated previously in https://llm-d.ai/blog/serving-glm-5-2-agentic-workloads-on-llm-d#wide-expert-parallelism; the issue is that with TP=8, the kv-cache has to be duplicated across all ranks within a node, while with EP+DP the kv-cache is sharded. I am not sure this evaluation will look credible/useful if we only show TP=8.

* **The Problem — KV Cache Capacity Collapse:** GLM-5.2's Multi-Head Latent Attention (MLA) compresses the KV cache to 44.93 KB/token. However, with ~744 GB of model weights on an 8× B200 node (1,440 GB total HBM), remaining HBM holds only ~1.16M tokens (~14 sessions of 80k tokens). Beyond 14 concurrent sessions, prefix eviction triggers a **10.8× compute surge**, causing queue timeouts and 429 shedding.
* **The Solution — 3-Tier Storage Hierarchy:**
1. **Tier 1 (L1 GPU HBM):** Ultra-low latency for active decoding.
2. **Tier 2 (L2 Host CPU DRAM):** Allocating 2.0 TB of Host DRAM per node (`--hicache-size=250`) expands resident KV cache capacity by **38.4× to 44.5 Million tokens**, retrieving cached prefixes over PCIe Gen5 in **10–20 ms**.

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.

Is this true? since we are using TP=8, the kv-cache will be duplicated, not sharded across the ranks, and so the calculation should be 250GB/44K ~= 5.5M tokens only, not 44.5M.

* KV cache precision: FP8 (1 byte per element)
* **KV Footprint:** $576 \times 78 \times 1\text{ byte} = \mathbf{44.93\text{ KB per token}}$ (replicated across all 8 GPU ranks under TP=8).

A single `a4-highgpu-8g` node features 8× NVIDIA B200 GPUs (180 GB HBM3e each, totaling 1,440 GB HBM). Model weights consume ~744 GB. At standard memory reservation fractions, roughly **696 GB remains for KV cache**, accommodating approximately **1.16 Million KV cache tokens**.

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.

roughly 696 GB remains for KV cache, accommodating approximately 1.16 Million KV cache tokens.

A couple of things:

  1. a significant part of HBM memory goes to memory buffers, cuda graphs and whatnot, the amount left for kv-cache is materially less than 696GB, we should be precise on how much memory was actually left for kv-cache from the experiment.
  2. If we assume 696GB, then the number 1.16M tokens doesn't sound right: 44KB x 8 ranks (since the kv-cache is duplicated), that adds up to 352KB / token, so 696GB/352KB ~= 1.9M tokens on a single node. Based on the actual memory we managed to allocate, the math should add up as to how many tokens that kv-cache can hold.

As soon as concurrency exceeds 14 active sessions:
1. **Eviction Storm:** GPU HBM fills up, and SGLang's radix tree evicts the oldest session prefixes.
2. **Recomputation Penalty:** When an evicted session resumes, the GPU must re-prefill all 80k–130k tokens. At a measured single-node B200 prefill throughput of **24,027 tokens/second**, recomputing 130k tokens takes **5.41 seconds of 100% GPU compute**.
3. **Queue Collapse:** As multiple sessions resume concurrently, incoming prefill demand explodes to over **260,000 tokens/second**—surpassing physical GPU compute by **10.8×**. The request queue saturates, time-to-first-token spikes to 30+ seconds, and ingress gateways begin rejecting traffic with HTTP 429 (Too Many Requests).

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.

With TP=1, EP=8 and DP=8, the concurrency that the node can sustain will likely be much higher than 14 (roughly 8x higher), similar to the other comment, using TP=8 is not going to be looked at as credible baseline.


## Decision Matrix: When is KV Cache Offloading Helpful?

Before diving into hardware math and benchmark traces, platform engineers evaluating SGLang should understand under what workload conditions hierarchical offloading delivers substantial ROI:

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.

this is not specific to sglang

| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **$C = 2$** | Tier 1: Hot GPU HBM | 74 turns | **2.34 s** | 5.21 s | 6.29 ms | **159.1 tok/s** | 3.22 s |
| **$C = 8$** | Tier 2: HiCache Host DRAM | 149 turns | **3.42 s** | 12.27 s | 8.15 ms | **122.6 tok/s** | 4.17 s |
| **$C = 16$** | Tier 2: DRAM Saturation | 305 turns | **3.74 s** | 10.18 s | 7.49 ms | **133.5 tok/s** | 3.68 s |

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.

pls be consistent in the naming of the storage tiers


| Concurrency Level | Primary Storage Tier | Total Turns Served | P50 TTFT (s) | P90 TTFT (s) | Median TPOT (ms) | Gen Speed (tok/s) | P50 Request Latency (s) |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **$C = 2$** | Tier 1: Hot GPU HBM | 74 turns | **2.34 s** | 5.21 s | 6.29 ms | **159.1 tok/s** | 3.22 s |

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.

I suspect that if we switch to EP/DP=8, TPOT will rise (roughly 2x or 3x), but since we will have 8 servers running in parallel, we will get 8x the throughput

| Concurrency Level | Primary Storage Tier | Total Turns Served | P50 TTFT (s) | P90 TTFT (s) | Median TPOT (ms) | Gen Speed (tok/s) | P50 Request Latency (s) |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **$C = 2$** | Tier 1: Hot GPU HBM | 74 turns | **2.34 s** | 5.21 s | 6.29 ms | **159.1 tok/s** | 3.22 s |
| **$C = 8$** | Tier 2: HiCache Host DRAM | 149 turns | **3.42 s** | 12.27 s | 8.15 ms | **122.6 tok/s** | 4.17 s |

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.

The tok/s here is a bit misleading, IIUC this is calculated as 1/ , which means it doesn't factor in prefill time, right?


---

### 3. Fleet Scaling Fronted by llm-d Router (EPP)

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.

"Multiple Replicas Fronted"

| Benchmark Stage | Concurrency (Sessions) | Successful Turns Completed | Prompt Tokens (Mean / P90) | Output Tokens (Mean / P90) | TPOT Med (ms) | Gen Speed (tok/s) |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **10 QPS Target Fleet Load** | **20 concurrent** | **871 turns** | 68,372 / 115,447 | 1,353 / 3,485 | **7.10 ms** | **140.8 tok/s** |
| **20 QPS Peak Fleet Load** | **50 concurrent** | **89 turns** | 25,897 / 59,879 | 452 / 926 | **4.36 ms** | **229.2 tok/s** |

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.

I assume the toks /s reported here is per node, we should report it for the whole deployment

@github-actions

Copy link
Copy Markdown
Contributor

This PR is marked as stale after 21d of inactivity. After an additional 14d of inactivity (7d to become rotten, then 7d more), it will be closed. To prevent this PR from being closed, add a comment or remove the lifecycle/stale label.

@tyuchn

tyuchn commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing in favor of #530 — thanks @ahg-g for the thorough review. We extended the upstream SGLang wide-EP P/D recipe (guides/models/glm-5-2/modelserver/gpu/sglang) with the shared-storage tier (hicache-fs) in llm-d/llm-d#2924 (llm-d/llm-d#2923) and re-ran the benchmarks on H200 (DEP8 prefill + decode) with both aiperf (inferencex-agentx-mvp) and multi-turn Weka trace replay so the post is directly comparable with the vLLM GLM-5.2 post.

@tyuchn tyuchn closed this Oct 26, 2026
tyuchn added a commit to tyuchn/llm-d.github.io that referenced this pull request Nov 3, 2026
Add "Serving GLM-5.2 on SGLang with llm-d: Wide-EP, Host DRAM, and
Shared Storage" with six figures. The post benchmarks the SGLang variant
of the GLM-5.2 well-lit path (v0.5.23, DEP8 prefill + DEP8 decode on
16x H200) across a three-tier KV cache: L1 GPU HBM, L2 host DRAM
(HiCache) and shared L3 storage (hicache-fs on a ReadWriteMany volume).

It answers two questions with 900 s aiperf sweeps and paused multi-turn
replays: when each KV tier helps and by how much (L1 alone thrashes
past concurrency 32; host DRAM raises c128 output 3.94x; shared storage
costs 14-33% median TTFT in steady state but restores cold ranks and
restarted pods 49-57% faster than recomputing), and how SGLang compares
with the earlier vLLM wide-EP runs under the same protocol, labeled
indicative with the cluster, fabric, build and router differences
spelled out. A sizing table maps agentic workload scenarios to tier
sizes.

Authors: tyuchn, nishjain, zetxqx and sagearc (the last two built the
upstream SGLang wide-EP recipe the post extends). Adds the gke tag.

Supersedes llm-d#490.

Signed-off-by: Yuchen Tian <[email protected]>
ahg-g pushed a commit that referenced this pull request Nov 22, 2026
* blog: Serving GLM-5.2 on SGLang with llm-d

Add "Serving GLM-5.2 on SGLang with llm-d: Wide-EP, Host DRAM, and
Shared Storage" with six figures. The post benchmarks the SGLang variant
of the GLM-5.2 well-lit path (v0.5.23, DEP8 prefill + DEP8 decode on
16x H200) across a three-tier KV cache: L1 GPU HBM, L2 host DRAM
(HiCache) and shared L3 storage (hicache-fs on a ReadWriteMany volume).

It answers two questions with 900 s aiperf sweeps and paused multi-turn
replays: when each KV tier helps and by how much (L1 alone thrashes
past concurrency 32; host DRAM raises c128 output 3.94x; shared storage
costs 14-33% median TTFT in steady state but restores cold ranks and
restarted pods 49-57% faster than recomputing), and how SGLang compares
with the earlier vLLM wide-EP runs under the same protocol, labeled
indicative with the cluster, fabric, build and router differences
spelled out. A sizing table maps agentic workload scenarios to tier
sizes.

Authors: tyuchn, nishjain, zetxqx and sagearc (the last two built the
upstream SGLang wide-EP recipe the post extends). Adds the gke tag.

Supersedes #490.

Signed-off-by: Yuchen Tian <[email protected]>

* blog(glm-5-2): drop the GKE-specific appendix

Remove the deployment-details appendix (cluster, node, driver and
version table), which was specific to the GKE testbed. Keep the
cloud-agnostic part, the AIPerf invocation behind every load-sweep
number, as the last step of 'Running the recipe'.

Signed-off-by: Yuchen Tian <[email protected]>

* blog(glm-5-2): align deepep_v2 bullet with uniform hybrid mode

Signed-off-by: Yuchen Tian <[email protected]>

* blog(glm-5-2): fix L2 hit-rate range, PCIe DMA wording, and L3 overhead split

Signed-off-by: Yuchen Tian <[email protected]>

* blog(glm-5-2): restructure around Wide-EP and L3 trade-off, improve prose clarity

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): reposition around first-class llm-d integration, multi-replica L3, and co-authors

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): add author photo for Nishtha Jain

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): remove redundant benchmark tables in Section 3

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): tighten title and prose, address DisaggregatedSet and L3 failover feedback

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): clarify observability changes, L3 filesystem overhead, and GiB units

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): dedup authors, update Figure 1, and clarify routing and L3 benchmarks

Signed-off-by: Yuchen Tian <[email protected]>

* blog(sglang): set publish date to 2026-11-23

Signed-off-by: Yuchen Tian <[email protected]>

---------

Signed-off-by: Yuchen Tian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants