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.
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.”
“We trained the base models for a total of 100,000 steps or 12 hours.”
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
| 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 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.
Prepared in the Course by
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?
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?
Our run
How many training steps did our miniature run for?