Repository navigation
Conversation
…-step heads as stacks h3_image had no train-to-rollout transform, so a sync of the DiT's weights sent the Diffusers layout as it is: the engine maps names but not layouts, and skips pdd_proj_out.* with a warning. Every weight but the heads goes through H3's transform. The heads of one suffix are held until every step's arrived and leave as one stack under the name sglang-d's weight update takes it by (sgl-project/sglang#51654); the prefix is read from sglang when a sync needs it, since a sglang-miles before that PR has no such constant and every family's bridge is imported with the adaptations package.
A forward runs the output head of one denoising step, so the other heads have no gradient on that rank. FSDP2 reduces the gradients of one wrap as a single buffer of the parameters that have one on that rank, in order, and the heads share a shape: two ranks with pairs of different steps line the buffers up head against head, and each head leaves the reduce with the mean of its own gradient and the other's. When the heads are trained, a forward hook on each head adds every head's parameters to its output at weight zero, so every rank reduces every head. The two-rank test fails without the hook: head 0's gradient differs from the mean of its own on every element on one rank and is missing on the other.
Both were refused because the rollout engine could not receive the per-step output heads and because the heads' gradients were not kept apart across ranks. A sync that carries the DiT's weights is now refused only on an sglang-d whose weight update takes no heads, at argument time.
Conflicts in the family's `validate_args` and its tests: the base added the refusal of a config named by path beside the merged-LoRA refusal this branch removes. Kept this branch's engine check and the base's new refusal; the accepted cases keep this branch's full-weight and merged-LoRA ones without the tile case the base dropped.
…rror with a remedy that holds The refusal was a RuntimeError raised by a getter called for its side effect, and its remedy named `--lora-ipc-weight-sync` alone, which is refused without `--colocate`. The bridge now answers whether the engine takes head stacks, `validate_args` raises the ValueError with the remedy for both layouts, and the refusal of a config named by path names the weight transform it would also lose.
…'s own FSDP wrapping The worker wrapped the blocks and the root by hand with stock policies. The hook is right only while every head is unsharded with the forward that runs one of them, which the family's plan decides: the worker now wraps through `apply_fsdp2` with that plan, so the patched reduce and a plan change are both in the test. The expected shard is cut locally (`src_data_rank=None`; the default scatters from rank 0), the tiny model and its layout come from the CPU test, and the test skips on fewer than two GPUs.
… merged LoRA The bridge tests call the transform directly. This drives the state dict through the weight iterator and its bucketing, with every tensor in a bucket of its own: the heads leave as the two stacks, and nothing leaves under a Diffusers name, also from a PEFT-wrapped model.
This was referenced Nov 20, 2026
Open
Open
Conflict in the family's `validate_args`: the base named the sync condition `syncs_weights_to_rollout` and kept the merged-LoRA refusal this branch replaces. Took the base's name and this branch's checks, and put the refusal of a config named by path before the engine check: both ways out the engine check names lead into it, and by path no transform would send a stack. A test pins that order.
…here the heads are dtype overrides At fp32 the plan's fp32 patterns equal the default and compile to nothing, so the worker ran torch's stock reduce. A full-weight run forwards in bf16 by default: the heads, `proj_in` and the time embedder are then per-parameter overrides in the root wrap, which reduces through the patched mixed-dtype collectives. The test runs both. The worker compares in deterministic mode. The per-token AdaLN lookup repeats one timestep index and back-propagates as an index_add whose order on CUDA is not fixed; in bf16 that moved the time-embedding chain's gradients by about 1% between the wrapped model and the reference, while every other parameter was equal. The test puts the repository root on the worker's path itself, as test_reference_models does.
…e namespace field nothing reads
…lready has none, and let the dumped-rollouts case tell again - `monkeypatch.delattr` raised on an sglang-d from before the head update, before `validate_args` ran. - With a merged LoRA sync accepted, nothing refused the dumped-rollouts launch whether `train_only` was derived early or late. On an engine without head updates the family hook refuses it unless it reads `train_only` set.
…32 at argument time Under `--fsdp-master-dtype bf16` diffusers still loads `proj_in`, the time embedder and the per-step heads in fp32. A LoRA trainer does not mind: only the adapters are trained. A full-weight trainer has both dtypes among the trained weights of the root wrap, and FSDP2 raises "expects uniform original parameter dtype" when the trainer is built, after every rank has loaded the DiT. Seen on 8 H200 with a bf16 master.
…aster rule and that fp16 is refused too
zhihengy
marked this pull request as ready for review
November 20, 2026 20:42
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.
[H3-Image] Stacked on #395, beside #400. Full-weight training for MiniMax-H3-Image: the per-step output heads reach the rollout engine, and each head's gradient reduces on its own.
Stack:
main<- #393 (step index) <- #394 (loader) <- #395 (family) <- this PR. #400 (LoRA recipe and model page) is the other PR on #395; neither needs the other.The head sync needs sgl-project/sglang#51654, which is not in
sglang-milesyet. It is stacked on sgl-project/sglang#51113, so it carries the image rollout too:ci-sglang-pr: #51654
What
models/diffusers/h3_image/weight_bridge.py, registered for familyh3_image, which had no train-to-rollout transform (a LoRA adapter sync does not use one):pdd_proj_out.{step}.{weight,bias}are held until the heads of every step arrived, then leave as one stack per suffix under the name sglang-d's weight update takes them by:final_layer.pdd_fused_heads.video_out.weight[steps, out, in]and.bias[steps, out]._to_fl2va.configs/h3_image.py:validate_argsno longer refuses a trainer without--use-lora, nor a LoRA synced merged into the DiT's weights. A run whose sync carries the DiT's weights is refused at argument time on an sglang-d that takes no heads, with the two ways out.--use-lorais accepted on--fsdp-master-dtype fp32only (see Why).--train-pipeline-config-pathfor a syncing run ([H3-Image 3/4] feat(h3-image): add the MiniMax H3 Image train family for t2i Flow-GRPO with LoRA #395) now names the weight transform too: it is looked up by the same unset key, so such a sync would send the Diffusers layout as it is. It comes before the engine check, whose two ways out both lead into it.postprocess_model_after_materializeputs a forward hook on eachpdd_proj_outhead when the heads are trained: whichever head a forward runs adds every head's parameters to its output at weight zero. A LoRA trainer and a frozen copy get no hook.Why
h3_imagesent the Diffusers layout as it is. The engine maps names but not layouts, so the feed-forward's[value, gate]halves would have landed swapped, andpdd_proj_out.*would have been skipped with a warning.[A2]pdd_fused_heads.safetensors, and its update takes that stack whole: a sender cannot update some steps and leave the others stale.[A5]MINIMAX_H3_PDD_FUSED_HEADS_WEIGHT_NAME_PREFIX), so the name has one owner.[A4]It is imported where it is used, not with the module:adaptationsimports every family's bridge, and asglang-milesbefore #51654 has no such constant. Only a run that sends the heads needs it, and it gets the reason at argument time instead of a rollout that keeps the heads it started with.[A2]Noneon that rank, in order (FSDPParamGroup.post_backward). The heads sit in the root wrap and have one shape. A forward runs one head, so when two ranks hold pairs of different steps their buffers line up head against head: head k leaves the reduce with the mean of its own gradient and another head's, and a rank that did not run it has none. With the hook every rank reduces every head, and a head a rank did not run contributes zeros.[A3][A5]--weight-decay 0, and decays it bylr x weight_decayper optimizer step otherwise.proj_in, the time embedder and the per-step heads in fp32. The root wrap then trains weights of two dtypes, which FSDP2 refuses when the trainer is built, after every rank has loaded the DiT (seen on 8 H200, see Validation). A LoRA trainer on a bf16 master is unaffected: only the adapters are trained. The same pin exists for familyh3; a check shared by the families is a follow-up.[A2][A2]no silent wrongness,[A3]every rank runs the same collective sequence,[A4]one owner per fact,[A5]the structure carries the invariant.Contract with the engine
sgl-project/sglang#51654: a tensor weight update loads
final_layer.pdd_fused_heads.<key>as a head stack,<key>and tensor as inpdd_fused_heads.safetensors. It checks every stack of a payload before it replaces one, narrows each to the TP rank's output shard, and fails the update on a stack it cannot load. H3 Image has no audio, so its keys arevideo_out.weightandvideo_out.bias.Validation
On this box, CI-recipe environment with diffusers 0.43.0 and sglang at sgl-project/sglang#51654 (c299c817b), head b4cb679, except the end-to-end runs, which name their commits.
End to end, 8 H200, FSDP DP=8 colocated with four TP2 engines over CUDA IPC, weights
MiniMaxAI/MiniMax-H3-Imageat 8ced6006. The LoRA recipe's rollout settings (#400:cps0.8 on steps 0-4, 512x512, OCR reward, engine debug mode, old log-probs recomputed) on 8 prompts x 2 samples, 2 optimizer steps per rollout, 3 rollouts, lr 1e-4.train/model_output_mean_abs_diffis the trainer's forward against the model output the engine generated the rollout with (mean magnitude about 1):MiniMax-H3 PDD: head stacks ['video_out.bias', 'video_out.weight'] replaced by a weight update(16 of 16), and no engine logged "Skipping weight update". A sync is 77 buckets per engine full-weight and 37 merged.--fsdp-master-dtype bf16failed when the trainer was built, inFSDPParamGroup._init_mp_dtypes("FSDP expects uniform original parameter dtype"), about three minutes in. That combination is now refused at argument time.Real weights,
MiniMaxAI/MiniMax-H3-Imageat 8ced6006, no engine process:transformer_diffusers/(644) through the transform registered forh3_image, against what the engine loadstransformer/under the emitted name; 2 head stacks bitwise equal topdd_fused_heads.safetensors; nothing emitted under a name the engine does not loadfinal_layer.video_out.{weight,bias}(the single head, which the engine does not run once the per-step heads are loaded) and the bufferrope.inv_freqWeightsUpdaterinto a real-size final layer, TP1 and TP2 (ranks built in one process)GPU, tiny real
MiniMaxH3ImageTransformer2DModelwith 3 heads:tests/fast-gpu/.../test_h3_image_head_gradients.py[fp32, bf16]: two ranks under FSDP2, wrapped throughapply_fsdp2with the family's plan, rank 0 on a pair of step 0 and rank 1 on a pair of step 2, in deterministic mode. At a bf16 forward, the default, the heads are fp32 dtype overrides and the root wrap reduces through miles' patched mixed-dtype collectives; at fp32 the plan compiles to nothing and the reduce is torch's ownpdd_proj_out.0.weightdiffers from that mean on 1152 of 1152 elements; rank 1:pdd_proj_out.0.weighthas no gradienttests/fast-gpu/.../test_h3_image_weight_sync.py: the DiT's state dict through the updater's weight iterator and bucketing, every tensor in a bucket of its own, plain and PEFT-wrapped with its LoRA merged inpdd_proj_out.*ortransformer_blocks.*CPU:
test_h3_image_weight_bridge.py(new)h3_imageresolves heads to the stacking transform and everything else to_to_fl2va,h3is unchangedtest_h3_image.py::test_a_forward_through_one_head_gives_every_head_a_gradient...::test_a_sync_that_sends_the_heads_needs_an_sglang_that_takes_them(6 cases)--train-onlyand--debug-rollout-onlyare not...::test_a_config_named_by_path_cannot_sync_to_an_engine(LoRA adapters, merged LoRA, full-weight)...::test_a_config_named_by_path_is_refused_before_the_engine_is_asked_about_heads...::test_supported_variations_are_accepted,...::test_unsupported_training_settings_are_rejected--train-onlyand merged LoRA moved from rejected to accepted. Full-weight on a bf16 master and full-weight--train-onlyon fp16 are rejected; a LoRA and a rollout-only run on a bf16 master are accepted...::test_a_run_on_dumped_rollouts_is_not_held_to_a_sync_mode(#395's)train_onlyis derived early or latetests/ci/run_suite.py --hw cpu --suite stage-a-cpupre-commit runon the changed filesEach new test was checked to fail with its behaviour removed.
Not executed:
test_supported_variations_are_acceptedand the bridge tests fail by design, so this PR's CPU suite needs theci-sglang-prpin until that PR is insglang-miles.Not in this PR
--fsdp-master-dtype fp32,--lr 1e-6.--diffusion-model-family, not by the config class; until they follow the class, a config named by path cannot sync (refused invalidate_args).MILES_VERIFY_WEIGHT_SYNClog of the merged-LoRA updater hashes the pairs it pushed and compares with the engine's checksum of its parameters. The pushed pairs now include the two head stacks, which that checksum does not cover, so for H3 Image the log reads a mismatch. It is log-only; whether it matched for H3 before was not established. Covering the stacks on the engine's read side goes with [Feat] diffusion: [sglang-miles] Load MiniMax-H3 PDD head stacks from a weight update sgl-project/sglang#51654's follow-up.Files
miles/backends/fsdp_utils/models/diffusers/h3_image/weight_bridge.pymiles/backends/fsdp_utils/adaptations/__init__.pymiles/backends/fsdp_utils/configs/h3_image.pytests/fast/backends/fsdp_utils/models/diffusers/h3_image/test_h3_image_weight_bridge.pytests/fast/backends/fsdp_utils/models/diffusers/h3/test_h3_weight_bridge.pytests/fast/backends/fsdp_utils/configs/test_h3_image.pytests/fast-gpu/backends/fsdp_utils/{test_h3_image_head_gradients,_h3_image_head_gradients_worker,test_h3_image_weight_sync}.py