Advanced

What a real pretraining run costs

A credible pretraining budget separates ideal FLOPs from realized device time, experiments, failures, data, people, and energy — and every figure in it is only as good as the assumption printed beside it.

Updated

01 · Concept

Concept

Someone will ask you what it cost to train Qwen3.8-27B. The honest answer has two parts, and both matter: nobody outside the team knows, and here is how you would estimate it by supplying the missing inputs. This lesson builds that estimate end to end, labelling every assumption as it goes, so that what emerges is a method you can apply rather than a figure you can quote.

For a dense decoder, the common Kaplan first-order shortcut for the model core is

Fcore6NcoreD,F_{core}\approx 6N_{core}D,

with NcoreN_{core} the non-embedding parameters and DD training tokens. The factor of six approximates forward and backward matrix work — roughly two operations per parameter per token forward, and twice that again backward. This shortcut estimates the core; it does not say that every operation outside NcoreN_{core} is free.

Start with the rough version people often produce. Take the marketed 27 billion parameters, choose 4 trillion tokens as a round illustrative input, and multiply:

6×(27×109)×(4×1012)=6.48×1023 FLOPs.6\times(27\times 10^{9})\times(4\times 10^{12})=6.48\times 10^{23}\ \text{FLOPs}.

The shortcut instead uses the non-embedding count. Lesson 5.3 showed that the 248,320-row input embedding and its untied output head together hold about 2.54 billion parameters, and there is a vision tower besides. Using about 24.5 billion for NcoreN_{core} gives

6×(2.45×1010)×(4×1012)=5.88×1023 FLOPs,6\times(2.45\times 10^{10})\times(4\times 10^{12})=5.88\times 10^{23}\ \text{FLOPs},

That 5.88e23 figure is the core approximation, not a better total. The untied output head still multiplies every final hidden state by a 248,320×5,120248{,}320\times5{,}120 matrix to produce logits. Chinchilla’s Appendix F counts that final logits projection separately. The head has about 1.27 billion weights, so under the same forward-plus-backward convention its contribution is

6×(1.2714×109)×(4×1012)3.05×1022 FLOPs.6\times(1.2714\times 10^{9})\times(4\times 10^{12})\approx3.05\times 10^{22}\ \text{FLOPs}.

Adding the core shortcut and the head gives about 6.19×10236.19\times10^{23} FLOPs before architecture-specific corrections. Treating the input embedding lookup as though it were another dense projection over the full vocabulary would also be wrong; direct operator accounting is what separates these costs.

The largest uncertainty is DD. There is no published token count for this model — no technical report exists, and the model card does not disclose training tokens, training compute, utilization, hardware, or cost. The 4 trillion above is a round assumption used only to demonstrate the method; it is not a claim about Qwen3.8-27B. Change the assumption to 2 trillion and every number below halves.

A further caveat sits underneath the shortcut. Here, 48 of the 64 layers are Gated DeltaNet rather than full attention, which changes the operation count per token and how cost grows with sequence length. Treat 6.19×10236.19\times10^{23} as a first-order construction, not a measurement; a precise estimate would count the actual operators in every path.

Now convert work into time. Realized device-hours are

H=FtrainPpeaku3600,H=\frac{F_{train}}{P_{peak}\,u\,3600},

where PpeakP_{peak} is applicable peak operations per second in the dtype actually used and uu is measured utilization. For a worked estimate, assume an order-of-magnitude 101510^{15} bf16 FLOP/s and 40% model FLOPs utilization. Those are illustrative inputs, not facts about Qwen’s hardware or run. With them:

H=6.19×10231015×0.40×3600430,000 device-hours.H=\frac{6.19\times 10^{23}}{10^{15}\times 0.40\times 3600}\approx 430{,}000\ \text{device-hours}.

On 1,024 accelerators that is about 420 hours, or 17.5 days of continuous training. At an illustrative rented rate of USD 2.50 per device-hour — a figure that must carry its date, region, and purchasing model — the final run costs roughly

430,000×2.50=USD 1,075,000.430{,}000\times 2.50 = \text{USD } 1{,}075{,}000.

That is one line of the budget, and it is the line everyone quotes as though it were the total.

Those non-compute lines are substantial: data acquisition and governance, deduplication and filtering at corpus scale, storage and inter-region transfer, checkpoint replicas — and note from lesson 5.7 that a single checkpoint of this model carries about 432 GB of state, so retention policy is a real storage decision — plus evaluation infrastructure, observability, security, and engineering salaries. Opportunity cost matters too when scarce cluster capacity delays other work. The BLOOM planning paper framed model choice explicitly around a one-million-A100-GPU-hour allocation, which is the right way to think about it: the experiment portfolio is planned alongside the target run, not discovered afterwards. Use that figure as evidence about that project at that date, never as a current price.

