Skip to content

[rl] Terminal-Bench 35B-A3B recipe: Dist-MoE in both roles, FULL CUDA graph generators, DAPO loss - #5868

Draft
felipemello1 wants to merge 1 commit into
mainfrom
felipemello1/tb-oss/4-dist-moe-recipe
Draft

felipemello1 wants to merge 1 commit into
mainfrom
felipemello1/tb-oss/4-dist-moe-recipe

Conversation

@felipemello1

@felipemello1 felipemello1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

TLDR: rl_grpo_qwen35_35b_a3b_terminal_bench carried "TODO: migrate to DistMoE and capture generator CUDA graphs in FULL mode". This PR does that TODO with Dist-MoE in both roles, lays the GPUs out for GB300, and switches the loss to DAPO, as rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

The 35B-A3B Terminal-Bench recipe goes from 8 trainer and 8 eager generator GPUs to 4 trainer and 16 generator GPUs, with Dist-MoE and FULL CUDA graphs.

main:     trainer 8 GPUs, FSDP 4 x TP 2 x EP 8, stock experts      generators 2 x 4 GPUs (DP 2 x TP 2 x EP 4), stock experts, eager   GRPO
this PR:  trainer 4 GPUs, FSDP 2 x TP 2 x EP 4, Dist-MoE experts   generators 4 x 4 GPUs (DP 4 x EP 4), Dist-MoE experts, FULL graphs   DAPO

Problem

  1. Eager generators. Main's generators split the experts over 4 GPUs (EP 4). The stock all-to-all dispatcher copies split sizes to the host, and CUDA graph capture forbids that copy.
  2. The TODO. Main's docstring asks for Dist-MoE and FULL CUDA graphs.
  3. GPU split. Terminal-Bench is generation-bound. A rollout makes up to 120 model calls in a row, with a sandbox command between each. The trainer processes all of a rollout's tokens in parallel. Main gives half of its 16 GPUs to the trainer.

Solution

  1. Dist-MoE in both roles. DistMoeTransform() on the trainer and on the generator, so both run Dist-MoE expert kernels, as the repo's other Dist-MoE RL recipes do. The generator gets DistMoeRuntime.Config(scratch_capacity_factor=4.0, inference=True), like the trainer and like the Qwen3-30B-A3B Dist-MoE DAPO-Math recipe's DP 4 x EP 4 generator: 4.0 = EP x min(top-k, local experts) / top-k = 4 x 8 / 8, the most one rank can receive as a multiple of balanced routing. Cost: 0.44 GiB of device scratch per GPU at the default token budget (2,048). With Dist-MoE the generators capture VLLMCudaGraphConfig(mode="FULL").
  2. Layout for GB300 (4 GPUs of 288 GB per host):
    • Trainer: one host, FSDP 2 x TP 2 x EP 4, scratch_capacity_factor=4.0 (4.0 = EP x min(top-k, local experts) / top-k = 4 x 8 / 8). Model state is 35.1B x 16 B (fp32 weights, gradients, AdamW m and v) / 4 = 140 GB per GPU, which leaves about 148 GB for activations.
    • Generators: the other 16 GPUs, as 4 engines, one 4-GPU host each, DP 4 x EP 4. Each GPU holds 64 of the 256 experts: (2.9B non-routed + 32.2B routed / 4) x 2 B (bf16) = 22 GB of weights, and the rest holds the KV cache. The cost: an expert all-to-all in every MoE layer, and the 4 DP ranks step together, each padded to the largest rank's tokens.
    • Total: 20 GPUs on 5 hosts. SlurmLauncher runs the controller on the trainer's host. torchtitan.rl.train uses one host, so wrap the recipe with a launcher (the README points to the Slurm example).
  3. Hardware. Dist-MoE needs SM100+ GPUs: DistMoeRuntime raises on older devices (dist_moe/runtime.py:301-302). The 4-GPU trainer also needs 288 GB GPUs (GB300, B300). A B200 (180 GB) would keep only about 40 GB per GPU for activations, so the docstring and README say to set the trainer's data_parallel_shard_degree=4 there (8 GPUs, EP 4 and the scratch factor unchanged).
  4. Loss: DAPOLoss with ratio clip 0.2 / 0.28, as the repo's DAPO-Math and Search-R1 recipes.
  5. Unchanged from main: lr, warmup, steps, 8 prompts x 32 samples, 4 steps off-policy, 120 turns, 65,536-token context, 16,384-token replies, FullActivationRematConfig, checkpoints, model path.

Results

Generator smoke, 4 GB300s: one engine built from this recipe's generator config (DP 4 x TP 1 x EP 4, Dist-MoE, scratch
factor 4.0, FULL graphs, default token budget 2,048, max_num_seqs 512; vLLM ran bf16), Qwen3.5-35B-A3B-Base weights
from the HF checkpoint. 384 Terminal-Bench-shaped sessions x 4 turns (random token ids, ~585 output + ~512 tool
tokens per turn, 5-9 s tool gaps).
  graph capture     136 graphs (85 mixed prefill-decode sizes + 51 decode sizes), 110 s, 1.2 GiB pool per GPU
  KV cache          223.77 GiB per GPU = 10.6M tokens; max use 4%, 0 preemptions
  engine steps      8,371 per rank: 7,138-8,049 scheduled + 322-1,233 idle-rank dummy batches; all FULL, 0 eager
  forward p50       steps with prefill 25.2-25.5 ms, decode 9.2-9.6 ms
  DP padding        271-307 decode-only steps per rank ran a mixed graph sized for another rank's prefill (mostly
                    1,536 or 2,048 tokens): +4.2-4.7 s over decode graphs = 5.0-5.6% of each rank's forward time
  output            914,205 tokens in 102.6 s = 8,906 tok/s (2,227 per GPU)

