Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
66100f7
feat(ray): hand earlier trainer groups' outputs to later groups as ex…
zhihengy Oct 19, 2026
459222d
fix(fsdp): box the train output so the driver's ray.get only waits
zhihengy Nov 9, 2026
2dc3538
fix(ray): hand later trainer groups the output boxes, not the raw refs
zhihengy Nov 10, 2026
a52f72f
feat(fsdp): add a train-input hook that preprocesses train pairs befo…
zhihengy Oct 24, 2026
77dedd4
refactor(fsdp): rename the train-input hook to custom_train_input_pos…
zhihengy Nov 9, 2026
4868030
feat(rollout): stop the rollout at a random step for DMD2 backward si…
zhihengy Oct 19, 2026
6f9884b
feat(dmd2): train a fake-score critic group from the teacher and scor…
zhihengy Oct 19, 2026
f8cb580
feat(dmd2): train the student with the distribution matching gradient…
zhihengy Oct 19, 2026
0c30c25
fix(dmd2): follow the train-input hook rename in the DMD2 defaults
zhihengy Nov 10, 2026
55a681e
perf(ray): sleep each trainer group right after its train
zhihengy Oct 26, 2026
c5644b6
feat(dmd2): add the MiniMax H3 4-step DMD2 recipe with the media and …
zhihengy Oct 26, 2026
7542deb
feat(dmd2): skip the engine's VAE decode of training rollouts when no…
zhihengy Oct 26, 2026
37695a1
build: declare imageio-ffmpeg, which the eval media muxing imports
zhihengy Nov 10, 2026
8328ef8
docs(h3): say the DMD2 recipe downloads the VidProM prompt list from …
zhihengy Nov 11, 2026
0d9f731
docs(dmd2): count the VidProM prompts after dedup
zhihengy Nov 11, 2026
ce6bda5
fix(dmd2): load the FastH3 reference by its Hub id on every node
Rockdu Nov 11, 2026
4ed4e78
refactor(args): drop the teacher consumer check
Rockdu Nov 10, 2026
b745e50
refactor(fsdp): select loss hooks from a (loss_type, role) table
Rockdu Nov 10, 2026
972e01e
fix(args): reject --custom-*-path outside --loss-type custom_loss
Rockdu Nov 10, 2026
711dc3a
fix(args): reject --diffusion-recompute-old-log-prob under dmd2
Rockdu Nov 10, 2026
0861d2d
refactor(fsdp): pass the loop counters to the hooks as arguments
Rockdu Nov 10, 2026
f7c5597
refactor(fsdp): hand the train-output list to the hooks as an argument
Rockdu Nov 10, 2026
60acc02
refactor(fsdp): freeze DiffusionLossContext
Rockdu Nov 10, 2026
827b527
refactor(fsdp): run the DMD2 teacher forward in the actor, requested …
zhihengy Nov 11, 2026
44eb2b6
fix(fsdp): run the teacher forward without the student's true_cfg_scale
zhihengy Nov 11, 2026
b9e206a
refactor(dmd2): pull the teacher request out of prepare_critic_batch
Rockdu Nov 11, 2026
7dbfaf1
test(e2e): run the H3 DMD2 recipe as a 2-GPU proxy in CI
zhihengy Nov 10, 2026
daff1b5
test(e2e): record the H3 DMD2 standard on CI and name the test as a p…
zhihengy Nov 10, 2026
5c9da32
test(e2e): re-record the H3 DMD2 standard on sglang-miles
zhihengy Nov 11, 2026
a38350d
Merge main into dmd2/06b-h3-dmd2-e2e after the PRs below it landed
Rockdu Nov 11, 2026
f4cc1d8
Merge main into dmd2/06b-h3-dmd2-e2e for the flow-grpo test fix (#380)
zhihengy Nov 12, 2026
1b40dca
Merge main into dmd2/06b-h3-dmd2-e2e before re-recording the standard
zhihengy Nov 23, 2026
439990e
test(e2e): run the H3 DMD2 proxy with LoRA adapters instead of CPU of…
zhihengy Nov 23, 2026
bc22ebe
test(e2e): re-record the H3 DMD2 standard for the LoRA proxy
zhihengy Nov 23, 2026
196f769
docs(dmd2): state the LoRA proxy's GPU memory as the trainer reports it
zhihengy Nov 23, 2026
5b99cf4
docs(h3): drop the single-node smoke section from the model page
Rockdu Nov 25, 2026
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
4 changes: 2 additions & 2 deletions miles/utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2149,9 +2149,9 @@ def validate_dmd2_args(args) -> None:
"--loss-type dmd2 samples the student unguided; set --diffusion-guidance-scale 1.0 "
"and drop --diffusion-true-cfg-scale"
)
if args.use_lora or args.teacher_lora_adapter_paths is not None:
if args.teacher_lora_adapter_paths is not None:
raise ValueError(
"--loss-type dmd2 trains the full student and critic; drop --use-lora and --teacher-lora-adapter-path"
"--loss-type dmd2 takes its teacher from --teacher-load alone; drop --teacher-lora-adapter-path"
)
if args.ref_mode != "none":
raise ValueError("--loss-type dmd2 uses no reference model; drop --ref-mode and --diffusion-kl-beta")
Expand Down
64 changes: 49 additions & 15 deletions scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@

