Repository navigation
Studio: MiniMax-H3 GGUF video follows the reference recipe and keeps quality through the MP4 export - #17770
Merged
Conversation
fit_h3_reference_image scales each ref2va reference image down (never up) to the "match" or "max" limit, but Diffusers' Ref2VA setup step then rescaled every image reference to its 2048 px short edge, upscaling included. The default "match" therefore ran at the full 2048 token cost with a blurred reference, and "max" upscaled images under 2048 px. Switch the pipeline's Ref2VA setup step to a subclass that skips that rescale for the images the request passed, so the VAE encode and the vision tower both receive the fitted LANCZOS image. One config value cannot express this because references in one request can differ in size. The step is identical in diffusers 0.41.0, 0.42.1 and 0.43.0. Pass ref_image_size=max to stable-diffusion.cpp with reference images: its default "match" rule is not idempotent after the 32 px snap and resized about 8% of fitted images a second time, while "max" leaves an image with a short edge of at most 2048 untouched.
[skip ci]
…licit soundtrack pairing - Pass res_multistep on the simple schedule (Euler on simple for distilled / PDD files) on both the sd-cli argv and the sd-server sample_params. UNSLOTH_H3_SD_CPP_SAMPLER=legacy restores Euler on the discrete grid. - Ask sd.cpp for an uncompressed AVI (sd-cli --lossless-video, sd-server output_format avi_raw, fetched from the job's media_url) when the build offers it, so the x264 / AAC export is the only lossy step. UNSLOTH_H3_SD_CPP_LOSSLESS=0 keeps MJPG. - The export uses the shared x264 stream (frame threads, AVX2-capped libx264). - A silent reference video may precede one with a soundtrack when the build takes --ref-video-audio-index (sd-server: ref_video_audio_indices). - The NaN-render probe also recognises float PCM that is all NaN.
…e types, bound float audio - sd.cpp's MJPG decodes to full-range yuvj420p, which the yuv420p encoder took as limited range and stretched (gain 1.14, offset -16): a real 1344x768 H3 clip came out at 28.0 dB against its frames. Such frames now go through RGB first (37.6 dB). - Decoded frames carry picture type I and libx264 obeyed it, so every export was all-intra (7.9 MB for 5 s). The type is cleared and x264 picks I / P / B (2.9 MB). - Float PCM from the uncompressed AVI is bounded to [-1, 1] with NaN zeroed before AAC, which refuses NaN; 16-bit PCM clipped the same range.
…uilds that take it Builds listing --audio-flow-shift get it on the sd-cli argv and as sample_params.audio_flow_shift on sd-server, and the request is checked like the Diffusers engine instead of refused. Older builds keep the refusal. The saved recipe records the shift that ran.
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
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
Makes Studio's MiniMax-H3 GGUF (stable-diffusion.cpp) video engine follow the reference workflow's sampling recipe and stop losing quality between sd.cpp and the exported MP4. Builds on #17747 (merged).
Needs a new sd.cpp prebuilt. Every new behaviour is gated on what the installed build offers, so this PR is safe on the current pin (
master-982-0518b34-u67cba2c), but the lossless handoff and explicit soundtrack pairing only switch on onceDEFAULT_TAGinstudio/install_sd_cpp_prebuilt.pypoints at a prebuilt that contains unslothai/stable-diffusion.cpp#88. Bump the tag in a follow-up after that fork PR merges and its prebuilt is published.Changes
res_multistepon thesimpleschedule, on both the sd-cli argv (--sampling-method,--scheduler) and the sd-serversample_params. Distilled and PDD files keep Euler, on the samesimpleschedule. Before this, Studio sent no sampler, so sd.cpp ran Euler on its discrete grid (baselinspace(1, 0.001, N)), which spends about one evaluation near sigma 0.UNSLOTH_H3_SD_CPP_SAMPLER=legacyrestores Euler on the discrete grid.--lossless-videowith a.avioutput on sd-cli, oroutput_format: "avi_raw"on sd-server. The server result is downloaded as raw bytes from the job'smedia_urlinstead of base64 JSON. Studio's x264 / AAC export is then the only lossy step.UNSLOTH_H3_SD_CPP_LOSSLESS=0keeps MJPG.transcode_video_to_mp4. These help every build, including the current pin:yuvj420p. Theyuv420pencoder treated them as limited range and stretched them (gain 1.14, offset -16), so they now go through RGB first.--ref-video-audio-index(on sd-server, theref_video_audio_indicesfeature). Older builds keep the refusal. If the soundtracks already pair by position, the argv is unchanged.audio_flow_shiftis no longer refused on builds that accept--audio-flow-shift. It is sent on the argv and insample_params, and the saved recipe records the shift that ran. Older builds keep the refusal.Evidence
studio/backend/tests/test_h3_sd_cpp_parity.py(24 tests). Each export test fails on the base branch: MJPG gain 1.099, 0 inter frames, and AAC raises on NaN audio.test_h3_native_server.py,test_h3_native_nonfinite.py,test_sd_cpp_args.py,test_video_backend.pyandtest_media_auto_switch.py(875 tests). Two failures exist on the base branch as well:test_h3_reference_image_size.py::test_vae_and_vision_tower_see_the_fitted_images[max]andtest_sd_cpp_moss_image.py::test_diffusers_takes_a_moss_safetensors_single_file.Writing the raw container takes 0.7 s, against 2.4 s for MJPG. The cost is temporary disk (about 385 MB per 5 s clip) and a 385 MB loopback download from sd-server. GPU end to end: Colab RTX PRO 6000 Blackwell, Studio defaults (1344x768, 124 frames, 20 steps), runs ordered base, head, head, base. Both runs of each arm were pixel-identical. Base is the current prebuilt plus the base branch; head is the new fork build plus this branch.
On head, the true frames are the raw AVI, which matches PNG frames written by sd-cli exactly. On base, they are the PNG frames that the base prebuilt's sd-cli writes at the same seed.
Denoise and VAE decode times are unchanged. The server handoff drops from 2.0 s to 0.8 s, of which the raw media download is 0.21 s. Python peak RSS rises by 0.55 GB because Studio holds the 385 MB AVI. LPIPS against the Diffusers engine was not measured.