Repository navigation
Implement delta model state dict transport - #6142
Closed
tushar00jain wants to merge 1 commit into
Closed
tushar00jain wants to merge 1 commit into
tushar00jain wants to merge 1 commit into
Conversation
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 16, 2026 23:16
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 16, 2026 23:59
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 16, 2026 23:59
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 17, 2026 00:09
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 17, 2026 00:09
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 17, 2026 17:07
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 17, 2026 17:07
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 17, 2026 23:55
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 17, 2026 23:55
8b10893 to
b84ff0d
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 17, 2026 23:56
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 18, 2026 00:19
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 18, 2026 00:19
b84ff0d to
750ac0e
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 18, 2026 00:19
This was referenced Nov 18, 2026
tushar00jain
marked this pull request as ready for review
November 18, 2026 23:32
tushar00jain
marked this pull request as draft
November 19, 2026 22:00
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 19, 2026 22:30
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 19, 2026 22:31
750ac0e to
51f09a5
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 19, 2026 22:31
d4l3k
reviewed
Nov 20, 2026
| stream.synchronize() | ||
|
|
||
|
|
||
| class ModelStateDictTransport(Configurable): |
Member
There was a problem hiding this comment.
should we make a "ModelStateDictDeltaTransport" impl? Wondering if it would be better to structure this separately. Would be nice to make a subfolder and split some of this logic up
Contributor
Author
There was a problem hiding this comment.
Sure. Also still in the process of updating this PR from the previous version - refactoring, changing the custom format to XOR, wire compression, researching on optimizing the delta to the staging buffer bottleneck. Will mark it ready for review after updating.
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 20, 2026 01:17
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 20, 2026 01:17
51f09a5 to
51b484b
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 20, 2026 01:17
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 20, 2026 02:54
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 20, 2026 02:54
51b484b to
bf2280a
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 20, 2026 02:54
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 20, 2026 03:38
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 20, 2026 03:38
bf2280a to
0fad7e6
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 20, 2026 03:38
tushar00jain
changed the base branch from
main
to
fs-base/delta-weight-sync/1
November 20, 2026 04:56
tushar00jain
force-pushed
the
fs-head/delta-weight-sync/1
branch
from
November 20, 2026 04:56
0fad7e6 to
bf2280a
Compare
tushar00jain
changed the base branch from
fs-base/delta-weight-sync/1
to
main
November 20, 2026 04:56
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
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.
Summary (human-written)
Why
Each pull reads the whole model, but an RL step changes only 1.6-2.2% of bf16 values, spread over every tensor. Delta sync sends only the changed 2-byte words, in NVIDIA 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, as other systems address changes per tensor; the generator applies them to the weights it loads, without translating them.
A pull moves only the compressed changes plus the copy the load already does. The prefetch buffer catches up off the critical path, before the next read. The first pull is full. A push with more than 1/16 of a window's words changed, or a generator that missed a push, reads the push whole.
What changed
stagecompares each 64 MiB window of the staging buffer with the new push on the GPU and stages the changed words' gaps, XORs and per-piece counts in a pinned buffer, with no host synchronization.finish_stagecompresses each changed window on CPU threads into a registered delta buffer.zstandardis not a PyTorch library; a TODO names its standard-library replacement (compression.zstd, Python 3.14).Alternatives considered
zstd(old ^ new)per window, CPU (humans& #6176, vLLM vime)User-facing changes
sync_mode="full"sync_mode="delta"Tradeoffs
Testing
test_delta_loads_changes: changes applied in place (row pieces) and to packed keys (column pieces), with pieces spanning windows.test_delta_reads_only_changed_windows: unchanged windows are not read, adjacent windows share one read, consecutive pushes chain, a read that is not loaded is applied by the next one, and a missed push reads whole.test_delta_reads_whole_past_capacity: a window over capacity makes the push read whole.test_delta_windows_span_pieces: a window with several pieces and a piece spanning windows, mixed dtypes.Loaded weights and prefetch buffers are bitwise equal to the trainer's after every delta in these tests and in a local 6.7 GB GPU check.
Qwen3.5 27B (53.8 GB bf16) on MAST, 2 GB300 hosts (4 NICs each), DAPO-Math recipe: trainer FSDP 2 x TP 2 on one host, 4 TP 1 vLLM generators on the other (each pulls the full model), 6 steps of 4 prompts x 16 samples, NIXL 1.5.0 (bundled UCX 1.23.0). The two columns run this PR's code; only
sync_modediffers. Pull times are for the slowest generator.sync_mode="full")sync_mode="delta")Trainer staging, same runs (trainer rank 0).
sync_mode="full")sync_mode="delta")forward_backwardincl. overlapped staging (steps 2-6)Memory, same runs (max over processes and steps).
sync_mode="full")sync_mode="delta")Stack (top to bottom):