320B Mixture-of-Experts Model: Sparse Routing and Hybrid Attention Explained

    This article examines a 320B total-parameter Mixture-of-Experts model, clarifying how its overall activation ratio relates to routed-expert sparsity and where common claims need official data. It then walks through token-level expert routing, capacity, load balancing, and All-to-All communication, followed by the linear/sparse attention interleaving and memory implications. It concludes with cautions for code generation and agent scenarios when evaluation details are missing.

    This article uses a Mixture-of-Experts (MoE) model with 320B total parameters as an example to analyze its architecture and discuss issues to watch when deploying it in code generation and agent scenarios.

    The available description does not provide the model name, an official technical report, or evaluation sources. The parameter and performance figures mentioned here should be checked against official public materials.

    First, Verify the Parameters: How Is the Activation Ratio Calculated?

    The model has 320B total parameters, and about 18B parameters are activated during the forward computation for each token. 18 divided by 320 is about 5.6%, which is the overall activation ratio.

    The available description also mentions 288 routed experts, with only 8 activated per token, giving a sparsity ratio of 36:1. This ratio applies only to the routed experts themselves: 8 divided by 288 is about 2.8%. The two sets of numbers do not conflict because activated parameters also include attention layers, shared modules, and embedding layers. Describing 36:1 directly as “using only about 5.6% of the parameters” conflates two concepts; they should be read separately in reports.

    The available description also mentions that “inference cost is reduced to one-tenth of traditional architectures or lower.” This multiplier lacks conditions such as the baseline model, hardware, batch size, and sequence length, so this article does not adopt it. The actual cost reduction needs to be measured under identical conditions.

    How MoE Layers Select Experts

    The first three layers use a dense structure, and later layers switch to an MoE structure. Keeping the early layers dense is said by the designers to help extract general syntactic and semantic features. This is a statement of design intent; whether it holds requires official ablation experiments.

    In an MoE layer, a token is processed as follows:

    1. The router (gate) computes the affinity score between the token and each expert.
    2. It selects the top 8 experts by score (top-k).
    3. It applies softmax normalization to these 8 scores to obtain weighted weights.
    4. It sends the token to the selected experts separately and sums the outputs by weight.

    These four steps are the mathematical core of routing. Deployment also has to handle three engineering issues.

    The first is expert capacity. Each expert has an upper limit on the number of tokens it can process in a batch. Tokens beyond that limit are usually dropped or handled by other paths, and this limit is controlled by the capacity factor.

    The second is load balancing. If most tokens are always routed to a small number of experts, those experts become overloaded while the rest sit idle. Training usually adds an auxiliary loss function to constrain this skew, and the inference side also needs to monitor the actual load of each expert.

    The third is communication. When experts are distributed across multiple GPUs or nodes, tokens must be sent to the corresponding experts through All-to-All communication, and the results must then be collected. Communication latency and inter-node bandwidth directly affect throughput.

    Attention: Alternating Linear and Sparse Layers

    According to the available description, the model periodically interleaves 3 linear attention layers with 1 sparse attention layer, and sets 11 sparse attention layers in 45 layers. Counting one group per 4 layers, 11 groups total 44 layers; the description does not explain how the extra layer is arranged. Readers should follow the layer-order table in the official report and not infer it themselves.

    Linear attention reduces computational complexity from O(N²) to O(N), where N is the sequence length. Its state size is fixed, so the memory footprint of the layer does not grow as the sequence gets longer. The tradeoff is that it compresses historical information into a fixed state, and its ability to recall early content exactly may be weaker than standard attention.

    Sparse attention restricts each token to attending only to a local window or some global key positions. It retains some ability to capture long-range dependencies while reducing computation. The available description suggests that sparse layers can anchor global information, but it does not provide ablation data to prove this.

    Therefore, when estimating total memory for long contexts, both types of layers need to be considered. The KV cache of sparse layers grows with the sequence, while the state of linear layers is fixed. Estimating VRAM only in the way used for a standard Transformer will produce a biased result.

    Code and Agent Scenarios

    The available description claims that the model is near the industry-leading level in code generation and agent tasks, but it does not give evaluation set names, scores, versions, or comparison targets. Such claims cannot be verified. Readers should directly check the results on specific benchmarks; the available description does not provide enough detail to verify the claim.