The cache we emptied every step

For three days we have been asking why our training steps on Vertex run about one and a half times slower than a run on Colab in May, on the same graph, batch and GPU model. Training is most of the cloud bill, so the answer is worth money. The first readout blamed the software stack. Yesterday a new image with May’s exact stack was 4% faster, so it wasn’t that. That left two guesses: the cloud machine itself, or the way our loader numbers the graph’s entities.

Today both guesses fell, and the answer was a line of code.

The free checks first

The numbering guess fell without spending anything. May’s processed graph is still on Drive, and its training edges are byte-identical to the ones our loader builds. The two dataset classes in question share one numbering function.

The platform guess needed one job, about fifty cents. Drive also still holds the split from a second May Colab run, on May 4, which used our own training loop and the same stack. Vertex ran that exact split, loop and stack at 3.65 s a step. Colab had done 3.66–3.72. The machine was never slower. And the instrumentation I added confirmed it: a genuine A100-SXM4-80GB at full clocks and its full 400 W, never throttled.

So the difference had to be in what the May 1 run did that our runs don’t.

The one line

The May 1 run used an edited copy of the training loop on Drive. One of its edits, with a comment from May, changes a call that empties the GPU’s memory cache from every step to every hundredth step. Our training code never had that edit, so every run we have trained since May empties the cache before and after every step.

The call itself takes 0.05 s. The cost comes after it: the next step has to request all of its memory from the GPU again, about 72 allocations of a gigabyte each. Once a step nearly fills the card, those requests get slow. I built an image that alternates the setting epoch by epoch on one card:

  • Run 3 B’s graph: 6.64 s a step with the cache emptied, 5.23 s with it kept, 21% less. That is about $22 off a $105 Run 3 arm.
  • The paper’s KG4FM graph: 4.27 s against 2.96, within 4% of May’s 2.85.
  • KG4FM at half the batch, half the card: only 4%. The penalty grows as the card fills, which is why it hid in some runs and not others.

Peak memory is the same either way. Nothing the model computes changes.

Why it took three readouts

The GPU’s own “busy” figure read 99–100% the whole time, and I took that to mean the time was spent computing. It counts the waiting too. Timing each part of a step separately is what finally showed the forward pass waiting on memory.

The other trap was comparing whole setups against whole setups. Each readout swapped a stack or a machine and found a difference it could not pin down. What settled it was holding the split, loop, stack and GPU fixed, and changing one thing.

What’s next

Making “keep the cache” the default is Richard’s call, along with the image rebuild that would carry it. My lean is to empty the cache every hundred steps rather than never, as May’s run did, which guards long runs for about 0.3% of the step. The instrumentation that found this is in review, and every job will now log what its GPU was doing. The whole investigation cost about $2.70.