You may ask: why DAPO? It is the author's choice for this recipe. DAPO's asymmetric clip-higher (0.28 above, 0.2 below) counters entropy collapse (DAPOLoss docstring), and these are the clips of the repo's DAPO-Math and Search-R1 recipes. The first run of this recipe is the evidence. You may ask: why not a separate PR for the loss? The loss is a few lines, the recipe's name carries it (rl_dapo_...), and the recipe has not run with either loss. A separate PR would rename the recipe twice. You may ask: why not keep main's 8-GPU trainer? On GB300 the 140 GB of model state fits one 4-GPU host. The 4 GPUs it frees go to generation, which bounds the step time. You may ask: why DP 4 x EP 4 and not 16 one-GPU engines? It is the author's choice for this recipe. Each GPU reads at most 64 experts' weights per MoE layer, not up to 256. On a Terminal-Bench-shaped replay at 96 sessions per GPU (token budget 8,192, not run side by side), DP 2 x EP 2 engines made 10% more output tokens per GPU than one-GPU engines (2,481 vs 2,245 tok/s); the cause was not profiled. DP 4 x EP 4 was not compared with 16 one-GPU engines. Its padding cost is larger: 5.0-5.6% of forward time here, vs 2.1-2.2% for DP 2 x EP 2 in that replay (different budgets and turn counts, so directional only). You may ask: does this need the generator's decode-specialized FULL graphs change? No. That change touches only the vLLM worker. Qwen3.5's linear attention already gets decode graphs on main, and max_num_seqs (512) is a capture size, so FULL mode works with or without it.

NOTE: not run end to end. The generator smoke (Results) does not cover the trainer, weight sync into the DP 4 x EP 4 generators, the router across 4 generators, the launcher and multi-host placement, validation, long contexts or KV pressure, or real-text routing. Not run yet: this recipe end to end, and the trainer's memory peak at 65,536 tokens. NOTE: main's 120 turns and 65,536-token context are unchanged here, so rollouts hit the context cap around turn 60 (the 9B recipe's comment: a turn is about 1.1K tokens). NOTE: a separate doc change for both Terminal-Bench recipes: the README now says local Docker needs at least 1 CPU and 2 GB per rollout in flight (1,280 here, plus 89 while a validation runs) on the controller host, and 21 of the 89 Terminal-Bench 2.1 tasks ask for 4-8 GB. So large runs should set a remote sandbox runtime. It also says where each process runs under the Slurm launcher, and says to give the agent a remote sandbox provider as its Verifiers runtime.

Test plan

pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components/test_renderer.py tests/unit_tests/cpu/config   # Verifiers 0.4.0, on main: 953 passed, 1 skipped
  • test_recipe_layouts_fit_the_model checks the new layout: 4 trainer GPUs, 4 generators of DP 4 x EP 4, KV heads and expert counts. Its old assert that the generator runs eager is gone.
  • test_recipes_share_the_loop_and_keep_fp32_master_weights now covers the new name. The 35B recipe still shares the 9B loop.
  • test_rl_recipes_get_model_defaults builds every recipe in the module with no arguments. The built 35B config has 40 Dist-MoE expert layers in each role, DistMoeRuntime.Config(scratch_capacity_factor=4.0, inference=True) on the generator and FULL graphs.

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Nov 5, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 5, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/3-finite-validation branch from cbf1092 to c512ff1 Compare November 5, 2026 20:54
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from ee56d2d to 4956e35 Compare November 5, 2026 20:55
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 3m 24s —— View job


Request changes -- see the review. Dist-MoE runs on the trainer only, and the trainer drops from 8 to 4 GPUs without a reason.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Request changes -- Dist-MoE is applied to the trainer only, unlike every other Dist-MoE RL recipe. That puts different expert kernels in the trainer and the generator, and it is what forces the topology rewrite (16 one-GPU generators, a 4-GPU trainer), which the TODO does not need.

What this PR does. It renames the 35B-A3B Terminal-Bench recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe and changes four things:

  • The trainer gets Dist-MoE experts and halves its GPUs to FSDP 2 x TP 2 x EP 4.
  • The generator becomes 16 one-GPU engines with stock experts at EP 1, which lets it capture FULL CUDA graphs.
  • The loss switches from GRPO to DAPO.
  • The README gains hardware and Docker sizing notes.

Example.

                main                        this PR                         smallest alternative
trainer         8 GPU, EP 8, stock          4 GPU, EP 4, Dist-MoE           8 GPU, EP 8, Dist-MoE
generator       2 x (DP2 TP2 EP4), stock    16 x 1 GPU, stock experts       2 x (DP2 TP2 EP4), Dist-MoE
cuda graphs     NONE                        FULL                            FULL (alphabet_sort.py:1099-1100)
expert kernels  same in both roles          differ (Dist-MoE vs grouped_mm) same in both roles
state/GPU       ~70 GB                      ~140 GB                         ~70 GB

Must fix

  1. PR description -- "Summary (human-written)" is empty. The description also says "Every other value is unchanged", but the trainer GPU count and FSDP degree changed.
  2. torchtitan_recipes/rl/verifiers_terminal_bench.py:445 -- Dist-MoE runs on the trainer only. This adds a trainer/generator expert-kernel mismatch and isn't needed for FULL graphs. Apply DistMoeTransform() to both roles and keep main's layout, or justify the 16 x 1 layout (see inline).
  3. torchtitan_recipes/rl/verifiers_terminal_bench.py:337-341 -- the trainer drops from 8 to 4 GPUs with no reason given, which doubles per-GPU model state to ~140 GB (see inline).
  4. torchtitan_recipes/rl/verifiers_terminal_bench.py:325 (and README.md:94) -- H200 is excluded because Dist-MoE requires SM100+ (dist_moe/runtime.py:301-302), not because of memory. State the hardware requirement directly.

Should consider

  • torchtitan_recipes/rl/verifiers_terminal_bench.py:415-416 -- the remat config is the same policy as FullActivationRematConfig(). Keep that, or give the reason in the comment instead of naming a recipe.
  • torchtitan_recipes/rl/verifiers_terminal_bench.py:425-429 -- the GRPO -> DAPO switch is a separate concern. Split it out.
  • tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py:478-481 -- the new assertions only re-read the config and pin the trainer-only asymmetry. A trainer missing the transform already fails at launch (DistMoeRuntime: "requires at least one expert module").

Questions

  • Is there a reason Dist-MoE can't or shouldn't run in this generator, e.g. a vLLM, Qwen3.5 linear-attention, or EP-group constraint? If so, the recipe docstring should say so. The current comment only says the generator "keeps stock experts".
Details
  • Gate. The problem is real: main's recipe carries the TODO, and EP > 1 with the all-to-all dispatcher blocks graph capture. The repo already shows how to resolve it. All three existing Dist-MoE RL recipes transform both trainer and generator and pass DistMoeRuntime.Config(inference=True) to the generator with mode="FULL", including Qwen3-30B-A3B at generator DP 4 / EP 4 (dapo_math.py:505-533). This PR is the only one that leaves the generator on stock experts. It also replaces EP-based generator sharding with 16 replicas, which changes the GPU count (16 -> 20) and the per-GPU memory profile.
  • Weight sync. DistMoeRoutedExperts keeps w13/w2 as GroupedLinear with the same FQNs (config/transform/dist_moe.py:63-75), so trainer -> generator sync should still map. Unverified at runtime.
  • Alternative size. About 10 lines changed versus main's recipe: add DistMoeRuntime.Config(scratch_capacity_factor=8.0) to the trainer (EP 8) and DistMoeRuntime.Config(scratch_capacity_factor=4.0, inference=True) to the generator, set mode="FULL", and apply DistMoeTransform() to both. Trainer parallelism, generator parallelism, num_generators, and the README table stay as they are.

Not verified: memory headroom of the 4-GPU trainer at 65K-token microbatches; that the Dist-MoE trainer and stock-expert generator sync weights correctly. Neither was run.

),
)
# Dist-MoE experts on the trainer only: each one-GPU generator keeps stock experts.
config.trainer = apply_transforms(config.trainer, [DistMoeTransform()])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dist-MoE goes on the trainer only. Every other Dist-MoE RL recipe applies it to both roles: rl_grpo_moe_debug_dist_moe_tp2_ep4 (alphabet_sort.py:1109-1110), Qwen3-30B-A3B DAPO-Math (dapo_math.py:520-533), and Muse Spark (dapo_math.py:390-399).

Consequences:

  • The trainer computes logprobs with Dist-MoE's grouped GEMMs, while the generator samples with stock RoutedExperts. That is a new trainer/generator kernel mismatch in the importance ratio. rules/models.md asks to "keep trainer and generator numerics consistent".
  • The mismatch is also why the topology had to change. The CI recipe's own comment (alphabet_sort.py:1099-1100) says Dist-MoE captures FULL graphs at EP > 1, so going to EP 1 with 16 one-GPU engines is not needed for FULL mode.

Smallest alternative (~10 lines, implements the TODO as written): keep main's layout (8 trainer GPUs, 2 generators of DP 2 x TP 2 x EP 4). Add dist_moe_runtime=DistMoeRuntime.Config(scratch_capacity_factor=4.0, inference=True) to the generator, set mode="FULL", and also apply DistMoeTransform() to config.generator. If the 16 x 1 layout is still wanted, the PR should give a reason (e.g. measured throughput) and say why stock experts in the generator are acceptable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Fixed in b7782cb. DistMoeTransform() now runs on the generator too, with DistMoeRuntime.Config(inference=True) and FULL graphs. At EP 1 every routed token stays on its GPU, so the default scratch factor 1.0 is the worst case.

Dist-MoE supports a one-GPU generator:

  • The runtime takes a size-1 EP mesh (get_optional_mesh("ep", include_singleton_axes=True), dist_moe/runtime.py:304-308).
  • tests/rl/unit_tests/gpu/test_generator_dist_moe_mxfp8.py runs a DP 1 x TP 1 x EP 1 generator with FULL graphs.

The 16 x 1 layout stays on purpose, and the docstring now explains it:

  • A GB300 host has 4 GPUs of 288 GB. The trainer's 140 GB of model state per GPU fits one host.
  • Terminal-Bench is generation-bound: a rollout makes up to 120 model calls in a row, with a sandbox command between each. So the other 16 GPUs generate.
  • A one-GPU engine holds all 256 experts (70 GB of bf16 weights) and needs no expert all-to-all and no TP all-reduce.