Energy follows the same discipline. Device power integrated over time gives the base: at an illustrative 700 W per accelerator, 430,000 device-hours are about 301 MWh at the chips. A facility multiplier covering hosts, networking, and cooling pushes delivered energy higher. Carbon then depends on where and when that electricity was generated; multiplying by a generic global intensity factor hides the single largest source of variation. The BLOOM carbon study is useful precisely because it separates dynamic training consumption from broader life-cycle boundaries and says which it is reporting.

Build the estimate as a calculator with exposed variables rather than a hardcoded total: parameters, tokens, architecture factor, peak throughput, a utilization range, device count, a dated hourly price, retry fraction, storage, staff, and contingency. Report device-hours, elapsed time at the chosen device count, direct compute cost, a program range, and a sensitivity analysis showing which input moves the answer most. In our example that input is unambiguously DD, which is also the one that is unknown.

Then reconcile after the run — planned versus actual tokens, utilization, device-hours, failures, and spend — and feed the variance into the next budget. A cost model that is never reconciled against reality is marketing arithmetic wearing a spreadsheet.

The durable lesson is accounting discipline. FLOPs estimate physical work; utilization maps work to hardware time; price maps time to money; program scope adds everything needed to make the run happen; environmental scope adds energy and emissions. Every headline number is meaningful only with its date, its assumptions, and its boundary attached — and for the model this course follows, the most important thing that chain produces is a clear view of exactly which number nobody has published.

02 · Analogy

Analogy

Estimating a bridge from tonnes of steel alone misses survey crews, cranes waiting on weather, rejected welds, access roads, inspections, financing, and future maintenance. Model FLOPs are the steel: essential and countable, but not the invoice. A real budget reconciles the theoretical material with utilization, retries, preparation, people, and the accounting boundary.

03 · Teach it back

Teach it back

Carry a 27-billion-parameter model through the full chain from the non-embedding 6ND shortcut plus the untied logits head to device-hours and money, stating every assumption, and say what part could honestly be published about Qwen3.8-27B.

Minimum: 80 characters and 15 words. Your writing stays only in this browser.

Waiting for your explanation.

Compare with a model answer

Assume 4 trillion training tokens purely as an illustrative input; Qwen has published no token count. The Kaplan shortcut 6ND, with about 24.5 billion non-embedding parameters, estimates about 5.88e23 FLOPs for the model core. That is not total training work: the untied 248,320 x 5,120 output head performs the dense logits projection and adds about 3.05e22 FLOPs under the same forward-plus-backward convention, bringing this first-order sum to about 6.19e23 FLOPs before architecture-specific corrections. Divide by peak throughput times measured utilization times 3,600: at illustrative values of 1e15 bf16 FLOP/s and 40 percent utilization, that is about 430,000 device-hours, roughly 17.5 days on 1,024 accelerators. At an illustrative rented rate of USD 2.50 per device-hour, the final run alone is about USD 1.07 million before pilots, failed runs, data work, storage, evaluation, and people. For Qwen3.8-27B, the architecture and parameter count are published, but the training-token budget, compute, utilization, hardware, and cost are not; every operational figure in this chain is a labelled assumption.

04 · Check your understanding

Check your understanding

01Why is the 5.88e23-FLOP 6ND result not a complete estimate of total training work?
Answer and explanation

Because it is the non-embedding shortcut, while the untied output head still performs a dense logits projection that adds about 3.05e22 FLOPs under the same assumptions — The Kaplan shortcut estimates the non-embedding core. Excluding the untied head from N does not make its logits matrix multiplication disappear; adding that work gives a first-order sum of about 6.19e23 FLOPs, still based on an assumed and unpublished token count.

02Lesson 5.12 covered spikes, restarts, and quarantined data. Where do those appear in a cost model?
Answer and explanation

In a retry or contingency line estimated from pilot failure and preemption rates, on top of the final successful run — Rolled-back steps, failed runs, and idle time while a job is diagnosed are real device-hours that a final-run-only estimate omits entirely.

03Why can peak accelerator FLOPs not be used as realized throughput?
Answer and explanation

Communication, memory, shapes, bubbles, and failures reduce utilization — Wall-clock cost depends on measured model FLOPs utilization and operational efficiency, not the chip's marketing maximum.

Complete the teach-back and answer the quiz correctly to finish this lesson.

◎ · Evidence marker

Sources

  1. Teven Le Scao et al. (2022). What Language Model to Train if You Have One Million GPU Hours?.
  2. Alexandra Sasha Luccioni, Sylvain Viguier, and Anne-Laure Ligozat (2022). Estimating the Carbon Footprint of BLOOM, a 176B Parameter Language Model.
  3. Jordan Hoffmann et al. (2022). Training Compute-Optimal Large Language Models — Appendix F.
  4. Qwen Team (2026). Qwen3.8-27B Model Card.