Skip to content

feat(pdd): MiniMax H3 t2va PDD with video and audio heads - #387

Open
niehen6174 wants to merge 2 commits into
feat/pdd-qwen-image21from
feat/pdd-h3
Open

niehen6174 wants to merge 2 commits into
feat/pdd-qwen-image21from
feat/pdd-h3

Conversation

@niehen6174

@niehen6174 niehen6174 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

PDD for MiniMax H3 text-to-audio-video, stacked on #365 (Qwen-Image 2.1 PDD with a LoRA student). Review only the last commit; the earlier ones are #365.

H3 trains two head stacks, video (proj_out) and audio (audio_proj_out), 32 interval heads each, with the same LoRA student, block-ordered updates and actor-run teacher as #365. One DiT forward per 4-interval block covers both streams, so a rollout still costs 8 DiT forwards.

How

  • Family registry. PDD_FAMILIES in miles/distillation/integration.py holds what differs per model: latent streams and their output layers, sigma grids, student/teacher time inputs, how to split the rollout trajectory, the rollout patch group, engine precision, FSDP param dtype and extra conditioning. feat(pdd): Qwen-Image 2.1 PDD training with a LoRA student from SGLang rollouts #365 dropped this abstraction because Qwen was its only user; H3 is the second.
    • qwen_image21: one visual stream, unchanged behavior.
    • h3: visual + audio on H3's shifted grids (shift 12 / 3), timesteps sigma * 1000, BF16 engine with FP32 heads, the H3 FSDP plan, h3_target_has_soundtrack=True.
  • Trainer. The prepare hook samples one interval per block for all streams and asks the actor for one joint teacher call per midpoint stage (teacher_mean_velocity accepts dicts of streams). The loss sums the per-stream interval losses and logs pdd_audio_* and per-stream losses.
  • Rollout patch pdd_h3. Keeps H3's native DiT, denoise loop and rollout collector.
    • Replaces final_layer.video_out / audio_out with live heads that weight sync updates; rejects native fused PDD heads and TP/SP > 1.
    • Turns an 8-step request into the 32-interval grid and runs the DiT only at block starts, stepping the other intervals on the cached heads.
    • Records the audio rows after each step and appends them, zero-padded to the video width, to the trajectory, and the engine's audio grid to the recorded video grid; split_states / split_sigmas cut them back apart, and the converter checks every stream's grid against the trainer's bit for bit.
  • The trajectory handed to the trainer is now a dict of streams for every family.

