Architectural Practices for Running Large Model Inference on Domestic AI Chip Clusters

    This article explains how to build large model inference services on domestic AI chip clusters, where real production traffic—not benchmark results—is the hardest constraint. It covers a five-layer decoupled architecture, a repeatable model-to-hardware adaptation process with numerical, performance, and long-stability checks, runtime optimizations such as token-budget batching and paged memory, multi-priority scheduling and metric-driven elasticity, observability and fallback paths, and cost governance based on effective token cost. A four-stage rollout path is included for teams moving from "it runs" to sustainable long-term service.

    1. Background: Why Real Traffic Is the Hardest Constraint

    Metrics observed during evaluation often differ sharply from production behavior. The reason is straightforward: evaluation traffic is usually short-lived, low-concurrency, and relatively evenly distributed, while real business traffic is long-tailed, bursty, concentrated on hot spots, and varies enormously in input and output length. When inference services run entirely on domestic chip clusters, this gap widens further, because operator coverage, compiler optimization maturity, and memory and interconnect bandwidth characteristics all differ from established ecosystems.

    So discussing “fully relying on domestic chip clusters to serve traffic” is not really about single-card peak compute. It comes down to three questions:

    1. Can the adaptation cost between models and hardware be amortized through engineering?
    2. Where is the stability boundary when traffic fluctuates?
    3. Is the cost per unit of effective throughput sustainable?

    These three points determine whether a solution moves from “it runs” to “it runs for the long term.”

    2. Overall Architecture: Layered Decoupling Comes First

    Split the system into five layers that communicate through explicit contracts, so hardware differences do not leak upward into business logic.

    1. Access layer: authentication, rate limiting, canary release, and request normalization.
    2. Scheduling layer: queue orchestration, priorities, timeouts, and retry policies.
    3. Inference runtime layer: model loading, batching, memory management, and operator execution.
    4. Model and operator adaptation layer: graph optimization, operator substitution, and precision alignment.
    5. Observability and governance layer: metrics, logs, tracing, and capacity and cost dashboards.

    The value of this layering is that when a certain operator performs poorly on domestic chips, you only replace or fall back at the adaptation layer instead of touching business code.

    3. Model and Hardware Adaptation: Confining Uncertainty to One Place

    The core goal of adaptation work is repeatability. A three-tier validation mechanism is recommended:

    • Numerical consistency checks: for the same batch of inputs, compare the logits or probability distributions produced by different backends and set an acceptable threshold.
    • Performance baseline checks: fix the input length distribution, record time to first token, time per token, and throughput, and turn these into a regression baseline.
    • Long-stability checks: run sustained high-pressure requests for several hours to detect memory fragmentation, handle leaks, or thermal throttling.

    A schematic adaptation validation flow:

    1. def validate_backend(model, sample_inputs, backend):
    2. baseline = run_and_cache(model, sample_inputs, backend="reference")
    3. for name, candidate in backends.items():
    4. out = run(model, sample_inputs, backend=candidate)
    5. diff = compare_distribution(out, baseline)
    6. assert diff < THRESHOLD, f"{name} precision deviation exceeded limit: {diff}"
    7. record_latency(name, out.metrics)

    Do not aim for a one-shot full adaptation. Rank operators by hit rate and handle the ones with the highest share and longest runtime first, where the payoff is most visible.

    4. Inference Runtime Optimization: Throughput Comes from Batching and Memory

    On domestic chip clusters, raising effective throughput usually depends less on higher clock speeds and more on higher parallelism and better memory utilization.

    • Dynamic batching: group by a token budget rather than request count, so long requests do not slow down the whole batch.
    • Paged memory management: split the KV cache into fixed-size blocks to reduce fragmentation and support more flexible concurrency.
    • Prefix reuse: cache and reuse common prefixes such as system prompts and templates to cut redundant computation significantly.
    • Quantization and sparsity: use low-bit weights or structured sparsity where precision allows, but always pair this with regression evaluation.
    • Pipeline versus tensor parallelism: when cross-node communication is expensive, prefer tensor parallelism within a node and pipeline parallelism across nodes.

    A simplified token-budget batching example:

    1. def build_batch(queue, token_budget=8192):
    2. batch, used = [], 0
    3. while queue:
    4. req = queue[0]
    5. cost = estimate_tokens(req)
    6. if used + cost > token_budget and batch:
    7. break
    8. batch.append(queue.popleft())
    9. used += cost
    10. return batch

    5. Traffic Scheduling and Elasticity: Handling Bursts and Long Tails

    The difficulty with real traffic is that it is unpredictable. Use multi-level queues with priority preemption: interactive requests go first, while offline batch jobs consume leftover capacity. Set request timeouts and degradation policies, for example automatically truncating extremely long context requests or moving them to asynchronous tasks.

    For elasticity, use metric-driven scaling based on queue wait time, batch fill rate, and memory utilization as scale-out signals rather than CPU utilization alone. On domestic chip clusters, scale-out speed is affected by image pulls, model loading, and graph compilation, so keep a proportion of warm standby instances and store model weights on high-throughput object storage with local caching to speed up loading.

    6. Stability and Observability: Shrinking the Failure Domain

    Group observability metrics into four categories: request level (latency, error codes), batch level (batch size, fill rate), device level (temperature, memory, interconnect bandwidth), and business level (success rate, degradation ratio). When device-level metrics go abnormal, the scheduling layer should automatically mark the node as unschedulable and migrate traffic away.

    Also build a fallback path: when the domestic chip backend shows precision or performance anomalies, temporarily switch to a compatible backend or reduce model size to keep the business running. Fallback is not a failure; it is necessary engineering redundancy.

    7. Cost Governance: From Card Hours to Effective Token Cost

    Evaluate cost around a single core metric—cost per million effective tokens—covering compute occupancy, network and storage, and the extra overhead from retries and degradation. Governance measures include tiered quotas by business value, nightly batching for low-priority tasks, caching for common prefixes and repeated queries, and periodically removing inefficient instances.

    8. Suggested Rollout Path

    Stage one: complete adaptation and baselines for a single model and a single business. Stage two: introduce dynamic batching and paged memory, and stress-test burst traffic. Stage three: establish multi-priority scheduling and automatic fallback. Stage four: build capacity and cost dashboards and enter a continuous optimization loop. In similar scenarios, Baidu AI Cloud typically proceeds with observability first, gradual canary rollout, and a closed cost loop—a rhythm that suits most domestic compute inference projects.

    Overall, running large model inference fully on domestic chip clusters is systems engineering: adaptation must be repeatable, the runtime must saturate parallelism, scheduling must absorb fluctuation, and governance must make cost calculable. Following this path is what yields stable and sustainable service under real traffic.