Skip to content

[DMD2 4/10] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching - #338

Merged
Rockdu merged 2 commits into
mainfrom
dmd2/02b-train-input-hook
Nov 11, 2026
Merged

Rockdu merged 2 commits into
mainfrom
dmd2/02b-train-input-hook

Conversation

@zhihengy

@zhihengy zhihengy commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fourth of the DMD2 stacked series, on top of #330. Adds a preprocessing step for a trainer group's train pairs. Once the rollout output has been converted into this rank's train pairs, and before they are split into micro-batches, a hook may filter, reorder or rewrite them, with the earlier groups' outputs at hand. In [DMD2 7/10], DMD2's actor uses it to keep only the samples the critic group scored.

What

  • New --custom-train-input-postprocess-path: fn(ctx, train_pairs) -> list, the preprocessing step on this rank's train pairs. _train_core runs it once the rollout data arrives, before the micro-batch schedule. It gets the same DiffusionLossContext as the prepare, loss and train-output hooks, with ctx.external_data from the earlier groups ([DMD2 3/10] feat(ray): hand earlier trainer groups' outputs to later groups as external_data #330), and returns the pairs to train on, in order. The schedule, the training forwards and the train-output hook all see the returned pairs.
  • The DiffusionLossContext is now built before the schedule, so the hook can read it. Its fields are unchanged, and none of them depends on the schedule.
  • Without the hook, the converted train pairs train as before.
  • Docs: cli-reference.md and customization.md.

Why

  • The rollout-side converter shapes the train pairs before any trainer group has run, so it can't use what an earlier group produced. DMD2's actor trains only on the samples the critic scored, and which ones those are is known only after the critic group has trained on the rollout. Without a train-side preprocessing step, the trainer would need a loss_type == "dmd2" and role == "actor" branch. The hook keeps the trainer algorithm-agnostic, as the prepare, loss and train-output hooks do. It is the input-side counterpart of [DMD2 3/10] feat(ray): hand earlier trainer groups' outputs to later groups as external_data #330's train-output hook.
  • Filters that don't depend on another group's output already have rollout-side hooks (--dynamic-sampling-filter-path, --rollout-sample-filter-path, --buffer-filter-path). This hook is for choices that need an earlier group's output, which exists only on the train side.
  • Upstream precedent: miles' Megatron actor has the same step, --rollout-data-postprocess-path, which post-processes the rollout data once log probs and the critic's values are in place, before training ("useful for updating loss masks"). That hook only receives args. The same actor also merges the PPO critic's values into the rollout data under if self.args.use_critic. Here the hook receives the pairs and the earlier groups' outputs, so neither kind of use needs a role check in the trainer.

Tests

  • tests/fast/backends/fsdp_utils/test_train_input_hook.py runs the production _train_core on CPU, with the forward, metrics and rank checks replaced:

    • the hook sees the converted train pairs and a ctx that carries external_data. It filters them and adds a field from external_data, and the training forwards and the train-output hook see exactly the pairs it returns, in order, with the same ctx;
    • without the hook, the converted train pairs train unchanged.

    Removing the hook call makes the first test fail.

  • The e2e suite was not run locally.

