Accelerating Hybrid LLM Inference: SEED Writes Memory to Avoid Reading the Entire Network

    This article explains a hybrid LLM inference acceleration approach built on a simple observation: during prefill, most tokens only need to write memory rather than predict the next token. It covers the underestimated memory cost of recurrent states, a shallow-layer prefill plus lightweight memory writer design, low-rank recurrent state compression for decoding, reported throughput gains, quality evaluation practices, and a practical deployment checklist.

    1. Background: The Memory Cost of Hybrid Architectures Is Underestimated

    Hybrid architecture LLMs typically keep only a small number of softmax attention layers to store the KV Cache, while most layers use linear attention or state space forms that maintain a fixed-size recurrent state. The intuitive advantage is clear: the KV Cache grows linearly with context length, while the recurrent state stays constant in size.

    But “constant” does not mean “small.” Using the scale given in the source material, the recurrent state for a single request in a hybrid model is roughly equivalent to the attention cache of about 4,500 tokens. More importantly, these states are read and written every time a token is generated, and they compete for GPU memory alongside active requests and prefix caches. As concurrency rises and contexts grow longer, memory pressure does not come only from the KV Cache; recurrent states also squeeze the available batch size.

    So the entry point for inference optimization should not be limited to “compute faster.” It should also look at “write less, store less.” The approach discussed here splits the cost into two parts: reducing deep computation during prefill, and compressing recurrent states during decoding.

    2. Core Insight: Writing Memory Requires Far Less Compute Than Predicting the Next Token

    During prefill, only the output of the last token in an input segment is used to predict the first response token. The value of the remaining tokens lies in the KV Cache and recurrent states they write for each layer. In other words, the job of most tokens is to “write memory,” not to “make predictions.”

    This leads to a measurable difference: writing memory for subsequent generation can require significantly less deep computation than predicting the next token. The approach measured this difference on five trained hybrid LLMs and used the measurements to cut deep computation during prefill.

    2.1 The First 31 Layers Are Enough to Write Memory for the Last 17

    The method is as follows: when processing an input, all tokens except the last one run only the first 31 layers. A lightweight memory writing component then generates the corresponding KV Cache and recurrent states for the remaining 17 layers. During generation, every token still runs the full 48 layers, so the output quality path is not weakened.

    The overall scheduling logic can be expressed with pseudocode (illustrative, not a specific product API):

    1. # Prefill: non-final tokens go through shallow layers + lightweight write
    2. def prefill(tokens):
    3. last = tokens[-1]
    4. others = tokens[:-1]
    5. h_others = model.forward_layers(others, upto=31)
    6. kv, recurrent = memory_writer.write(h_others, target_layers=range(31, 48))
    7. h_last = model.forward_layers([last], upto=48) # final token runs full depth
    8. return kv, recurrent, h_last
    9. # Decode: every step still runs the full 48 layers
    10. def decode(step_input, kv, recurrent):
    11. return model.forward_layers(step_input, upto=48, kv=kv, state=recurrent)

    The key constraint of this design is that the original model weights stay frozen throughout, while the new memory writing component is trained via distillation, keeping the error from “shallow write, deep fill-in” within an acceptable range.

    3. Decoding Optimization: Compressing Recurrent States into a “Main Direction + Low-Rank Residual”

    The recurrent states of a hybrid model are read and written at every step. Storing them directly in dense form leads to high memory and bandwidth overhead. The approach observes that a recurrent state often contains a dominant component close to a fixed direction, and the remaining content has low-rank structure. The state is therefore stored in this decomposed form, letting the model read and update it directly instead of reconstructing the full dense tensor at every step.

    3.1 Scale of the Compression

    On a hybrid model, the recurrent state for a single request drops from 113.2MB to 29.2MB right after compression, with an average of 43.4MB over the full compression cycle. Under the same memory budget, this leaves more room for concurrent requests and prefix cache space.

    An illustrative state representation (pseudocode):

    1. # state = main direction component + low-rank residual
    2. class LowRankState:
    3. def __init__(self, base_dir, U, V):
    4. self.base_dir = base_dir # dominant component close to a fixed direction
    5. self.U = U # low-rank basis
    6. self.V = V # low-rank coefficients
    7. def read(self):
    8. return self.base_dir + self.U @ self.V
    9. def update(self, delta):
    10. # update low-rank coefficients directly, avoiding full state reconstruction
    11. self.V = self.V + project_to_lowrank(delta, self.U)

    Two engineering points matter: first, low-rank projection and inverse projection add extra operators, which need to be amortized through fusion and batching; second, state consistency within the compression cycle must be guaranteed, so prefix cache reuse and active request updates do not contaminate each other.

    4. Performance: Throughput per GPU and User-Side Speed

    On a single GPU, with a common inference framework and a workload of “coding agent session traces” featuring long contexts and multi-turn tool calls, the approach increases peak throughput per GPU for a hybrid model by 16%–42%. At the comparison point of the same P90 user end-to-end output speed, throughput improves by 23%–42%.

    The significance of these numbers is that the optimization is not only effective at an ideal batch size, but still raises overall capacity under a user-perceptible tail latency constraint. For online serving, a P90 constraint is often closer to real capacity planning than average throughput.

    5. Quality Cost and Evaluation Method

    The approach was evaluated for quality across five models and six checkpoints, to check whether shallow-layer writing during prefill and state compression during decoding cause accuracy loss. Since the original weights are frozen and only the new components are trained, the evaluation typically focuses on tasks that hybrid architectures are more sensitive to: long-context retrieval, multi-turn consistency, code generation, and tool calling.

    The practical recommendation is to split the evaluation into two ablation groups, “prefill write error” and “state compression error,” and observe their respective effects on first-token quality, long-range stability, and tail latency, avoiding mixed attribution from combining the two error types.

    6. Deployment Checklist

    • Workload profile: confirm requests are mainly long inputs and multi-turn sessions with a high prefill share, which leaves more room for gains.
    • Memory accounting: include recurrent states in the capacity model using the average over the compression cycle, not just the peak.
    • Consistency strategy: define the read/write order among prefix cache, active requests, and low-rank state updates.
    • Observability: separately monitor the prefill depth distribution, memory writer latency, state compression/decompression time, and P90 output speed.
    • Fallback: keep the full-depth path as a degradation switch for canary rollout and fault isolation.

    7. Conclusion

    The common thread in this kind of optimization is that it does not try to “read the entire network.” Instead, it identifies the memory structure the model already exhibits, decouples “writing memory” from “making predictions,” and replaces “dense states” with a “main direction + low-rank residual.” As hybrid architectures become a mainstream choice, this kind of inference acceleration that starts from the memory path is becoming a practical direction for improving throughput per GPU and stabilizing tail latency.