Skip to content

Studio: give the MiniMax-H3 reference denoiser an int8 and fp8 rung - #8329

Merged
danielhanchen merged 6 commits into
mainfrom
h3-ref2va-prequant
Aug 10, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
h3-ref2va-prequant

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The omni-reference (Ref2VA) half of MiniMax-H3 had no pre-quantized rung. Only the keyframe partition did, so a reference run always pulled the bf16 denoiser: 66 GB against the 21 GB the keyframe path had been getting since the prequant work landed, and on a 24 GB card it simply did not run.

Both artifacts are now published in the public unsloth/MiniMax-H3-FP8 repo:

file size notes
MiniMax-H3-Ref2VA-INT8-ConvRot.pt 20.25 GB 313 Linears quantized, 55 skipped, adaLN at full precision, ConvRot group size 256
MiniMax-H3-Ref2VA-FP8.pt 20.26 GB same coverage, no rotation

Both are built from minimax_h3_ref2va_pruned_bf16.safetensors. Measured against the bf16 reference on the same seeds: SSIM 0.92 / 0.82 for INT8-ConvRot, 0.88 / 0.78 for FP8, against a determinism ceiling of 1.00.

What changed

The prequant tables were keyed on scheme alone, which cannot express "this file is for one partition". A (scheme, filename) row now optionally carries a task, so prequant_filenames holds (scheme, task, filename) where it needs to and the old two-tuple form keeps working unchanged. A task-specific row wins over an agnostic one, and a malformed row is skipped rather than raising.

resolve_prequant_source takes the task. A task-specific name deliberately gets no fallback_filename: every other artifact in the repo passes every metadata check while being the wrong partition, so falling back would silently load keyframe weights into a reference run.

The rest follows from the partition actually being opened rather than the literal transformer/: the config subfolder, the download plan's skip set, the seed, the offload pin and the update_components target all route through a new h3_denoiser_component(task), which answers transformer_ref for ref2va.

The blanket ref2va prequant refusal becomes a (scheme, task) availability check that names the partition, and video_family_prequant_schemes takes an optional task so a refusal cannot advertise a scheme that only exists for keyframes.

Tests

test_video_prequant.py +167, test_video_backend.py +193, test_video_routes.py +20. The prequant-relevant files run 352 passed. hub/tests 478 passed. The remaining failures in the full backend suite reproduce identically on an untouched checkout of the same base: test_kv_cache_estimation::test_resolves_real_transformers_arches, three test_mcp_stdio_improvements cases, test_studio_api::test_help_output and the 15 test_studio_api server-startup errors.

No frontend change is needed: the video feature never gated transformer_quant on the task, so the backend refusal is the only contract, and h3_task is already in the request type.

danielhanchen and others added 4 commits August 10, 2026 09:35
MiniMax-H3 ships two denoiser partitions in one base repo: transformer/ for the
keyframe workflow fl2va (which also covers text-only) and transformer_ref/ for the
omni-reference workflow ref2va. Until now only keyframe checkpoints were hosted, so a
quantized reference pick was refused outright: the two partitions share a class, a
config and a 635-key state dict, so seeding the keyframe artifact would have loaded
cleanly, passed every metadata check and generated from the wrong weights.

unsloth/MiniMax-H3-FP8 now also carries MiniMax-H3-Ref2VA-INT8-ConvRot.pt and
MiniMax-H3-Ref2VA-FP8.pt, 20.25 GB and 20.26 GB, built with the same recipe as the
keyframe rungs from the ref2va pruned bf16 source. Wire them up:

- prequant_filenames becomes task-aware. A row may now be (scheme, task, filename),
  which beats the task-agnostic (scheme, filename) row for that task and gets NO
  filename fallback, since every other artifact in the repo would pass every check
  and be the wrong partition. A family with no such row, or a task it says nothing
  about, resolves exactly what it resolved before.
- the blanket ref2va refusal becomes conditional on the (scheme, task) pair. A new
  prequant_partition_tasks field names the tasks that need their own artifact, so a
  scheme with only a keyframe checkpoint is still refused for reference video, and
  the message names only the schemes that cover the task asked for.
- the download plan drops the shards of the partition the load actually opens.
  skip_transformer_weights named the literal transformer/, which a reference load
  never stages, so a ref2va pre-quantized pick dropped nothing and the plan carried
  the full 66.28 GB of transformer_ref/.
- the seed, the offload pin and the denoiser config subfolder all follow the
  partition, through one h3_denoiser_component helper. Seeding "transformer" for a
  reference load leaves the denoise step with no denoiser and pulls the dense
  partition anyway.