Checklist

  • pre-commit hooks (black, isort, ruff at the pinned versions) pass on the changed files
  • Added/updated tests for new behaviour (pairs seen by each stage after preprocessing, no-hook default)
  • pytest tests/fast is green (522 passed, 6 skipped; 520 on [DMD2 3/10] feat(ray): hand earlier trainer groups' outputs to later groups as external_data #330)
  • If launch flags changed, python3 train_diffusion.py --help still parses (the new flag is listed)
  • If a public flag was added, it appears in the CLI reference docs (--custom-train-input-postprocess-path in cli-reference.md and customization.md)
  • If an example was added, it has a real walkthrough (no examples added)

Stack

DMD2: distill a flow-matching teacher into a few-step student with distribution matching. Merge in order:

  1. [DMD2 1/10] [DMD2 1/10] refactor(ray): build each trainer's args from a trainer config list #335: per-trainer args from a trainer config list
  2. [DMD2 2/10] [DMD2 2/10] feat(ray): train several colocated trainer groups in the sync driver #329: several colocated trainer groups in the sync driver
  3. [DMD2 3/10] [DMD2 3/10] feat(ray): hand earlier trainer groups' outputs to later groups as external_data #330: hand earlier trainer groups' outputs to later groups as external_data
  4. [DMD2 4/10] this PR: a train-input hook that preprocesses a trainer group's train pairs before micro-batching
  5. [DMD2 5/10] [DMD2 5/10] feat(rollout): stop the rollout at a random step for DMD2 backward simulation #331: few-step rollout and the DMD2 step strategy (needs [Feat] diffusion-rl: stop a rollout at a requested step sgl-project/sglang#45230)
  6. [DMD2 6/10] [DMD2 6/10] feat(dmd2): train a fake-score critic group from the teacher and score the student's samples #333: DMD2 critic group: critic training and teacher/critic scoring of its last step
  7. [DMD2 7/10] [DMD2 7/10] feat(dmd2): train the student with the distribution matching gradient from the critic group's scores #334: --loss-type dmd2 on the actor
  8. [DMD2 8/10] [DMD2 8/10] perf(ray): sleep each trainer group right after its train #342: sleep each trainer group right after its train
  9. [DMD2 9/10] [DMD2 9/10] feat(dmd2): add the MiniMax H3 4-step DMD2 recipe with eval media and DMD2 metrics #343: MiniMax H3 4-step DMD2 recipe, eval media and DMD2 metrics

A GAN head and other follow-ups come after this series.

@zhihengy
zhihengy added this pull request to stack #339 October 24, 2026 00:09
@zhihengy
zhihengy marked this pull request as ready for review October 24, 2026 00:14
@zhihengy
zhihengy force-pushed the dmd2/02b-train-input-hook branch from ff83350 to d3244bf Compare October 24, 2026 00:17
@zhihengy zhihengy changed the title [DMD2 4/8] feat(fsdp): let a trainer group pick its train pairs with a train-input hook [DMD2 4/8] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching Oct 24, 2026
@zhihengy zhihengy changed the title [DMD2 4/8] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching [DMD2 4/9] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching Oct 26, 2026
@zhihengy zhihengy changed the title [DMD2 4/9] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching [DMD2 4/10] feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching Nov 2, 2026
@Rockdu
Rockdu force-pushed the dmd2/02b-train-input-hook branch from d3244bf to 09820eb Compare November 4, 2026 19:41
Comment thread miles/backends/fsdp_utils/actor.py Outdated
external_data=external_data,
)
if self.custom_train_input_func is not None:
train_pairs = self.custom_train_input_func(loss_ctx, train_pairs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

custom_train_input_postprocess_func here is clearer

@zhihengy
zhihengy force-pushed the dmd2/02b-train-input-hook branch from 09820eb to 17bd1ba Compare November 9, 2026 22:16
zhihengy added a commit that referenced this pull request Nov 9, 2026
…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>
@zhihengy zhihengy added the run-ci-e2e Run e2e metric-regression tests on this PR label Nov 9, 2026
@zhihengy
zhihengy force-pushed the dmd2/02b-train-input-hook branch from fc579c4 to 22e3377 Compare November 10, 2026 03:59
niehen6174 pushed a commit to niehen6174/miles_diffusion that referenced this pull request Nov 10, 2026
…tprocess

Review on radixark#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>
zhihengy added a commit that referenced this pull request Nov 10, 2026
…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>
@zhihengy
zhihengy force-pushed the dmd2/02b-train-input-hook branch from 22e3377 to cd303eb Compare November 10, 2026 11:44
zhihengy added a commit that referenced this pull request Nov 10, 2026
#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>
external_data=external_data,
)
if self.custom_train_input_postprocess_func is not None:
train_pairs = self.custom_train_input_postprocess_func(loss_ctx, train_pairs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CC cmt

[P2] Still open from the last round: the empty check at L359 runs on the raw list, so a hook that returns [] passes 0 % num_steps_per_rollout and build_microbatch_schedule (n empty steps) and the loop then does optimizer.step / lr step / global_step / EMA step / train-output hook with no forward at all. Only fp16 and nft fail loudly; bf16 GRPO/DMD2 log a zero-loss step and move on.
select_scored_pairs can't return [] today, hence P2, but the hook is documented as a filter, so please re-check if not train_pairs: raise after the hook and add the [] case to the test.

zhihengy added a commit that referenced this pull request Nov 11, 2026
…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>
@zhihengy
zhihengy force-pushed the dmd2/02b-train-input-hook branch from cd303eb to 77dedd4 Compare November 11, 2026 08:18
zhihengy added a commit that referenced this pull request Nov 11, 2026
#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>
@zhihengy zhihengy removed the run-ci-e2e Run e2e metric-regression tests on this PR label Nov 11, 2026
Base automatically changed from dmd2/02-external-data to main November 11, 2026 15:43
zhihengy and others added 2 commits November 11, 2026 07:43
…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>
@Rockdu
Rockdu force-pushed the dmd2/02b-train-input-hook branch from 77dedd4 to d8e53e5 Compare November 11, 2026 15:43
@Rockdu
Rockdu merged commit 5ebd7e6 into main Nov 11, 2026
3 of 5 checks passed
Rockdu pushed a commit that referenced this pull request Nov 11, 2026
… from the critic group's scores (#334)

* feat(dmd2): train the student with the distribution matching gradient from the critic group's scores

* fix(dmd2): follow the train-input hook rename in the DMD2 defaults

#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>

---------

Co-authored-by: Claude Mythos 5.1 <noreply@anthropic.com>
Rockdu added a commit that referenced this pull request Nov 11, 2026
* feat(ray): hand earlier trainer groups' outputs to later groups as external_data

* fix(fsdp): box the train output so the driver's ray.get only waits

`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>

* fix(ray): hand later trainer groups the output boxes, not the raw refs

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>

* feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching

* refactor(fsdp): rename the train-input hook to custom_train_input_postprocess

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>

* feat(rollout): stop the rollout at a random step for DMD2 backward simulation

* feat(dmd2): train a fake-score critic group from the teacher and score the student's samples

* feat(dmd2): train the student with the distribution matching gradient from the critic group's scores

* fix(dmd2): follow the train-input hook rename in the DMD2 defaults

#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>

* perf(ray): sleep each trainer group right after its train

* feat(dmd2): add the MiniMax H3 4-step DMD2 recipe with the media and metrics to judge it

* feat(dmd2): skip the engine's VAE decode of training rollouts when no reward reads the media

* build: declare imageio-ffmpeg, which the eval media muxing imports

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>

* docs(h3): say the DMD2 recipe downloads the VidProM prompt list from the Hub

* docs(dmd2): count the VidProM prompts after dedup

* fix(dmd2): load the FastH3 reference by its Hub id on every node

* refactor(args): drop the teacher consumer check

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).

* refactor(fsdp): select loss hooks from a (loss_type, role) table

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).

* fix(args): reject --custom-*-path outside --loss-type custom_loss

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.

---------

Co-authored-by: Andy Ye <89891424+zhihengy@users.noreply.github.com>
Co-authored-by: Claude Mythos 5.1 <noreply@anthropic.com>
Rockdu added a commit that referenced this pull request Nov 11, 2026
* feat(ray): hand earlier trainer groups' outputs to later groups as external_data

* fix(fsdp): box the train output so the driver's ray.get only waits

`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>

* fix(ray): hand later trainer groups the output boxes, not the raw refs

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>

* feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching

* refactor(fsdp): rename the train-input hook to custom_train_input_postprocess

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>

* feat(rollout): stop the rollout at a random step for DMD2 backward simulation

* feat(dmd2): train a fake-score critic group from the teacher and score the student's samples

* feat(dmd2): train the student with the distribution matching gradient from the critic group's scores

* fix(dmd2): follow the train-input hook rename in the DMD2 defaults

#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>

* perf(ray): sleep each trainer group right after its train

* feat(dmd2): add the MiniMax H3 4-step DMD2 recipe with the media and metrics to judge it

* feat(dmd2): skip the engine's VAE decode of training rollouts when no reward reads the media

* build: declare imageio-ffmpeg, which the eval media muxing imports

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>

* docs(h3): say the DMD2 recipe downloads the VidProM prompt list from the Hub

* docs(dmd2): count the VidProM prompts after dedup

* fix(dmd2): load the FastH3 reference by its Hub id on every node

* refactor(args): drop the teacher consumer check

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).

