Fix CUDA resume and optimize training throughput - #1
Merged
Conversation
ferdinandobons
force-pushed
the
agent/fix-cuda-rng-resume
branch
from
July 21, 2026 19:06
678075b to
f1c876e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
--log-intervalprogress output independent of validation and checkpoint cadence.CUDA_TRAINING_OPTIMIZATIONS.mdwith concepts, measurements, tradeoffs, and production commands.Why
CUDA resume failed because
torch.load(..., map_location="cuda")moved RNG-state tensors to CUDA whiletorch.cuda.set_rng_state_allrequires CPU ByteTensors.The educational attention implementation also launched Q, K, V, and SDPA separately for every head. On the measured 12-block, 12-head model this caused 432 QKV projections and 144 attention calls per micro-batch. Fusing heads preserves the model computation while substantially reducing Python and CUDA launch overhead.
Separating logging from evaluation gives frequent progress visibility without running validation, context diagnostics, and multi-gigabyte checkpoint writes every 100 steps.
Impact
--fused-attention.Validation
python -B tools/validate_learngpt.pypython -B -m unittest discover -s tests -v