Comment on lines 337 to +341
trainer_parallelism = ParallelismConfig(
data_parallel_replicate_degree=1,
data_parallel_shard_degree=4,
data_parallel_shard_degree=2,
tensor_parallel_degree=2,
expert_parallel_degree=8,
expert_parallel_degree=4,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trainer drops from 8 GPUs (FSDP 4 x EP 8) to 4 GPUs (FSDP 2 x EP 4), with no reason given. The description says "Every other value is unchanged", but this doubles model state per GPU from ~70 GB to ~140 GB before activations, at a 65,536-token microbatch. On B200 (~180 GB) that leaves little headroom for activations, Dist-MoE scratch, and the unsharded bf16 layer (unverified, not run).

Dist-MoE works at EP 8 with scratch_capacity_factor=8.0. Please keep the 8-GPU trainer, or say what the 4-GPU trainer buys.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: The 4-GPU trainer is on purpose, and the docstring now says why. The recipe is sized for GB300 (288 GB per GPU). 140 GB of model state per GPU leaves about 148 GB for activations, Dist-MoE scratch and the unsharded layer. So the trainer fits one 4-GPU host, and the 4 GPUs it frees go to generation, which bounds the step time.

The description no longer says "every other value is unchanged". Not run, so the activation peak at 65,536 tokens is not measured. B200 (180 GB) may need the 8-GPU trainer; the docstring says the layout is sized for GB300.

TODO: migrate to DistMoE and capture generator CUDA graphs in ``FULL`` mode.
Memory (35.1B parameters):
trainer: 35.1B x 16 B (fp32 weights, gradients, AdamW m and v) / 4 GPUs
= 140 GB per GPU before activations, so it does not fit an H200 (141 GB)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"does not fit an H200" points at the wrong cause. Dist-MoE raises on anything older than SM100 (dist_moe/runtime.py:301-302: "Dist-MoE requires an SM100-or-newer CUDA device"), so H200 is ruled out whatever the memory. The same applies to README.md:94.

Suggest stating the hardware requirement directly, e.g. "Dist-MoE needs SM100+ (B200/GB300)", and keeping the memory line as a plain per-GPU figure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Fixed in b7782cb. The docstring and the README now say that Dist-MoE needs SM100+ GPUs (B200, GB300). The memory lines are plain per-GPU figures.

Comment on lines +415 to +416
# Saves no region, like rl_grpo_moe_debug_dist_moe_tp2_ep4, the Dist-MoE CI recipe.
activation_remat=ActivationRematConfig(save_regions=[]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the PR's own analysis, ActivationRematConfig(save_regions=[]) is the same policy as FullActivationRematConfig() (activation_remat.py:167-179). The new comment justifies it by naming another recipe rather than giving a reason.

Either keep FullActivationRematConfig(), which drops this hunk and the new import, or say in the comment why this spelling is needed. Citing a recipe name will go stale.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Reverted in b7782cb to FullActivationRematConfig(), as on main. The hunk and the import are gone.

Comment on lines +425 to 429
loss_fn=DAPOLoss.Config(
ratio_clip_low=0.2,
ratio_clip_high=0.28,
global_vocab_size=decoder_vocab_size(trainer_model),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GRPO -> DAPO switch is a separate concern from the TODO (Dist-MoE + FULL graphs). It changes the training algorithm of a recipe that has never been run. Its only justification is that a different task (DAPO-Math) uses these clips, while the 9B Terminal-Bench sibling stays on GRPO.

Consider splitting it out, so this PR changes only the execution backend and a loss change comes with a run behind it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: DAPO stays in this PR: it is the author's choice for this recipe.

  • DAPO's asymmetric clip-higher (0.28 above, 0.2 below) counters entropy collapse (DAPOLoss docstring, losses/dapo.py:41-45).
  • These are the clips that the repo's DAPO-Math and Search-R1 recipes use.
  • The first run of this recipe is the evidence.

The PR title and description name the loss change, so it is not hidden inside the backend change.

Comment on lines +478 to +481
# Dist-MoE experts in the trainer only: a one-GPU generator keeps stock experts.
dist_moe_experts = DistMoeRoutedExperts.Config
assert list(config.trainer.model.traverse(dist_moe_experts))
assert not list(config.generator.model.traverse(dist_moe_experts))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This re-reads what the recipe just set (rules/tests.md: no tests that only re-read a config), and it pins the trainer-only asymmetry questioned at verifiers_terminal_bench.py:445.

If Dist-MoE moves to both roles, drop these lines. A missing transform already fails at launch through the Dist-MoE runtime checks, so the test catches no silent regression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Dropped in b7782cb, since Dist-MoE now runs in both roles.

@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/3-finite-validation branch from c512ff1 to 7024bf4 Compare November 5, 2026 21:31
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 4956e35 to b7782cb Compare November 5, 2026 21:31
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Thanks for the review. Changes are in b7782cb, and each inline thread has a reply.

  • Summary (human-written): the author fills it in before this PR leaves draft.
  • "Every other value is unchanged": gone from the description and the commit message. They now list the layout change and the values that stay main's.
  • Question, Dist-MoE in the generator: it now runs there too (see the :445 thread).

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 2m 31s —— View job


Approve, with doc fixes to make before merging -- see the review. Before merging: fill in the human-written summary, and fix the docstring and README lines that list B200, since the 4-GPU trainer needs 288 GB GPUs.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the items below before merging. Dist-MoE now runs in both roles, the same way as the repo's other Dist-MoE RL recipes, and the layout change is explained. What's left are doc edits.

What this PR does. It does main's TODO for the 35B-A3B Terminal-Bench recipe: DistMoeTransform() on both trainer and generator, and FULL generator CUDA graphs. It moves the GPUs to a GB300-sized layout and switches GRPO to DAPO. It also renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    16 x 1 GPU, Dist-MoE (inference, scratch 1.0), FULL
expert kernels  stock in both roles         Dist-MoE in both roles
state/GPU       ~70 GB trainer              ~140 GB trainer, 70 GB bf16 weights per generator
loss            GRPO                        DAPO (0.2 / 0.28)

Earlier review, checked at b7782cb

  • Dist-MoE on the trainer only -- resolved. Both roles are transformed. The generator passes DistMoeRuntime.Config(inference=True), and factor 1.0 is the exact worst case at EP 1 (runtime.py:196-198).
  • 4-GPU trainer with no reason given -- answered. The docstring now explains the GB300 sizing and why the run is generation-bound.
  • H200 / SM100 wording -- resolved. But see the B200 item below.
  • Remat spelling -- resolved (back to FullActivationRematConfig()).
  • Test that re-read the config -- resolved (removed).
  • GRPO -> DAPO in the same PR -- the author keeps it on purpose. The title and description name it. Whether to split it is a maintainer's call.

Must fix

  1. PR description -- "Summary (human-written)" is still empty. The author has said they'll fill it in before the PR leaves draft. It needs to be there before merge.
  2. torchtitan_recipes/rl/verifiers_terminal_bench.py:289 (and README.md:93-95) -- these lines list B200 as supported, but the 4-GPU trainer needs 288 GB GPUs (see inline).

Should consider

  • torchtitan/rl/examples/verifiers/terminal_bench/README.md:100-104 -- the Docker sizing paragraph also covers the 9B recipe, so it goes beyond the 35B TODO. The numbers do check out: (3+1) x 12 x 32 = 1,536 and (4+1) x 8 x 32 = 1,280 (controller.py:207-208). Keep it if you want; just mention it in the description as a separate doc change.
Details
  • Weight sync. DistMoeTransform keeps w13/w2 as GroupedLinear with the source FQNs (config/transform/dist_moe.py:66-77). Both roles now use the same expert parameter layout, so the trainer/generator kernel mismatch from the earlier review is gone.
  • Qwen3.5 linear attention under FULL. TorchTitanCudagraphDispatcher (rl/generator/vllm/worker.py:27-55) keeps separate decode graph keys for GDN in FULL mode, so FULL here is not a regression from the 9B sibling's FULL_DECODE_ONLY.
  • Trainer scratch. Factor 4.0 at EP 4 matches the Qwen3-30B-A3B DAPO-Math recipe (dapo_math.py:487). The trainer keeps disable_accelerator_graphs=True, like that recipe.

Not verified: no recipe in the repo has run Qwen3.5-MoE with Dist-MoE (the GPU coverage uses the debug MoE model). The 4-GPU trainer's memory peak at 65,536-token microbatches has not been measured. A maintainer still needs to review.


16 GPUs: 8 trainer (FSDP=4, TP=2, EP=8) and 2 generators of 4 GPUs
(DP=2, TP=2, EP=4).
Dist-MoE routed experts in both roles, so it needs SM100+ GPUs (B200, GB300).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line says the recipe runs on B200, but the layout as written needs 288 GB GPUs. 140 GB of model state per trainer GPU leaves about 40 GB on a B200 (~180 GB). That 40 GB has to hold the activations of a 65,536-token microbatch, the Dist-MoE scratch at factor 4.0, and the unsharded bf16 layer. Your own reply says "B200 (180 GB) may need the 8-GPU trainer". So a B200 user who reads this line will likely OOM (unverified, not run).

SM100+ is only the floor that Dist-MoE sets. The recipe's real requirement is a 288 GB GPU. Suggest:

Suggested change
Dist-MoE routed experts in both roles, so it needs SM100+ GPUs (B200, GB300).
Dist-MoE routed experts in both roles, so it needs SM100+ GPUs; the 4-GPU trainer
below needs 288 GB GPUs (GB300, B300). On B200, use an 8-GPU trainer.

README.md:93-95 says the same thing ("needs SM100+ GPUs (B200, GB300)"), so it needs the same edit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Fixed in d18d127. The docstring now says:

  • Dist-MoE needs SM100+ GPUs.
  • The 4-GPU trainer needs 288 GB GPUs (GB300, B300).
  • A B200 (180 GB) would keep only about 40 GB per GPU for activations, so give the trainer 8 GPUs there.

README.md and the commit message say the same.

@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from b7782cb to d18d127 Compare November 5, 2026 21:40
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/3-finite-validation branch from 7024bf4 to 4e15338 Compare November 5, 2026 21:40
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Thanks. The B200 item is fixed in d18d127 (see the inline thread). For the Docker sizing paragraph, which covers both Terminal-Bench recipes: it stays, and the description now lists it as a separate doc change. The Summary (human-written) and the DAPO split are left for the author and maintainers.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 51s —— View job


Approve, but fill in the human-written summary before merging -- see the review. The B200 wording is fixed at d18d127.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the item below before merging. The B200 wording from the last review is fixed at d18d127. The only item left is the empty human-written summary.

What this PR does. It does main's TODO for the 35B-A3B Terminal-Bench recipe: DistMoeTransform() in both roles, and FULL generator CUDA graphs. It also moves the GPUs to a GB300 layout (a 4-GPU trainer and 16 one-GPU generators), switches GRPO to DAPO (0.2 / 0.28), and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    16 x 1 GPU, Dist-MoE (inference), FULL
hardware        >80 GB GPUs                 SM100+, 288 GB GPUs (B200: 8-GPU trainer)
loss            GRPO                        DAPO

Since the last review (d18d127)

  • B200 listed as supported -- resolved. The docstring (verifiers_terminal_bench.py:291-293) and README.md:93-96 now say SM100+, 288 GB GPUs for the 4-GPU trainer, and an 8-GPU trainer on B200.
  • Docker sizing paragraph -- the description now lists it as a separate doc change. Its numbers check out: 1,280 x 2 GB = 2.56 TB and 1,536 x 2 GB = 3.07 TB.
  • No recipe, test, or doc still uses the old recipe name.

Must fix

  1. PR description -- "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • torchtitan_recipes/rl/verifiers_terminal_bench.py:291-293 -- "give the trainer 8 GPUs there" doesn't say which field to change. data_parallel_shard_degree=4 alone is enough: EP 4 still divides FSDP x TP = 8, so the scratch factor 4.0 stays. Naming the field saves a B200 user some guesswork.
  • GRPO -> DAPO in the same PR -- the author keeps it on purpose, and the title names it. Whether to split it is a maintainer's call.
Details
  • Generator EP. InferenceParallelismConfig.expert_parallel_degree defaults to 1 (rl/generator/parallelism.py:24). With DP 1 x TP 1, the check in generator.py:180-189 (EP is 1 or DP x TP) passes.
  • Transforms in both roles. This follows the same pattern as dapo_math.py:533 and alphabet_sort.py:1110. DistMoeTransform keeps the w13/w2 FQNs, so weight sync maps between the same layouts.

Not verified: no Qwen3.5-MoE recipe has run with Dist-MoE, and the 4-GPU trainer's memory peak at 65,536-token microbatches has not been measured. A maintainer still needs to review.

@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from d18d127 to 15c5226 Compare November 5, 2026 21:46
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Applied the B200 suggestion in 15c5226. The docstring and README now name the field: set the trainer's data_parallel_shard_degree=4 (8 GPUs). EP 4 still divides FSDP x TP = 8, so EP and the scratch factor stay. The DAPO split and the Summary (human-written) are left for maintainers and the author.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 5s —— View job


Approve, but fill in the human-written summary before merging -- see the review. The B200 note now names the field to change. All that's left is the summary plus two small optional fixes (a blank line in the docstring, the PR title).

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the items below before merging. The only change since the last review is that the B200 note now names the field to change. The empty human-written summary is still the one blocking item.

What this PR does. It does main's TODO for the 35B-A3B Terminal-Bench recipe: DistMoeTransform() in both roles and FULL generator CUDA graphs. It also moves the GPUs to a GB300 layout (a 4-GPU trainer and 16 one-GPU generators), switches GRPO to DAPO (0.2 / 0.28), and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR (15c5226)
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
                                            B200: data_parallel_shard_degree=4 (8 GPU)
generator       2 x (DP2 TP2 EP4), eager    16 x 1 GPU, Dist-MoE (inference), FULL
loss            GRPO                        DAPO

Since the last review (d18d127 -> 15c5226, squashed)

  • Name the B200 field -- resolved. The docstring (verifiers_terminal_bench.py:291-294) and the README both say data_parallel_shard_degree=4. EP 4 still divides FSDP x TP = 8, so the scratch factor 4.0 still holds.
  • Nothing else in the code changed. Both roles are transformed, the generator passes DistMoeRuntime.Config(inference=True), and the trainer uses factor 4.0, as in dapo_math.py:487-533.

Must fix

  1. PR description -- "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • torchtitan_recipes/rl/verifiers_terminal_bench.py:294-295 -- add a blank line between the docstring paragraphs (see inline).
  • PR title -- "Dist-MoE trainer, FULL CUDA graph generators" is out of date now that Dist-MoE runs in both roles. Something like "Dist-MoE in both roles, FULL CUDA graph generators, DAPO loss" would fit.
  • GRPO -> DAPO in the same PR -- the author keeps it on purpose and the title names it. Whether to split it is up to a maintainer.

Not verified: no Qwen3.5-MoE recipe has run with Dist-MoE, and nobody has measured the 4-GPU trainer's memory peak at 65,536-token microbatches. A maintainer still needs to review.

Comment on lines +294 to +295
and the scratch factor unchanged).
20 GPUs on GB300 (4 GPUs per host): 5 GPU hosts plus a controller.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no blank line between the hardware paragraph and the GPU-layout paragraph, so the layout line reads as part of the B200 sentence. The other paragraphs in this docstring are separated by blank lines.

Suggested change
and the scratch factor unchanged).
20 GPUs on GB300 (4 GPUs per host): 5 GPU hosts plus a controller.
and the scratch factor unchanged).
20 GPUs on GB300 (4 GPUs per host): 5 GPU hosts plus a controller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Applied in b032e95. The only change is the blank line.

