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
48 changes: 33 additions & 15 deletions training/rdsp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,51 @@ __pycache__/
dist/
build/

# raw run logs and profiles
# raw results of the old Modal Qwen3-0.6B grid
bench/results/

# bench_oct10: the working folder of the October-November benchmark rounds
# (plans, queues, notes, raw logs, profiles).
bench_oct10/

# what the bench/ scripts write when they run stays local...
bench/**/logs*/*
bench/**/profiles*/
bench/**/prep/
bench/mimo_vs_rdsp/sweep/
bench/mimo_vs_rdsp/convert.log
# what the bench/ scripts write when they run stays local: each experiment's logs/ folder (logs,
# profiles, prep output, the result notes kept beside them)
bench/*/logs/
*.sqlite
*.nsys-rep
*.qdrep
*.pt.trace.json
*.dmon

# benchmark logs and raw results stay local: docs/REPRODUCE.md names the log
# each run writes; the write-ups (*.md) are kept
bench/published/
bench/blog_round/logs27b/
bench/encoder_test/results/**
!bench/encoder_test/results/**/
!bench/encoder_test/results/**/*.md
bench/torchtitan/results/data_check.txt
# kept on disk, not in the repository: the old Modal Qwen3-0.6B grid, one-off checks and tools
bench/modal_bench.py
bench/modal_smoke.py
bench/analyze.py
bench/megatron_hf_loop.py
bench/megatron_pretrain.sh
bench/rdsp_bench.py
bench/bench_hooks.py
bench/torchtitan/checks/
bench/cluster/three.sh
bench/cluster/ray_cluster3.sh
bench/mimo/nsys_breakdown.py
tests/unit/test_nsys_breakdown.py
bench/encoder/summarize.py
bench/encoder/sync_stacks.py

# kept on disk, not in the repository: internal notes, slides, the Modal runners, recipes without
# a published result
CONTEXT.md
docs/CODING_STANDARDS.md
docs/CONTRACTS.md
docs/P0.md
docs/REPRODUCE.md
docs/presentation/
docs/research/
scripts/
recipes/qwen35-4b-vision1-tp2pp2.sh
recipes/qwen35-4b-vision1-tp4.sh
recipes/qwen35-4b-vision2-tp2dp2.sh

# nCompass profiling plugin's working files
ncompass/
167 changes: 0 additions & 167 deletions training/rdsp/CONTEXT.md

This file was deleted.

22 changes: 10 additions & 12 deletions training/rdsp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Qwen3.5 vision-language models on H100 GPUs, trained on CORD-v2. Median time per

- On the 35B that is 1.36× Megatron-Bridge's throughput and 1.43× TorchTitan's; on the 27B, 1.42× and 1.23×. With two rows per microbatch, the fastest setting for both pipelines on the 27B, rdsp is 1.05× Megatron-Bridge.
- On MegatronMIMO's own layouts, with one GPU for the vision encoder, rdsp runs at 0.99–1.09× MIMO's throughput.
- rdsp ran the 35B with the vision encoder on its own 4-GPU stage and six 2-GPU language stages, and the 27B as eight 1-GPU stages, each choosing how many of its layers to recompute. Megatron-Bridge used the layout of NVIDIA's H100 recipe on the 35B and rdsp's eight-stage split on the 27B. TorchTitan sharded over all GPUs, with expert parallelism on the 35B.
- rdsp ran the 35B with the vision encoder on its own 4-GPU stage and six 2-GPU language stages, and the 27B as eight 1-GPU stages, each recomputing its own number of layers. Both measured their own cuts. Megatron-Bridge used the layout of NVIDIA's H100 recipe on the 35B and rdsp's eight-stage split on the 27B. TorchTitan sharded over all GPUs, with expert parallelism on the 35B.

