LLM Training Costs Explained: Formulas, Cost Categories, and a Worked Example
Learn how to distinguish total R&D spending, a single training run, and cluster capital costs. This guide breaks down five major cost categories and uses a hypothetical 70B-parameter model to show how compute, GPU-hours, utilization, pricing, and reruns affect pretraining costs.
Start by Separating Three Cost Measures
Public reports have attributed a claim to an overseas AI model company that the full development cost of its next flagship model exceeds $10 billion. This figure is unaudited, and the original source should be verified before it is cited. Even if accurate, a figure of this size could refer to very different accounting scopes.
| Cost measure | What it includes | Depreciation treatment | Reusability | Main purpose |
|---|---|---|---|---|
| Total R&D spending | Spending across the project lifecycle, including preliminary experiments, multiple pretraining runs, post-training, failed runs, and cluster purchases | Depends on the accounting method | Consumed project spending is not reusable; purchased assets may remain available | Assessing organizational scale and funding requirements |
| Single-run training cost | The monetary value of compute consumed by one complete pretraining run | Allocated by usage time where applicable | Consumed compute cannot be reused | Estimating the financial barrier to an individual training run |
| Cluster capital investment | Purchased hardware and supporting infrastructure | Capitalized assets are depreciated over their useful lives | Reusable across multiple training and inference workloads | Assessing long-term ownership and operating commitments |
Treating these measures as interchangeable can overstate the cost of a single run while understating the burden of ongoing operations.
For example, suppose a team purchases a large cluster and uses it for one medium-scale experiment. Charging the entire purchase price to that experiment would substantially inflate its apparent cost. Conversely, counting only electricity and rental charges can leave hardware depreciation and operations staff out of the picture, depending on what the quoted rates already include.
Five Major Components of LLM Training Costs
1. Pretraining
Pretraining is typically the largest compute expense. Total compute requirements depend primarily on parameter count and training-token count, often requiring a large cluster to run continuously for weeks or months.
Key inputs include:
- Accelerator type and count
- Training duration
- Model FLOPs utilization, or MFU
- Number of failure-related interruptions
This compute belongs in the cost of the individual training run. A common omission is the extra work caused by failed runs and checkpoint rollbacks.
2. Data Engineering
Data engineering covers corpus collection, cleaning, deduplication, mixture design, and the generation and filtering of synthetic data.
Key inputs include:
- Raw corpus size
- Retention rate after cleaning
- Annotation labor hours
- Inference tokens used to generate synthetic data
For a particular training run, allocate the processing costs associated with the data actually used in that run. Synthetic data is a frequent blind spot: generating it consumes inference compute.
3. Post-Training
Post-training includes supervised fine-tuning, preference alignment, and reinforcement learning. Individual stages usually require less compute than pretraining, but repeated iterations, human annotation, and automated evaluation can add up.
Key inputs include:
- Number of fine-tuning examples
- Evaluation-set size
- Number of iterations
Sampling during reinforcement learning can incur substantial inference costs and should be tracked separately. A common mistake is to count one iteration rather than the cumulative cost of the full process.
4. Exploratory Experiments
Before a production-scale run, teams often use smaller models to test architectures, hyperparameters, and data mixtures.
Key inputs include:
- Experimental model sizes
- Number of experiments
- Training tokens per experiment
These costs are generally excluded from the cost of a single formal training run, but they belong in total R&D spending. With enough experiments, exploration can become a major share of the overall budget.
5. Infrastructure Operations and Depreciation
This category covers facility power, networking, storage, operations staff, and hardware depreciation.
Key inputs include:
- Cluster size
- Depreciation period
- Residual value
- Annual operating expenses
These are cluster-level ownership and operating costs. They should be allocated to projects according to usage rather than charged in full to a single training run.
A Formula for Estimating Pretraining Costs
The estimate has three steps:
- Estimate total compute.
- Convert compute into accelerator-hours.
- Multiply by the hourly rate and account for failures and reruns.
A common engineering approximation for training compute is:
Total compute ≈ 6 × N × D
Where:
- N is the number of model parameters.
- D is the number of training tokens.
This approximation omits details such as attention-related computation, so it is best used for order-of-magnitude estimates.
The full cost formula is:
C = [6 × N × D / (F_peak × MFU)] / 3,600 × P × (1 + r)
Where:
| Symbol | Meaning | Unit |
|---|---|---|
| C | Estimated compute cost of one pretraining run | CNY |
| N | Model parameter count | Parameters |
| D | Training-token count | Tokens |
| F_peak | Peak compute throughput per accelerator | FLOP/s |
| MFU | Model FLOPs utilization | Fraction |
| P | Price per accelerator-hour | CNY per accelerator-hour |
| r | Additional overhead from failures and reruns | Fraction |
The bracketed term gives aggregate accelerator-seconds, not elapsed cluster time. Dividing by 3,600 converts it into accelerator-hours.
The accelerator count is used separately to estimate wall-clock duration.
Worked Example: A 70B Model Trained on 2T Tokens
All figures below are hypothetical. Replace them with your own quotes and measured utilization data.
| Input | Assumption |
|---|---|
| Parameter count, N | 70B = 7 × 10^10 |
| Training tokens, D | 2T = 2 × 10^12 |
| Peak throughput per GPU, F_peak | 1 PFLOP/s = 1 × 10^15 FLOP/s |
| MFU | 40% |
| GPU count | 1,024 |
| Price per GPU-hour, P | CNY 10 |
| Failure and rerun overhead, r | 15% |
Step 1: Calculate Total Compute
6 × 7 × 10^10 × 2 × 10^12 = 8.4 × 10^23 FLOPs
Step 2: Calculate Effective Throughput per GPU
1 × 10^15 × 0.4 = 4 × 10^14 FLOP/s
Step 3: Convert Compute to GPU-Hours
8.4 × 10^23 ÷ 4 × 10^14 = 2.1 × 10^9 GPU-seconds
Converting to hours:
2.1 × 10^9 ÷ 3,600 ≈ 583,333 GPU-hours
Step 4: Estimate Wall-Clock Duration
With 1,024 GPUs:
583,333 GPU-hours ÷ 1,024 GPUs ≈ 570 hours
That is approximately 24 days, before adding failure and rerun overhead.
Step 5: Calculate the Base Compute Cost
583,333 GPU-hours × CNY 10 ≈ CNY 5.83 million
Step 6: Add Failure and Rerun Overhead
CNY 5.83 million × 1.15 ≈ CNY 6.71 million
Applying the same overhead to elapsed time gives approximately 655 hours, or 27 days.
Under these assumptions, pretraining a 70B-parameter model on 2T tokens costs about CNY 5.83 million before rerun overhead, or CNY 6.71 million with a 15% allowance.
This estimate does not separately include data engineering, post-training, exploratory experiments, or infrastructure depreciation. When building a broader budget, check which infrastructure costs are already embedded in the hourly rate to avoid double-counting.
Why MFU Matters
MFU has a substantial effect on the estimate.
If MFU falls from 40% to 30%, the required GPU-hours increase from approximately 583,333 to 777,778. At the same hourly rate and rerun allowance, the cost rises by roughly one-third.
The practical takeaway is that training efficiency matters as much as the quoted hourly rate. A useful estimate must keep total R&D spending, single-run compute costs, and cluster ownership costs distinct—and use measured utilization wherever possible.
