Repository navigation
Studio MiniMax-H3 video: ship the reference implementation's defaults - #17802
Conversation
Flip the defaults the reference-recipe work kept on the Diffusers engine, so a default render matches what the reference workflow produces: - Decoded reference frames are quantised to 8 bits by truncation, as the reference LANCZOS helper does (astype(uint8)), not rounded. - Output frames leave the decoder on the truncated 8-bit grid, the reference save's (x * 255).clamp(0, 255).byte(); every export path (np, PIL, the on-device uint8 path, the stream encoder) then writes those values. - Dense checkpoints round the time embedding to the compute dtype before the AdaLN SiLU, as the reference does. Curve-form checkpoints are unchanged (they already interpolate the table the reference way). - Keyframe and reference conditions use the VAE posterior mean in float32, as the reference encode returns. UNSLOTH_H3_REFERENCE_LATENT=sample restores the seeded draw rounded to float16. - Keyframes without a size render at the reference node's 1344x768 (first frame stretched, last centre-cropped) instead of an aspect-matched canvas. The page no longer switches to "Match source" on its own; picking it sends the matched size. The page starts at the reference templates' 864x480. - The video decoder stays float16 by default; the int8 ConvRot decoder is opt-in with UNSLOTH_H3_VAE_INT8=1.
The reference workflow saves H.264 at CRF 18, converts RGB with the BT.709 matrix and tags the stream BT.709 / sRGB transfer / limited range, and writes the soundtrack as float AAC. Studio wrote libx264's default CRF 23, let swscale convert with its BT.601 default untagged, and quantised the soundtrack to int16 first. MiniMax-H3 renders now write that file on both the stream encoder and the post-decode encode (encode_x264 reference=True). Other families are unchanged. Frame threading stays: it is a speed lever whose pictures agree with the reference's slice-threaded encode to about 52 dB PSNR.
The page keeps a size the user already picked; 864x480 is what the Default preset applies. Comments and the status field description only.
… path and pinned tests Other families open the x264 stream with the stock call again (the reference flag is passed only for MiniMax-H3), and the tests that pinned the old H3 behaviour expect the reference defaults: the streamed MP4 matches the reference export, a portrait last frame without a size keeps 1344x768, the page builds the request size with requestCanvas, and the recipe report lists the new entries.
…iles The recipe install shims Diffusers' module-level condition encode, as the load does. The recipe tests now restore it after each test, and the condition-encode tests unwrap to Diffusers' own function, so the files pass in any order and worker.
…a work The BT.709 conversion now reuses one swscale reformatter per encode: a per-frame reformat with a colorspace rebuilt the context every frame and cost 2.2x the encoder's own conversion. With it, the reference export costs the same as main except for CRF 18 itself (more bits to entropy-code). The output truncation runs in place on the decode's own float32 frames, so it adds no copy of the clip; it is idempotent on the 8-bit grid, so a fallback that postprocesses the same tensor again still gets the same frames.
The reference templates decode with an int8 ConvRot VAE, not a float one. Decoding the reference's own final latent on one G4, Studio's int8 decoder lands LPIPS 0.00087 from the reference's int8 decode and its float16 decoder 0.00086, while float16 costs 0.84 s more per 124-frame clip and 1.12 GiB more resident VRAM. So the int8 decoder stays the default, as on main; UNSLOTH_H3_VAE_INT8=0 keeps the decoder float16.
The fused q/k RMSNorm + RoPE op gains a second rounding mode. The video denoiser now rotates the bf16 normed values with the bf16 table in float32 (fma(x1, f01, x0 * f00), the reference CUDA kernel's order) and rounds once, instead of diffusers' chain that rounds each product and the sum. Same Triton kernel and device check (bit-exact against the unfused math of the chosen rounding), so speed is unchanged. UNSLOTH_H3_QK_ROPE_ROUNDING=eager restores the old chain; the image pipeline keeps it.
The page only applied the Default preset's size when the preset was picked, so a fresh page rendered at a fit of the generic 768x512 fallback. When a family that declares a first-render size loads, the page now takes it, behind the same gate as the family's default clip length (a stored recipe or the user's own pick still wins).
Where the Triton kernel does not run, the once rotation is an addcmul in float32 (within one float32 bit of the reference kernel's fma) instead of a float64 emulation, which was about 3x slower than the eager chain on a G4. The device check still compares the kernel against the exact float64 emulation.
…ence numerics The conditioner loader recognises the reference workflow's nvfp4_awq file: NVFP4 projections stay packed (15.7 GB resident for the 50 layers, against 27.2 GB for int8) and each call dequantizes the weight in the reference CUDA kernel's order (code * (block scale * global scale) in float32, one rounding; one fused Triton pass on NVIDIA), after the AWQ input scale, then a dense matmul, as the file's full_precision_matrix_mult asks. The int8 embedding is dequantized once at load. No scheme points at the file yet: hosting it is a separate decision.
…wq conditioner An unset text_encoder_quant now takes nvfp4_awq, the conditioner every reference video template loads, read with the reference's numerics. On a G4 its conditioning is within 0.9% of the reference's (int8: 2.2%), the t2va render's LPIPS to the reference render falls from 0.214 to 0.075, peak VRAM drops from 60.1 to 50.4 GiB, host RAM at load from 39.5 to 30.1 GiB, and the encode is no slower. int8 stays an explicit request; nvfp4_awq is auto-only. Merge prerequisite: host the reference templates' qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors unchanged (sha256 35a88d51044231fe332301d7a62aa81e3f2cba62febeb446e2c1e3e0ef76f2c6) in unsloth/MiniMax-H3-FP8 as text_encoders/official/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors. Without it an unset load keeps the dense encoder.
… nvfp4_awq conditioner" This reverts commit bfa004a.
… file is unhosted An unset text_encoder_quant keeps the hosted int8 conditioner, no scheme names an nvfp4_awq file, and a request naming nvfp4_awq is refused at validation with the supported list. The nvfp4_awq loader only engages on a file in that layout.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…le is hosted (no request reaches it) [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbe94376f5
ℹ️ 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".
| if (familyChanged && loadedFamily && applyFamilyDefault) { | ||
| // The family's first-render size (MiniMax-H3: the templates' 864x480), so a fresh page renders it. | ||
| const firstSize = familyFirstRenderResolution(status?.defaults, resolutionPresets); | ||
| if (firstSize) { | ||
| setResolutionIntent(firstSize); |
There was a problem hiding this comment.
Preserve an explicitly chosen resolution when loading H3
If a user chooses a resolution and then unloads/reloads MiniMax-H3 or switches to it from another family, this effect replaces their selection with 864×480. shouldApplyModelDefaults returns true for an already-seeded form unless the current model pick was superseded, so applyFamilyDefault does not establish that the resolution is untouched. Previously, resolutionIntent survived these family transitions and was fitted to the newly loaded family's limits. Gate this first-render initialization on whether the resolution has actually been initialized or explicitly chosen, rather than reusing the clip-length defaults gate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4fa8f10: the first-render size now applies only while the form's size is untouched. Picking a size or restoring a clip's recipe marks it chosen, so a reload or a switch to MiniMax-H3 keeps it (fitted to the family's limits as before).
…-render size only on an untouched form) [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
MiniMax-H3 video on the Diffusers engine now ships the reference implementation's defaults. #17764 matched the recipe (sampler, sigma grid, noise, media handling); this PR flips the divergences it kept on purpose, plus the ones found while checking the reference's pinned workflow templates and the kernels it runs on GPU.
UNSLOTH_H3_QK_ROPE_ROUNDING=eagerastype(uint8))round(x * 255)(x * 255).clamp(0, 255).byte()truncation, as the reference saveUNSLOTH_H3_REFERENCE_LATENT=samplewidth/height, or pick "Match source"Unchanged because they already equal the reference: 20 steps, CFG 1, 124 frames, 24 fps, shifts 12 / 3,
res_multistep+simple, the AdaLN curve, and the int8 ConvRot video decoder (the templates load an int8_convrot VAE; Studio's int8 and float16 decoders are equally close to it, 0.00087 vs 0.00086 LPIPS on the reference's own latent, so int8 stays andUNSLOTH_H3_VAE_INT8=0gives float16). The denoiser file stays Studio's hosted INT8 ConvRot build: the templates' pruned int8_convrot file is no faster, needs 0.74 GiB more VRAM and 16.6 GiB more host RAM at load, and is not consistently closer to the reference render (closer on one t2va case, further on fl2va and on t2va with the reference's conditioning).Speed levers that do not change what the reference computes stay on: compile, INT8 attention routing, the fused VAE kernels, the int8 decoder, tile batching, frame-threaded x264.
The request API keeps 1344x768 for a request without a size (the reference node's default). The page takes the templates' 864x480 for its first render; a size the user picked, or a stored recipe, is kept.
The text encoder default does not change: a request without
text_encoder_quantstill loads the hosted int8 ConvRot conditioner, exactly as onmain. The reference templates' nvfp4_awq conditioner is not adopted: against the bf16 conditioner it is less accurate than the int8 one (per-token cosine 0.99744 vs 0.99990; video LPIPS vs a bf16-conditioner render 0.0876 vs 0.0325).q/k-norm + RoPE
The reference CUDA kernel normalises, rounds the normed value to bf16, then rotates with
fma(x1, f01, x0 * f00)in float32 and rounds once. Diffusers rounds each product and the sum. The video denoiser now uses the reference's rotation in the same Triton kernel (the device check compares it bit for bit against an exact emulation before engaging). On H3's shape (41,811 tokens x 24 heads x 128, rotary 96) against the reference kernel on a G4:The rest comes from the RMS sum order. The image pipeline keeps the eager rounding.
Measurements
Colab G4 (RTX PRO 6000 Blackwell) unless noted, Studio defaults otherwise (hosted INT8 denoiser, compiled), 1344x768x124, 20 steps. Every arm ran in a fresh process. The reference renders come from the reference implementation at
eee5918with exactly the files its templates load; they are bit-identical across two VMs, as are Studio's. LPIPS is AlexNet on every 4th frame.LPIPS to the reference render of the same seed,
mainagainst this PR (the int8 conditioner on both sides). Two G4 VMs ran both sides in fresh processes, and every main/main and PR/PR pair across them is bit-identical, so the differences below are the change, not noise.ref2va_long, the job the condition-latent change targets, is closer on all 3 seeds, which is why the posterior mean stays. t2va has no condition latents: only the RoPE rounding and the output truncation touch it, and its trajectories are chaotic, so a kernel-level change that brings the RoPE within 0.0013% of the reference still moves a single render as much as any perturbation.
Speed and memory against
main, same VM, fresh processes (VM a / VM b):The flips add +0.1 to +0.4 s per clip (at most 0.1%, on the edge of the 0.4 s same-arm spread on one VM; fl2va 4242 is the first fl2va of each VM, cold cuDNN autotune) and leave peak VRAM and the decode peaks unchanged.
Costs beyond noise:
Evidence
scripts/h3_parity/ref_parity.py, default mode): 97/97 after (the original 59/59), 72/97 before. The 38 new checks cover the dense time embedding, the AdaLN curve, the condition posterior, output quantisation, the keyframe canvas, the template defaults and the MP4 export against the reference's own save (pictures 29.4 -> 51.8 dB PSNR, soundtrack bit-identical).tests/test_h3_reference_defaults.py, new cases intest_h3_ref_encode.py,test_video_encode.py,test_h3_qk_rope_exact.pyandtest_video_minimax_h3_attn.py(CUDA cases ran on G4 and A100). Tests that pinned the old behaviour were updated:test_h3_reference_recipe.py: the 8-bit conversion expects truncation ([0, 1, 254], was[0, 2, 255]).test_h3_ref_encode.py: the chunked-vs-stock tests run the explicitsampleswitch, because they compare against Diffusers' sampled encode.test_video_backend.py: a portrait last frame without a size renders 1344x768.test_video_stream_encode.py: the H3 stream is compared with the reference-profile export (CRF 18).test_h3_qk_rope_exact.py: monkeypatched helpers take the new rounding argument.video-start-frame-upload.test.ts: the 1:4 to 4:1 warning shows only where a keyframe would pick the canvas.test_video_*,test_h3_*andtest_openai_videos*file, CPU): the head failures are a subset of base's and all pre-existing in the CPU venv (the chunked-encode contiguity assertion on torch 2.14 and three ffmpeg-missing cases). Head merged with currentmain: 4864 passed, 7 failed; base: 4769 passed, 8 failed (its extra one is a timing flake that passes alone). Frontend: the touchednode --testfiles pass,tscand the Vite build pass.Not covered
Screenshots
MiniMax-H3 on the Video page, using the status a loaded MiniMax-H3 pipeline reports (no weights are loaded for the screenshot). A fresh render now opens at 864 x 480, the reference workflow's default (800 x 544 before):
Uploading a start frame no longer switches the size to Match source; the chosen 864 x 480 is kept: