Skip to content

feat(minimax-h3): support AdaLN curve checkpoints - #1391

Open
Leonccaa wants to merge 2 commits into
ModelTC:mainfrom
Leonccaa:agent/upstream-h3-adaln-curve
Open

feat(minimax-h3): support AdaLN curve checkpoints#1391
Leonccaa wants to merge 2 commits into
ModelTC:mainfrom
Leonccaa:agent/upstream-h3-adaln-curve

Conversation

@Leonccaa

@Leonccaa Leonccaa commented Aug 17, 2026

Copy link
Copy Markdown

Summary

  • support MiniMax-H3 checkpoints that replace the timestep MLP with an adaln_t_table
  • linearly sample the table at normalized timesteps with boundary clamping
  • keep the curve table, its AdaLN consumers, and block-offload device buffers on the FP32-sensitive path
  • preserve the existing full-checkpoint path unless h3_adaln_curve is explicitly enabled
  • integrate curve inputs with the request-level AdaLN cache added in perf(minimax_h3): cache AdaLN outputs across requests #1413
  • reject h3_adaln_curve=true with dit_quantized=true before loading because current quantized AdaLN checkpoints require scale-aware projections
  • add interpolation, input-validation, cache-hit, default-path, offload-buffer, and configuration-boundary regression tests

Configuration 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_table with shape [adaln_curve_grid, time_embed_dim] instead of time_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_proj and emits weight_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 main at f8aee98b5462cca8d7288888146ebd95592bf266, 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-ForceFp32 now also converts its CUDA offload buffers before FP32 curve inputs reach the projection.

Validation

  • repository-pinned pre-commit run --all-files
  • Ruff 0.11 lint and format checks
  • Python bytecode compilation
  • PyTorch 2.11 CPU interpolation checks for clamping, exact interpolation, and invalid inputs
  • PyTorch 2.11 CPU checks for curve-mode cache miss/hit reuse and the unchanged full-checkpoint SiLU/dtype path
  • PyTorch 2.11 CPU regression for FP32 offload-buffer loading and projection
  • CPU configuration regression proving quantized curve checkpoints are rejected before model loading

GPU validation was not run for this review update because the available V100s were in use.

@Leonccaa
Leonccaa force-pushed the agent/upstream-h3-adaln-curve branch from 368970d to c8695e2 Compare August 23, 2026 01:53
@Leonccaa
Leonccaa marked this pull request as ready for review August 23, 2026 01:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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