Engineering Inference on Domestic AI Accelerators: A Practical Analysis

    This article examines the engineering realities of running production inference on domestic AI accelerators, using publicly available benchmark and traffic data. It explains why performance gaps are structural rather than uniform, how long-retention prefix caching becomes the primary lever for long-context workloads, how to build a total cost model with a one-third cost threshold, and why open-sourcing production inference code reduces the cost of early-stage adaptation.

    1. Start by Reading the “Imperfect” Benchmarks

    The first step in judging whether domestic compute can carry production traffic is not the marketing narrative, but the unflattering ratios in public data. In a comparison between a domestic accelerator card (referred to as Card A) and a leading overseas card (referred to as Card B), running the same model at the same precision, one detail stands out: in raw compute scenarios that exclude cache hits, Prefill throughput is about 26.03K tokens/s and Decode is about 7.409K tokens/s. The corresponding figures for Card B are 77.74K and 17.84K tokens/s.

    The two ratios are 2.99x and 2.41x, and 2.99 / 2.41 ≈ 1.24, which matches exactly the 1.24:1 P:D card ratio noted in the deployment plan. This is not a coincidence but the result of engineering derivation: when a card’s compute shortfall is concentrated on the Prefill side, adding more Prefill cards is required to level the load on both sides.

    This leads to a general conclusion: the gap of domestic cards is not a uniform “two to three times slower” but a structural one — the matrix-multiplication-heavy compute dimension suffers more, while the memory bandwidth dimension is relatively less affected. This determines the priority of all subsequent optimization efforts: reduce the absolute compute volume of Prefill first, rather than blindly adding cards.

    Laying out this kind of structural data is more valuable for engineering than releasing vague claims of “leading overall benchmarks,” because it directly provides input parameters for card ratios, scaling, and cost models.

    2. The Key to Keeping User Experience Intact: Turning Repeated Computation into Cache Hits

    Public data shows an average input length as high as 98.44K tokens, a typical signature of long-context and coding-oriented AI Agent traffic: the same repository context, the same long document is repeatedly brought into requests, with highly repetitive prefixes.

    The engineering response is to extend KV Cache retention beyond 72 hours, achieving an input cache hit rate of 97.20%. The implication is direct: less than 3% of new tokens per request actually need to be computed from scratch, the Prefill stage where Card A is most disadvantaged is largely bypassed, and pressure shifts to memory access and scheduling.

    The result is a median time to first token of 277 milliseconds and an output speed of 137.9 tokens/s with nearly 100K-token inputs. These two numbers show that single-card peak compute is not the only determinant of the online experience; cache hit rate is the first lever in long-context scenarios.

    Reusable decision logic:

    • If the average input length is much larger than the output length and prefix repetition is high, prioritize prefix caching and long retention;
    • If request prefixes are scattered with low reuse, cache benefits are limited, and only then should card ratios be set based on raw compute ratios;
    • Each percentage point of hit rate improvement saves the repeated computation of the full prefix, with benefits scaling linearly with input length.

    Illustrative hit-determination logic (pseudocode, expressing the idea only):

    1. def handle(request, cache):
    2. prefix = request.prefix_tokens # stable prefix such as system prompt + repository context
    3. entry = cache.lookup(prefix) # reuse existing KV on a hit
    4. if entry is None:
    5. kv = prefill(model, prefix) # pay the full prefill cost only on a miss
    6. cache.store(prefix, kv, ttl_seconds=72 * 3600)
    7. else:
    8. kv = entry
    9. return decode_stream(model, kv, request.new_tokens)

    3. The Cost Equation Must Follow the “One-Third” Line

    The observation window was set during the regular 4:00–6:00 PM period, while revenue was conservatively converted at off-peak low prices (4 CNY per million output tokens). Even so, a single card can still earn 117.9 CNY per hour; under the same calculation, Card B earns 318.1 CNY, and the former is about 37% of the latter.

    This means that to carry the same scale of traffic, the Card A solution costs two to three times more in cards, racks, power, and cooling. The decision therefore converges on a clear dividing line: the deal only makes sense when the total procurement and operating cost of a domestic cluster is compressed to about one-third of the competitor’s.

    Cost modeling should cover at least the following items, avoiding a comparison based only on “per-card unit price”:

    Cost Item Description
    Hardware procurement and depreciation Converted based on actual card count per full rack and ratio, not per card
    Power and cooling Near-linear growth as card count rises
    Racks and networking Switch and cabling overhead from multi-card communication topology
    Operations labor Long-term investment in operator adaptation, version upgrades, and fault localization
    Cache storage Memory/VRAM pressure from long-retention KV Cache

    4. Why Open-Sourcing Production-Grade Code Matters: Absorbing the Cost of Pitfalls Up Front

    The biggest friction in adopting domestic chips in the past was the gap between the announcement that adaptation was complete and actual business execution: incomplete operator coverage, low multi-card communication efficiency, and improper memory scheduling strategies meant paper performance could not be realized, leaving teams to explore from scratch.

    Fully open-sourcing a set of inference service code that already carries large-scale online traffic is valuable not because of “leading performance” but because it turns engineering know-how into a reproducible starting point: how parallel strategies are partitioned, how caches are evicted, how batching is grouped, and how exceptions are degraded. Users can perform secondary tuning on their own models and traffic without paying the first round of trial-and-error costs again.

    Four points to focus on during implementation: first, start with a small-traffic canary and measure hit rates using the real prefix distribution; second, adjust the card ratio based on the measured Prefill/Decode ratio; third, incorporate time to first token and output rate into monitoring and alerting dashboards; fourth, tune cache retention duration for capacity and hit rate.