Millisecond-Scale... I mean, Million-Token Context LLMs: Architecture and Engineering Practices

    This article breaks down the technical architecture and engineering practices behind million-token context large models. It explains why long context is fundamentally a challenge of memory, bandwidth, and attention complexity, then walks through sparse MoE design, attention restructuring, kernel-level optimization, and layered inference serving. Developers will find capacity estimation formulas, tuning order recommendations, and a four-dimension evaluation framework for building and optimizing long-context systems.

    1. Background: What an Unannounced Open-Source Release Signals

    In late April 2026, an open-source large model series released a preview version with open weights, raising both parameter scale and context length at the same time. The flagship tier has roughly 1.6T total parameters with about 49B sparse activations; the lightweight tier has roughly 284B total parameters with about 13B sparse activations. Both tiers support approximately 1M tokens of context by default. Benchmarks cover coding, math, agentic tasks, and long-form text, with overall results in the top tier.

    What matters is not the scores but the release approach: no warm-up, no staged rollout, weights opened directly. This usually means three things have matured: the stability of the training and inference stack, the reusability of operators and parallelism strategies, and the feasibility of community self-hosting. For developers, the real value is turning “long context” from a switch into an engineering system that can be decomposed and tuned.

    Two common misconceptions should be cleared up first:

    • The lightweight tier is not a distilled product of the flagship tier. They are independently pre-trained sparse MoE models that differ only in scale and sparsity.
    • Long context is not a runtime switch. Both tiers are long-context by default, and the server side no longer distinguishes between short and long models.

    2. Capability Breakdown: Where Long Context Gets Hard

    The difficulty of long context concentrates in three areas: memory, bandwidth, and attention complexity.

    1. The KV cache grows linearly with length and is the main memory consumer.
    2. The decoding phase is memory-access intensive, so the bottleneck is bandwidth rather than compute.
    3. Attention has quadratic complexity with respect to sequence length, so both computation and communication scale up on long sequences.

    Therefore, competition in long-context capability is essentially competition over “cost per token.” Any approach that only optimizes benchmark scores will quickly expose throughput and cost problems once it enters real-world, high-concurrency, long-document scenarios.

    3. Architecture Layer: Co-Designing Sparse MoE and Attention

    3.1 Sparse Activation Decouples Parameter Scale from Per-Token Compute

    Sparse mixture-of-experts allows the total parameter count to be very large while each token activates only a small number of experts. The flagship tier’s 1.6T total parameters with 49B activations means per-token computation is compressed to about 3% of the total parameters. This yields two direct benefits: higher model capacity and knowledge coverage, and controllable per-token compute overhead.

    Engineering-wise, you need to address load balancing, expert routing jitter, and communication overhead. Common practices include capacity factor constraints, auxiliary balancing losses, and combining expert parallelism with data parallelism to prevent individual experts from becoming hotspots.

    Illustrative routing and capacity-constraint logic:

    1. # Pseudocode: expert routing + capacity constraint
    2. logits = router(x) # [tokens, num_experts]
    3. probs = softmax(logits, dim=-1)
    4. topk_idx, topk_w = topk(probs, k=2) # sparse activation
    5. assign = capacity_limited(topk_idx, capacity=C) # drop or overflow to shared experts
    6. y = sum(experts[e](x_i) * w_i for i, e, w in zip(idx_i, assign_i, topk_w))

    3.2 Attention Restructuring: Sparsification, Chunking, and Position Encoding Extrapolation

    Long context typically relies on three coordinated techniques: attention sparsification (local windows plus a small number of global tokens), chunking with hierarchical caching, and scale extrapolation of position encoding. The goal is to make the effective receptive field cover the full sequence while keeping the number of tokens actually involved in computation within a controllable range.

    It is important to note that sparsification changes the model’s effective receptive field, so dedicated validation is required on tasks such as long-document retrieval and cross-segment reasoning, rather than looking only at perplexity.

    4. Operator and Kernel Layer: Turning Theoretical Gains into Real Throughput

    To realize architectural benefits, operator-level optimization is essential:

    • Fused attention kernels to reduce memory round-trips of intermediate tensors.
    • Paged KV cache management to reduce fragmentation and copying.
    • Quantization and low-precision accumulation to improve bandwidth efficiency while keeping accuracy under control.
    • Overlapping communication and computation to hide synchronization overhead from expert parallelism.

    A simplified capacity estimate for planning:

    1. KV_bytes ≈ 2 * layers * kv_heads * head_dim * seq_len * batch * bytes_per_elem

    Increasing seq_len from 4K to 1M inflates KV usage by roughly 250x. This is precisely why long-context serving must adopt cache paging, quantization, and tiered offloading.

    5. Serving Layer: Tiering and Scheduling for Long-Context Inference

    In real business settings, long-context serving requires a layered design:

    1. Prefix cache reuse: system prompts, tool definitions, and long-document prefixes are reused on cache hits.
    2. Chunked prefill and streaming output: reduces jitter in time-to-first-token.
    3. Separate pools for long and short requests: prevents long requests from blocking the queue for short requests.
    4. Elastic scaling and graceful degradation: when memory is tight, prioritize throughput and reduce concurrency.

    When deploying on the cloud, you can compose general-purpose services: container platforms host inference instances, object storage holds models and long documents, message queues buffer requests, and logging plus monitoring and alerting provide observability.

    6. Evaluation and Tuning: Don’t Look at the Total Score Alone

    A four-dimension evaluation is recommended: effectiveness (coding/math/agentic/long-form text), efficiency (throughput, time-to-first-token, cost per token), stability (no drift in long sessions), and safety/compliance (instruction following and data boundaries under long context).

    The recommended tuning order is: first fix the evaluation set and baseline, then tune caching and batching strategies, and finally adjust precision and parallelism. Each step should have a rollback switch.

    7. Conclusion

    The core competitiveness of million-token context lies not in the parameter table but in the coordination of three layers: architecture, operators, and serving. The takeaway for developers is to treat long context as a systems engineering problem: use a capacity model for planning, layered serving for cost control, and four-dimension evaluation to safeguard effectiveness and stability. For quick validation, you can build a minimal viable pipeline on general container and storage capabilities on platforms such as Baidu AI Cloud, then progressively load-test and tune.