Usage (after the multi-node bring-up, on the head node):
MILES_SCRIPT_EXTERNAL_RAY=1 python3 scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py

Single node, for smoke runs and the e2e CI: the script starts its own ray cluster. Two GPUs hold the
rollout engine (tp2) and FSDP DP=2 over the student, the critic and the teacher in one of two ways:
--lora the student and the critic train LoRA adapters (rank 64, lr 1e-4) over frozen
bf16 bases, with no CPU offload; what the e2e CI runs, not a tuned recipe;
--fsdp-cpu-offload the full-parameter recipe with its parameters, gradients and optimizer states
in host memory (about 1.6 TB with the engine). The master stays fp32: H3 keeps
proj_in / time_embedder / proj_out in fp32, and FSDP2 wants one original dtype
across a group's trainable parameters.
python3 scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py --num-nodes 1 --num-gpus-per-node 2 \
--rollout-batch-size 4 --critic-steps-per-rollout 2 --num-rollout 2 --eval-interval 0 \
--save-interval 0 --lora
"""

import hashlib
Expand Down Expand Up @@ -80,10 +92,20 @@
@dataclass
class ScriptArgs(U.ExecuteTrainConfig):
num_rollout: int = 200
# 5 critic steps x 64 samples; the student steps on the last 64.
# critic_steps_per_rollout critic steps x 64 samples; the student steps on the last 64.
rollout_batch_size: int = 320
critic_steps_per_rollout: int = 5
# 0 disables eval / checkpoints.
eval_interval: int = 5
save_interval: int = 50
# Colocated train + rollout GPUs; one node starts its own ray cluster.
num_nodes: int = 2
num_gpus_per_node: int = 8
# Below 16 GPUs the two 31B optimizers do not fit: keep params, grads and optimizer states in
# host memory (the optimizer steps on the CPU).
fsdp_cpu_offload: bool = False
# Or train LoRA adapters of the student and the critic over frozen bf16 bases.
lora: bool = False
duration_seconds: float = 5.0
data_dir: str = "/root/datasets"
# "teacher" or "fasth3": render the eval prompts with that model instead of training.
Expand Down Expand Up @@ -169,6 +191,8 @@ def execute(args: ScriptArgs, prompt_dir: str) -> None:
"--n-samples-per-eval-prompt 1 "
f"--save-eval-media-dir {run_dir}/eval_media "
)
if not args.reference and args.eval_interval <= 0:
eval_args = ""

# Every eval video; training rollouts carry no media, since --rm-type none skips their decode.
wandb_args = U.get_default_wandb_args(
Expand All @@ -189,13 +213,14 @@ def execute(args: ScriptArgs, prompt_dir: str) -> None:
"--update-weight-buffer-size 4294967296 "
)

num_gpus = args.num_nodes * args.num_gpus_per_node
topology_args = (
"--actor-num-nodes 2 "
"--actor-num-gpus-per-node 8 "
"--num-gpus-per-node 8 "
"--rollout-num-gpus 16 "
f"--actor-num-nodes {args.num_nodes} "
f"--actor-num-gpus-per-node {args.num_gpus_per_node} "
f"--num-gpus-per-node {args.num_gpus_per_node} "
f"--rollout-num-gpus {num_gpus} "
"--rollout-num-gpus-per-engine 2 "
"--rollout-parser-num-workers 16 "
f"--rollout-parser-num-workers {num_gpus} "
"--colocate "
# H3 denoising blocks the engine's event loop for tens of seconds per sample.
"--rollout-health-check-interval 60 "
Expand All @@ -219,37 +244,46 @@ def execute(args: ScriptArgs, prompt_dir: str) -> None:
f"--diffusion-eval-num-steps {eval_steps} "
)
else:
save_args = f"--save {run_dir}/ckpt --save-interval {args.save_interval} " if args.save_interval > 0 else ""
offload_args = "--fsdp-cpu-offload --teacher-cpu-offload " if args.fsdp_cpu_offload else ""
if args.lora:
# The adapters leave H3's fp32-pinned modules frozen, so the master can be bf16.
params_args = (
"--use-lora --lora-ipc-weight-sync --lora-rank 64 --lora-alpha 128 "
"--sglang-lora-merge-mode merge "
"--lr 1e-4 --critic-lr 1e-4 "
"--fsdp-master-dtype bf16 --fsdp-reduce-dtype bf16 "
)
else:
params_args = "--lr 2e-6 --critic-lr 2e-6 --fsdp-master-dtype fp32 --fsdp-reduce-dtype fp32 "
mode_args = (
f"--hf-checkpoint {MODEL} "
f"--save {run_dir}/ckpt "
f"--save-interval {args.save_interval} "
f"{save_args}"
f"--num-rollout {args.num_rollout} "
f"--eval-interval {args.eval_interval} "
f"{f'--eval-interval {args.eval_interval} ' if args.eval_interval > 0 else ''}"
"--loss-type dmd2 "
f"--teacher-load {MODEL} "
"--dmd2-teacher-guidance-scale 1.0 "
"--dmd2-critic-steps-per-rollout 5 "
f"--dmd2-critic-steps-per-rollout {args.critic_steps_per_rollout} "
"--dmd2-score-sigma-range 0.001 0.999 "
"--dmd2-critic-loss-space x0 "
"--fsdp-flow-shift visual=5.0 "
"--diffusion-step-strategy-path miles.rollout.step_strategy_hub.stop_at_random_step "
"--diffusion-sde-type ode "
"--lr 2e-6 "
"--critic-lr 2e-6 "
f"{params_args}"
"--weight-decay 0.01 "
"--train-backend fsdp "
"--fsdp-master-dtype fp32 "
"--fsdp-reduce-dtype fp32 "
"--diffusion-forward-dtype bf16 "
"--gradient-checkpointing "
f"{offload_args}"
)

U.execute_train(
train_args=(
f"{mode_args} {rollout_args} {diffusion_args} {eval_args} {wandb_args} {sglang_args} "
f"{topology_args} {args.extra_args}"
),
num_gpus_per_node=8,
num_gpus_per_node=args.num_gpus_per_node,
config=args,
extra_env_vars={"PYTORCH_CUDA_ALLOC_CONF": "expandable_segments:True"},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"meta": {
"commit": "439990e5e86b6d6bac94a9ac2d0e154e690ff26e",
"source": "test_h3_t2va_dmd2_16xGPU_single_node_2xGPU_proxy.py"
},
"metrics": {
"train/critic-grad_norm": [
[
1.0,
0.06304825842380524
],
[
2.0,
1.4389699697494507
],
[
3.0,
0.04073259234428406
],
[
4.0,
0.30865904688835144
]
],
"train/critic-loss": [
[
1.0,
0.10361059755086899
],
[
2.0,
0.3423595726490021
],
[
3.0,
0.04162454791367054
],
[
4.0,
0.8172207176685333
]
],
"train/dmd2_grad_abs_mean": [
[
1.0,
0.08365654572844505
],
[
2.0,
0.027618293650448322
]
],
"train/dmd2_score_gap_abs_mean": [
[
1.0,
0.03811744134873152
],
[
2.0,
0.021260653622448444
]
],
"train/dmd2_teacher_dist_abs_mean": [
[
1.0,
0.39523235708475113
],
[
2.0,
0.83000248670578
]
],
"train/dmd2_x0_mean": [
[
1.0,
0.056482404470443726
],
[
2.0,
-0.15415865182876587
]
],
"train/dmd2_x0_std": [
[
1.0,
1.0739970207214355
],
[
2.0,
2.4941294193267822
]
],
"train/grad_norm": [
[
1.0,
0.009701848961412907
],
[
2.0,
0.04545477405190468
]
],
"train/x0_mean_abs_diff": [
[
1.0,
0.0606351857462888
],
[
2.0,
0.33430661600102823
]
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""E2E: MiniMax H3 t2va 4-step DMD2 (data-free), 2-GPU colocate (FSDP DP=2 over the student,
the critic and the teacher, one tp2 sglang rollout engine, no reward), 2 rollouts of 4
prompts: 2 critic steps of 2 samples, then 1 student step on the last 2 — runs the recipe
script itself with its single-node knobs and checks its metric series against the registered
standard (tests/ci/fixtures/e2e_standards/). Two GPUs cannot hold the full-parameter recipe,
and its CPU-offloaded form (--fsdp-cpu-offload, about 1.6 TB of host memory) does not fit the
shared CI node next to another e2e, so the student and the critic train LoRA adapters over
frozen bf16 bases here (--lora, about 110 GB per GPU at the critic step). Runs with
--deterministic-mode, so every metric is compared strictly, bit for bit. The only e2e
exercising the multi-trainer-group driver, the critic -> actor hand-off and the rollout
stopped at a random step."""

