LLM Inference Without Full-Network Recompute: Memory Writes Boost Throughput by 42%
This article explains how to decouple memory writes from next-token prediction in large language model inference. It covers shallow prefilling with a lightweight memory writer, low-rank storage for recurrent states, and the quality constraints that keep the original weights frozen. Readers will find pseudocode, engineering caveats, reported throughput gains, and practical rollout advice.
1. The Problem: Compute Asymmetry Between Prefill and Decode
In LLM inference serving, a request typically goes through two phases: prefill and decode. Prefill processes the entire input in one pass, with high compute density and high parallelism. Decode advances one token at a time, serially, constrained by memory bandwidth and the cost of reading and writing state. Traditional implementations require every layer to participate fully in both phases, even though the two phases have different goals: the core output of prefill is the memory prepared for later generation (KV Cache and recurrent state), while the core output of decode is predicting the next token.
That distinction is the opening for optimization: the deep computation needed to prepare memory for generation can be significantly smaller than the deep computation needed to predict the next token.
2. Method 1: Shallow Prefilling for Memory Writes
Take a 48-layer hybrid model as an example. When processing the input, all tokens except the last one can pass through only the first 31 layers, after which a lightweight memory-writing component fills in the KV Cache and recurrent state for the remaining 17 layers. Once generation begins, every token still goes through all 48 layers. The benefit: the deep matrix multiplications for a large number of tokens in prefill are skipped, while generation quality is still guaranteed by the full depth.
Illustrative logic (pseudocode):
# Prefill: shallow compute + lightweight memory writeh = embed(input_tokens)for layer in layers[:31]:h = layer(h)kv_cache, recurrent_state = memory_writer(h, target_layers=range(31, 48))# Decode: full depthfor step in range(max_new_tokens):h = embed(last_token)for layer in layers: # all 48 layersh = layer(h, kv_cache, recurrent_state)last_token = sample(h)
Three engineering points matter. First, the memory-writing component must align with the output distribution of the backbone layers, otherwise cumulative error is introduced. Second, the shallow truncation point must be calibrated against the model structure; different layer ratios yield different results. Third, the generation phase cannot be simplified, or the quality drop will show up immediately.
3. Method 2: Low-Rank Factorized Storage for Recurrent State
A hybrid model reads and writes recurrent state at every decode step. Such state often has a dominant component pointing in a nearly fixed direction, with the remainder forming a low-rank structure. Storing the state as a decomposition of “dominant component + low-rank factors” lets the model read and update directly in that form, avoiding moving the full state at every step.
For a 48-layer hybrid model, the recurrent state per request drops from 113.2MB to 29.2MB after compression, averaging about 43.4MB over a full compression cycle. For high-concurrency serving, this directly reduces memory footprint and the bandwidth pressure of state reads and writes, making it one of the key sources of decode-side throughput improvement.
# State stored in factorized form: main direction + low-rank residualstate = {"main": main_component, "lowrank": (U, V)}def read_state(state):return state["main"] + U @ Vdef update_state(state, delta):# Incremental update directly on the factorized form, avoiding materializing the full statestate["lowrank"] = shrink(state["lowrank"] + project(delta))
4. Results and Quality Constraints
On a single accelerator card, a mainstream inference framework, and long-context workloads such as AI coding assistant session traces, this combination of optimizations delivers a 16% to 42% increase in peak throughput per GPU. At the comparison point of P90 user-facing end-to-end output rate, the improvement range is 23% to 42%. On the quality side, the approach is: the original model weights stay frozen throughout, and the new components are trained via distillation. Accuracy was then evaluated across five trained hybrid models and six checkpoints, confirming the changes do not sacrifice output quality.
5. Rollout Recommendations
- Quantify where the gains come from first: measure the time share of prefill and decode separately to decide whether to prioritize shallow writes or state compression.
- Make distillation data cover the real workload distribution, especially long contexts and tool-call traces.
- Before launch, run P90/P99 end-to-end rate alignment evaluations rather than looking at peak throughput alone.
- If you use a cloud container platform with monitoring, alerting, and logging services, add cache hit rate and state compression cycle to the core metrics dashboard.
The essence of this approach is decoupling memory writes from next-token prediction, so compute is spent where it actually affects output quality, yielding a meaningful per-GPU throughput gain while the original weights remain frozen.
