Repository navigation
Implement delta model state dict transport - #6311
Closed
tushar00jain wants to merge 1 commit into
Closed
tushar00jain wants to merge 1 commit into
tushar00jain wants to merge 1 commit into
Conversation
Add optional delta synchronization to the direct model state dict transport, keeping full synchronization as the default. At RL learning rates an optimizer step changes few bf16 values (about 2%), but they are spread over every tensor, so a range-level delta still sends nearly everything. Delta sync instead sends only the changed 2-byte words, in NeMo RL's sparse refit format: the gap before each changed word and the word XOR its old value, compressed with zstd level 1. A 1-ulp change leaves the high bits of the XOR zero, so it compresses better than the new value. Gaps restart at each staged piece, so every change is addressed in the tensor that receives it. - The trainer keeps one dense staging buffer holding the latest push, as for full sync. After the first push, `stage` assembles each 64 MiB window of the staging buffer on the GPU, compares it with the window's previous contents (read back from the pinned buffer) before overwriting them, and copies the changed words' gaps, XORs and per-piece counts to a pinned buffer, with no host synchronization. `finish_stage` compresses each changed window's record on CPU threads into a registered delta buffer. A push with more than 1/16 of a window's words changed, or whose records exceed the delta buffer, is not sent as a delta. - `finish_stage` returns each window's (offset, size, gap width, changes per piece) and the push index as ordinary Monarch endpoint metadata; the controller forwards them unchanged. - Each generator rank reads the first push whole, then one range per run of adjacent changed windows covering its pieces into one registered receive buffer, decompresses the windows on CPU threads, and packs each FSDP group's changes into one pinned buffer. The load copies the prefetch buffers to the GPU as for full sync, and per FSDP group copies the changes there, computes their positions with one running sum and XORs them into the copies, so a pull moves only the compressed changes and the load's own copy. CPU threads then XOR the same words into the prefetch buffers in the background; the next read waits for them. A generator that missed a push, or a delta that was not sent, reads the push whole. zstandard is not a PyTorch library; a TODO names its standard-library replacement (Python 3.14). The controller remains the sole coordinator, finishes pull N before push N+1, and keeps the restart-on-failure behavior. Test Plan: ``` pytest -q tests/rl/unit_tests/cpu/test_model_state_dict_transport.py tests/rl/unit_tests/cpu/test_inter_generator_router.py tests/rl/unit_tests/cpu/test_trainer_loop.py ``` Authored with assistance from an AI coding assistant. fs-branch: delta-weight-sync/1
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 21, 2026 00:48
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.
Add optional delta synchronization to the direct model state dict transport, keeping full synchronization as the default.
At RL learning rates an optimizer step changes few bf16 values (about 2%), but they are spread over every tensor, so a range-level delta still sends nearly everything. Delta sync instead sends only the changed 2-byte words, in NeMo RL's sparse refit format: the gap before each changed word and the word XOR its old value, compressed with zstd level 1. A 1-ulp change leaves the high bits of the XOR zero, so it compresses better than the new value. Gaps restart at each staged piece, so every change is addressed in the tensor that receives it.
stageassembles each 64 MiB window of the staging buffer on the GPU, compares it with the window's previous contents (read back from the pinned buffer) before overwriting them, and copies the changed words' gaps, XORs and per-piece counts to a pinned buffer, with no host synchronization.finish_stagecompresses each changed window's record on CPU threads into a registered delta buffer. A push with more than 1/16 of a window's words changed, or whose records exceed the delta buffer, is not sent as a delta.finish_stagereturns each window's (offset, size, gap width, changes per piece) and the push index as ordinary Monarch endpoint metadata; the controller forwards them unchanged.zstandard is not a PyTorch library; a TODO names its standard-library replacement (Python 3.14). The controller remains the sole coordinator, finishes pull N before push N+1, and keeps the restart-on-failure behavior.
Test Plan:
Authored with assistance from an AI coding assistant.
Stack (top to bottom):