from tests.ci.e2e_metrics_registry import register_e2e_ci

register_e2e_ci(
est_time=1200,
suite="stage-c-3-gpu-h200",
labels=["e2e"],
script="scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py",
args=[
"--num-nodes",
"1",
"--num-gpus-per-node",
"2",
"--num-rollout",
"2",
"--rollout-batch-size",
"4",
"--critic-steps-per-rollout",
"2",
"--eval-interval",
"0",
"--save-interval",
"0",
"--duration-seconds",
"4",
"--lora",
"--extra-args",
"--deterministic-mode",
],
metrics=[
"train/critic-loss",
"train/critic-grad_norm",
"train/grad_norm",
"train/dmd2_grad_abs_mean",
"train/dmd2_score_gap_abs_mean",
"train/dmd2_teacher_dist_abs_mean",
"train/dmd2_x0_mean",
"train/dmd2_x0_std",
"train/x0_mean_abs_diff",
],
)
3 changes: 1 addition & 2 deletions tests/fast/utils/test_dmd2_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ def test_valid_dmd2_args_pass_unchanged():
({"dmd2_score_sigma_range": [0.5, 1.5]}, "0 <= MIN < MAX <= 1"),
({"diffusion_guidance_scale": 4.5}, "samples the student unguided"),
({"diffusion_true_cfg_scale": 4.5}, "samples the student unguided"),
({"use_lora": True}, "drop --use-lora"),
({"teacher_lora_adapter_paths": ["teacher-adapter"]}, "drop --use-lora and --teacher-lora-adapter-path"),
({"teacher_lora_adapter_paths": ["teacher-adapter"]}, "drop --teacher-lora-adapter-path"),
({"ref_mode": "ref"}, "uses no reference model"),
({"diffusion_recompute_old_log_prob": True}, "not DMD2"),
({"num_steps_per_rollout": 2}, "one actor step per rollout"),
Expand Down
Loading