Optimizing MoE LLM Inference on Dedicated AI Chips: A Practical Case Study

    This article describes an open-source LLM inference engine running on a dedicated AI chip. It covers decode kernel fusion, sparse attention for million-token contexts, FP8 quantization of a 320B-parameter MoE model, and test results for concurrent agent workloads. It also outlines the deployment steps and the checks needed before reproducing the results, and notes that the reported figures depend on specific hardware and workloads.

    Large language models have grown from billions to hundreds of billions of parameters, and context windows have expanded from 8K to millions of tokens. As parameter counts and context lengths grow together, inference cost and response speed become the first obstacles to deployment. When running Mixture-of-Experts (MoE) models with very long contexts, general-purpose GPUs are often limited by memory bandwidth, and their compute capacity is hard to use fully. As a result, the industry has started optimizing inference on dedicated AI accelerator chips.

    This article uses the practice of an open-source LLM inference engine on a dedicated AI chip as a case study. It discusses four areas: kernel fusion, long context, MoE quantization, and concurrent performance. The test data comes from the original test report, which has not been independently reproduced. Readers should verify the results in their own environments.

    1. Decode Kernel Fusion

    Autoregressive decoding generates one token at a time. Each step involves little computation, so the main bottleneck is memory access. If each operator launches its own kernel, intermediate results must be written back to memory and read again, and launch overhead accumulates.

    The engine addresses this by merging as much of the decoding computation as possible into a single megakernel. LayerNorm, linear projections, and activation functions run within the same kernel execution flow, so intermediate states do not need to be written back to memory. This reduces memory accesses and improves memory bandwidth utilization.

    How far fusion can go depends on the model architecture and the hardware resources. Whether MoE routing and attention computation are included in the same kernel, and how computation is partitioned under tensor parallelism, both affect the result. If a single kernel uses too many registers or too much on-chip storage, the compiler may need to split it. The degree of fusion should therefore be judged by measured latency and throughput. More fusion does not always mean faster execution.

    2. Ultra-Long Context and Sparse Attention

    Standard self-attention has a computational complexity of O(n²). At a context length of 1M tokens, both the attention computation and the KV cache memory footprint grow substantially. Without sparsification, quantization, or sharding, a single device usually cannot handle requests of this size.

    Sparse attention reduces computation by limiting the range of tokens that each token can attend to. Common approaches include block sparsity, sliding windows, and keeping a small number of global tokens. How the computation scales with context length depends on the window size, the number of blocks, and the number of global tokens. The original report’s claim of O(n log n) or lower complexity holds only for a specific scheme, so it must be checked against that scheme.

    Sparse attention also has trade-offs. Pruned dependencies may affect tasks that require precise retrieval across documents. When choosing an approach, evaluate recall and answer accuracy on your own long-context benchmark. Throughput alone is not enough.

    3. MoE Models and FP8 Quantization

    The original practice targets a mixture-of-experts model with 320B total parameters and 18B activated parameters per forward pass. MoE activates only a subset of experts for each token, which trades a smaller compute cost for greater model capacity. Total parameters determine how much knowledge the model can store. Activated parameters determine the compute cost per token.

    The engine uses FP8 quantization. Compared with BF16 or FP16, each FP8 value takes half the storage, so the memory used by weights and the KV cache is roughly halved. If the chip has hardware acceleration for FP8, compute throughput can also increase. The original report states that a single dedicated compute instance can hold the 320B model with output quality essentially preserved. This conclusion depends on the specific quantization method and evaluation set. Before going live, compare task metrics before and after quantization.

    4. Concurrent Agent Test Results

    The original report used an agent concurrency replay tool to simulate production workloads. The tests ran on a large-scale AI compute instance on a cloud platform. The configuration was 32 concurrent agents, a context length pushed to 1M tokens, continuous operation for one hour, and a default batch size of 12.

    Under this configuration, the test recorded 28.9 requests processed per minute, about 3.57 million tokens generated per hour, and a P50 decoding speed of 22.3 tokens/s. These figures describe only this test condition. The report does not specify the hardware model or the engine version, does not explain how the measurement period was defined, and does not say whether the prefill stage was included. The figures should therefore not be extrapolated to other hardware, workloads, or business scenarios.

    To draw conclusions from this data, build a controlled comparison. Compare results across batch sizes and context lengths on the same machine, and compare against general-purpose GPU solutions using the same measurement method. Only under such controlled comparisons do the differences in throughput and latency become meaningful.

    5. Deployment Process and Considerations

    The original report outlines the deployment process as follows:

    1. Clone the inference engine code from the open-source community.
    2. Use a Docker image to standardize the dependency libraries and driver environment.
    3. Before the first run, precompile the fused kernels and cache them. This step takes a long time, but later service startups are faster.
    4. Start the service through a command-line tool. The service exposes an interface compatible with a widely used LLM API standard.

    These steps are not sufficient for direct reproduction. Before running them, confirm the following:

    • Whether the Docker image and driver versions match.
    • Where the precompiled artifacts are cached, and how to rebuild them if the cache becomes invalid.
    • Whether the container runtime has the permissions required to access the accelerator device.
    • Which version of the API standard is supported, and what known differences exist.

    If startup fails, check the driver and image versions first, then the device permissions, and finally the precompilation logs.

    Cost also needs careful evaluation. Spot prices for cloud instances fluctuate, and the actual cost per token must include networking, storage, and retries after failures. The original report does not explain how its unit price was calculated, so this article does not cite that figure. Readers should calculate costs based on their own workloads and billing models.

    6. Conclusion

    Inference optimization is an important step in deploying LLMs. Fused kernels reduce memory access overhead, sparse attention makes million-token contexts possible on a single machine, and FP8 quantization reduces memory pressure. The effects of these techniques depend closely on the hardware, the model, and the workload. When choosing an approach, start with small-scale tests using your own business data, and then decide whether to deploy at scale.