How to Calculate the Compute Economics of Large Model Inference
This article breaks down the unit economics of large language model inference and explains when self-hosted GPUs become cheaper than pay-as-you-go APIs. It introduces a per-million-token cost model, shows why utilization is the most sensitive variable, outlines three sources of utilization loss, and presents a hybrid routing architecture across self-hosted, external API, and fallback tiers. It also contrasts usage-based and subscription revenue models, and closes with a reusable measurement checklist for quantitative, testable, and reversible cost decisions.
1. The Starting Point: From Calling Someone Else’s Model to Running Your Own GPUs
A recent disclosure from an AI coding platform stated that roughly 40% of its tokens, about 16 trillion in total, were served by its own deployed GPUs, while the remaining ~20 trillion relied on external inference resources. The self-hosted compute was described as three high-density racks with a little over 200 accelerators, plus short-term access to a thousand-GPU-scale pool (about 40% next-generation high-density machines and 60% the previous generation). Whether the exact numbers are precise or not, the technical question behind this phenomenon is universal: once inference volume crosses a certain threshold, the marginal cost of self-hosted compute falls below pay-per-use calls, making hybrid scheduling the rational choice.
Note that this article does not evaluate any specific vendor or product. It treats the phenomenon as a sample of “economics of inference at scale” and extracts transferable measurement and engineering methods.
2. Breaking the Bill into Computable Quantities: A Unit Economics Framework
To decide whether self-hosting pays off, the key is not “is the hourly rental expensive,” but the gap between the real cost per million tokens and the revenue per million tokens. The following sample code fixes the logic so parameters can be swapped for sensitivity analysis:
def unit_cost(gpu_count, price_low, price_high, tokens_per_day, util=1.0):# Daily rental range (USD)daily = [gpu_count * p * 24 for p in (price_low, price_high)]# Effective throughput decays linearly with utilization (simplified model)eff_tokens = tokens_per_day * utilreturn [d / (eff_tokens / 1e6) for d in daily]# Example: 216 GPUs, $9-10 per GPU-hour, 16T tokens per dayprint(unit_cost(216, 9, 10, 16e12, util=1.0)) # ideal full loadprint(unit_cost(216, 9, 10, 16e12, util=0.6)) # 60% utilization
Under the ideal full-load assumption, daily rental is about $47K-$52K, which corresponds to roughly $0.0029-$0.0032 per million tokens. This explains the intuition that “the gross margin looks very high.” But a real system can almost never run at 100% load, and utilization is the most sensitive variable: when utilization drops from 1.0 to 0.6, unit cost rises by about 67%.
3. Why “Full Load” Is an Illusion: Three Sources of Utilization Loss
- Traffic peaks and valleys: Coding requests concentrate on weekday daytime, with deep valleys at night and on weekends. If GPUs are provisioned for the peak, off-peak utilization can fall below 30%.
- Mismatch between models and GPU types: High-throughput small models and low-latency large models have different requirements for memory bandwidth and compute ratio; mixing them creates fragmentation.
- Context length variance: Memory and compute cost for long-context requests grow non-linearly. Without length bucketing, batching efficiency is dragged down by a few extremely long requests.
Common engineering mitigations include request bucketing and length routing, continuous batching, prefix cache reuse, and filling valleys with low-priority batch jobs (such as offline evaluation and code repository indexing).
4. Hybrid Scheduling: How Self-Hosted and External APIs Split the Work
The rational architecture is neither “all self-hosted” nor “all outsourced,” but tiered routing:
- Baseline tier (self-hosted): Handles high-frequency, short-context, predictable traffic, aiming for high utilization;
- Elastic tier (external API): Handles burst peaks, extra-long contexts, and tasks that need stronger reasoning capability;
- Fallback tier: Automatically falls back to the external channel when the self-hosted cluster fails or queueing exceeds a threshold.
request -> classifier(length/difficulty/tenant) -> self-hosted pool(high utilization) ┐-> external API(peak/long text) ┴-> unified metering and billing
The key metric for routing is a dual objective of queueing latency and unit cost, which can be implemented with a simple threshold policy: when the self-hosted pool’s P95 queueing exceeds a set value, or the request context exceeds a threshold, overflow to the external channel.
5. The Revenue Side: Gross Margin Differences Between Subscription and Usage-Based Models
The confusion in the original account is this: if revenue mainly comes from subscriptions at around ten dollars per month, gross margin seems diluted. Two revenue forms need to be distinguished:
- Usage-based billing: Revenue grows linearly with tokens, self-hosted cost reduction translates directly into gross margin, and the margin range is indeed considerable at high utilization;
- Subscription billing: Revenue is approximately fixed while cost fluctuates with usage, so profit is entirely determined by utilization and plan quota design. Under subscriptions, the levers for improving gross margin are quotas, priority queues, and off-peak filling, rather than simply adding more GPUs.
Therefore, “is self-hosting a loss or a gain” cannot be answered with a single-point number; it must be viewed as the weighted unit cost under a mixed revenue structure.
6. A Reusable Measurement Checklist
- Measure the real traffic distribution: bucket by hour, by context length, and by model tier;
- Use the function above to compute per-million-token cost at different utilization levels;
- Set the split thresholds between self-hosted and outsourced, and simulate the weighted cost;
- Run sensitivity analysis: utilization ±20%, rental ±15%, long-context share doubled;
- Use “gross margin per million tokens” rather than “hourly rental” as the decision metric.
7. Conclusion
The essence of self-deployed GPUs is trading “variable cost” for “fixed cost plus utilization risk.” When scale is large enough and traffic is predictable enough, self-hosting can push unit cost down to a fraction of pay-per-use calls; but when utilization is insufficient or traffic fluctuates sharply, hybrid scheduling and external elasticity are the more robust choice. For developers and enterprises, what really needs to be built is not a stance on “whether to self-host,” but a quantifiable, load-testable, and reversible unit economics method.
