Storage hardware behind SGLang HiCache: HBM, DRAM, and SSDs
SGLang HiCache keeps KV in CPU memory and external storage when it no longer fits on the GPU. The next request can load that KV instead of computing the same prefix again. But why use HBM on the GPU, DRAM on the CPU, and sometimes SSDs further down? This article follows one document’s KV through those devices, explains how the data moves between them, and works through when loading it actually saves time.
Background
Suppose we give a model a long document and ask it to write a summary. After reading the summary, we ask about one detail in the same document. The questions differ, but the document at the start of both requests is the same. If its KV is still cached, the model can reuse it and compute only the new question. It does not need to run prefill over the document again. KV here means the key and value tensors that attention uses to read earlier tokens.
Keeping that KV on the GPU would make the next request easy. The problem is that the GPU also needs memory for model weights and requests it is currently serving. As more users bring more documents, it cannot keep every old prefix. SGLang HiCache saves some of them in CPU memory or external storage. When the document is needed again, it loads the KV back onto the GPU. This works only for matching token prefixes and compatible model state; similar wording is not enough. The HiCache lesson explains the cache management. Here we look at the hardware that makes each storage tier useful, and the cost of moving between them.
HiCache calls GPU memory L1, CPU memory L2, and its storage backend L3. These names describe where HiCache keeps data; L1 does not mean the small hardware L1 cache inside a GPU core. On the accelerators discussed here, GPU memory is HBM. HBM is also a kind of DRAM. We will compare how HBM connects to the GPU with how ordinary server DRAM connects to the CPU.
Storage at a glance
Before looking inside the hardware, it helps to separate four properties. Capacity is how much data it can hold; bandwidth is how many bytes it can move per second; latency is how long one access takes; cost per byte is how much we pay for the same amount of storage. Different devices make different tradeoffs:
| Term and meaning | Main advantages | Main limitations | Use in HiCache |
|---|---|---|---|
| SRAM (Static Random-Access Memory): small memories inside the GPU chip | Low latency and high on-chip bandwidth | Large silicon area per bit, so capacity is small and costly | Hardware caches and kernel working data; not a separate HiCache tier |
| HBM (High Bandwidth Memory): stacked DRAM beside the GPU chip | High aggregate bandwidth for reading large amounts of KV | Expensive packaging and limited room for capacity; cannot expand by adding DIMMs | L1: KV being used by the GPU and prefixes retained in GPU memory |
| CPU DRAM: DRAM means Dynamic Random-Access Memory; CPU memory commonly uses DDR or LPDDR | Usually offers more capacity at a lower cost per byte than HBM | GPU reads or copies must cross the CPU–GPU link; CPU memory bandwidth is not the same as transfer bandwidth to the GPU | L2: reusable local KV copies and transfer buffers |
| Remote DRAM: memory on other machines, accessed through a cache service | Pools capacity and can share KV across inference instances | Adds network and service latency; limited by NICs and network bandwidth | One option for L3, such as a distributed memory cache |
| SSD / NAND flash: an SSD is a solid-state drive; NAND flash is the medium it uses to store data | Large capacity, usually cheaper per byte than DRAM, and retains data without power | Higher access latency than memory, plus extra work during updates and finite write endurance | Another option for L3, for retaining a larger history |
HBM: feeding the GPU
Why bandwidth matters
Return to the document example. While generating an answer, full attention repeatedly reads the document’s KV. A longer document means more historical KV to read at each decode step. The GPU can do a great deal of arithmetic in parallel, but it needs the data to arrive fast enough. This is why active KV belongs in high-bandwidth GPU memory.
How HBM moves more data
HBM stacks several DRAM dies vertically and connects them with through-silicon vias, or TSVs. The stacks sit beside the GPU die in the same package. Dense wiring inside the package provides a wide interface between the GPU and memory. Short connections help reduce the energy spent moving each bit, and multiple memory channels let the GPU transfer more data at once. HBM sits close to the GPU’s compute die; it is not memory built inside that die. Micron’s HBM3E overview
Inside each die, a typical DRAM cell stores one bit as charge in a capacitor, with a transistor controlling access. Charge leaks away, so the memory must refresh it regularly. Cells are arranged in rows within banks, which are groups that can handle some operations independently. To read a row, the memory activates it and senses the stored charge; switching rows in the same bank may first require closing the old row, a step called precharge. HBM still does this work. Its wide interface helps move many bytes in parallel, but does not remove the time needed to access the cells. Micron’s HBM memory architecture
The cost of this design is in the package as well as the memory chips. There is limited space beside the GPU, stacking makes manufacturing and cooling harder, and the dense connections require advanced packaging. Adding HBM capacity usually means choosing a different accelerator design, rather than plugging in another memory module. HBM also loses its contents without power, just like other DRAM.
What stays in L1
HBM is therefore a good place for KV that attention is using now. GPU kernels read chunks of that data into on-chip caches and shared memory as they work, while the full KV pool stays in GPU memory. If the GPU uses GDDR instead of HBM, its GPU memory still serves as HiCache L1; the software tier does not require one particular memory technology.
The GPU’s on-chip caches and shared memory use SRAM. A typical SRAM cell holds a bit in a transistor circuit while power is supplied, without DRAM’s periodic refresh. This makes it useful for fast on-chip access, but each bit takes much more silicon area. It can hold the small working blocks a kernel needs, not the entire history of many conversations. HiCache therefore does not treat it as another storage tier. CUDA memory spaces
Once the answer is finished, the document’s KV may sit unused until the next question. Keeping it in HBM saves a future load, but also takes space away from new requests. HiCache can keep a copy in a lower tier and reclaim the GPU space when needed. That leads to the next question: where can we keep more KV without paying for more GPU memory?
CPU memory: keeping more KV
Where the extra capacity comes from
A server usually has DRAM chips on DIMM memory modules, connected to the CPU’s memory controller. We call this Host memory. The motherboard can provide several memory channels and slots, so capacity can be increased within the server’s supported configurations. Compared with HBM beside a GPU, this usually gives us more affordable capacity. The tradeoff is that this memory connects to the CPU, not directly to the GPU’s memory interface.
DGX H200 uses DDR5 DIMMs. Vera Rubin uses LPDDR5X on replaceable SOCAMM modules, with NVLink-C2C connecting its CPUs and GPUs. The modules and links change, but Host memory still sits on the CPU side. The diagram compares one DGX H200 server with one Vera Rubin NVL72 rack; the expanded view shows their local connections. DGX H200 architecture · Vera memory design · Vera Rubin specifications
DGX H200
One of the server’s 8 GPUsHow does HiCache use this capacity?
HBM serves as L1, while part of CPU-attached DRAM can form L2. The OS, model weights, and runtime also consume memory, and instances allocate their own KV pools. The 54 TB figure is a rack total; an instance’s usable capacity depends on process placement, parallelism, and memory configuration. NVLink-C2C changes the CPU–GPU access path; it does not automatically create a rack-wide HiCache pool.
The GPU still has to receive it
Suppose the next question arrives after the document’s KV has left the GPU, but a copy remains in Host memory. In a conventional PCIe server, loading it means reading Host DRAM, sending the bytes over PCIe, and writing GPU memory. The transfer can only run as fast as the slowest part of that path. If several GPUs share memory channels or an upstream link, they also compete for that bandwidth.
Let’s put numbers to this difference. Suppose the GPU needs to read 1 GB of KV data, using decimal units throughout. The ideal time is data size ÷ bandwidth. If the data is already in H100 SXM’s HBM, its listed bandwidth of 3.35 TB/s = 3,350 GB/s gives 1 ÷ 3,350 seconds ≈ 0.30 ms to read it. If the same 1 GB is stored in CPU memory and must first be copied to the GPU over PCIe Gen 5 x16, the listed one-way bandwidth of 64 GB/s gives 1 ÷ 64 seconds ≈ 15.6 ms for that transfer alone. The advertised 128 GB/s adds both directions together and does not apply to this one-way copy. These estimates assume full bandwidth utilization and ignore other overheads; they are not measured KV restore times. CPU memory can provide room for more KV data, but bringing that data back to the GPU still takes time. H100 specifications · Hopper PCIe specifications
Why L2 is still useful
HiCache does not need to read the document from CPU memory at every decode step. It loads the cached KV back onto the GPU, then attention uses that GPU copy. The cost to compare is one restore against another prefill over the document. If restoring is cheaper, L2 saves time even though its path to the GPU is much slower than HBM access.
Where the Host buffer is allocated also matters. On a server with several CPU sockets, allocating it near the GPU’s socket avoids an extra trip across the CPU-to-CPU link. This is NUMA locality. The buffer can also use pinned memory, whose pages stay fixed for device transfers. Pinning helps the transfer path; it does not make the DRAM cells faster, and pinning too much memory leaves less flexibility for the rest of the system. CUDA Host–device transfer guidance
L3: keeping a larger history
Using DRAM on other machines
Remote DRAM gives us access to memory on other machines, so we can keep more KV than one machine can hold. DRAM itself supports fast reads and writes. A shared cache service also lets several inference instances reuse the same KV instead of each computing and storing a separate copy.
The tradeoff is the extra network access. Reading remote DRAM means locating the data and transferring it back to the local machine. This adds waiting time and can be limited by network bandwidth, even though the memory chips are fast. DRAM also usually costs more per GB than SSDs and loses its contents without power.
In HiCache, a remote DRAM service such as Mooncake Store can serve as L3. Software saves reusable KV there. On a later hit, it reads the KV into local Host memory and then copies it to the GPU. Sharing requires the instances to access the same cache and use compatible models and KV formats; calling a backend L3 does not automatically make it shared. HiCache tier sharing
Using SSDs
SSDs are another option for documents that are worth keeping but are read less often. They offer large capacity at a lower cost per GB than DRAM and retain data without power. When there is too much KV to keep affordably in GPU or CPU memory, SSDs can hold history that may be useful again later.
The tradeoff is slower reads and writes than DRAM, and writes consume the device’s finite endurance. SSDs therefore suit historical KV that is used less often. KV that attention is actively reading should still stay in GPU memory. If the SSD is on another machine, reading it also takes a network transfer.
In HiCache, SSDs can provide the storage for L3. Software writes KV worth keeping to the backend and, on a later hit, restores it through Host memory to the GPU. There are two decisions: when writing, favor KV likely to be reused; when reading, compare the restore time with recomputation. Writing KV that is never reused wastes resources, and waiting for an SSD read may not pay off when recomputation is cheap.
These tiers can hold copies of the same KV at the same time. Backing up the document to L2 does not require deleting its GPU copy immediately. Loading it from L3 does not require deleting the L3 copy either. We choose which copies to retain based on the available space and how likely the document is to be used again.
Moving KV back to the GPU
KV in local CPU memory needs a Host-to-GPU transfer. Remote KV first needs a network transfer as well. Compare the two stages separately.
Local memory → GPU
| PCIe | NVLink-C2C | |
|---|---|---|
| Benefit | Widely supported | High CPU–GPU bandwidth |
| Tradeoff | Large KV transfers can be limited by bandwidth | Requires a platform such as Grace Hopper or Vera Rubin |
Remote machine → this machine
| TCP | RDMA | |
|---|---|---|
| Benefit | Broad compatibility; easy to deploy | Less CPU work and fewer copies |
| Tradeoff | Heavy traffic can consume substantial CPU time | Requires suitable NICs, network setup, and backend support |
Optional: can data skip Host memory?
GPUDirect RDMA sends network data directly into GPU memory. GPUDirect Storage does the same for storage reads. Both can avoid Host-memory staging, but require hardware and software support; the network or storage read still takes time.
The HiCache example below uses L3 → Host → GPU. Receiving KV into Host memory over RDMA still leaves the Host-to-GPU step.
Following one restore
If the document’s KV is only in L3, the restore path is L3 → Host memory → GPU memory. The GPU can use each part once it arrives. An L2 hit skips the L3-to-Host step; an L1 hit needs no restore transfer. Switch the hit location in the animation to compare the paths.
Is restoring faster than recomputing?
Reuse saves time when waiting for the KV to return is faster than recomputing the document’s prefix.
In a teaching example, reading from L3 into Host memory takes 100 ms, then copying to the GPU takes 20 ms. Running these steps one after the other means a 120 ms wait. If recomputation takes 150 ms, reuse saves 30 ms. If it takes only 50 ms, waiting for the cache is slower.
Adjust the inputs to see when reuse becomes faster. Prefetching moves some data before the request needs it, reducing the wait that remains. For a real deployment, compare times measured on actual requests.
Further reading
This visualized tutorial was written by Yichi Zhang.