Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 115 additions & 1 deletion .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,56 @@ jobs:
"test_args": "--transport nccl --flush-cache-interval 2",
"test_file": "test_qwen2.5_0.5B_pipeline_rl.py"
},
{
"num_gpus": 4,
"test_args": "--crash-mode server",
"test_file": "test_qwen2.5_0.5B_rollout_health.py"
},
{
"num_gpus": 4,
"test_args": "--crash-mode actor",
"test_file": "test_qwen2.5_0.5B_rollout_health.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 3 --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --role-config --kill-manager --manager-crash-phase training",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"test_args": "--mode debug --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 1 --weight-sync disk-delta --kill-manager",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --pd --wedge-engine --kill-manager",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 8,
"straw": true,
"test_file": "test_qwen3_30B_A3B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
Expand Down Expand Up @@ -789,6 +839,20 @@ jobs:
"num_gpus": 0,
"test_file": "test_pipeline_rl.py"
},
{
"num_gpus": 0,
"straw": true,
"test_file": "test_training_recovery.py"
},
{
"num_gpus": 0,
"test_file": "test_disk_delta_recovery.py"
},
{
"num_gpus": 0,
"straw": true,
"test_file": "test_rollout_manager_recovery.py"
},
{
"num_gpus": 0,
"straw": true,
Expand Down Expand Up @@ -956,7 +1020,7 @@ jobs:
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install pytest numpy packaging pyyaml omegaconf tqdm httpx requests ray pybase64 pylatexenc sympy aiohttp pillow safetensors psutil

pip install transformers wandb
pip install transformers wandb zstandard



Expand Down Expand Up @@ -1221,6 +1285,56 @@ jobs:
"test_args": "--transport nccl --flush-cache-interval 2",
"test_file": "test_qwen2.5_0.5B_pipeline_rl.py"
},
{
"num_gpus": 4,
"test_args": "--crash-mode server",
"test_file": "test_qwen2.5_0.5B_rollout_health.py"
},
{
"num_gpus": 4,
"test_args": "--crash-mode actor",
"test_file": "test_qwen2.5_0.5B_rollout_health.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 3 --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --role-config --kill-manager --manager-crash-phase training",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"test_args": "--mode debug --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --save-interval 1 --weight-sync disk-delta --kill-manager",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
"test_args": "--mode straw --failure-rollout 1 --pd --wedge-engine --kill-manager",
"test_file": "test_qwen2.5_0.5B_training_recovery.py"
},
{
"num_gpus": 8,
"straw": true,
"test_file": "test_qwen3_30B_A3B_training_recovery.py"
},
{
"num_gpus": 4,
"straw": true,
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/pr-test.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
{'test_file': 'test_qwen2.5_0.5B_pipeline_rl.py', 'test_args': '--transport nccl', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_pipeline_rl.py', 'test_args': '--transport disk', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_pipeline_rl.py', 'test_args': '--transport nccl --flush-cache-interval 2', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_rollout_health.py', 'test_args': '--crash-mode server', 'num_gpus': 4},
{'test_file': 'test_qwen2.5_0.5B_rollout_health.py', 'test_args': '--crash-mode actor', 'num_gpus': 4},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode straw --failure-rollout 1 --save-interval 3 --no-fault-tolerance', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode straw --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode straw --failure-rollout 1 --role-config --kill-manager --manager-crash-phase training', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode debug --failure-rollout 1 --save-interval 3 --kill-manager --no-fault-tolerance', 'num_gpus': 4},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode straw --failure-rollout 1 --save-interval 1 --weight-sync disk-delta --kill-manager', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_training_recovery.py', 'test_args': '--mode straw --failure-rollout 1 --pd --wedge-engine --kill-manager', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen3_30B_A3B_training_recovery.py', 'num_gpus': 8, 'straw': True},
{'test_file': 'test_straw_checkpoint_fork.py', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen2.5_0.5B_fanout_short.py', 'num_gpus': 4, 'straw': True},
{'test_file': 'test_qwen3_4B_streaming_partial_rollout.py', 'num_gpus': 8},
Expand Down Expand Up @@ -73,7 +82,7 @@
'label': 'run-ci-cpu-unittest',
'always': True,
'cpu': True,
'extra_pip_deps': 'transformers wandb',
'extra_pip_deps': 'transformers wandb zstandard',
'tests': [
{'test_file': 'test_megatron_argument_validation.py', 'num_gpus': 0, 'straw': True},
{'test_file': 'utils/test_megatron_role_config.py', 'num_gpus': 0},
Expand Down Expand Up @@ -114,6 +123,9 @@
{'test_file': 'test_read_file_slicing.py', 'num_gpus': 0},
{'test_file': 'test_fully_async_rollout.py', 'num_gpus': 0},
{'test_file': 'test_pipeline_rl.py', 'num_gpus': 0},
{'test_file': 'test_training_recovery.py', 'num_gpus': 0, 'straw': True},
{'test_file': 'test_disk_delta_recovery.py', 'num_gpus': 0},
{'test_file': 'test_rollout_manager_recovery.py', 'num_gpus': 0, 'straw': True},
{'test_file': 'test_distributed_rollout.py', 'num_gpus': 0, 'straw': True},
{'test_file': 'test_straw_fully_async_recovery.py', 'num_gpus': 0, 'straw': True},
{'test_file': 'test_rollout_buffer_order.py', 'num_gpus': 0},
Expand Down
18 changes: 9 additions & 9 deletions docs/en/advanced/delta-weight-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ need nothing extra on the slime side.
| Flag | Role |
|---|---|
| `--update-weight-disk-dir` | Shared filesystem directory the trainer publishes deltas to and the rollout hosts read from. |
| `--update-weight-local-checkpoint-dir` | Host-local (e.g. NVMe) full HF checkpoint that `/pull_weights` keeps in sync — deltas are applied into it in place; a published full checkpoint replaces it. Each host seeds it from the engine's model path on the first `/pull_weights`. |
| `--update-weight-local-checkpoint-dir` | Host-local (e.g. NVMe) full HF checkpoint that `/pull_weights` keeps in sync. The initial full publication establishes its baseline; later deltas apply in place, and a new full publication replaces it. |
| `--update-weight-delta-encoding` | On-disk delta encoding: `xor` (default) or `overwrite`. |
| `--update-weight-delta-checksum` | Per-tensor integrity checksum: `xxh3-128` (default), `blake3`, or `adler32`. |

Deltas are always zstd-compressed (level 1); profiling showed it dominates lz4 / gzip / snappy / brotli on both wire size and decompress speed for this data, so it is not a knob.

## How it works

1. **Seed.** On the first sync the trainer captures a CPU snapshot of every parameter — seeded
from `--hf-checkpoint`, which is exactly what each rollout host materializes its local
checkpoint from. Nothing is published; this snapshot is the base the next sync diffs against.
The trainer also issues `/pull_weights` with `target_version=0` so every host materializes
its local base now, overlapped with the snapshot capture.
1. **Seed.** The first sync, including after trainer recovery or an engine replacement,
publishes a full HF checkpoint from the trainer's current weights. It captures the CPU
snapshot from those exact tensors and reloads every engine before generation resumes.
The version exceeds every existing version directory, including an update whose reply
was lost. Existing versions are retained; restarting does not delete the stream.
2. **Publish.** On every later sync the trainer diffs each gathered HF tensor against the
snapshot, encodes and compresses the change, and writes a new version directory
`weight_v{N:06d}/` under `--update-weight-disk-dir`. The directory is a canonical HF
Expand All @@ -60,9 +60,9 @@ Deltas are always zstd-compressed (level 1); profiling showed it dominates lz4 /
4. **Reload.** The engines reload the patched local checkpoint through the vanilla
`update_weights_from_disk` path — the weight-loading code never sees the delta format.

Because the snapshot is seeded from `--hf-checkpoint` (the engine's actual base) rather than
from the current GPU weights, the scheme is correct for any model even where the Megatron→HF
round-trip is not byte-exact (e.g. trimmed vocab-padding rows in the embedding / LM head).
The snapshot and the engines start from the same published HF bytes, including when the
trainer restored a newer model than `--hf-checkpoint`. Megatron→HF conversion differences
(such as trimmed embedding / LM-head padding) therefore do not corrupt the next delta.

## Encodings

Expand Down
Loading
Loading