Repository navigation
feat(pdd): MiniMax H3 t2va PDD with video and audio heads - #387
Open
niehen6174 wants to merge 2 commits into
Open
niehen6174 wants to merge 2 commits into
niehen6174 wants to merge 2 commits into
Conversation
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.
niehen6174
requested review from
Rockdu,
guapisolo and
zhihengy
as code owners
November 16, 2026 02:23
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
PDD_FAMILIESinmiles/distillation/integration.pyholds 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: onevisualstream, unchanged behavior.h3:visual+audioon H3's shifted grids (shift 12 / 3), timestepssigma * 1000, BF16 engine with FP32 heads, the H3 FSDP plan,h3_target_has_soundtrack=True.teacher_mean_velocityaccepts dicts of streams). The loss sums the per-stream interval losses and logspdd_audio_*and per-stream losses.pdd_h3. Keeps H3's native DiT, denoise loop and rollout collector.final_layer.video_out/audio_outwith live heads that weight sync updates; rejects native fused PDD heads and TP/SP > 1.split_states/split_sigmascut them back apart, and the converter checks every stream's grid against the trainer's bit for bit.Recipe and serving notes (export adapter + heads, fuse with sglang's
fuse_minimax_h3_pdd_heads, serve 8 steps with--lora-pathandSGLANG_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/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.pyandtests/fast-gpu/test_lora_weight_sync.py: passed.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.