@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 15c5226 to b032e95 Compare November 5, 2026 21:52
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: The blank line is in b032e95. That commit changes only one blank line from 15c5226, which you approved. The PR title is left for the author to update ("Dist-MoE in both roles"). Title edits are his call. The DAPO split and the Summary (human-written) are left for maintainers and the author.

@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from f0145d1 to 2c15367 Compare November 11, 2026 06:29
@felipemello1
felipemello1 changed the base branch from main to felipemello1/tb-oss/1-taskset-workdir November 11, 2026 06:30
@felipemello1
felipemello1 added this pull request to stack #6028 November 11, 2026 06:30
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/1-taskset-workdir branch from c62a9d2 to 10c8b9a Compare November 11, 2026 08:40
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 2c15367 to 11c01d1 Compare November 11, 2026 08:40
@felipemello1
felipemello1 removed this pull request from stack #6028 November 11, 2026 20:19
@felipemello1
felipemello1 changed the base branch from felipemello1/tb-oss/1-taskset-workdir to main November 11, 2026 20:20
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 11c01d1 to 6027b7f Compare November 11, 2026 20:20
@felipemello1
felipemello1 changed the base branch from main to felipemello1/tb-oss/1-taskset-workdir November 11, 2026 20:21
@felipemello1
felipemello1 added this pull request to stack #6034 November 11, 2026 20:21
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/1-taskset-workdir branch from 0e8d822 to f0d1adc Compare November 11, 2026 22:50
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 6027b7f to 7dca250 Compare November 11, 2026 22:50
@felipemello1
felipemello1 removed this pull request from stack #6034 November 12, 2026 00:33
@felipemello1
felipemello1 changed the base branch from felipemello1/tb-oss/1-taskset-workdir to main November 12, 2026 00:34
@felipemello1
felipemello1 force-pushed the felipemello1/tb-oss/4-dist-moe-recipe branch from 7dca250 to 899817a Compare November 12, 2026 00:35
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push puts the stack on a draft copy of the look-aside router PR, rebased onto main (row 0, DO NOT REVIEW; it closes when the original lands). The generate answer now comes from the generator, so the docs and bodies say so; each body says not to merge while row 0 is under the stack.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 3s —— View job


