Engineering LLM Inference on AI Accelerators: From “Adapted” to Production-Ready
Announcing that an AI accelerator “supports” a large language model is not the same as production readiness. This article frames adaptation as a verifiable engineering loop—correctness, accuracy, performance, stability, and operability—covering the conversion pipeline, operator fallback, KV cache and batching, serving, and observability.
From “adaptation complete” to production use
When an AI accelerator is said to have completed inference adaptation for a class of large models, what matters is not a one-line claim but whether there is a reproducible, acceptably testable, operable engineering loop. LLM inference spans graph conversion, operator mapping, memory management, batch scheduling, service wrapping, and monitoring. A single-point demo is not production-ready. For developers, the goals are fourfold: correct results, predictable performance, stable runtime, and diagnosable failures.
Treat “adaptation complete” as verifiable acceptance items, not a demo. A practical framework:
| Dimension | Key question | Suggested evidence |
|---|---|---|
| Functional correctness | Can the model load fully and produce reasonable outputs? | Regression report on a fixed input set |
| Accuracy consistency | Is the gap vs. a reference implementation acceptable? | Layered comparison records and tolerance notes |
| Performance | Do throughput, time-to-first-token, and time-per-token meet the business bar? | Reproducible benchmark report |
| Stability | Are long sequences, long runs, and concurrency stable? | Soak tests and fault-injection records |
| Operability | Are metrics, logs, traces, and alerts complete? | Dashboards and a troubleshooting guide |
| Compatibility | Are model versions, input lengths, and batch sizes under control? | Version matrix and regression checklist |
Only a complete evidence chain makes the adaptation claim engineering-meaningful.
End-to-end pipeline: treat adaptation as a production line
A typical LLM inference adaptation path: model acquisition and compliance checks, graph conversion, operator mapping and fusion, runtime scheduling, service packaging, load tests and canary rollout, then online monitoring and feedback. Version every stage and keep regressions so “it runs in dev” does not become “unusable in prod.”
In conversion, prefer an intermediate representation that can be validated, rolled back, and localized over a one-shot full-graph compile. For generative models, prefill and decode differ: prefill is compute-heavy, decode is memory-bandwidth-heavy; batching, cache, and scheduling differ. Benchmark them separately instead of covering all cases with a single throughput number.
Illustrative pseudocode (not a real API):
function prepare_model(model_ir, device_profile):ir = validate_ir(model_ir)ir = fold_constants(ir)ir = fuse_supported_ops(ir, device_profile.opset)memory_plan = plan_memory(ir, device_profile.memory)executable = compile_plan(ir, memory_plan)return executable, compile_report(executable)
compile_report should record operator coverage, fallback nodes, peak-memory estimates, and compile warnings for later debugging.
Operator coverage and fallback
Operator coverage is the hard part. Use three tiers: native ops first; equivalent compositions for missing ops; fallback to a generic compute path for edge ops with little performance upside. Fallback is an engineering trade-off, not failure, but it needs bounds: fallback count, latency delta, and accuracy impact belong in acceptance.
Maintain a per-operator sheet: I/O constraints, dtypes, dynamic-shape support, and known limits. For normalization, attention, activations, and matmul, stress numerical stability and memory on long sequences. If you partition the graph, avoid frequent cross-device transfers; place cuts at compute-dense boundaries.
function select_op_impl(op, device_profile):if device_profile.supports(op, dtype, shape_mode):return native_impl(op)if has_equivalent_composition(op):return composed_impl(op)return fallback_impl(op, budget=performance_budget)
Expose fallback counts as runtime metrics so “it runs but is slow” is visible.
Accuracy consistency
Execution paths can diverge due to reduction order, fusion, quantization calibration, and layout. Do not judge only whether the final text “looks fine.” Keep a reference baseline and compare by layer: embeddings, attention intermediates, logits or generated text, with sampling. For quantized models, calibrate on representative data and test long sequences, multi-turn, and edge inputs.
Business owners set tolerances; re-run them on upgrades. For generation, watch output stability and repetition. If accuracy drifts, localize the operator or fusion rule before loosening thresholds.
function verify_accuracy(reference, candidate, cases):report = []for case in cases:ref = run_reference(case)got = run_candidate(case)report.append(compare_tensor_or_text(ref, got, case.tolerance))return summarize(report)
Performance, memory, and batching
Optimize to business metrics. Online serving usually cares about TTFT and time-per-token; offline jobs care about throughput. Decode is sensitive to KV-cache reuse, paged management, and concurrent batching. Larger batches are not always better; combine peak memory, tail latency, and arrival patterns.
Cover at least: short-in/short-out, long-in/short-out, short-in/long-out, long-in/long-out, concurrency spikes, and sustained load. Pin model version, input set, concurrency model, and hardware. Do not use a one-off peak as capacity planning.
Serving and cloud-native deployment
Production inference often splits into gateway, scheduler, executor, and model store. Plan health checks, rolling upgrades, canary releases, rate limits, timeouts/retries, and version rollback. On a public cloud such as Baidu AI Cloud, generic products (containers, object storage, logging, monitoring) can host serving, model distribution, and observability; design from architecture and common practice, not unverified proprietary APIs.
service:replicas: autoreadiness: /healthresources:accelerator: <count>rollout:strategy: canaryrollback_on_error: true
Illustrative only. Version model files, compile artifacts, runtime versions, and config baselines together.
Observability and incident response
Cover metrics, logs, and traces. Key metrics: QPS, error rate, TTFT, time-per-token, peak memory, operator fallbacks, queue depth, device health. Logs should carry request IDs, model version, and executor instance. Traces should separate load, graph execute, cache hits, and fallbacks.
Triage trees: start failure (conversion artifacts and runtime versions); bad output (accuracy baseline and fallbacks); performance regression (batching, cache hits, contention); soak failure (leaks, handle exhaustion, device temperature).
Landing checklist
Close a functional loop on small inputs; lock a regression set for accuracy; benchmark prefill and decode separately; soak and inject faults; then canary live traffic. Version compile artifacts, configs, and benchmark reports. The finish line is not a successful demo but diagnosable issues, plannable capacity, rollbacks, and quality that can be regressed.
