Deep Dive into Large-Scale MoE Architecture: Highlights of 1M Context Inference

    This article breaks down a preview large-scale MoE model that natively supports 1M-token context inference, with roughly 1.6T total parameters and about 49B activated parameters. It explains why long context forces a redesign of attention, how the 61-layer structure is arranged, and how two compressed attention variants (CSA and HCA), sliding window attention, regular and hash-based experts, and an MTP head work together to keep memory and compute costs manageable. It also offers practical guidance on capacity planning and observability for teams evaluating similar designs.

    1. Why Long Context Requires “Reconstructing” Attention

    As parameter counts scale toward the trillion level, context length has stretched from a few thousand tokens to 1M. The real bottleneck has shifted from “can the model parameters fit” to “can the KV cache fit, and can attention finish computing in time.” Standard attention complexity grows quadratically with sequence length, while the KV cache expands linearly with length. Combined, these two factors push memory and bandwidth costs of long-text inference out of control.

    A recently released preview version offers a representative answer: roughly 1.6T total parameters, about 49B activated parameters, native support for 1M context inference, and a pure language model with no multimodal branch. Its approach is not simply to pile on compute, but to compress long-sequence costs into an operable range through three things: hierarchical compression, sparse selection, and expert sparsification. The following sections walk through the overall structure, the two attention types, the expert layers, and the training/inference tooling layer by layer.

    2. Overall Structure: Division and Layout of 61 Layers

    The model has 61 layers, clearly divided into three segments:

    • First 3 layers: use hash experts (hash-MoE), with attention being heavy-compression attention, heavy-compression attention, and compressed sparse attention in order;
    • Middle 58 layers: regular mixture-of-experts layers, with heavy-compression attention and compressed sparse attention alternating;
    • Final layer: wraps up with sliding window attention;
    • An additional multi-token prediction (MTP) head is attached at the end to predict subsequent tokens.

    This arrangement of “heavy compression in front, sparsity in the middle, window at the end” is not arbitrary: shallow layers focus more on the global semantic skeleton and are suited to trading a high compression ratio for an ultra-long receptive field; deep layers focus more on local details and bursty information and are suited to using sparse selection to retain high-value tokens; the final layer uses sliding window for local refinement at the lowest cost.

    The inter-layer connection is also modified: instead of a plain residual direct connection between attention and expert layers, a connection scheme with pre-processing and post-processing is introduced (typically denoted as pre and post operators in engineering). Pre-processing handles preparation such as normalization/projection before cross-layer transfer, while post-processing maps the sub-layer output back to the main trunk scale. Compared with a bare residual, these two extra steps allow sub-layer outputs with different compression ratios to align on the same numerical scale, which is friendlier to training stability in ultra-deep networks.

    A simplified sketch of intra-layer computation (pseudocode, expressing only data flow order):

    1. # General skeleton of a single-layer forward pass
    2. x = hc_pre(x) # Cross-layer pre-processing, align scale
    3. if layer_type == "HCA":
    4. y = hca(x, kv_cache) # 128:1 heavy-compression attention
    5. elif layer_type == "CSA":
    6. y = csa(x, kv_cache, indexer) # 4:1 compression + sparse selection
    7. else:
    8. y = swa(x, kv_cache) # Sliding window attention
    9. x = hc_post(x, y) # Post-processing, write back to trunk
    10. h = moe(x) if layer_idx >= 3 else hash_moe(x)

    3. CSA: Two KV Channels of Compressed Sparse Attention

    The key to compressed sparse attention (CSA, compression ratio about 4:1) is splitting KV into two complementary channels: one preserves local information, the other preserves global information.

    The first path is the sliding window channel. Each token computes attention only with tokens inside the window; KV outside the window is no longer retained, and the cache is overwritten cyclically in a ring fashion. Taking the decoding stage (sequence length 1, batch size 1) as an example, the input shape is [1, hidden_size]; after KV downsampling, the cache shape degenerates to [1, head_dim]. The first rope_head_dim portion is subject to rotary position encoding, and the remaining portion goes through quantized compression before being written into the window cache. The benefit is constant memory usage that does not grow with context length.

    The second path is the compression channel. The input state first passes through a Compressor to generate T compressed KV tokens and update the compression cache, then an Index module scores these compressed tokens and retains no more than topK of them for subsequent attention computation. Compression is responsible for “squeezing long history into a few summaries,” and indexing is responsible for “picking the most relevant few from the summaries.” In series, the cost of obtaining global information drops from O(sequence length) to a constant level related to T and topK.

    Three points worth noting in engineering:

    1. Compression block size T and topK are a pair of key knobs. T determines summary granularity, and topK determines how many summaries actually participate in each computation; both must match the strength of long-range dependencies in the task;
    2. Position encoding acts only on part of the window channel dimensions, while quantization acts on the remaining dimensions. This “per-dimension handling” avoids interference between positional information and numerical precision;
    3. The outputs of the two channels must be fused before entering the expert layer, and the fusion weights are usually learnable so the model can adaptively trade off between “local details” and “global summaries.”

    4. HCA: 128:1 Heavy Compression and Ultra-Large Receptive Field

    Heavy-compression attention (HCA, compression ratio about 128:1) takes a more aggressive route, with its compressor output dimension denoted as a C128A-like form. It compresses ultra-long history into a very small number of tokens, trading extremely low cache and compute cost for a near-global receptive field. It is therefore placed in the first two layers, which handle global semantic positioning rather than fine-grained retrieval.

    The division of labor between HCA and CSA can be understood this way: HCA answers “what is this passage about overall,” CSA answers “where are the few segments most relevant to the current generation,” and sliding window answers “what is the immediately preceding context.” In series, the three form a three-level retrieval chain from coarse to fine.

    5. MoE: Two-Layer Sparsity of Regular and Hash Experts

    There are also two types of expert layers. Regular mixture-of-experts uses a gating network to select a few experts for each token, with only about 49B activated parameters, a tiny fraction of the 1.6T total parameters. This is the fundamental source of controllable inference cost. The first 3 layers use hash experts: tokens are deterministically routed to fixed experts based on token IDs or a fixed hash function, eliminating gating computation while naturally guaranteeing load balance.

    Placing hash experts in shallow layers makes sense: shallow features are not yet highly differentiated, so the information gain from routing decisions is limited, and trading deterministic routing for throughput and stability is more worthwhile; deep features are clearly differentiated, making it worth paying the gating overhead for fine-grained selection.

    6. MTP and Engineering Implementation Advice

    The MTP head at the end predicts multiple subsequent tokens in a single forward pass. It can be combined with speculative decoding during inference to reduce latency, and serve as an auxiliary loss during training to improve representation quality.

    To borrow this design in your own system, start in three places: first, quantitatively assess the “effective length distribution” of business context; most scenarios do not need 1M, and 4:1 compression is enough to cover them. Second, factor the KV cache into capacity planning, estimating the upper bound of memory by the three parameters of window size, compression block size, and topK. Third, improve observability by continuously tracking cache hit rate, expert load skew, and first-token latency through logging services and monitoring alerts, then adjust replica counts with the elastic scaling of a container platform. Using object storage for offline indexing of long documents can further reduce online retrieval pressure.