feat(minimax-h3): support AdaLN curve checkpoints - #1391
Conversation
368970d to
c8695e2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8695e2953
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| bias=True, | ||
| create_cuda_buffer=create_cuda_buffer, | ||
| tp_split="col", | ||
| force_fp32=bool(config.get("h3_adaln_curve", False)), |
There was a problem hiding this comment.
Allocate curve AdaLN offload buffers in FP32
When h3_adaln_curve=true is combined with block CPU offload, the two buffer blocks construct this projection with create_cuda_buffer=True. MMWeightForceFp32.load() delegates that case to the default allocator without converting the buffer, so a BF16 checkpoint creates BF16 AdaLN buffers; later FP32 source weights are copied back into those BF16 buffers, while _compute_adaln_table() passes the curve's FP32 input directly to apply(). This either triggers a mixed-dtype matrix-multiplication error or defeats the required FP32 path, so the force-FP32 implementation must allocate FP32 CUDA buffers as well.
Useful? React with 👍 / 👎.
| bias=True, | ||
| create_cuda_buffer=create_cuda_buffer, | ||
| tp_split="col", | ||
| force_fp32=bool(config.get("h3_adaln_curve", False)), |
There was a problem hiding this comment.
Reject or preserve quantized AdaLN projections
When both h3_adaln_curve and dit_quantized are enabled, this override discards dit_quant_scheme specifically for every AdaLN projection even though the repository's H3 converter includes adaln_proj among its quantization targets. MMWeightForceFp32 then treats the checkpoint's FP8/INT8 weight as an ordinary matrix and ignores its weight_scale, silently corrupting all modulation outputs. Curve mode should either retain a compatible quantized projection or reject this configuration before loading it.
Useful? React with 👍 / 👎.
Summary
adaln_t_tableh3_adaln_curveis explicitly enabledh3_adaln_curve=truewithdit_quantized=truebefore loading because current quantized AdaLN checkpoints require scale-aware projectionsConfiguration contract
Curve-form MiniMax-H3 checkpoints set values matching the table they contain:
{ "h3_adaln_curve": true, "adaln_curve_grid": 1000, "time_embed_dim": 2688 }The checkpoint contains
adaln_t_tablewith shape[adaln_curve_grid, time_embed_dim]instead oftime_embedder.linear_1/2. Converters should populate both dimensions from the actual table shape.Quantized DiT weights are not currently supported together with curve checkpoints. H3's quantization converter includes
adaln_projand emitsweight_scale, while curve mode requires those projections in FP32. The runtime now rejects that unvalidated combination instead of silently ignoring the scales.Compatibility
The default is off, so existing full BF16 and quantized checkpoint paths are unchanged. The representation follows the curve-form MiniMax-H3 checkpoint layout used by ComfyUI; this PR adds LightX2V runtime support and does not claim to originate that format.
After rebasing onto current upstream
mainatf8aee98b5462cca8d7288888146ebd95592bf266, curve mode selects its FP32 pre-projection input inside_compute_adaln_table(). This preserves #1413's cache lookup, TP gather, block-offload, and dynamic-LoRA invalidation paths.Default-ForceFp32now also converts its CUDA offload buffers before FP32 curve inputs reach the projection.Validation
pre-commit run --all-filesGPU validation was not run for this review update because the available V100s were in use.