Commit Graph
1 Commits
Author SHA1 Message Date
digital-garbageandClaude Opus 5 a689aaa87d perf(vf): train the value functions on the sample's device, not always the CPU
Measured rather than assumed. The three value functions are ~16s of a 26.5s
rated run, and the phase that costs it is the training, not the disk:

  text cond, dim 5120   3,982,467 params  16.2MB  load 19ms  TRAIN 1068ms  save 26ms
  x0 latent, dim 512      221,955 params   0.9MB  load  3ms  TRAIN   46ms  save  2ms

The nets are tiny in FLOPs and not in parameters — a 5120-wide input makes the
first layer 94% of the weights — and twenty Adam steps over that ran on the
CPU because the checkpoint loads with map_location="cpu". Roughly 1.1s here,
about 7.5s on the rental's vCPU, three times per rated generation.

The conditioning is already on the GPU when there is one, so training moves
there and moves back before returning: the buffer and the checkpoint stay on
the CPU so the file remains portable, and inference elsewhere still finds a CPU
module. Adam's state does not follow module.to(), so it is dropped on the move
rather than migrated — it is rebuilt lazily and never persisted, so a run
starts from fresh moments either way.

Nothing about what training does changes; only where it runs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 14:19:39 +03:00