LLM Inference on Dedicated Accelerator Chips: An Engineering Practice

    Inference, more than training, often drives cost and user experience as large models move into production. This article treats running a model on NPUs and other AI accelerators as a set of verifiable engineering problems—graph closure, operator coverage, numerical stability, and measurable throughput and latency—without focusing on a specific vendor or device.

    Inference, more than training, often determines cost and user experience as large models move from training into scaled production. Dedicated accelerators (NPUs and AI cards) use matrix units, on-chip memory, and custom instruction sets to take dense work such as attention and MLPs off the general-purpose CPU/GPU path. This article does not discuss a particular vendor or SKU. It breaks “getting a model running on an accelerator with a usable SLA” into engineering checks you can verify: whether graph compilation closes, whether critical operators are covered, whether numerics are stable, and whether throughput and latency can be measured.

    The real problem: alignment of graph and hardware, not “it runs”

    The inference graph is a stack of Transformer blocks: LayerNorm, QKV projections, attention, residuals, feed-forward, and sampling. For an accelerator to consume that graph, three conditions must hold.

    First, the operator set must close. Operators the chip does not support fall back to the CPU and immediately hurt bandwidth and latency. Start with a static scan: list every operator type, compare it to the support list, and handle gaps with equivalent rewrites (for example, splitting a normalization into fusable elementwise and reduction ops), custom kernels, or approximate ops when a controlled accuracy loss is acceptable.

    Second, tensor layout must match the memory hierarchy. Accelerators typically impose hard constraints on dimension alignment, tiling, and SRAM residency. If weights, KV cache, and activations constantly go off-chip, peak compute is wasted on bandwidth. Be explicit about which weights stay on-chip, how KV cache is split by layer or head, and whether activations reuse the same buffer.

    Third, the precision path must be consistent. Training often uses mixed precision; switching to lower bit-width at inference without care can shift logits and sampling. Fix which floating-point format is used for compute, which precision is used for accumulation, and whether outputs are dequantized back to higher precision before sampling.

    Writing these three items as an acceptance checklist is more useful than claiming that “a model has been adapted.”

    Compilation and graph optimization: from a dynamic graph to a schedulable static plan

    Most accelerator stacks compile a framework graph into a device-executable plan. For large models, compilation typically includes:

    • Operator fusion: fuse LayerNorm, residual add, activations, and adjacent linear layers to cut intermediate write-back.
    • Constant folding and shape specialization: once sequence length, batch, and head count are fixed, many dynamic branches can be removed.
    • Pipelining and double buffering: overlap compute and DMA to hide off-chip access.
    • Graph partitioning: split large weights by layer or by expert (for MoE) across cards, and define collective primitives (AllReduce, AllGather) and topology.

    Compilation success is not the same as meeting performance targets. Record the compiled operator list, estimated FLOPs, and estimated memory traffic, and compare them with a profiler. If a layer is much slower than estimated, check missing fusion, unexpected host sync, or non-contiguous KV cache access.

    For variable-length input, avoid a full recompile per request. A common approach is to bucket by sequence length, pad or mask inside a bucket, and recompile only when leaving a bucket. That amortizes compile cost on elastic cloud instances and in on-prem clusters.

    KV cache and throughput: the main optimization battlefield

    In autoregressive decoding, work grows with generated length; the bottleneck is often KV cache traffic, not GEMM itself. Directions include:

    1. Paged or blocked cache: avoid pre-allocating one large contiguous block for max length, reducing fragmentation and waste.
    2. Quantized cache: store K/V at lower bit-width and upcast before compute. Evaluate perplexity and task metrics on a calibration set; “it produces tokens” is not enough.
    3. Prefix reuse: share K/V for common prefixes (system prompts, tool descriptions) and compute only the user suffix per session.
    4. Continuous batching: pack requests at different decode steps into one batch to raise occupancy. The scheduler must handle finished requests leaving and new ones joining without frequent reshuffles that create sync bubbles.

    Split latency SLA into TTFT (time to first token) and TPOT (time per output token). Prefill is compute-heavy; decode is bandwidth-heavy. Do not let a single “tokens/s” hide tail latency: P99 is often a cache miss, a graph switch, or sampling falling back to CPU.

    Accuracy, alignment, and regression: proving “done” is reliable

    Treat adaptation as complete only after regressions, not a one-off chat demo.

    • Numerical alignment: same input, greedy decode; compare token sequences or max/mean logit error against a reference (high precision or a validated path). Small differences can be allowed, but set thresholds.
    • Task sets: fixed evals for reading comprehension, code completion, instruction following; check whether metric drift is within business limits.
    • Long context: samples near the window limit; watch for repetition, crashes, or obvious forgetting—often position encoding or cache bugs.
    • Stability: hours of high concurrency; monitor temperature, ECC, queue buildup, and timeouts. Silent errors on accelerators need logs and checksums more than on general-purpose CPUs.

    If you quantize, pin the calibration dataset version; do not change scales ad hoc in production. Any weight or compiler version change should rerun this subset.

    Production: from a single machine to an operable service

    When packaging the model as an inference service, layer the stack:

    • Model layer: version weights, tokenizer, and sampling parameters, and ship them bound to chip binaries and driver versions.
    • Runtime layer: queues, batching, timeouts, circuit breaking; isolate accelerator failures so one device does not take down the fleet.
    • Observability: collect QPS, TTFT, TPOT, accelerator utilization, HBM/on-chip memory watermarks, and CPU fallback counts via standard monitoring and logs. Alerts should point to a layer or operator, not only “inference failed.”

    For elasticity, put a stateless HTTP/gRPC front door on a container platform and scale model instances by queue depth. Store weights and compile caches in object storage and verify checksums at startup to avoid silent corruption. Message queues can back async long jobs; interactive chat should stay a short synchronous path.

    Security and compliance still apply: input/output audit, access control for keys and weights, tenant isolation. For multi-tenant accelerators, confirm side channels and residual VRAM; zero context when needed.

    Capability building

    Teams gain more from three durable assets than from one “it runs” announcement: an operator-and-graph coverage matrix, accuracy and performance baselines, and a repeatable release pipeline. A new model should hit coverage first, then baselines, then production. Object storage, containers, and monitoring can run that pipeline without tying the story to a single proprietary product.

    In short, LLM inference on accelerators is graph closure, memory and KV policy, compile plans, and quantified acceptance. Encoding those steps as a checklist in CI reduces the cost of the next model more than any one-off claim.