* refactor(fsdp): select loss hooks from a (loss_type, role) table

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).

* fix(args): reject --custom-*-path outside --loss-type custom_loss

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.

* fix(args): reject --diffusion-recompute-old-log-prob under dmd2

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.

* refactor(fsdp): pass the loop counters to the hooks as arguments

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).

* refactor(fsdp): hand the train-output list to the hooks as an argument

The DMD2 critic formula appended its scoring inputs to a list on the
context and the train-output hook read them back: a hook-to-hook channel
invisible in the call graph. The trunk now owns one list per train call
and passes it to the formulas and to the train-output hook.

* refactor(fsdp): freeze DiffusionLossContext

Nothing writes the context after construction any more: it is the
rollout-level, read-only view the hooks share. eq=False keeps identity
comparison; a synthesized hash would fail on the dict fields.

---------

Co-authored-by: Andy Ye <89891424+zhihengy@users.noreply.github.com>
Co-authored-by: Claude Mythos 5.1 <noreply@anthropic.com>
Rockdu added a commit that referenced this pull request Nov 11, 2026
…by the critic's prepare hook (#372)

* feat(ray): hand earlier trainer groups' outputs to later groups as external_data

* fix(fsdp): box the train output so the driver's ray.get only waits

`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>

* fix(ray): hand later trainer groups the output boxes, not the raw refs

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>

* feat(fsdp): add a train-input hook that preprocesses train pairs before micro-batching

* refactor(fsdp): rename the train-input hook to custom_train_input_postprocess

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>

* feat(rollout): stop the rollout at a random step for DMD2 backward simulation

* feat(dmd2): train a fake-score critic group from the teacher and score the student's samples

* feat(dmd2): train the student with the distribution matching gradient from the critic group's scores

* fix(dmd2): follow the train-input hook rename in the DMD2 defaults

#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>

* perf(ray): sleep each trainer group right after its train

* feat(dmd2): add the MiniMax H3 4-step DMD2 recipe with the media and metrics to judge it

* feat(dmd2): skip the engine's VAE decode of training rollouts when no reward reads the media

* build: declare imageio-ffmpeg, which the eval media muxing imports

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>

* docs(h3): say the DMD2 recipe downloads the VidProM prompt list from the Hub

* docs(dmd2): count the VidProM prompts after dedup

* fix(dmd2): load the FastH3 reference by its Hub id on every node

* refactor(args): drop the teacher consumer check

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).

* refactor(fsdp): select loss hooks from a (loss_type, role) table

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).

* fix(args): reject --custom-*-path outside --loss-type custom_loss

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.

* fix(args): reject --diffusion-recompute-old-log-prob under dmd2

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.

* refactor(fsdp): pass the loop counters to the hooks as arguments

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).

* refactor(fsdp): hand the train-output list to the hooks as an argument

The DMD2 critic formula appended its scoring inputs to a list on the
context and the train-output hook read them back: a hook-to-hook channel
invisible in the call graph. The trunk now owns one list per train call
and passes it to the formulas and to the train-output hook.

* refactor(fsdp): freeze DiffusionLossContext

Nothing writes the context after construction any more: it is the
rollout-level, read-only view the hooks share. eq=False keeps identity
comparison; a synthesized hash would fail on the dict fields.

* refactor(fsdp): run the DMD2 teacher forward in the actor, requested by the critic's prepare hook

* fix(fsdp): run the teacher forward without the student's true_cfg_scale

* refactor(dmd2): pull the teacher request out of prepare_critic_batch

prepare_critic_batch did three things in one body: build the SFT batch,
pick the scoring step's grid range, and collate the teacher's CFG inputs.
The teacher part is its own function now, _request_teacher_forward, and
the two helpers it shared with #351 are back, so the critic's prepare
reads as SFT plus the last step's teacher request. No behaviour change.

---------

Co-authored-by: Claude Mythos 5.1 <noreply@anthropic.com>
Co-authored-by: rockdu <kangrdu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants