Building a Production-Grade Inference Stack for Domestic AI Accelerators
Why peak compute specs rarely decide online inference performance. This article explains what "production-grade" means for LLM inference stacks running on domestic or heterogeneous accelerators — covering acceptance criteria, memory-bandwidth bottlenecks, software-hardware co-design, rollout discipline, observability, and common failure modes — and shows how model teams can become ecosystem builders rather than chip consumers.
Inference Competition Has Entered the “Stack” Stage
Over the past few years, industry discussion has centered on parameter counts, training data, and benchmark scores. But once chip supply becomes constrained, that path exposes its weaknesses: the same model architecture may fail to reproduce even research-environment throughput on accelerators with inferior memory bandwidth, on-chip cache, collective communication, and driver stacks. This creates a second layer of competition — teams that own the models can no longer act only as chip buyers and callers; they must become builders of the compute ecosystem. Chips provide the form of compute; the inference stack translates it into stable tokens per second, predictable tail latency, and unit costs the business can accept. The two must be calibrated against each other, not wait for one side to “mature first.”
The real lifeline is not another algorithm blog post, but a production-grade inference implementation that has already run under real traffic: one that absorbs bursts, isolates faults, reorders computation according to hardware characteristics, and writes bottlenecks down as reproducible engineering constraints. Without this layer, domestic or heterogeneous accelerators remain “compatibility demos.” With it, model iteration and chip iteration form a closed loop.
What Production-Grade Actually Means
Research code succeeds when numbers align and a single run completes. Production code must satisfy five criteria at once.
Functional correctness. Logits or sampled outputs must match a reference implementation within agreed precision. Tool calls, stopping conditions, and multi-turn context assembly must not be corrupted by batching.
Service levels. Distinguish first-token latency, decode-phase latency, and tail latency. A good average with an out-of-control P99 is unusable in interactive scenarios.
Resource efficiency. Memory (or equivalent HBM) usage, bandwidth utilization, and compute utilization must be observable separately. Many cases of “not enough compute” are actually memory walls or startup overhead.
Elasticity and isolation. Request lengths, concurrency, and prefix repetition rates all fluctuate. The framework must reshape batches without restarting processes and prevent one extremely long request from stalling the whole card.
Evolvability. New model architectures, quantization formats, and parallelism schemes should not require rewriting the scheduler. Operators and the runtime need clean boundaries.
Failing these five, an open-source demo repo is not production-grade. Meeting them, it becomes the shared infrastructure chip ecosystems genuinely lack — one that spares later models from rebuilding everything from the driver up.
The Bottleneck Is Rarely Peak Compute
Peak floating-point performance on accelerator datasheets is rarely the main constraint for online inference. Autoregressive decoding is memory-bandwidth sensitive: every token generated requires streaming the full weight matrix and a growing KV cache, so compute intensity typically falls below the chip’s arithmetic peak. Engineers should therefore ask three questions first.
Where do the weights live, and in what layout? Row-major, column-major, or tiled layouts directly determine how much computation a single load can feed. If the layout mismatches the microarchitecture of tensor cores or matrix units, more kernel fusion merely packages inefficient memory access.
How does the KV cache grow? Pre-allocating too large wastes capacity; appending per step creates fragmentation and copies. Production systems typically use paged or block-based caching, letting different requests share physical blocks while remaining logically contiguous. Block size is a trade-off between internal fragmentation and kernel launch counts — a trade-off that must be tuned to the target chip’s cache line and alignment requirements, not copied from defaults on other architectures.
Can communication be hidden under computation? Tensor parallelism, pipeline parallelism, and expert routing all introduce collective communication. If the communication library cannot overlap with compute streams, adding more parallel dimensions only turns interconnect bandwidth into a new serial stage. Where the hardware has known data-transfer bottlenecks, the software side should reduce unnecessary synchronization, coalesce small messages, adjust split granularity, and even feed back to chip designers “which transfer primitives are missing.” This feedback is not a courtesy — it translates online profiling into requirements for the next generation of interconnect and memory hierarchy.
A Workable Division of Labor for Software-Hardware Co-Design
If model teams and chip teams interface only through “does operator X work,” collaboration stalls at a compatibility checklist. A more effective split:
Chip and compiler teams own: memory hierarchy, alignment, vector widths, async copies, collective communication primitives, and stable graph-compilation or hand-written kernel interfaces. Interfaces should expose a cost model, not just “it runs.”
The inference framework owns: request lifecycle, continuous batching, cache management, preemption and recomputation policies, precision and quantization path selection, and failure retries. The framework is where an unstable arrival process becomes a stable sequence of kernel launches.
The model team owns: whether the architecture is hardware-friendly. Does attention allow chunking? Is there non-fusable dynamic control flow? Do the vocabulary and sampling create synchronization points? Engineers from HPC or trading-system backgrounds, used to squeezing performance from clock cycles, cache misses, and firmware paths, bring the same instinct here: measure first, then fix data layout, and only then talk about bigger cards.
One actionable principle: every model release ships with a “bottleneck report” for the target accelerator — bandwidth usage, cache peaks, communication share, and a list of non-fusable operators. Chip teams use it to prioritize kernels and driver work instead of guessing at business needs; model teams use it to decide which architectural choices are worth adapting for the hardware. “Helping each other improve” means this executable report, not a joint press release.
From Prototype to Production Traffic
Progress in four stages, each with explicit exit criteria.
Stage 1: Numerical and shape baseline. Fix a set of length distributions and compare against the reference implementation. No premature fusion at this stage — otherwise you cannot tell whether the bug is in the algorithm or the kernel.
Stage 2: Single-request profiling. Profile prefill and decode separately. Prefill should saturate compute; decode should saturate bandwidth. If both are low, investigate launch overhead, synchronization, and layout before buying more cards.
Stage 3: Continuous batching with mixed lengths. Introduce a realistic arrival process: short questions, long contexts, bursts. Watch for head-of-line blocking. Chunk extremely long prefills when necessary so decode requests can interleave, keeping first-token latency from being dominated by a single long prefill.
Stage 4: Faults and rollout. Simulate single-card timeouts, cache exhaustion, and request migration after process restarts. During canary rollouts, compare latency distributions and rejection rates between old and new stacks — not just average throughput. Only when rejection policies, timeouts, and degradation (e.g., temporarily lowering concurrency or disabling optional speculative paths) are all configurable is the stack ready to carry large-scale user traffic.
Sketch: Turning Requests into Schedulable Batches
Below is vendor-agnostic scheduling pseudocode to illustrate responsibilities, not a directly compilable interface.
def step(queue, kv_pool, budget):batch = admit(queue, kv_pool.free_blocks(), budget.max_tokens)prefill, decode = split_by_phase(batch)if prefill:chunk = cut_prefill(prefill, budget.prefill_chunk)run_prefill(chunk) # compute-intensive; aim to saturate computekv_pool.commit(chunk)if decode:block = plan_decode_blocks(decode, kv_pool)run_decode(block) # bandwidth-intensive; avoid extra syncsfinish, keep = sample_and_route(block)release(finish, kv_pool)requeue(keep, queue)observe(batch) # latency, bandwidth, fragmentation, rejection reasons
admit must check both remaining cache blocks and the per-step token budget; otherwise the system over-admits and fails inside the kernel. cut_prefill is the key lever for interactive latency. observe must record why requests were rejected: insufficient cache, queue timeout, or slow kernels. Without reason codes, capacity planning is guesswork.
Memory, Quantization, and Correctness
Quantization is a general tool for easing bandwidth and capacity pressure, but in production treat it as an error budget, not a switch. Weight, activation, and KV cache quantization differ in sensitivity; cache quantization tends to hurt long contexts most. Before launch, measure perplexity or task-metric degradation on target-domain samples, and keep a high-precision fallback path for complaints or evaluation traffic.
Recomputation and offloading are alternative capacity strategies: for very long contexts, it can be cheaper to discard some intermediate results and recompute on demand, or offload to a larger but slower storage tier. Whether it pays off depends on the compute-to-bandwidth cost ratio — there is no universal optimum, only profiling. Fragmentation also masquerades as “out of memory.” Even after paging, monitor block utilization; if it stays low, adjust block size or merging strategy.
Don’t Add Parallelism Dimensions on Faith
Parallelism is not free throughput. Tensor parallelism fits cases where a single layer’s weights exceed one card’s capacity and interconnect bandwidth can cover the shard-reduction cost. If transfer itself is the hardware bottleneck, finer splits amplify synchronization. Expert parallelism adds routing skew: hot experts overload a few cards, and average utilization lies. Track expert hit distributions in production and prepare throttling or hot-expert replication strategies.
Pipeline parallelism faces bubbles. Microbatches too small mean high bubble ratios; too large, and latency suffers. Online services care more about bubbles’ effect on tail latency than offline throughput does. Avoid multi-node setups when possible; when unavoidable, feeding the communication-primitive gaps into the hardware roadmap beats endlessly patching software. This is the legitimate place to “advise chip designers”: recommendations should come from measured transfer granularity, synchronization points, and bandwidth shortfalls — not abstract slogans.
Observability, Cost, and Release Discipline
An inference stack dashboard should include at minimum: queueing latency, prefill latency, decode latency, per-step batch size, cache block occupancy and fragmentation rate, bandwidth utilization, kernel-time distributions, rejection reasons, and accelerator-hours per thousand tokens. Cost accounting must go beyond card-hours to include retries, idle spin, and headroom reserved for tail latency. Headroom is the price of a service level.
On release discipline: version kernels, scheduling policies, and model weights separately. Change one variable at a time. Use small fixed-seed sets for numerical regression and replayed length distributions for performance regression. Online, go shadow comparison → small traffic → full rollout. Rollback must switch back to the old stack without losing request semantics — at minimum, accepted requests must either continue or fail explicitly.
Team Capability: Performance Tuning Is a Method, Not a Talent
Teams that fully utilize hardware tend to share habits. They start from counters and timelines, not gut feeling. They are willing to change data layouts and memory allocators, not just tune inference parameters. They draw clear boundaries between firmware, driver, and runtime, avoiding optimization at the wrong layer. They load-test with realistic arrival processes instead of fixed-batch-size microbenchmarks. Quant trading, HPC, or systems-engineering backgrounds make these habits easier to form — but the habits themselves can be trained inside an inference team.
For a chip ecosystem, the scarcest resource is not another “hello world” example; it is model teams willing to write production-path pain into reproducible issues and mergeable patches. Chip vendors, in turn, must provide stable performance counters, predictable driver semantics, and a mechanism for microarchitecture changes driven by software feedback. Missing either side, the other’s investment turns into waiting.
Common Failure Modes at Deployment
Optimizing only average throughput while ignoring tail latency, then watching interactive experience collapse at launch. Reserving peak cache per request, rejecting traffic under high concurrency while nominal compute sits idle. Fused kernels without precision regression, leaving sporadic sampling anomalies untraceable. Copying parallel topologies from other architectures so communication becomes the main path. No rejection reasons or profiling, so capacity decisions are held hostage by demo data. Exposing a demo repo directly to peak traffic with no timeouts, isolation, or degradation. None of these failures are about models being “too small” — they are incomplete stacks.
Roadmap Suggestions
Near term: lock in one accelerator; get paged caching, continuous batching, and basic profiling working; drive a real length distribution to a stable latency distribution. Mid term: add quantization error budgets, prefill chunking, and multi-card communication overlap, and feed bottleneck reports back to compiler and chip interfaces. Long term: let new models plug in via configuration and a handful of kernels rather than replicating an entire runtime; make chip iterations acceptable against the same set of service-level metrics.
Only when this stack carries primary production traffic do domestic or heterogeneous accelerators stop being “backup cards” and become plannable supply. At that point, model companies shift from users to ecosystem builders: using engineering to translate a chip’s physical limits into inference capability the business can rely on. That is the lifeline to hold when continuing to chase the frontier under constraint.