Verified against the published artifacts: both load through the pre-quantized path
against the transformer_ref config with no missing or unexpected keys, and render a
640x384 124-frame reference clip. Divergence from the reference-partition bfloat16
denoiser at the same prompt, seed and shape (20 steps): SSIM 0.92 / 0.82 for INT8 and
0.88 / 0.78 for FP8, against a determinism ceiling of 1.00.
resolve_prequant_source now takes task=, and _load_h3_modular_pipeline passes the
workflow through it. The stub in the best-effort None-contract test still had the
old three-parameter signature, so the call raised TypeError before the guard under
test ever ran. Widen the stub; the assertion it guards is unchanged.

@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: 58ba18fa13

ℹ️ 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".

Comment on lines +730 to +732
if not video_family_prequant_available(
fam, requested_scheme, task = h3_task, base_repo = quant_base
):

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 Refuse reference prequants for unmatched pipeline bases

When a Ref2VA request targets a local or Hub derivative selected via family_override, this check still reports the public MiniMax-H3 artifact as available because video_family_prequant_repo falls through to prequant_repos when no variant matches. The load then skips the derivative's dense transformer_ref shards and either fails after checkpoint base validation, or—if the derivative has the same final path segment, which _same_base_model accepts—silently generates with the public reference weights instead of the derivative. This commit newly unblocks that previously refused Ref2VA pairing, so availability must require an exact/equivalent base or a variant-specific entry before accepting and planning the prequant.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one. The fall-through is pre-existing, deliberate and unchanged by this PR.

video_family_prequant_repo is byte-identical to the version on the merge base (3bbed68), and the derivative case it describes already reaches the same conclusion for the keyframe partition today: with family_override = minimax-h3 and a derivative base, video_family_prequant_repo(fam, 'int8', 'unsloth/my-h3-finetune') returns unsloth/MiniMax-H3-FP8 on main just as it does here. This PR only makes ref2va behave the way fl2va already did; it introduces no new tolerance.

The fall-through is also the documented contract, on prequant_variant_repos: a variant that ships its own denoiser gets its own row, and one without a row falls through to prequant_repos where the loader's base_model_id check sends the load back to the dense path. That check is the gate, and prequant_variant_repos is the seam. Requiring an exact base at availability time would refuse a legitimate local-path load of the official pipeline and send it to a 98.7 GB dense download, which is the cost the tolerance in _same_base_model was added to avoid; requiring an equivalent base is what the loader already does.

The narrower same-final-segment hole is real but orthogonal, equally present on the keyframe path, and already has a precedent for where it gets closed when it matters: the conditioner reads the pipeline's own modular index (_h3_te_index_source) rather than tightening the shared resolver. That belongs in its own change covering both partitions, not in this one.