One run per configuration. Settings and commands for each number: [docs/REPRODUCE.md](docs/REPRODUCE.md). Earlier Qwen3.5-2B and 4B results on 8 GPUs: [docs/BENCHMARK_RESULTS.md](docs/BENCHMARK_RESULTS.md).
One run per configuration. Settings and commands for each number: [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md#reproducing-the-blogs-results). Earlier Qwen3.5-2B and 4B results on 8 GPUs: [docs/BENCHMARK_RESULTS.md](docs/BENCHMARK_RESULTS.md).

## Install

Expand All @@ -29,7 +29,7 @@ Linux, CUDA GPUs, Python 3.12. On a fresh node:
bash bench/setup_node.sh
```

This builds `~/venv` with torch, DeepSpeed at the commit every result was measured with, and rdsp, and pulls the container the Megatron comparisons run in. To install by hand, or without the container: [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md#install).
This builds `~/venv` with torch, DeepSpeed at the commit every result was measured with, and rdsp, and pulls the container the Megatron comparisons run in ([docs/GETTING_STARTED.md](docs/GETTING_STARTED.md#install)).

Importing `ray_deepspeed_pipeline` doesn't import Ray or DeepSpeed; only the stage actors do.

Expand All @@ -40,7 +40,7 @@ Importing `ray_deepspeed_pipeline` doesn't import Ray or DeepSpeed; only the sta
./recipes/qwen35-2b-tp2pp2dp2.sh --steps 200 # extra flags override the recipe
```

`recipes/` has one script per benchmarked layout, plus a text-only Qwen3 recipe. [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) covers the flags, your own data, and common failures.
`recipes/` has one script per Qwen3.5-2B and 4B layout in [docs/BENCHMARK_RESULTS.md](docs/BENCHMARK_RESULTS.md), plus a text-only Qwen3 recipe; the 9B to 35B runs are scripts in `bench/`. [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) covers the flags, your own data and the environment variables.

## Python API

Expand All @@ -67,7 +67,7 @@ loss = engine.train_batch(data_iter) # consumes exactly M (inputs, labels) ent
engine.save_checkpoint("ckpt/", tag="step100")
```

If the input embedding and output layer share a weight and land on different stages, untie them first (`train_vl.py --untie-embeddings`); on one stage they stay tied. Every public name, what it guarantees and what it raises are listed in [docs/CONTRACTS.md](docs/CONTRACTS.md). `train_vl.py` is a complete training script.
If the input embedding and output layer share a weight and land on different stages, untie them first (`train_vl.py --untie-embeddings`); on one stage they stay tied. The docstrings in `src/ray_deepspeed_pipeline/` give each public name's guarantees and errors. `train_vl.py` is a complete training script.

## How it works

Expand All @@ -82,29 +82,27 @@ Vision encoder placement, how the cuts are chosen, memory, and the reasoning beh

| Builder | Models | Validation |
|---|---|---|
| `HFModelStage` | Any HF model with a `config`: Llama, Mistral, Qwen2/3/3.5, Qwen3-MoE, Mixtral, Gemma 1–3, Phi-3, OLMo2, Granite, Cohere, StarCoder2, StableLM, DeepSeek-V3, GLM-4/4-MoE/5.3, GPT-2, GPT-NeoX, Falcon, Bloom, Mamba, Qwen3-VL, Qwen3.5-VL | Pipeline loss equals the unsplit model's on CPU (`tests/integration/test_hf_families.py`). Qwen3, Qwen3-MoE and Qwen3.5-VL validated on GPU. |
| `CausalLMStage` | Llama, Qwen3, Qwen3-MoE | GPU-validated in every layout in CONTRACTS.md |
| `HFModelStage` | Any HF model with a `config`: Llama, Mistral, Qwen2/3/3.5, Qwen3-MoE, Mixtral, Gemma 1–3, Phi-3, OLMo2, Granite, Cohere, StarCoder2, StableLM, DeepSeek-V3, GLM-4/4-MoE/5.3, GPT-2, GPT-NeoX, Falcon, Bloom, Mamba, Qwen3-VL, Qwen3.5-VL | Pipeline loss equals the unsplit model's on CPU (`tests/integration/test_hf_families.py`, `tests/integration/test_vl_pipeline.py`). Qwen3, Qwen3-MoE and Qwen3.5-VL validated on GPU. |
| `CausalLMStage` | Llama, Qwen3, Qwen3-MoE | GPU-validated in every layout in `src/ray_deepspeed_pipeline/support_matrix.py` |
| `GenericSequentialStage` | Plain sequential models | CPU |

TP inside a stage uses the model's AutoTP plan. Configs without one get a plan for the standard projection names. Qwen3-VL injects vision features into its first decoder blocks, so its encoder can't be colocated and the first cut must come after them.

## Tests

```bash
pytest -q # CPU: full runtime on Ray with a stub engine (~500 tests); GPU tests skip
pytest -q # CPU: full runtime on Ray with a stub engine (about 630 tests); GPU tests skip
ruff check .
```

The GPU tests (parity against the unsplit model, checkpoint round trip, rank-kill recovery) run on Modal: `scripts/modal_tests.py`.
On a node with GPUs and DeepSpeed (`bench/setup_node.sh`), the same command also runs the GPU tests: parity against the unsplit model, checkpoint round trip and rank-kill recovery.

## Docs

| | |
|---|---|
| [GETTING_STARTED](docs/GETTING_STARTED.md) | Install, terms, recipes, flags, your own data, common failures |
| [REPRODUCE](docs/REPRODUCE.md) | Rerun the benchmarks |
| [GETTING_STARTED](docs/GETTING_STARTED.md) | Install, recipes, flags, environment variables, rerunning the benchmarks |
| [BENCHMARK_RESULTS](docs/BENCHMARK_RESULTS.md) | Qwen3.5-2B and 4B results, per-layout settings, what moved the numbers |
| [CONTRACTS](docs/CONTRACTS.md) | Public API guarantees, errors, supported layouts |
| [ENGINEERING](docs/ENGINEERING.md) | Design |

## Limitations
Expand Down
27 changes: 27 additions & 0 deletions training/rdsp/bench/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# bench

The benchmark scripts: rdsp against Megatron-Bridge, MegatronMIMO and TorchTitan on Qwen3.5. How to run each one, the settings held equal and the numbers: [docs/GETTING_STARTED.md](../docs/GETTING_STARTED.md#reproducing-the-blogs-results). Every script writes into a `logs/` folder next to it, which stays out of git.

| Experiment | Script | What it writes |
|---|---|---|
| Set up a fresh GPU node | `setup_node.sh` | `~/venv`, the NeMo container |
| Qwen3.5-2B and 4B, one node, against MIMO and Bridge | `qwen35_small/bench.sh` | `~/bench/<model>/r<round>/<case>.log`, `summary.txt` |
| Qwen3.5-35B-A3B, two nodes: prepare both nodes | `qwen35_35b/prep.sh` (runs `node_prep.sh` on each) | `qwen35_35b/logs/prep/` |
| 35B: rdsp, vision encoder on its own stage | `qwen35_35b/rdsp_vision_stage.sh` | `qwen35_35b/logs/vision_stage/rdsp-k<K>*.log` |
| 35B: rdsp, TP1 × PP8 × DP2 | `qwen35_35b/rdsp_pp8dp2.sh` | `qwen35_35b/logs/pp8dp2/rdsp*.log` |
| 35B: Bridge, TP1 × PP8 × DP2 | `qwen35_35b/bridge_pp8dp2.sh` | `qwen35_35b/logs/pp8dp2/bridge*.log` |
| 35B: Bridge, TP1 × PP2 × EP8 (NVIDIA's layout) | `common/runs.sh custom-megatron` through `cluster/both.sh` (the command is in GETTING_STARTED) | `qwen35_35b/logs/pp2ep8/bridge-pp2ep8-nv.log` |
| 35B: TorchTitan, FSDP over 16 GPUs | `qwen35_35b/torchtitan.sh` | `qwen35_35b/logs/fsdp16/<fit\|run>-<config>-node<rank>.log` |
| 35B: rdsp, ZeRO-3 over 16 GPUs | `qwen35_35b/rdsp_zero3.sh` | `qwen35_35b/logs/fsdp16/rdsp-zero3*.log` |
| Qwen3.5-27B: prepare both nodes (35B prep, then the 27B) | `qwen35_27b/prep.sh` | `qwen35_27b/logs/prep/` |
| 27B, one node, TP1 × PP8: Bridge or rdsp | `qwen35_27b/pp8.sh` (rdsp side: `rdsp_pp8.sh`) | `qwen35_27b/logs/pp8/` |
| 27B: rdsp with recompute set per stage | `qwen35_27b/rdsp_tune.sh` | its output (GETTING_STARTED's commands save it in `qwen35_27b/logs/pp8/`) |
| 27B: one node's whole queue | `qwen35_27b/one_node.sh` | `qwen35_27b/logs/pp8/`, `torchtitan/logs/` |
| 9B against MIMO, one node | `mimo/mimo_9b.sh` | `mimo/logs/<layout>/`, `mimo/logs/sweep/` |
| 9B: Bridge against rdsp, TP4 × PP2, and the 9B prep | `mimo/bridge_9b.sh` (rdsp side: `rdsp_9b_tp4pp2.sh`) | `mimo/logs/9b_tp4pp2dp1/` |
| 27B against MIMO, two nodes: rdsp's side | `mimo/rdsp_27b.sh` | `mimo/logs/27b_v1_tp4pp2dp1/rdsp-9gpu.log` |
| 27B against MIMO: MIMO with Bridge's memory settings | `mimo/patch_mimo.py` (`patch.diff`: the result) | a patched copy of MIMO's launcher in `/tmp` |
| TorchTitan on Bridge's rows | `torchtitan/run.sh` (one node), `torchtitan/run_two_node.sh`, `torchtitan/setup_box.sh` | `torchtitan/logs/` |
| Vision encoder alone | `encoder/enc_bench.py`, `encoder/grids.py` | the JSON given with `--out` |
| Two-node helpers | `cluster/both.sh`, `ray_cluster.sh`, `efa_env.sh`, `nccl_check.sh` | `~/both-<time>.log` on node 2 |
| Shared by the scripts above | `common/runs.sh` (Bridge, MIMO and rdsp cases in the NeMo container), `two_node.sh`, `meg_extra_bf16.txt`, `export_bridge_batches.py`, `medians.py`, `summarize.py`, `layout_from_log.py` | `$LOGS/<case>.log` |
Loading
Loading