Skip to content

refactor(fsdp): teacher and actor extra forward take their own input batch; flat trunk - #418

Closed
Rockdu wants to merge 1 commit into
dmd2/07c-original-scoring-in-trunkfrom
rockdu/pr416-flat-trunk
Closed

Rockdu wants to merge 1 commit into
dmd2/07c-original-scoring-in-trunkfrom
rockdu/pr416-flat-trunk

Conversation

@Rockdu

@Rockdu Rockdu commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What

Rework of #416's trunk, for cherry-picking into #416 (base is #416's branch). Review thread on #416.

  • PreparedBatch.teacher_guidance_scale and forward_only_batch become teacher_batch and actor_forward_batch, both full PreparedBatches. The teacher's CFG fields and neg_cond / joint_cond live on teacher_batch, built by dmd2._teacher_batch; the trunk no longer derives use_cfg from a scale.
  • The trunk stays flat: four stages (teacher, the actor's extra no-grad forward, the training forward, EMA / ref) through one _compute_noise_pred(model, batch, inputs). EMA and ref reuse the training batch's inputs. _forward_teacher_and_model and the returned closure go away.
  • The formula receives teacher_pred and actor_forward_pred; forward_only_teacher_pred is gone (it was teacher_pred on another batch, never both set). keep_scores takes (fake_batch, fake_pred, real_batch, real_pred).

Why

A stage is model x input x grad. Only the actor has two kinds of forward (training, and an extra no-grad one whose input may differ); the teacher, EMA and ref forwards are all no-grad, so the actor's extra forward is one more sibling stage, not a mechanism of its own. "forward-only" named a batch, not a grad mode, and read as a tautology on the teacher.

Validation

  • pytest tests/fast/backends/fsdp_utils/test_loss_hub_dmd2.py test_reference_models.py test_train_input_hook.py tests/fast/utils/test_reference_arguments.py: 71 passed; pre-commit clean.
  • H3 DMD2 proxy e2e recorded on this head via record-e2e-standards.yml (run 45132900931, 3gpu runner) and compared with the committed standard ([DMD2 e2e] test(e2e): 2-GPU H3 DMD2 proxy with a CI-recorded standard #366, recorded on sglang-miles): every metric identical, so the default reuse-critic-step path is unchanged end to end.
  • run-ci-e2e on this PR.

Files

  • miles/backends/fsdp_utils/loss_hub/types.py — the two batch fields.
  • miles/backends/fsdp_utils/loss_hub/dmd2.py — _teacher_batch, prepare_critic_batch fills both batches under original, keep_scores per batch.
  • miles/backends/fsdp_utils/actor.py — the flat trunk.
  • docs/user-guide/customization.md, docs/fsdp_model_roles.md, docs/user-guide/cli-reference.md — contract wording.
  • tests/fast/backends/fsdp_utils/test_loss_hub_dmd2.py, test_reference_models.py — harnesses follow the contract.

Checklist

  • pre-commit run --all-files passes (touched files)
  • Added/updated tests for new behaviour (the two harnesses and the teacher-batch assertions)
  • pytest -x is green (the touched suites)
  • If launch flags changed, python3 train.py --help still parses — no flag changed
  • If a public flag was added, it appears in the CLI reference docs — none added
  • If an example was added, it has a real walkthrough — none added

@Rockdu Rockdu added the run-ci-e2e Run e2e metric-regression tests on this PR label Nov 23, 2026
@Rockdu
Rockdu force-pushed the dmd2/07c-original-scoring-in-trunk branch 2 times, most recently from 3c339bf to 07a6f9d Compare November 25, 2026 07:25
@Rockdu

Rockdu commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Folded into #416 (commits 07a6f9d and 3debb87 on its branch); closing.

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.

1 participant