Comment thread studio/backend/core/inference/video.py Outdated
Comment on lines 1966 to 1968
skip_transformer_weights = self._denoiser_prequant_covered(
fam, transformer_quant, base
fam, transformer_quant, base, h3_task
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep dense reference shards when the hosted file is unavailable

When the task-specific Ref2VA filename is absent or its prequant repo cannot be inspected, _denoiser_prequant_hub_files returns no replacement entry, but this independent registry-only probe still returns true and removes every dense transformer_ref weight from the base entry. The resulting download plan can therefore complete without either denoiser, so an offline load fails even though the loader's documented behavior is to fall back to bf16 when the hosted checkpoint is unavailable. The dense-shard skip needs to depend on dq_repo/dq_files actually resolving, as the text-encoder path immediately above already does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and fixed in 1b0ab06. The plan gated the dense-shard skip on _denoiser_prequant_covered, a registry-only probe, while the two encoder skips right above it gate on the artifact actually resolving (te_files / h3_te_repo). So when the Ref2VA file is absent or its repo cannot be read, _denoiser_prequant_hub_files returned (None, []) and the base entry still dropped every dense transformer_ref weight: a plan with neither denoiser, under-reporting by 66 GB, and nothing offline for the documented bf16 fallback to open. Task-specific rows get no filename fallback, which is what makes this reachable here. The skip is now dq_repo is not None and _denoiser_prequant_covered(...); the registry probe stays because it is the half that refuses a non-modular family and an auto request.

Mutation check: test_download_plan_keeps_the_dense_reference_shards_when_its_artifact_is_absent (new) and test_download_plan_keeps_the_dense_denoiser_when_the_prequant_repo_is_missing (which asserted no phantom entry but never the dense shards its own name promises) both fail with the gate reverted and pass with it restored. test_download_plan_still_drops_the_reference_shards_its_artifact_replaces covers the other half, so the gate cannot be satisfied by simply never skipping.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1b0ab0697c

ℹ️ 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".

# Conflicts:
#	studio/backend/core/inference/video.py
@danielhanchen
danielhanchen merged commit d20f3e8 into main Aug 10, 2026
1 of 44 checks passed
@danielhanchen
danielhanchen deleted the h3-ref2va-prequant branch August 10, 2026 11:37

@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: afa93777cd

ℹ️ 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".

Comment on lines 1103 to 1105
skip_transformer_weights = self._denoiser_prequant_covered(
fam, kwargs.get("transformer_quant"), base
fam, kwargs.get("transformer_quant"), base, kwargs.get("h3_task")
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify the reference artifact before skipping dense shards

When the task-specific Ref2VA checkpoint is missing or cannot be fetched, this registry-only probe still returns true, so _predownload_base removes the transformer_ref weight shards before load_prequantized_transformer has established that its replacement is usable. The later documented bf16 fallback then runs against a scoped snapshot without those weights, causing an offline/staged load to fail or an online load to pull roughly 66 GB outside the reported progress and disk budget. Although the download-plan path now gates its skip on dq_repo, the fresh evidence is that the actual _run_load path still has no equivalent denoiser fetch/verification before applying this skip.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct. #8329 merged before this round landed, so the fix is in #8337 (451e6bf).

The plan-side gate I added in 1b0ab06 did not cover _run_load, and you are right that this is the path that matters more: _predownload_base acts on the flag, and nothing re-checks it afterwards. With a task-specific row getting no filename fallback, a renamed, unpublished or gated Ref2VA artifact left the registry saying covered while the dense transformer_ref shards were already gone, so the documented bf16 fallback had nothing to open offline and an online load pulled ~66 GB outside the progress, cancel and disk budget.

_denoiser_prequant_verified is now the registry probe plus the Hub resolution, shaped like _h3_te_quant_scheme_verified two methods down and fail-closed the same way: unanswerable keeps the dense shards.

Mutation check: test_the_verified_probe_keeps_the_dense_shards_when_the_artifact_is_absent covers the four outcomes (absent, published, unreadable repo, bf16) and test_the_load_path_gates_its_dense_skip_on_the_verified_probe asserts over the AST that _run_load reaches the verified probe and not the registry-only one. Both fail with the gate reverted and pass with it restored.

# transformer is never fetched. It must happen BEFORE load_components -- after,
# the dense one has already been pulled and built.
pipe.update_components(transformer = transformer)
pipe.update_components(**{denoiser_component: transformer})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Expose the reference denoiser to the optimization helpers

For a Ref2VA prequant load this seeds only pipe.transformer_ref, but the subsequently invoked apply_attention_backend and apply_speed_optims helpers enumerate only transformer, transformer_2, and unconditional_transformer. Consequently the newly supported reference denoiser silently ignores an explicitly selected attention backend and never receives the regional compile used by the default/max speed profiles; because its pin succeeds, the H3 loader also retains and reports the requested speed profile instead of downgrading to eager. Pass the selected component to those helpers or expose it through an appropriate proxy.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and it is a regression this PR introduced. Fixed in #8337 (451e6bf).

Confirmed against the code: _denoiser_dits and _attention_dits both enumerate exactly transformer, transformer_2, unconditional_transformer, and their docstrings name this failure mode outright ('else the second DiT runs eager / native while status over-reports the optim as engaged'). On main the pin read getattr(pipe, "transformer", None), which is absent on a reference load, so denoiser_pinned stayed False, effective_speed fell to eager, and the report was at least honest. Pinning the partition the load actually opens removed that downgrade, which is what exposed the gap you describe.

Fix follows the seam already in the file: _NamedDiTView generalises _SecondDiTView to present pipe.<component> as pipe.transformer, reading and writing everything else through to the real pipe, and _denoiser_view returns the pipe itself when the component is transformer so a keyframe load is byte-for-byte unchanged.

Mutation check: test_a_named_dit_view_presents_the_reference_denoiser_as_the_transformer shows both enumerators return [] for the bare pipe and the reference DiT through the view, plus write-through and the keyframe identity case; test_the_h3_loader_optimises_the_partition_it_denoises_with asserts over the AST that both helpers are handed the view. Reverting the two call sites to pipe fails them.

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