Recipe and serving notes (export adapter + heads, fuse with sglang's fuse_minimax_h3_pdd_heads, serve 8 steps with --lora-path and SGLANG_DIFFUSION_MINIMAX_H3_PDD_HEADS): docs/developer/pdd.md.

Requires #357 (FSDP param-dtype patch for torch 2.14) when running on torch 2.14; the H3 FSDP plan keeps the heads, input projections and timestep MLP in FP32.

Validation

  • Tests.
    • tests/fast/distillation/test_pdd.py (CPU), new H3 cases: H3 grids match sglang's schedule and its 8-step block boundaries; the trajectory splits into video and zero-padded audio rows; the student gets both head stacks; both streams share one sampled interval and one joint teacher call per midpoint stage, and the loss equals the sum of per-stream interval losses; H3 defaults and invalid H3 settings; the engine-side head layout and audio packing round-trip through the converter, which rejects a drifted audio grid. The Qwen cases are unchanged apart from the stream dict. 61 passed, together with the loss-hub, reference-model and patch-group tests.
    • tests/fast-gpu/backends/sglang_diffusion_utils/test_pdd_sglang_loop.py and tests/fast-gpu/test_lora_weight_sync.py: passed.
    • H3 end to end with this branch on 8 × H200 (4 training GPUs + 2 engines, non-colocated): two rollouts and sixteen block updates with the adapter and heads synced to both engines (312 LoRA sections per sync). The first update reproduces the long run's first-update loss (1.9429) exactly; block-0 trainer/engine next-state error 1.1% (video) / 0.7% (audio). Rerun on the last commit: same first-update loss, and the engine-recorded video and audio sigma grids pass the converter's bitwise check against the trainer's grids.
  • Long run on 8 × H200 with the recipe in the docs: LoRA r64/α128, lr 5e-6, batch 8, 400 rollouts (about 7 min each), 1:1 / 4 s / short edge 768. Prompts: 57k filtered video prompts (motion and camera descriptions), each used once.
rollouts video loss, block 0 audio loss, block 0 mean loss, 8 blocks video next-state rel. error audio next-state rel. error
0–39 1.053 0.023 0.265 1.24% 0.82%
80–119 0.675 0.020 0.193 2.01% 0.91%
160–199 0.615 0.018 0.179 2.00% 0.90%
240–279 0.630 0.017 0.177 2.10% 0.90%
360–399 0.652 0.023 0.173 2.06% 0.91%
  • Trainer/engine parity. The block-0 next-state error grows from about 0.9% to 2% as the adapter trains, then stays flat. Dumps of both sides at one checkpoint show that weight sync is exact (heads and LoRA factors bit-identical to the checkpoint, including the fused QKV and the SwiGLU row order) and that the heads compute identically on the same hidden state. The gap is in the backbone's hidden state: it starts at 0.2% after block 0 and grows smoothly through the 50 blocks, with no single block jumping, i.e. BF16 kernel differences amplified by depth rather than a mapping bug. Computing the LoRA delta in FP32 in the trainer removes only a small part of it. The teacher target is computed in the trainer, so this gap moves the rollout's starting states, not the training target.

  • Quality. On the 5 fixed A/B prompts of the prompt set (2 seeds each), the 8-step student served through sglang's native PDD path is clearly sharper and more detailed than the base model at 8 steps and close to the 32-step teacher; compositions follow the teacher more closely as training goes on. Rollouts 200 and 400 are at about the same level.

  • Samples: frame at 2 s of each fixed A/B prompt (eye close-up, field run, card trick, talking Statue of Liberty, wink emoji). Columns: teacher 32 steps, base model 8 steps, PDD student 8 steps at rollouts 100 / 200 / 400.

H3 PDD, seed 42
H3 PDD, seed 43

Stacked on the Qwen-Image 2.1 PDD PR. H3 is the second model family, so the
per-family registry comes back:

- PDD_FAMILIES holds what differs per model: latent streams and their output
  layers, sigma grids, student/teacher time inputs, trajectory splitting, the
  rollout patch group, engine precision, FSDP param dtype and extra conditioning.
  Qwen-Image 2.1 keeps one "visual" stream; H3 adds "audio" on its own shifted
  grid (shift 12 / 3), BF16 engine weights with FP32 heads and the H3 FSDP plan.
- The prepare hook samples one interval per block for all streams and runs one
  joint teacher call per midpoint stage; the loss sums the per-stream interval
  losses and logs pdd_audio_* and per-stream losses. Rollout trajectories are a
  dict of streams.
- pdd_h3 rollout patch: live video/audio heads in place of the native output
  projections, the 8-step request run on the 32-interval grid with one DiT
  forward per block, and audio rows recorded and appended to the trajectory.

Docs cover the H3 recipe and serving through sglang's native PDD path. CPU tests
cover the H3 grids, stream splitting, both head stacks, the joint teacher call
and H3 argument validation.
…ne side

- The pdd_h3 patch appends the engine's audio sigma grid to the recorded video
  grid, and the converter checks every stream's grid against the trainer's bit
  for bit (a family's split_sigmas cuts the recorded grid into streams). Before,
  only the video grid was checked, so an engine audio schedule that drifted from
  --diffusion-audio-flow-shift would have trained against misplaced teacher
  targets without an error.
- Factor the head-cache lookup (heads_at) and the audio packing (pack_audio) out
  of the patch closures and cover them on CPU: the cached [rows, N*C] layout
  yields head k, and a packed trajectory round-trips through the converter.
- Docs: the unweighted sum of per-stream losses, the stream metric names, and the
  one-request-per-engine assumption of the block cache.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant