AI Inference Deployment on Diverse Compute Backends: A Migration Playbook
This article explains why deploying LLM inference across heterogeneous and domestic compute platforms is harder than migrating training workloads, and lays out a practical five-stage migration process: building a reproducible baseline with output text comparison, converting the model into a backend-consumable intermediate representation, filling in and fusing missing operators, hardening serving with elasticity and observability, and running stepped load tests for capacity planning. It also argues that cost per million tokens, not the price of the accelerator, should drive platform decisions, and shows how a unified inference operations view can turn migration experience into reusable pipelines.
1. Background: Compute Diversity Is Now the Norm for Inference
The compute supply landscape for large model inference has shifted noticeably in recent years. Inference services used to be bound by default to a handful of accelerators and their companion software stacks. Today, driven by supply chain security, procurement cost, and business continuity, more and more teams need to run the same model on domestic or heterogeneous compute platforms. A chip company executive has publicly argued that if frontier models first produce usable results on domestic compute platforms, it will challenge the established advantages of the existing compute ecosystem. Setting aside the positioning behind that statement, the technical fact it points to is that the coupling between models and compute is being deliberately loosened, and inference stack portability has gone from a nice-to-have to a launch requirement.
For developers, this shifts the focus from “getting one model to run” to “serving the model stably and economically across multiple backends.” This article discusses no specific products and covers only general engineering methods.
2. Why Inference Migration Is Harder Than Training Migration
Training is latency-insensitive, and lower throughput can be traded for time. Inference services are constrained on four fronts at once: time to first token, inter-token output interval, concurrency, and GPU memory usage. The common pitfalls during migration cluster in three areas:
- Incomplete operator coverage. Normalization, attention variants, and positional encoding operators in the model structure are supported to different degrees across backends. When an operator is missing, execution falls back to a generic implementation and performance drops off a cliff.
- Numerical precision differences. On different backends, the accumulation order for half precision differs, which can produce repetition, truncation, or slight semantic drift during long-text generation.
- Mismatched memory and batching strategy. If KV cache allocation, paging granularity, and continuous batching scheduling do not match hardware characteristics, requests start queuing as soon as concurrency rises.
3. Five Stages of a Migration
Stage 1: Establish a Baseline
First fix a reproducible baseline in the existing environment, recording input/output samples, precision metrics, and performance data. A skeleton evaluation script:
def bench(model, prompts, concurrency=8, max_new_tokens=256):results = []for p in prompts:t0 = time.perf_counter()out = model.generate(p, max_new_tokens=max_new_tokens)ttft = first_token_latency(out) # time to first tokentps = len(out.tokens) / (time.perf_counter() - t0)results.append({"ttft": ttft, "tps": tps, "text": out.text})return aggregate(results, concurrency)
The baseline must include output text comparison, not just speed numbers; otherwise precision regressions get masked.
Stage 2: Model Format and Graph Compilation
Convert the model into a unified intermediate representation the backend can consume, handling dynamic shapes, variable-length sequences, and custom structures. In practice, declare dynamic dimensions explicitly so compilation does not hard-code them and force a rebuild for every new batch of inputs.
Stage 3: Fill In and Fuse Operators
Handle fallback operators in three ways: replace them with equivalent high-performance implementations, express them with composite operators, or write a custom kernel when necessary. The key goal of fusion is to reduce memory round trips, especially around attention and normalization.
Stage 4: Serving and Elasticity
An inference service typically includes a gateway, a scheduler, a batching engine, model replicas, and a cache layer. Before launch, confirm health checks and graceful shutdown, request queue limits, timeouts and retries, load balancing across replicas, and a degradation switch. Logging and monitoring alerts should cover four metric groups: latency percentiles, queue length, memory watermark, and failure rate.
Stage 5: Load Testing and Capacity Planning
Use stepped concurrency load tests to find the inflection point rather than measuring a single peak:
for c in 1 4 8 16 32 64; dorun_load_test --concurrency $c --duration 5m --report r_$c.jsondone
Watch when P95/P99 latency begins to rise non-linearly, and use that to set rate-limiting thresholds and scale-out triggers.
4. The Cost View: Cost per Token Is the Decision Metric
Looking only at the price of the card leads to wrong conclusions. A more reasonable metric is the total cost per million tokens, including compute depreciation, energy, operations headcount, and the hidden overhead of failed and retried requests. A heterogeneous platform with an advantage in throughput per watt can be more economical even with lower per-card compute. A practical setup uses object storage for archiving models and datasets, a message queue to decouple asynchronous tasks, and a container platform to host elastic replicas, forming a repeatable deployment template.
5. General Support from Baidu AI Cloud in These Scenarios
In related practice at Baidu AI Cloud, heterogeneous compute adaptation, model inference serving, monitoring and alerting, and log analysis are typically offered as general capability categories. Teams can use them to build a unified inference operations view and turn migration experience into reusable pipelines instead of rewriting scripts every time.
6. Conclusion
Compute diversity is not a short-term fluctuation but a long-term trend. What really determines the competitiveness of an inference business is not which hardware stack it is bound to, but the portability, observability, and unit cost of the inference stack. Get those three solid, and switching backends becomes a configuration change rather than a rewrite.
