Inside a Trillion-Parameter MoE Architecture: Breaking Down 1M-Token Context Inference

    This article analyzes a preview ultra-large sparse Mixture-of-Experts (MoE) language model with roughly 1.6T total parameters, about 49B activated parameters per token, and support for around 1M tokens of context. It walks through the layer-by-layer design that keeps attention and KV cache costs manageable at long context: a two-stage compressed sparse attention (CSA) funnel, heavily compressed attention (C128A), a mix of hash-routed and learned-routed feed-forward layers, an mHC reconnect mechanism with pre- and post-processing, and a multi-token prediction (MTP) head. It closes with a practical engineering checklist covering memory budgeting, operator fusion, routing observability, long-context validation, and cloud deployment considerations.

    1. Why It Matters: The Tension Between Long Context and Inference Cost

    The evolution of ultra-large sparse models (MoE) is shifting from “stacking parameters” to “controlling cost.” When the context window expands from a few thousand tokens to the million-token range, the memory and bandwidth overhead of the attention portion grows super-linearly with sequence length. That overhead does not shrink just because the parameters are sparsified. So the core design question for a new generation of architectures can be stated in one sentence: while keeping total parameter count and representational capacity intact, push the marginal cost of attention and the KV cache down into an acceptable range.

    This article uses a preview ultra-large sparse language model (a text-only LLM with roughly 1.6T total parameters, about 49B activated parameters per token, and support for around 1M context) as the analysis sample, and breaks down its computation flow layer by layer. Note that all parameters below come from public architecture descriptions; they illustrate the design approach and are not performance commitments for any specific product.

    2. Overall Architecture: Layer Roles and Connections

    The model has 61 layers, divided into three segments:

    • First 3 layers: sparse feed-forward layers with hash routing (hash-MoE), paired with attention that is, in order, heavily compressed attention, heavily compressed attention, and compressed sparse attention.
    • Middle 58 layers: regular sparse feed-forward layers, with attention alternating between compressed sparse and heavily compressed.
    • Final layer: sliding window attention to close things out.
    • At the end: a multi-token prediction (MTP) head is attached to help predict subsequent tokens.

    Two design points are worth emphasizing.

    First, the early layers use hash routing rather than learned routing. Features in shallow layers are not yet abstract, so routing decisions carry little information and a lot of noise. Replacing a learnable gate with a deterministic hash mapping reduces the load imbalance caused by routing jitter, and makes the computation graph of the first few layers more stable and easier to optimize statically.

    Second, the connection between attention and feed-forward layers is not a plain residual. It is a reconnect mechanism with pre- and post-processing (denoted mHC): a pre-processing step (hc_pre) runs before entering the sub-layer, a post-processing step (hc_post) runs after the sub-layer output, and then the states are merged. Compared with direct addition, this three-stage “pre-process — sub-layer — post-process” pattern effectively gives each sub-layer a learnable pair of scaling and projection operations. That lets attention with different compression ratios and FFNs with different routing methods coexist on the same residual trunk without suppressing one another. The engineering cost is two extra element-wise/projection operations; the payoff is better numerical stability when stacking many layers.

    3. Compressed Sparse Attention (CSA): Two Channels Working Together

    The key to CSA is not “sparse” but a two-stage funnel of “compress first, then select,” with a KV side made up of two channels.

    The first channel is the sliding window channel. Each token computes attention only with tokens inside the window, and the KV cache only needs to hold window-sized entries, cyclically overwriting once the window is exceeded. So cache usage is constant rather than growing linearly with the sequence. In the decode phase (sequence length 1, batch size 1), the data flow can be sketched as follows:

    1. # Single decode step (shapes are illustrative)
    2. x = hidden_state # [1, hidden_size]
    3. kv = downsample(x) # KV downsample -> [1, head_dim]
    4. rope_part, quant_part = split(kv, at=rope_head_dim)
    5. kv = concat(rope(rope_part), quantize(quant_part))
    6. window_cache.ring_put(kv) # ring overwrite, capacity = window_size

    There is an easily overlooked detail here: rotary position encoding is not applied to the whole head_dim, but only to the first rope_head_dim dimensions; the remaining dimensions go through the quantization path. The point is to decouple position-sensitive from position-agnostic information, so quantization error does not pollute the relative distance information carried by the position encoding.

    The second channel is the compression channel. Historical states are first aggregated by a compression module, which produces T compressed KV entries each time and writes them to the compressed cache; an index module then scores the T candidates and keeps no more than topK of them for the attention computation. The benefit of the two-stage funnel is clear: compression turns “keep per token” into “keep per block,” and indexing turns “keep per block” into “keep by relevance,” so the number of entries that actually participate in attention scoring is only weakly correlated with sequence length.

    4. Heavily Compressed Attention (C128A): Where the Compression Ratio Goes Extreme

    When the compression ratio reaches the 128:1 range, the compression module is no longer just “saving bandwidth” — it is “carrying long-range memory.” Its structural logic is the same as CSA — compression produces candidates, indexing selects — but the compression granularity is coarser, so each pass outputs fewer compressed entries with higher information density per entry. Architecturally, alternating it with CSA is essentially about letting two time scales coexist: the coarse-grained channel handles global recall across hundreds of thousands of tokens, the fine-grained channel handles local detail reconstruction, and the sliding window in the final layer guarantees accuracy for the nearest context.

    5. Sparse Feed-Forward Layers: Regular Routing vs. Hash Routing

    Regular MoE relies on a learnable gate to assign tokens to experts. It is expressive but needs load-balancing auxiliary loss and capacity factor control. Hash MoE trades that for stability and low overhead via a deterministic mapping. Splitting the two by depth is a pragmatic compromise: stability in the shallow layers, strength in the deep ones.

    6. The Multi-Token Prediction Head and the Inference Path

    At the end, the multi-token prediction head provides an extra supervision signal during training, improving representation quality. During inference it can serve as a draft source for speculative decoding, working with the main model’s verification to reduce the average number of decode steps. It is complementary to the compressed attention described above: one reduces the attention cost per step, the other reduces the total number of steps.

    7. Engineering Checklist

    • Memory budget: separately account for the window cache (constant), the compressed cache (inversely proportional to the compression ratio), and the temporary overhead of index scoring.
    • Operator fusion: fuse hc_pre/hc_post with quantization and RoPE as much as possible to reduce memory access.
    • Routing observability: track the distributions of hash and learned routing separately to avoid frequent capacity factor jitter.
    • Long-context validation: use “needle in a haystack” style retrieval tasks to validate the recall boundaries of the coarse and fine compression channels layer by layer.
    • Cloud form: combine with a container platform for elastic scaling, use object storage to hold weights and cache snapshots, and use monitoring, alerting, and logging services to track first-token latency and throughput.

    8. Summary

    The highlights of this architecture come down to four points: attention uses a two-stage funnel (compression plus indexing); the compression ratio is divided by layer; the residual trunk is reshaped by pre- and post-processing to accommodate heterogeneous sub-layers; and the prediction head works with sparsification to reduce end-to-end cost. Understanding these four points gets you to the main design thread of a trillion-parameter model in a million-token context scenario: being big and being cheap at the same time.