Repository navigation
[H3-Image 3/4] feat(h3-image): add the MiniMax H3 Image train family for t2i Flow-GRPO with LoRA - #395
Open
zhihengy wants to merge 19 commits into
Open
[H3-Image 3/4] feat(h3-image): add the MiniMax H3 Image train family for t2i Flow-GRPO with LoRA#395zhihengy wants to merge 19 commits into
zhihengy wants to merge 19 commits into
Conversation
…PO with LoRA The family key is `h3_image`; `MiniMaxAI/MiniMax-H3-Image` resolves to it over `h3` by the longer name pattern. Its forward runs `MiniMaxH3ImageTransformer2DModel` on the engine's packed t2i layout and selects the PDD output head by the pair's rollout step. It reuses H3's conditioning, FSDP dtype patterns and fused-qkv LoRA group. Argument validation refuses what cannot work yet: any loss but Flow-GRPO, any weight sync that sends the per-step heads, a flow shift, and trainer sequence parallelism.
… refuses The default --diffusion-num-steps 10 passed validation and failed at the first rollout with a 400 that the client retries for a minute, after both sides had loaded the DiT; a micro-batch above one failed at the first train step. The LoRA requirement now applies only to runs that sync weights, a local path spelled h3_image resolves to this family, and the plan test goes through compile_param_dtype_maps like H3's. The test file runs in the default CPU suite like its siblings.
The LoRA check was skipped for --train-only, which syncs nothing but still trains: without --use-lora it would train all weights, the per-step output heads among them. LoRA is now required unless the run has no trainer (--debug-rollout-only); the adapter sync mode is required only of runs that sync. The sync error names the form each topology accepts. A parse-level test drives a launch through the real parser, whose defaults the hand-built namespace did not have.
…d LoRA errors as what they reject The family re-derived the sample x timestep tiles that miles_validate_args has already folded into micro_batch_size, and one test pinned a namespace the parser cannot produce. The loss error claimed no other loss sets the step, which custom_loss can; the LoRA error spoke of training for a run that only has a trainer. Adapters over NCCL, the form non-colocated and async runs use, get an accepted case.
zhihengy
force-pushed
the
h3-image/02-family
branch
from
November 18, 2026 06:30
0ba4145 to
958db5a
Compare
…e checks that read it `miles_validate_args` set `train_only` for a run on dumped rollouts near its end, after the family hook, the LoRA sync check and the sft check had read it. Such a run starts no engine, yet H3 Image refused it for the sync mode of its LoRA.
…an engine `--train-pipeline-config-path` leaves `--diffusion-model-family` unset, and the fused-qkv LoRA group is looked up by that key: the adapters of to_q, to_k and to_v could reach the engine in different buckets, and its merge replaces a fused layer's LoRA with the sections one request carries. The lookup by a second key is on main for every family; here the run is refused by name until the group follows the config class.
…onditions `--diffusion-quality high` alone was told to drop `--diffusion-true-cfg-scale`, and the condition named the one level the engine refuses instead of the two it serves.
`validate_args` reads only `micro_batch_size`, which the parser folds the tiles into before the family hook runs. The cases that set the tile fields on a hand-built namespace read nothing; one launch line through the parser pins the fold order instead.
The only test of the move went through H3 Image's refusal of a merged LoRA sync, which #410 relaxes. A run on dumped rollouts with `--lora-ipc-weight-sync` and no `--colocate` is refused by the shared LoRA sync check when `train_only` is derived after it.
The error blamed the loss, which `validate_args` already restricts to policy_loss. Since the prepare hook takes pairs without `denoising_step_index`, the forward sees None only when an expander did not set the key.
… weights to an engine
The forward handed the pair's step to `pdd_proj_out[step]` as it came: a step of -1 from a custom expander ran the last head without a word, and one past the end raised a bare IndexError.
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 3/4] Stacked on #394. The train family for MiniMax-H3-Image: t2i Flow-GRPO, LoRA only.
Stack:
main<- #393 (step index) <- #394 (loader) <- #395 (family) <- #400 (recipe and model page) and #410 (full-weight training), both on #395. #392 (diffusers 0.43.0) has merged, so the stack runs in the default CI image.What
configs/h3_image.py: familyh3_image, a subclass of the H3 family.MiniMaxAI/MiniMax-H3-Imageand a local.../h3-imageor.../h3_imagepath resolve to it: the id's patternminimax-h3-imageis longer than H3'sminimax-h3. A local path that also containsminimax-h3, such as/data/minimax-h3/h3-image, still resolves toh3and needs--diffusion-model-family h3_image.compute_noise_predrunsMiniMaxH3ImageTransformer2DModelon the engine's packed t2i layout, att = 1 - sigma, through the PDD output head of the pair's rollout step, and negates the result like H3 (H3 predicts clean - noise). A step that names none of the model's heads is refused: the built-in expander cannot emit one, but a custom expander's -1 would index a head from the end.apply_rollout_sampling_paramssetsmin_generation_areato--diffusion-widthx--diffusion-height, so the engine generates on the requested canvas.validate_argsrefuses, before anything loads:policy_loss(no other built-in loss sets the step;custom_lossis untested);--diffusion-flow-shift; trainer sequence parallelism;--use-lora. Only--debug-rollout-only, which has no trainer, is exempt:--train-onlysyncs nothing but would still train the per-step heads;--lora-ipc-weight-sync, or adapters over NCCL without--colocate);--train-pipeline-config-pathfor a run that syncs to an engine: the fused-qkv LoRA group is looked up by--diffusion-model-family, which a config path leaves unset, so the adapters of q, k and v could split across buckets. That second key is on main for every family; here the run is refused by name;--diffusion-num-stepsis 10), more than one image per request (--rollout-microgroup-size,--diffusion-output-num-frames),--diffusion-quality high,--diffusion-true-cfg-scale;--micro-batch-size,--micro-batch-size-sample,--micro-batch-size-tstep), which the packed forward does not take.models/diffusers/h3_image/parallel_plan.py: H3's FSDP dtype patterns, which cover the image DiT's fp32 modules (proj_in,time_embedder,pdd_proj_out).atomic_groups.py:h3_imagegets H3's fused-qkv LoRA group.cli-reference.md: the family key and its task; the three H3-named rollout flags are familyh3's alone;--load-debug-rollout-dataimplies--train-only.miles/utils/arguments.py(shared):train_onlyis derived from--load-debug-rollout-databefore the checks that read it. Four read it before it was set: the family hook, the LoRA sync check, the actor LoRA adapter check (throughrollout_merges_lora) and the sft check. A run on dumped rollouts, which starts no engine, was refused for the sync mode of its LoRA.--load-debug-rollout-data:--lora-ipc-weight-syncwithout--colocate; an rsLoRA or rank/alpha-pattern--lora-adapter-path;--loss-type sft_losswithout--train-only(it passes the train-only requirement and goes on to the next sft check).argsas its explicit--train-onlytwin, which was already accepted.Why
MiniMaxH3ImagePipeline(MiniMaxH3Pipeline)).[A8]pdd_proj_out.*with a warning, so a full-weight run would train heads that never reach the rollout. And on the trainer each rank's pairs can come from different steps, so each rank would give a different head its gradient, which nobody has run under FSDP.[A2][H3-Image] feat(h3-image): support full-weight training (per-step head sync and head gradients) #410 lifts both.min_generation_area: by default the engine generates a 512x512 request on a 2048x2048 canvas and resizes the image back, which is 16 times the tokens for the trainer too.[A2][A2]to_q,to_k,to_vcould reach the engine in different buckets, and its merge replaces a fused layer's LoRA with the sections one request carries.Contract with the engine
The forward reads what the engine's image rollout returns (sgl-project/sglang#51113, the rollout hook for the image denoise loop):
encoder_hidden_states,h3_packed_layout,h3_token_tags, per-step target rows[T + 1, N, 96]fp32, and the trajectory's step numbers. Until #51113 is insglang-miles, CI's engine has no image pipeline, so the CPU tests build their layouts with sglang'sminimax_h3_packed_sequence_ref2va_blocks(latent_t=1,audio_t=0), the function the engine's image path calls.Validation
CPU, on this box, CI-recipe environment with diffusers 0.43.0, head fcd56d4:
test_h3_image.py::test_forward_runs_the_output_head_of_the_pairs_step[fp32, bf16]MiniMaxH3ImageTransformer2DModelwith 3 heads: the prediction for step k equals the negated direct forward withpdd_step_index=kandtimestep=1 - sigma; steps 0 and 2 differ...::test_forward_without_the_rollout_step_is_rejected,...::test_forward_rejects_a_layout_with_reference_rows...::test_forward_rejects_a_step_without_an_output_head[-1, 3]ValueErrorthat names the pair key. Without the check -1 runs the last head and 3 is a bareIndexError...::test_unsupported_training_settings_are_rejected(12 cases),...::test_full_weight_training_is_rejected_even_without_an_engine...::test_lora_flow_grpo_is_accepted,...::test_supported_variations_are_accepted(rollout-only without LoRA, train-only with LoRA, adapters over NCCL without--colocate, 6 eval steps, a config named by path with--train-only)...::test_a_launch_with_the_required_flags_passes_the_real_parserload_fsdp_args,set_default_diffusion_argsandmiles_validate_argson a launch line, with the parser's own defaults...::test_micro_batch_tiles_above_one_pair_are_rejected_through_the_parsermicro_batch_sizebefore the family hook reads it...::test_a_run_on_dumped_rollouts_is_not_held_to_a_sync_modetrain_onlyderivationtest_loss_type_recipes_parse.py::test_a_run_on_dumped_rollouts_counts_as_train_only_for_every_check--use-lora --lora-ipc-weight-syncon dumped rollouts without--colocatevalidates; with the derivation after the shared LoRA sync check it is refused. The H3 Image case above stops discriminating once #410 accepts a merged LoRA sync...::test_a_config_named_by_path_cannot_sync_to_an_engine...::test_parallel_plan_keeps_the_fp32_modules_in_fp32compile_param_dtype_mapspins exactly the parameters under the class's_keep_in_fp32_modulestest_train_pipeline_config_registry.py::test_known_patternsMiniMaxAI/MiniMax-H3-Image,/data/ckpts/h3-image,/data/ckpts/h3_image->h3_image;MiniMaxAI/MiniMax-H3->h3test_lora_atomic_update_groups.py::test_fused_qkv_adapters_share_one_bucket[h3_image]test_h3_image.pyat this headtests/ci/run_suite.py --hw cpu --suite stage-a-cpuat the stack's two tops, which contain this headpre-commit run --all-filesGPU, H200, the released
MiniMaxAI/MiniMax-H3-Imageweights (8ced6006), trainer loaded throughDiffusersModelBackend.load_componentwith a bf16 master, engine from sgl-project/sglang#51113 (TP2). These ran at 5aad91a or earlier; the forward has not changed since, and the loader only in its error paths:compute_noise_predon a 512x512 t2i layout (256 image rows, 20 text rows), random inputs, once per step of the release's grid(1, 256, 96)fp32 predictions; at sigma 0.75 head 3 and head 0 differ by up to 0.28 on the same input; 61.9 GiB allocatedcompute_noise_predon a deterministic rollout's returned latents and conditioning, against the velocity its consecutive latents implyupdate_weights_from_tensorin one bucket or threeUpdated 312 LoRA layers ... (skipped 0 unknown layers); the trainer holding the same adapter predicts the engine's velocity to 1.7-3.0% per step, the trainer without it is off by 9-27%; a zero adapter restores the pre-LoRA image and trajectory bit for bittrain/log_prob_mean_abs_diff0.7e-4 to 1.1e-4;train/model_output_mean_abs_diff0.020 to 0.027 (the trainer's forward against the engine's own model output, whose mean magnitude is about 1);train/prev_mean_diff_over_noise_std0.014 to 0.019; 72 GB peak per GPUNot executed: the GPU suites and the e2e of CI; the adapter sync over NCCL (non-colocated engines) and the async entry point, which accept the same adapters through the same engine call but were not run here. The recipe, its training curve and its e2e are the next PR.
Files
miles/backends/fsdp_utils/configs/h3_image.pymiles/backends/fsdp_utils/models/diffusers/h3_image/{__init__,parallel_plan}.pymiles/backends/training_utils/weight_update/hf_weight_iterator/atomic_groups.pydocs/user-guide/cli-reference.mdmiles/utils/arguments.pytests/fast/backends/fsdp_utils/configs/test_h3_image.pytests/fast/backends/fsdp_utils/configs/test_train_pipeline_config_registry.pytests/fast/utils/test_loss_type_recipes_parse.pytests/fast/backends/training_utils/weight_update/hf_weight_iterator/test_lora_atomic_update_groups.pyNot in this PR
sglang-miles(or aci-sglang-prpin) and the release'stransformer_diffusers/on the CI node.atomic_groups.pyhere;register_param_transformand the encoder hub when full-weight sync or SFT arrive). A class attribute onTrainPipelineConfigwould follow the subclass; it is a change to the frame, not to this family.