Approve, but fill in the human-written summary before merging -- see the review. The rebase onto row 0 at 899817a leaves this PR's diff and config values the same as at 024f4f9.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the item below before merging. At 899817a the rebase onto the look-aside router copy (row 0) leaves this PR's diff the same as the one approved at 024f4f9. The only open item is still the empty human-written summary.

What this PR does. It resolves main's TODO for the 35B-A3B Terminal-Bench recipe: DistMoeTransform() in both roles, and FULL CUDA graphs in the generators. It also moves to a GB300 layout: a 4-GPU trainer plus 4 generators of DP 4 x EP 4, 20 GPUs in total. It switches GRPO to DAPO (0.2 / 0.28) and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR (899817a)
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    4 x (DP4 TP1 EP4), Dist-MoE (inference, scratch 4.0), FULL
loss            GRPO                        DAPO

Since the last review (024f4f9 -> 899817a, rebased onto row 0)

  • No config value changed. That covers the parallelism degrees (2/2/4 and 4/1/4), num_generators=4, both DistMoeRuntime.Configs, mode="FULL", the transforms in both roles and the DAPO clips.
  • The rebase doesn't break anything this recipe uses:
    • InterGeneratorRouter, StickySessionRoutingStrategy(fallback_strategy=LeastLoadedRoutingStrategy) and Generator.Config.dist_moe_runtime still exist (rl/routing/strategies.py:134-144, rl/generator/generator.py:123).
    • The README line this PR touches ("router picks one") still matches look-aside routing: the router chooses the generator and the caller then generates.
  • The repo has no other references to the old recipe name.

