Hy4 Architecture Breakdown: How Long Context and Sparse Attention Work

    This article explains the Hy4 model's architecture. It covers total and active parameter counts, memory needs for deployment, the main changes from the previous Hy3 model, the Gated DSA attention mechanism with IndexCache, and the practical value of a 1M-token context window. It also identifies which performance and pricing claims lack verifiable data, and offers guidance on model selection, cost estimation, hardware planning, and framework compatibility.

    1. Scale: What Total and Active Parameters Mean

    Hy4 has 770B total parameters, and it activates 49B parameters for each token. A Mixture-of-Experts (MoE) model spreads its parameters across many expert networks and calls only a subset of them in each forward pass. As a result, inference compute scales mainly with the active parameter count, while model capacity comes from the full parameter set.

    Deployment requires considering two separate factors. Compute depends on the active parameters, but memory must hold all parameters. Counting weights alone, 770B parameters take about 1.54 TB in BF16 precision. In FP8, at 1 byte per parameter, they take about 770 GB. Actual memory use also includes the KV cache, activations, and overhead from the inference framework. The main deployment constraints for Hy4 are therefore memory capacity and inter-GPU bandwidth, not only the active parameter count.

    2. Changes from the Previous Hy3 Model

    The table below compares Hy3 and Hy4, based on the figures in the original article. The source did not verify these figures item by item.

    Feature Hy3 Hy4
    Total parameters 295B 770B
    Active parameters per token 21B 49B
    Context length 256K 1M
    Layers 80 78
    Hidden size 4096 6144
    Routed experts 192 256
    Active experts per token Top-8 Top-8 plus 1 shared expert
    Attention GQA Gated DSA + MLA + IndexCache
    Residual channels Standard single path 4-path iHC
    Available precisions BF16 BF16, MXFP8

    Hy4 has slightly fewer layers but wider hidden states and more experts. The original article argues that this combination increases the capacity of each layer while keeping the layer count moderate to control latency. Whether this trade-off works in practice requires real latency testing.

    The shared expert processes every token and handles general knowledge. The routed experts handle more specialized capabilities. The original article uses this split to explain the motivation for the design.

    The original article also states that Hy4 uses a 4-path residual stream (iHC) in place of a single residual connection. Multiple channels give information more paths to travel between layers. The article argues that this helps reduce vanishing gradients in deep networks and improves the capture of long-range dependencies. Gains of this kind usually need ablation experiments to confirm. The original article provides no data for them.

    3. Attention: From GQA to Gated DSA

    Hy3 uses Grouped-Query Attention (GQA). Hy4 uses Gated DSA, which is based on Multi-Head Latent Attention (MLA), together with IndexCache. MLA compresses keys and values into a low-dimensional latent space, so the KV cache is much smaller than in standard multi-head attention. This is one of the basic conditions that make a 1M-token context practical.

    3.1 How the Indexer Selects Tokens

    According to the original article, all 78 layers of Hy4 use DSA, but only some layers run the full Indexer. The article lists 21 full Indexer layers: layers 0, 1, 5, 9, and 13, then every fourth layer after 13 up to layer 77. The other 57 layers reuse the indices produced by these Indexer layers. The Indexer scores historical tokens, and the main attention computes only over the top 2048 positions with the highest scores.

    The complexity of this design should be read carefully. Each query in the main attention processes only 2048 selected positions, so this part of the cost does not grow linearly with context length. However, the Indexer still scores historical tokens, so its cost still depends on context length. The overall complexity therefore cannot be described as reduced to O(n). A more accurate description is that the main attention is limited to a fixed number of candidates, while total cost remains affected by the Indexer.

    3.2 The Role of IndexCache

    IndexCache stores the Indexer output so that later layers can reuse it. The original article bases this on the observation that relevant tokens in adjacent layers are often similar. If the reuse holds, the model can avoid repeated Indexer computation and reduce the associated memory access. The original article gives no latency or throughput measurements, so the size of this benefit must be confirmed by benchmarking.

    4. The Practical Value of a 1M-Token Context

    How much text fits into a 1M-token context depends on the tokenizer. In English, one token is roughly 0.75 words. In Chinese, one character usually consumes about 1 to 2 tokens. Code varies widely depending on the programming language and indentation. Comparisons such as “enough to hold several books” therefore need to be checked against the specific tokenizer.

    The value of a long context lies less in how much text fits and more in whether the model can find and use the key passages. The original article says that the Indexer dynamically selects relevant tokens, which reduces interference from irrelevant content. This capability may help in codebase analysis, long-document question answering, referencing earlier turns in multi-turn conversations, and literature reviews. The original article provides no accuracy or recall figures for these tasks, so you should test with your own data before adopting the model.

    Long context also has costs. Longer inputs require more computation during the prefill stage and occupy more cache. Even with sparse attention, very long inputs consume significant resources.

    5. Performance and Pricing: What You Can Use Directly

    The original article states that Hy4 scores on par with a mainstream open-source model on some public benchmarks. It does not name the benchmark suites, their versions, or the actual scores. Without this information, you cannot judge whether the comparison is fair. The article also mentions possible data contamination in the evaluations, but without specific data, that risk cannot be assessed either. This article therefore makes no quantitative judgment about the benchmark results. A more reliable approach is to run small-scale tests on the code generation, logical reasoning, and multi-step instruction tasks that matter to your own work.

    For pricing, the original article gives Hy4 input and output prices of 6 yuan and 1 yuan per million tokens, respectively. It does not link to an official pricing page, and it does not say whether these prices include cache or batch discounts. Check the current figures on the official pricing page and record the date you looked them up. Hy4 is still in Preview, so both pricing and model capabilities may change.

    6. Selection Guidance

    1. Task type: If your work mainly involves very long documents, large codebases, or reasoning across multiple documents, the 1M context and sparse attention may be valuable. For short question answering or text classification, a model with fewer parameters usually has lower latency and more predictable costs.

    2. Cost estimation: Measure the input and output token counts on a sample of real workloads, then multiply by the official per-token prices to estimate monthly costs. Applications with a high share of input tokens are more sensitive to the input price.

    3. Hardware planning: Hy4’s weight size means it requires a multi-GPU deployment. Evaluate the deployment plan together with precision, concurrency, context length, KV cache size, and inference framework. Do not consider only the memory of a single GPU.

    4. Framework compatibility: The original article states that mainstream inference engines are gradually adding support for new attention mechanisms such as DSA. Feature support may differ across framework versions. Before deploying, confirm that your framework version supports Gated DSA, IndexCache, and your target precision, and run a full regression test.

    7. Conclusion

    Hy4 focuses on increasing total parameters while keeping active parameters under control. It uses Gated DSA and IndexCache to reduce the attention cost of long contexts. These design choices have clear engineering motivations. However, most of the performance and cost figures in the original article lack sources, so readers should verify them with official documentation and their own tests. For developers who work with long text, it is worth running a small-scale evaluation on real tasks before deciding whether to use Hy4 in production.