Attention Is All You Need · Section 5.2

5.2 Hardware and schedule

How long the paper's models trained, on what: one machine with eight GPUs, twelve hours for the base model, three and a half days for the big one.

Twelve hours, three and a half days, four minutes
  • The paper's big model 3.5 days · 8 NVIDIA P100 GPUs · 300,000 steps
  • The paper's base model 12 hours · 8 NVIDIA P100 GPUs · 100,000 steps
  • Our miniature 4 minutes · 1 laptop processor · 4,000 steps

Bars on a logarithmic scale: each step of the scale is ten times longer than the one before.

The paper's two training runs and ours as bars on a logarithmic scale of hours, each labelled with its hardware and its number of training steps: the big model 3.5 days on eight GPUs, the base model 12 hours on eight GPUs, our miniature a few minutes on one laptop processor.

What this section says

The paper trained on one machine with eight NVIDIA P100 GPUs, graphics cards of 2016. A training step, one batch through the model and one update of every weight, took about 0.4 seconds for the base model; it trained for 100,000 steps, about 12 hours. The big model, with vectors of 1024 numbers and 16 heads (the last row of Table 3), took 1.0 second a step and trained for 300,000 steps, 3.5 days.

That was cheap for 2017: section 6.1 shows the base model's training cost was a fraction of its competitors'. It is the payoff of the parallel design of sections 1 and 4: no step of a sentence waits for the one before, so eight GPUs are kept busy.

For Daniel the numbers set a scale. Today's large language models train on thousands of GPUs for weeks or months on far more text; the recipe of steps, batches and updates is the one this section describes.

In the paper's words

“We trained our models on one machine with 8 NVIDIA P100 GPUs.”

Section 5.2 In plain words: All training ran on a single machine with eight graphics cards.

“We trained the base models for a total of 100,000 steps or 12 hours.”

Section 5.2 In plain words: The base model trained for 100,000 updates, about half a day.

Quoted from Vaswani et al., Attention Is All You Need, arXiv:1706.03762v7(opens in a new tab). The figures on this page are redrawn, not copied.

The notation

The symbols of this section, in the paper and in our model
Symbol Meaning In the paper Our miniature
\(\text{step}\) one batch through the model and one update of every weight 0.4 s (base), 1.0 s (big) about 0.06 s
\(\text{steps}\) how many updates training ran for 100,000 (base), 300,000 (big) 4,000
\(\text{GPU}\) a graphics card used for its many parallel processors 8 NVIDIA P100 none: one laptop processor

Try it

Our model learning, from noise to a pattern
Playback speed

Our own recorded run of the paper's model, not the paper's: 4,000 steps on a laptop's processor. First the training loss falling, step by step. Then the learning rate following the paper's formula: a straight climb for the warm-up steps, then a slow fall. Then label smoothing: the target for the right word is not 100 % but a little less, the rest spread thinly over every other word. Last, one encoder–decoder head's map on our probe sentence at four moments of training, from even noise at step 0 to a sharp pattern.

How our miniature differs

Our miniature trained for 4,000 steps in 239 seconds on one laptop processor, recorded by our training script. It has 244,800 weights against the paper's 65 million, and our sentences are short and simple, which is why minutes are enough.

Check yourself

Three questions a reader of this section should now be able to answer. The lab checks your answer against the paper and our models.

The base model's schedule

The base model took about 0.4 seconds per step for 100,000 steps. How many hours is that, to the nearest hour?

Your answer
A whole number

The big model's schedule

The big model took 1.0 second per step for 300,000 steps. How many days is that, to one decimal?

Your answer
Within 0.05 of the answer

Our run

How many training steps did our miniature run for?

Your answer
A whole number
An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.