Skip to content

[DMD2 e2e] test(e2e): 2-GPU H3 DMD2 proxy with a CI-recorded standard - #366

Merged
Rockdu merged 36 commits into
mainfrom
dmd2/06b-h3-dmd2-e2e
Nov 25, 2026
Merged

Rockdu merged 36 commits into
mainfrom
dmd2/06b-h3-dmd2-e2e

Conversation

@zhihengy

@zhihengy zhihengy commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Update 2026-11-23: the CI proxy trains LoRA adapters

The full-parameter 2-GPU proxy kept about 1.6 TB in host memory, and Ray's memory monitor killed it whenever another e2e shared the CI node: record run 45140738708 ran next to #418's stage-c-5-gpu-h200 and died at 1931.92 / 2013.20 GB, with 1562 GB in this job's own processes. As suggested in review, the proxy now trains LoRA adapters of the student and the critic over frozen bf16 bases. The 16-GPU recipe stays full-parameter.

  • scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py --lora: --use-lora --lora-ipc-weight-sync (rank 64, alpha 128, --sglang-lora-merge-mode merge), lr 1e-4 for both groups, bf16 master. --fsdp-cpu-offload still runs the full-parameter recipe on fewer GPUs.
  • --loss-type dmd2 accepts --use-lora; --teacher-lora-adapter-path is still rejected.
  • The e2e passes --lora instead of --fsdp-cpu-offload; est_time 3300 -> 1200.
  • main e6129d0 is merged in (1b40dca).
LoRA proxy full-parameter proxy
Wall time 12 min locally, 14 min for the record job on CI 50 min
GPU, each card (140 GB) 110 GB used and 93 GB allocated peak at the critic step, 74 / 62 GB at the student step 48 GB used, 33 GB allocated peak
Host memory of the job's processes about 530 GB 1562 GB

Standard: re-recorded by https://github.com/radixark/miles_diffusion/actions/runs/45285320503 on the 3gpu runner at 439990e. Two local runs (2 x H200, an environment built from the CI recipe) and the CI record agree on all 22 metric points bit for bit. The step-1 values that depend only on the initial models (critic loss, teacher distance, x0 mean and std) equal the full-parameter standard's, as a fresh LoRA leaves the base unchanged.

Coverage: the proxy no longer exercises the full-weight sync, the fp32 master or the CPU-offloaded optimizers. It now exercises the two groups' sleep / wake hand-off, which the CPU-offloaded form skipped.

The sections below describe the earlier full-parameter form of the proxy.


On main: #372 and the DMD2 stack below it landed on 2026-11-11 and main is merged in (a38350d, f4cc1d8), so the diff is the two e2e commits plus the standard. The H3 DMD2 recipe gets the knobs a CI proxy needs, and a 2-GPU e2e runs it nightly against a recorded standard.

What

  • scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py: --num-nodes / --num-gpus-per-node (one node starts its own ray cluster, as the other recipes do), --critic-steps-per-rollout, --eval-interval 0 and --save-interval 0 to run without eval or checkpoints (0 used to reach should_run_periodic_action's modulo), --fsdp-cpu-offload (also offloads the teacher). The 16-GPU defaults are unchanged.
  • tests/e2e/short/test_h3_t2va_dmd2_16xGPU_single_node_2xGPU_proxy.py in stage-c-3-gpu-h200, label e2e: 2 rollouts of 4 prompts (4 s, 16:9), 2 critic steps of 2 samples and 1 student step on the last 2, --deterministic-mode. Checks train/critic-loss, train/critic-grad_norm, train/grad_norm and the DMD2 metrics (dmd2_grad_abs_mean, dmd2_score_gap_abs_mean, dmd2_teacher_dist_abs_mean, dmd2_x0_mean, dmd2_x0_std, x0_mean_abs_diff) bit for bit.
  • docs/models/h3/h3.md: the single-node form and why it needs CPU offload.

Stack fixes this run surfaced (on the branches below, not in this PR's diff)

Why this shape

  • H3 is ~31B parameters and --loss-type dmd2 trains the student and the critic in full, so student + critic + teacher only fit 2 GPUs with --fsdp-cpu-offload: parameters, gradients and optimizer states live in host memory (about 1.1 TB) and the optimizer steps on the CPU.
  • The master stays fp32. H3 keeps proj_in / time_embedder / proj_out in fp32 (_keep_in_fp32_modules), and FSDP2 wants one original dtype across a group's trainable parameters; a bf16 master trips FSDP expects uniform original parameter dtype for full-parameter training (the H3 SFT e2e gets away with bf16 because LoRA freezes those modules).
  • 2 GPUs rather than 4: with one sample per rank per step the per-rank work is the same, the host memory is the same, and the 3gpu suite has the shorter queue.
  • The engine needs the stop step (rollout_stop_step_index, [Feat] diffusion: [sglang-miles] Stop a rollout at a requested step inside the rollout controller sgl-project/sglang#49440) and the skipped decode (rollout_return_generated_output=False, [Feat] diffusion: [sglang-miles] Let a rollout request skip the VAE decode and return only its trajectory sgl-project/sglang#49143); both merged into sglang-miles on 2026-11-11, so CI runs on the default engine with no ci-sglang-* override. The e2e asks for no generated output, so it needs nothing else.

Local run (2 x H200, this node)

The CI arg set, in the e2e tree (torch 2.13 with the ad-hoc param-dtype patch port, sglang dmd2/h3-dmd2-e2e), on an otherwise idle pair of H200s. It passes end to end in 50 min; every registered metric is emitted at the expected steps (critic steps 1-4, student steps 1-2).

Phase Time
Engine up (tp2) 1.5 min
Trainer init: 3 x 62 GB checkpoints into pinned host shards (critic, its teacher, student) 21.5 min
Rollout 0: generate 4 samples at 4 steps / critic 2 steps + scoring / student 1 step 0.5 / 8.3 / 5.0 min
Rollout 1: same 0.7 / 7.3 / 3.6 min
GPU, each rank 33 GB allocated peak, 48 GB used
Host memory for the job about 0.9 TB

The time is the two offloaded 31B optimizers, so est_time=3300 lifts run_suite's per-file cap to 4125 s (max(timeout_per_file, 1.25 x est_time)); the nightly 3gpu job grows by about 50 min. Smaller is not available: sglang's H3 pins 1344x768 and >= 4 s, and the checkpoint materialization is 20 of the 50 minutes regardless of the rollout count.

Standard

The standard is recorded on the CI runner with record-e2e-standards.yml (runs_on: ["h200","3gpu"], the same sglang ref), not locally: the local tree runs torch 2.13 with an ad-hoc port of the FSDP param-dtype patch and would not match bit for bit.

Record run: https://github.com/radixark/miles_diffusion/actions/runs/43032161294 (48 min on the 3gpu runner, this branch at daff1b5 on sglang-miles 47930723, the tip with #49440 and #49143); the artifact is committed as tests/ci/fixtures/e2e_standards/test_h3_t2va_dmd2_16xGPU_single_node_2xGPU_proxy.json. The test file is named ..._16xGPU_single_node_2xGPU_proxy.py like the wan22 and krea2 proxies.

Reproducibility: the two earlier records on the previous combo branch (dmd2/h3-dmd2-e2e, a 2026-10-13 sglang-miles base that shares no history with today's rebuilt branch; runs 42809959116 and 42875943793) and this one on the rebuilt sglang-miles agree on all 22 metric points bit for bit, so the commit only moves meta.commit. A first record on the rebuilt branch (run 43004893234) died in FSDPTrainRayActor init with Ray's host-memory OOM: the 3gpu and 5gpu runners share one node (2013 GB), this job's four offloaded actors plus the engine take about 1.5 TB as Ray counts RSS, and a 5gpu e2e was running at the time. The record has to run while the 5gpu runner is idle, and the nightly will hit the same wall whenever the two e2e suites overlap.

PR Test with run-ci-e2e: https://github.com/radixark/miles_diffusion/actions/runs/43125180885 is green on the merge of this branch and main 841089c. The 3gpu e2e suite passed in one go (1 h 39 min; this test 50.6 min, 9 metric series match). The 5gpu suite needed two reruns for failures outside this PR: cosmos3's engine found port 15002 still held by the previous test's engine (address already in use), then a Ray worker died in Ray's OpenTelemetry exporter (getenv SIGSEGV under OtlpGrpcMetricExporter::Export); the main nightly 43132910928 passed the same suite in between.

Earlier PR Tests ran the whole suite on the previous combo branch through a ci-sglang-pr override; there the sd3 NFT and wan22 standards drifted at step 2+ and the hosted CPU suite lacked radix_transfer_plugins.stashes.tensor_stash (runs 42819564862, 43027602064). With the override gone the suite runs every standard on the engine it was recorded with.

Checklist

  • pre-commit hooks pass on the changed files
  • Added/updated tests for new behaviour (the e2e)
  • python3 scripts/run_diffusion_dmd2_h3_t2va_16gpu_multinode.py --help still parses; the CI arg set and the 16-GPU defaults both go through parse_args
  • No public train flag added; the recipe knobs are documented in the H3 model page

@zhihengy zhihengy added the run-ci-e2e Run e2e metric-regression tests on this PR label Nov 10, 2026
@zhihengy
zhihengy force-pushed the dmd2/06b-h3-dmd2-e2e branch from 38a1383 to adc83da Compare November 10, 2026 12:53
zhihengy and others added 13 commits November 11, 2026 06:53
`train` returned its train output directly, so the driver's ray.get on the
train refs pulled every rank's output into the controller before the next
group read it again from the object store. Return `Box(ray.put(output))`
like the rollout shards: the driver gets a small box, the payload stays in
the store until the paired rank of a later group unboxes it.

Also note the train-output hook as a `--teacher-load` consumer in
docs/fsdp_model_roles.md, which cli-reference.md already did.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
train returns Box(ray.put(output)); the driver discarded its ray.get and
passed the task refs on, so the consumer's box.inner hit an ObjectRef.
Keep the boxes the way the rollout shards are kept.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…tprocess

Review on #338: `custom_train_input_postprocess_func` says what the hook
does, a post-processing step on the converted train pairs. The flag
follows the prepare hook's pattern: `--custom-train-input-postprocess-path`
sets `args.custom_train_input_postprocess_path`, loaded into
`self.custom_train_input_postprocess_func`. Docs and the hook test follow.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
#338 renamed the hook to --custom-train-input-postprocess-path; the DMD2
defaults and the critic override still set custom_train_input_function_path,
so --loss-type dmd2 failed in parse_args.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
miles/ray/rollout.py imports imageio_ffmpeg to mux the eval audio; the
GPU image had it only as a transitive dependency and the hosted CPU
suite not at all, so tests/fast/rollout/test_eval_media.py failed to
import there.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
Whether a hook forwards the teacher is the hook's business; the argument
layer cannot tell from --loss-type and the hook paths who will read it,
so the check only ever guessed. --teacher-load is now accepted under every
loss type (dmd2 still requires it).
Stop filling the --custom-*-path arguments on behalf of nft / dmd2 and
stop overriding them per trainer role: a group's prepare, formula,
train-input and train-output hooks come from loss_hub.LOSS_HOOKS keyed by
(loss_type, role), the way miles core's get_loss_function does. Only
custom_loss reads the path flags. The critic overrides shrink to the six
values that really differ (checkpoint, lr, load/save dirs, steps, batch).
A path given under any other loss type would be silently ignored now that
the table selects the hooks, so fail at parse time instead.
DMD2 has no log-prob ratio to recompute, and once the recompute loop
passes its real step index the critic's last window would run its
scoring prepare and formula a second time. sft_loss and nft already
reject the flag.
microbatch_id and optim_step_idx were written onto DiffusionLossContext
before every forward and read back by the hooks; the planned micro-batch
prefetch would race on them. They are now required keyword arguments of
every prepare and formula hook, passed by the two trunk loops; the
numbering is unchanged (training from 0, the old-log-prob recompute of
windows 1.. reuses their training forwards' numbers).
zhihengy and others added 2 commits November 11, 2026 05:15
The DMD2 recipe only knew its 2 x 8 topology. Give it the knobs an e2e
needs: --num-nodes / --num-gpus-per-node (one node starts its own ray
cluster), --critic-steps-per-rollout, --eval-interval 0 / --save-interval 0
to drop eval and checkpoints (0 used to reach should_run_periodic_action's
modulo), --fsdp-cpu-offload and --master-dtype. The three 31B models do not
fit two GPUs with their optimizers, so the proxy keeps parameters, gradients
and optimizer states in host memory with a bf16 master and steps on the CPU.

tests/e2e/short/test_h3_t2va_dmd2_2xGPU.py runs 2 rollouts of 4 prompts
(2 critic steps of 2, 1 student step on the last 2) under --deterministic-mode
and checks the critic loss and grad norm, the student grad norm and the DMD2
metrics against the recorded standard. The 16-GPU defaults are unchanged.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
…roxy

The standard comes from record-e2e-standards.yml on the 3gpu runner
(run 42809959116, sglang zhihengy/sglang:dmd2/h3-dmd2-e2e), not from a
local run. The test is renamed to the 16xGPU_single_node_2xGPU_proxy
form the wan22 and krea2 proxies use, since it runs the 16-GPU recipe
shrunk to two GPUs.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
@Rockdu
Rockdu force-pushed the dmd2/06b-h3-dmd2-e2e branch from 350c1d8 to daff1b5 Compare November 11, 2026 13:16
@Rockdu
Rockdu changed the base branch from dmd2/06-h3-recipe to dmd2/08-teacher-in-trunk November 11, 2026 13:16
@Rockdu
Rockdu added this pull request to stack #374 November 11, 2026 13:41
record-e2e-standards.yml run 43032161294 on the 3gpu runner, this branch
at daff1b5 on sglang-miles 47930723 (the tip with sgl-project/sglang#49440
and #49143, so no ci-sglang-pr override). All 22 metric points match the
two records on the previous combo branch bit for bit; only meta.commit moves.

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
@Rockdu
Rockdu removed this pull request from stack #374 November 11, 2026 15:54
@Rockdu
Rockdu added this pull request to stack #379 November 11, 2026 15:55
@Rockdu
Rockdu deleted the branch dmd2/08-teacher-in-trunk November 11, 2026 17:01
Base automatically changed from dmd2/08-teacher-in-trunk to main November 11, 2026 17:01
@zhihengy zhihengy added run-ci-e2e Run e2e metric-regression tests on this PR and removed run-ci-e2e Run e2e metric-regression tests on this PR labels Nov 12, 2026
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
@Rockdu

Rockdu commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR! When I ran this test it was killed by a host-memory OOM: with three full-parameter 31B models offloaded to CPU it takes most of the node's memory, so it fails whenever it overlaps another e2e on the shared node.

Could the CI proxy train the student and the critic with LoRA instead? With frozen bf16 bases it should fit on 2 GPUs without CPU offload, while the 16-GPU recipe stays full-parameter.

…fload

The full-parameter 2-GPU proxy keeps about 1.6 TB in host memory and Ray's memory monitor
kills it whenever another e2e shares the CI node. The recipe script gets --lora: the student
and the critic train LoRA adapters over frozen bf16 bases (about 112 GB per GPU, about 530 GB
of host memory), and the e2e test uses it. The 16-GPU recipe stays full-parameter, and
--fsdp-cpu-offload still runs it on fewer GPUs. --loss-type dmd2 now accepts --use-lora.
Recorded on the 3gpu CI runner by run 45285320503 at 439990e.
@Rockdu
Rockdu removed this pull request from stack #379 November 25, 2026 06:21
The model page carries recipes meant to be run; the single-node --lora / --fsdp-cpu-offload modes are
smoke configurations for CI and development, documented where they live: the recipe script's docstring
and the e2e test. The section also copied the docstring word for word.
@Rockdu
Rockdu merged commit 963c37a into main Nov 25, 2026
6 of 7 checks passed
@Rockdu
Rockdu deleted the dmd2/06b-h3-dmd2-e2e branch November 25, 2026 06:22
@Rockdu
Rockdu restored the dmd2/06b-h3-dmd2-e2e branch November 25, 2026 06:23
@Rockdu
Rockdu deleted the dmd2/06b-h3-dmd2-e2e branch November 25, 2026 06:23
Rockdu added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci-e2e Run e2e metric-regression tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants