Repository navigation
Conversation
Each generator's prefetch reads the trainer's CPU-staged weights through TorchStore, and pull_model_state_dict starts every generator's prefetch at once. A TorchStore NIXL get copies every non-contiguous slice it serves into a staging buffer up front, so the trainer hosts briefly hold a copy of each requesting generator's whole shard; with a large model and several generators, concurrent fetches multiply that host RAM. InterGeneratorRouter.Config.max_concurrent_prefetches caps the concurrent TorchStore fetches with a semaphore; each generator's local CPU-to-GPU apply still runs as soon as its own fetch ends. The default, 0, keeps fetching from every generator at once. Replaces the TODO that asked for this stagger.
A generator's prefetch reads its whole weight shard with one TorchStore get_state_dict request, so the trainer-side storage volumes stage and serve all of it at once. For very large models that single burst can exhaust trainer host RAM at the first weight sync. Generator.Config.fetch_weights_per_module splits the fetch into one request per top-level module (each layers.<i>, then the remaining modules), written in place into the same pinned receive buffers. Keys this rank has no buffer for are skipped, as with strict=False. The default keeps the single get_state_dict request.
This branch has not been deployed
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.
TLDR
Two opt-in knobs bound the trainer-host memory burst of the generators' weight fetch:
InterGeneratorRouter.Config.max_concurrent_prefetchescaps how many generators fetch from TorchStore at once, andGenerator.Config.fetch_weights_per_modulesplits each generator's fetch into one request per top-level module. Defaults keep today's behavior.Problem
InterGeneratorRouter.pull_model_state_dictstarts every generator'sprefetch_model_state_dictat once, and each generator rank fetches its whole weight shard with onets.get_state_dictrequest.Solution
InterGeneratorRouter.Config.max_concurrent_prefetches(default 0 = all): a semaphore around each generator's TorchStore fetch. Each generator still applies its weights CPU-to-GPU as soon as its own fetch ends. Replaces the TODO inpull_model_state_dictthat asked for this stagger.Generator.Config.fetch_weights_per_module(default False): the same reads asget_state_dict, written in place into the same pinned receive buffers, but oneget_batchper top-level module (eachlayers.<i>, then the remaining modules). Keys this rank has no buffer for are skipped, as withstrict=False.Unchanged: with both defaults, the fetch path is exactly today's single
get_state_dictper generator rank, all generators at once.Results
fetch_weights_per_module=Trueandmax_concurrent_prefetches=1pulled weights and trained.NOTE: no A/B of fetch time with and without the knobs; per-module requests add round trips, so measure before turning them on for small models, where the burst is harmless.
NOTE: this bounds the burst from the generator side. A TorchStore-side change (copying non-contiguous slices in bounded groups inside the NIXL get handler) would bound it independently of how requests are split.
Test plan
test_max_concurrent_prefetches_staggers_weight_fetches(third generator waits for a fetch slot),test_group_fqns_by_module_splits_each_layer,test_prefetch_model_state_dict_per_module_fetches_in_place(one request per module, written into the pinned buffers themselves, unknown keys skipped). All three fail without the change.pytest tests/rl/unit_tests/cpu/test_inter_generator_router.py tests/rl/unit_tests/cpu/test_generator.py tests/rl/unit_tests/cpu/test_engine_loop.py: 114 passed, 1 skipped (GB300 venv).pre-commit run --fileson the touched files: clean (Pyrefly skipped locally).