Must fix

  1. PR description -- "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • GRPO -> DAPO in the same PR: the author keeps it on purpose. Whether to split it out is a maintainer's call.
  • Per the stack note, don't merge while row 0 is under this PR.

Not verified: the recipe has not run end to end, so the trainer's memory peak at 65,536 tokens and the weight sync into the DP 4 x EP 4 generators are still unchecked. A maintainer still needs to review.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. The stack is reordered: Verifiers groups in workers, then Verifiers 0.4.1, then worker placement come first (the stack table shows the new rows). It is also rebuilt with three reviewed passes: a code-style pass over every changed file, the rewritten placement docs (the VerifiersRollouter docstring and the two Verifiers READMEs; the old SVG is deleted), and the 3 newest main commits. No behavior change from the passes.

@claude

claude Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 2m 3s —— View job


Approve, but fill in the human-written summary before merging -- see the review. At aeb8e95 the recipe config is unchanged, and the new Slurm placement text matches the launcher. There's one small README fix: "(below)" at README:126 points nowhere.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the item below before merging. At aeb8e95 the stack is reordered and rebuilt, and the recipe's config values match the ones approved at 899817a. The only new text is about Slurm placement, and it matches what the launcher does. The only open item is still the empty human-written summary.

What this PR does. It resolves main's TODO for the 35B-A3B Terminal-Bench recipe: DistMoeTransform() in both roles, and FULL CUDA graphs in the generators. It also moves to a GB300 layout: a 4-GPU trainer plus 4 generators of DP 4 x EP 4, 20 GPUs in total. It switches GRPO to DAPO (0.2 / 0.28) and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR (aeb8e95)
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    4 x (DP4 TP1 EP4), Dist-MoE (inference, scratch 4.0), FULL
loss            GRPO                        DAPO
Slurm hosts     --                          4-GPU nodes: 5 hosts; 8-GPU nodes: 3 hosts, 4 GPUs idle

Since the last review (899817a -> aeb8e95, stack rebuilt)

  • No config value changed:
    • parallelism 2/2/4 and 4/1/4
    • num_generators=4
    • both DistMoeRuntime.Configs
    • mode="FULL"
    • the transforms in both roles
    • the DAPO clips
  • New placement text, checked against the code:
    • Docstring "SlurmLauncher runs the controller on the trainer's host": matches launcher/slurm.py:55-57 (the controller runs on the first node) and provisioning.py:303-304.
    • README:117-119: MonarchLauncher._layout (launcher/base.py:164-214) gives a 4-GPU trainer its own mesh on 4-GPU nodes, so the total is 5 hosts. On 8-GPU nodes it packs trainer+gen0, gen1+gen2, gen3, so the total is 3 hosts with 4 GPUs idle. "Every CPU process on host 0" matches the recipe's workers_on_controller_host=True (verifiers_terminal_bench.py:153).
    • rl_grpo_qwen3_0_6b_flex_slurm and MonarchControllerWithLauncher.Config.from_controller_config exist (alphabet_sort.py:273, launcher/base.py:264).
  • The repo has no remaining references to the old recipe name.

Must fix

  1. PR description: "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • torchtitan/rl/examples/verifiers/terminal_bench/README.md:126: "(below)" points to no section. The runtime note is the "Toy sandbox" block at the top (see inline).
  • GRPO -> DAPO in the same PR: the author keeps it on purpose. Whether to split it out is a maintainer's call.
  • Per the stack note, don't merge while row 0 is under this PR.

Not verified: the recipe has not run end to end, so the trainer's memory peak at 65,536 tokens and the weight sync into the DP 4 x EP 4 generators are still unchecked. A maintainer still needs to review.

Comment on lines +125 to +126
keeps up to 1,280, plus the same 89: 1,369 CPUs and 2,738 GB. For runs this size, set a remote
sandbox as the `runtime` (below).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"(below)" doesn't point to anything. No later section of this README covers the Verifiers runtime. The only text about it is the "Toy sandbox" note at the top (lines 9-13). Point to that note instead:

Suggested change
keeps up to 1,280, plus the same 89: 1,369 CPUs and 2,738 GB. For runs this size, set a remote
sandbox as the `runtime` (below).
keeps up to 1,280, plus the same 89: 1,369 CPUs and 2,738 GB. For runs this size, set a remote
sandbox as the Verifiers `runtime` (see "Toy sandbox" above).

