feat(minimax-h3): hybrid AdaLN overlay (FL2VA base + Ref2VA modulation) - #254
Open
lstein wants to merge 2 commits into
Open
feat(minimax-h3): hybrid AdaLN overlay (FL2VA base + Ref2VA modulation)#254lstein wants to merge 2 commits into
lstein wants to merge 2 commits into
Conversation
- New "Hybrid AdaLN Overlay - MiniMax H3" node swaps a second checkpoint's AdaLN projections onto the loaded transformer at denoise time (block range, optional final layer), re-expressed on the base's curve table for pruned files. - Video panel offers an optional FL2VA quality base + start block on Ref2VA mains; graph, metadata and recall carry it. - OpenAPI schema and legacy types regenerated for the new node/field.
lstein
requested review from
JPPhoto,
Pfannkuchensack and
blessedcoolant
as code owners
September 14, 2026 00:51
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.
Summary
MiniMax H3 ships two task transformers: FL2VA (keyframe conditioning, the better output quality) and Ref2VA (reference conditioning, but a known training defect degrades its output). A tensor-by-tensor comparison (scottmudge/ComfyUI_MinimaxH3HybridLoader) shows the two differ almost only in their per-block AdaLN modulation projections. This PR adds that hybrid as an option: run the FL2VA transformer with Ref2VA's AdaLN projections for a block range (recommended 25..49), so references still route while attention, MLPs and output heads keep FL2VA's quality.
invokeai/backend/minimax_h3/adaln_overlay.py): reads only the selected AdaLN tensors from the overlay checkpoint (mmap; ~1.7 MB/block on the pruned repacks), caches them in the RAM model cache as one record per selection, and swaps them onto the cached transformer for the duration of the denoise with full restoration (out-of-place, alias-preserving for partially loaded weights). No merged checkpoint is written.adaln_t_tablecurve, and the two tables differ (several columns sign-flipped). The overlay re-expresses the coefficients in the base's basis (8×8 least squares), reproducing Ref2VA's modulation on the base curve to float precision; a raw swap only transfers part of it.Hybrid AdaLN Overlay - MiniMax H3(transformer in, overlay checkpoint, start/end block, include final layer). Validates H3 checkpoint, pruned/full kind match, non-empty selection; stamps the transformer's task variant from the overlay so the denoise guard expects references. LoRAs apply on top of the hybrid.Interaction with the Turbo LoRAs
The LightX2V v1.0 Turbo LoRAs (FL2VA 8-step and Ref2VA 8-step 768p) patch only the attention and MLP projections of the 50 blocks and the token refiner; neither carries AdaLN layers (checked against the installed files). The hybrid swaps only the AdaLN projections, so the two act on disjoint weights: LoRA deltas land on FL2VA's attention/MLP, which the reference analysis shows near-identical to Ref2VA's (cosine ≥ 0.9997). The denoise node enters the overlay before the LoRA patcher and unwinds it after, and that order is covered by a test. The older larryvrh v4 Turbo does carry AdaLN layers; on the pruned transformer those are re-injected as output-additive forward hooks driven by the full model's silu(t_emb) grid, so they add on top of the hybrid's modulation and are independent of the curve-basis re-expression.
The video panel keys the accelerator off the top model's task, so on a Ref2VA main with the hybrid enabled it auto-picks the Ref2VA Turbo at 8 steps and leaves the FL2VA Turbo out of the toggle (it can still be added by hand under Concepts). Neither distillation saw the hybrid's mixed modulation path; the Ref2VA Turbo is the safer default in reference mode since it was distilled on reference-conditioned samples, and the FL2VA Turbo is a legitimate experiment. Not measured on real renders.
Related Issues / Discussions
Reference implementation and per-tensor analysis: https://github.com/scottmudge/ComfyUI_MinimaxH3HybridLoader
QA Instructions
Run from the branch worktree (
uv sync --locked --extra rocm --extra testvenv, Node 24 / pnpm 11.8):uv run --no-sync pytest tests/backend/minimax_h3/test_adaln_overlay.py tests/app/invocations/test_minimax_h3_hybrid_overlay.py tests/app/invocations/test_minimax_h3_denoise_adaln_overlay.py→ 23 passed. Covers: selected-only reads and selection paths; overlay == merged-checkpoint denoise output bit for bit (same curve table); curve-basis re-expression reproduces the overlay model's modulation while a raw swap does not; restore on success, mid-swap failure, and CPU-resident re-aliasing; overlay→LoRA composition in the denoise node's order; node validation; denoise materialization plumbing.uv run --no-sync pytest tests/app/invocations tests/backend/minimax_h3 tests/backend/model_manager/load tests/backend/patches tests/model_identification -n logical→ 2301 passed. The 4 failures intest_flux2_working_memory.pyfail identically onmain;test_model_cache_ram_budget.pyfails collection onmaintoo (filterwarningsnot in strict markers).uv tool run ruff@0.11.2 check/format --checkon changed files: clean.pnpm -C invokeai/frontend/webv2 lint(format, oxlint, tsc, architecture): clean.pnpm -C invokeai/frontend/webv2 test src/features/video src/workbench/image-actions/videoRecall.test.ts→ 290 passed (graph wiring, policy slot/filter, selection clearing, persisted-state healing, catalog sync, comparator, recall incl. the block-only-with-its-base rule).python scripts/generate_openapi_schema.py→openapi.json+pnpm typegen;pnpm -C invokeai/frontend/web lintclean.VideoComponentsSectionin Chromium (vitest browser mode) with a Ref2VA main, FL2VA base and encoder selected — the slot and slider render under the base slot with help text; axe reported only the pre-existing select-value contrast of the shared picker under the bare test harness.Review
Three independent read-only reviews (correctness/spec; architecture/safety/performance; tests/product quality) plus a final adversarial fresh-context review of the diff. Material findings resolved: full-checkpoint overlays loaded all 50 blocks (~26 GB) regardless of range → records are now per selection and read only the selected tensors; restore duplicated CPU-resident weights outside the cache's accounting → restore re-aliases the canonical tensor; recall could apply a recorded start block onto a different base → gated on the base being recalled; pruned raw swap ignored the per-file curve basis → change of basis added; overlay/LoRA composition order and the hand-maintained sync/comparator field lists were untested → covered. Final adversarial review: no material findings.
Compatibility / Rollout
MiniMaxH3TransformerFieldgains an optionaladaln_overlay(defaultNone); existing workflows and theminimax_h3_denoise/ loader node versions are unchanged. OpenAPI andschema.tsregenerated.normalizeVideoSettings(h3HybridBaseModel: null, start block 25).Checklist
What's Newcopy (if doing a release after this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01ShQCN86ix9DEFBuAVoH2Hb