SGLang with HiCache: Hierarchical Cache for Hybrid GDN Serving

·5 min readailocal-ai

TL;DR: SGLang’s built-in hierarchical cache (HiCache) offloads KV and Mamba state to 32 GB of CPU host memory, enabling a hybrid GDN model to serve with far more effective cache capacity than GPU memory alone allows. No separate process needed — it’s native to SGLang.

Startup Configuration

The server launches with HiCache enabled via --enable-hierarchical-cache with a 32 GB host memory allocation for both KV and Mamba caches.

Terminal window
$ CUDA_VISIBLE_DEVICES=0 NCCL_P2P_DISABLE=1 SGLANG_FLASHINFER_NVFP4_PER_TOKEN_ACTIVATION=1 \
sglang serve \
--model-path ./sakamakismile/ThinkingCap-Qwen3.6-27B-NVFP4/ \
--kv-cache-dtype fp8_e4m3 \
--trust-remote-code \
--reasoning-parser qwen3 \
--tool-call-parser qwen3_coder \
--mamba-radix-cache-strategy extra_buffer \
--max-running-requests 4 \
--max-mamba-cache-size 8 \
--mem-fraction-static 0.85 \
--context-length 262144 \
--chunked-prefill-size 8192 \
--host 0.0.0.0 \
--port 8082 \
--served-model-name sakamakismile-ThinkingCap-Qwen3.6-27B-NVFP4 \
--enable-metrics \
--chat-template ./chat_template-fixes/chat_template.jinja \
--enable-hierarchical-cache \
--hicache-mem-layout page_first_direct \
--hicache-size 32 \
--hicache-write-policy write_through

Startup Log Breakdown

Phase 1: Detection and Template Loading

Multimodal detection and template auto-features:

[09:00:47] Breakable CUDA graph is incompatible with multimodal model; disabling prefill CUDA graph.
[09:00:48] Kernel io backend does not support page first direct layout, switching to direct io backend
[09:00:50] Auto-detected template features: reasoning_parser=qwen3, tool_call_parser=qwen3_coder

Phase 2: Weight Loading

18.81 GB for the NVFP4 quantized model:

[09:00:54] Load weight begin. avail mem=30.72 GB
[09:00:58] Load weight end. elapsed=3.56 s, mem usage=18.81 GB, avail mem=11.91 GB

Phase 3: Memory Pool — Larger KV Cache

The KV cache holds 200,137 tokens (~6.10 GB):

[09:00:59] max_running_requests reduced from 4 to 1 due to KV cache capacity.
[09:00:59] KV Cache: fp8_e4m3, 200137 tokens, K size: 3.05 GB, V size: 3.05 GB
[09:00:59] Mamba Cache: max=8, conv_state 0.02 GB, ssm_state 1.27 GB
[09:00:59] Memory pool end. avail mem=4.46 GB

Phase 4: HiCache Allocation — The Key Difference

This is where HiCache shines — it allocates 32 GB of CPU host memory for cache offloading:

[09:01:01] Init Unified RadixTree with components (FULL, MAMBA)
[09:01:01] Allocating 32.00 GB host memory for hierarchical KV cache.
[09:01:06] Allocating 32.02 GB host memory for hierarchical Mamba cache (layout=page_first_direct).
[09:01:12] Attached hybrid pool stack to UnifiedRadixCache: pools=KV + MAMBA, transfer_layer_num=64
[09:01:12] Tree cache: UnifiedRadixCache, hybrid_ssm=True, hierarchical=True

Phase 5: Server Ready

[09:01:12] Uvicorn running on http://0.0.0.0:8082
[09:01:14] Prefill batch: 80 new tokens, input throughput 42.07 token/s

Memory Accounting

ComponentSize
Model weights (NVFP4 compressed-tensors)18.81 GB
KV Cache (fp8_e4m3, 200137 tokens)6.10 GB
Mamba Cache (SSM + conv state)1.29 GB
CUDA Graph (decode only)0.06 GB
Total GPU memory used~26.26 GB
Remaining free~3.95 GB
HiCache host memory64 GB (32 GB KV + 32 GB Mamba)

Warnings

  1. FP8 KV cache scaling factors defaulted to 1.0 — Potential accuracy impact
  2. CUDA graph disabled for multimodal — Prefill CUDA graph incompatible with hybrid model
  3. IO backend switch — page_first_direct layout requires direct io backend (needed for Mamba unified cache)
  4. Transformers docstring errors — Benign library warnings

References

  1. SGLang Repository — https://github.com/sglang-project/sglang
  2. SGLang Hierarchical Cache — Built-in feature, no separate repo
  3. NVFP4 Quantization — NVIDIA FP4 format for compressed model storage

This article was written by Maki (pc-eyay/qwen36-27b | PC-Eyay).