@felipemello1

felipemello1 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. The stack is rebased onto main (the look-aside router PR merged), and the PRs below this one are updated. The Terminal-Bench diagram below is redrawn as lanes that name no loss, so the first commit here no longer renames trainer (GRPO) in it.

@claude

claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 55s —— View job


Approve, but fill in the human-written summary before merging -- see the review. At 374dd2e the diff is the same as at aeb8e95, and the README "(below)" pointer at line 114 still points nowhere.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the items below before merging. At 374dd2e the stack is rebased onto main. This PR's diff is the same as at aeb8e95, and every symbol it uses still exists. Two items are still open: the empty human-written summary, and the README "(below)" pointer.

What this PR does. It resolves main's TODO for the 35B-A3B Terminal-Bench recipe by adding DistMoeTransform() in both roles and FULL CUDA graphs in the generators. It also moves to a GB300 layout: a 4-GPU trainer plus 4 generators of DP 4 x EP 4, 20 GPUs in total. It switches the loss from GRPO to DAPO (0.2 / 0.28) and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR (374dd2e)
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    4 x (DP4 TP1 EP4), Dist-MoE (inference, scratch 4.0), FULL
loss            GRPO                        DAPO

Since the last review (aeb8e95 -> 374dd2e, rebased onto main)

  • No config value changed:
    • parallelism 2/2/4 and 4/1/4
    • num_generators=4
    • both DistMoeRuntime.Configs
    • mode="FULL"
    • the transforms in both roles
    • the DAPO clips
  • Everything the recipe and README use is still on the new base:
    • DistMoeTransform (config/transform/dist_moe.py:90)
    • Generator.Config.dist_moe_runtime (rl/generator/generator.py:123)
    • DAPOLoss.Config.ratio_clip_low/ratio_clip_high (losses/dapo.py:58-63)
    • the SM100 check (dist_moe/runtime.py:302)
    • MonarchControllerWithLauncher.Config.from_controller_config (launcher/base.py:264)
    • rl_grpo_qwen3_0_6b_flex_slurm (alphabet_sort.py:273)
  • The README text inherited from the PRs below doesn't conflict with this PR's lines. The "Toy sandbox" note (README:15-18, workers_on_controller_host=True) matches "host 0 runs ... every CPU process" at README:105.
  • The repo has no remaining references to the old recipe name.

Must fix

  1. PR description: "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • torchtitan/rl/examples/verifiers/terminal_bench/README.md:114: still open from the last review. "(below)" points to no section, and no later section covers the Verifiers runtime. Point to the "Toy sandbox" note above instead (see the earlier inline suggestion).
  • GRPO -> DAPO in the same PR: the author keeps it on purpose. Whether to split it out is a maintainer's call.

Not verified: the recipe has not run end to end, so the trainer's memory peak at 65,536 tokens and the weight sync into the DP 4 x EP 4 generators are still unchecked. A maintainer still needs to review.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review

@claude

claude Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 46s —— View job


Approve, but fill in the human-written summary before merging -- see the review. At 875acdc the README "(below)" pointer is fixed, and no config values changed.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: Approve -- please address the item below before merging. At 875acdc the README "(below)" pointer is fixed and the config values are the same as at 374dd2e. The only open item is still the empty human-written summary.

What this PR does. It resolves main's TODO for the 35B-A3B Terminal-Bench recipe by adding DistMoeTransform() in both roles and FULL CUDA graphs in the generators. It also moves to a GB300 layout: a 4-GPU trainer plus 4 generators of DP 4 x EP 4, 20 GPUs in total. It switches the loss from GRPO to DAPO (0.2 / 0.28) and renames the recipe to rl_dapo_qwen35_35b_a3b_terminal_bench_dist_moe.

Example.

                main                        this PR (875acdc)
trainer         8 GPU, FSDP4 TP2 EP8        4 GPU, FSDP2 TP2 EP4, Dist-MoE (scratch 4.0)
generator       2 x (DP2 TP2 EP4), eager    4 x (DP4 TP1 EP4), Dist-MoE (inference, scratch 4.0), FULL
loss            GRPO                        DAPO

Since the last review (374dd2e -> 875acdc)

  • README "(below)" pointer: resolved. README.md:76 now links to "Sandboxes" in the Verifiers README (../README.md#sandboxes). That heading exists at torchtitan/rl/examples/verifiers/README.md:178 and covers remote runtimes.
  • Docstring: "5 hosts. SlurmLauncher runs the controller on the trainer's host" (verifiers_terminal_bench.py:126-127). This matches launcher/slurm.py:55-57, which runs the controller on the first node.
  • No config value changed. That covers parallelism 2/2/4 and 4/1/4, num_generators=4, both DistMoeRuntime.Configs, mode="FULL", the transforms in both roles and the DAPO clips.
  • The repo has no remaining references to the old recipe name. DistMoeTransform, from_controller_config, rl_grpo_qwen3_0_6b_flex_slurm and the SM100 check (dist_moe/runtime.py:302) are all still present.

Must fix

  1. PR description: "Summary (human-written)" is still empty. The author has to fill it in before merge.

Should consider

  • GRPO -> DAPO in the same PR: the author keeps it on purpose. Whether to split it out is a maintainer's call.

Not verified: the recipe has not run end to end, so the trainer's memory peak at 65,536 tokens and the weight sync into the DP 4 x EP 4 generators are still unchecked. A maintainer still needs to review.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: answers to the points in the review that have no inline thread.

the review bot (review): GRPO -> DAPO in the same PR: the author keeps it on purpose. Whether to split it out is a maintainer's call.

Kept in one PR on purpose. The loss change is a few lines, the recipe's name carries it (rl_dapo_...), and the recipe hasn't run with either loss yet, so a split would rename the recipe twice. Happy to split it if a maintainer prefers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant