Repository navigation
Studio: video families default to a hosted quantized text encoder - #14000
Conversation
… ComfyUI's templates An unset text_encoder_quant on Wan2.1 / Wan2.2, LTX-2 / LTX-2.3 and HunyuanVideo-1.5 now resolves to the family's te_quant_auto (fp8, the scheme each ComfyUI workflow template loads) and takes the hosted pre-cast file; none / off still pin the released encoder, and an automatic pick the host cannot run or that does not engage loads dense without a refusal. The download plan and memory budget resolve the same default. UMT5-XXL: one fp8 and one int8 ConvRot file in unsloth/Wan2.2-TI2V-5B-FP8 serve all four Wan bases (one equivalence group: Wan2.1's fp32 encoder rounds to Wan2.2's bf16 one bit for bit). The int8 ConvRot loader now builds headless encoder-only classes (encoder.block stack, no lm_head, fp32-kept modules stay fp32) and fills a tied alias the file stores once; the converter gains --drop-tied-copies so the UMT5 fp8 file does not carry the 2.1 GB embedding twice. HunyuanVideo-1.5's Qwen2.5-VL text tower gets unsloth/HunyuanVideo-1.5-FP8 (480p and 720p share it); ByT5 stays dense.
UMT5 / T5 encoder blocks quantize q/k/v/o and wi_0 / wi_1 / wo; --keep-dense leaves named projections dense, and a kept fp32 module (T5 wo) is stored float32. Metadata records the key pattern and the kept projections.
…as ComfyUI's LTX-2.5 templates An unset text_encoder_quant on LTX-2.5 now runs the int8 ConvRot encoder; none / off pin bf16 and UNSLOTH_LTX25_TE_INT8=0 turns the unset default off. The sidecar worker loads unsloth/LTX-2.5-FP8/LTX-2.5-text_encoder-INT8-ConvRot.safetensors (13.03 GB), the saved state dict of its own at-load build (scripts/build_ltx25_te_int8_convrot.py), instead of reading the 23.9 GB bf16 encoder and quantizing it: meta-init from the pack's text_encoder config, Int8ConvRotLinear swap, strict assign, the tied lm_head re-tied. On the real encoder every one of the 1005 tensors and the packed hidden states of 4 prompts are bit-identical to the at-load path. A file that is missing, from another base or does not match falls back to quantizing the dense encoder at load; a scoped snapshot that skipped the dense shards retries the pack's Hub id.
…its dense shards _te_prequant_sources answers for LTX-2.5 from video_ltx25.ltx25_te_prequant_sources, so the estimate, the download plan and the pre-fetch stage the hosted int8 ConvRot file and skip text_encoder/ weights only when it resolves. The worker gets the upstream base id, and a skipped text_encoder is not topped up into the pipeline snapshot (the worker owns it).
Codex Review SummaryThis 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef092f970f
ℹ️ 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".
| from huggingface_hub import hf_hub_download | ||
|
|
||
| return hf_hub_download(spec["repo"], spec["filename"], **common) |
There was a problem hiding this comment.
Resolve the staged LTX encoder from alternate cache roots
When local_files_only is enabled after the Hub cache root has changed, _fetch_te_prequant can successfully stage the hosted file from an older cache root via reuse_other_cache_root=True and consequently omit the dense encoder from the scoped base snapshot. This plain hf_hub_download lookup is pinned to the current cache_dir, so the worker misses that already accepted artifact; _load_dense then refuses its hub_repo retry under local_files_only, leaving neither hosted nor dense weights and failing the load. Use the same alternate-root-aware resolver as the staging path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Real: staging accepts a copy under huggingface_hub's own root, but the worker looked only in the configured cache_dir, so an offline load had neither the hosted file nor the dense shards. Fixed in 9b1563d: _hosted_path does the same switch to the other root as hf_hub_download_with_xet_fallback, and the configured root still wins when it has the file. Test: test_hosted_path_resolves_a_copy_under_the_other_cache_root.
| if config.get("_te_source") != "quantized_at_load": | ||
| raise SystemExit(f"expected the at-load build, got {config.get('_te_source')!r}") | ||
| quantized = sum(1 for m in model.modules() if isinstance(m, _int8_convrot_linear_class())) | ||
| tensors = {k: v.detach().to("cpu").contiguous() for k, v in model.state_dict().items()} |
There was a problem hiding this comment.
Remove the tied LM head before serializing
worker._load does not actually trim this model's head because trim_text_encoder only recognizes Qwen3VLForConditionalGeneration, while Gemma 4 declares lm_head.weight tied to the input embedding in the Transformers implementation. Calling raw model.state_dict() therefore returns both names, and this comprehension makes independent contiguous copies before the custom writer serializes them, so the hosted artifact contains the supposedly omitted 262k-vocabulary BF16 head and is inflated by roughly 2 GB, increasing download and peak host-memory requirements beyond the documented build. Explicitly drop lm_head.weight before constructing the tensor map.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The shipped file does not carry the head: the worker's dead-tail truncation (diffusion_te_truncate.apply_truncation, not trim_text_encoder) swaps the unread head for NoLogitsHead before state_dict(), and the artifact has 1005 keys with no lm_head. The builder relied on that implicitly though, so 9b1563d drops lm_head.weight whenever it shares storage with the embedding. Test: test_builder_drops_a_tied_lm_head.
…ker resolves the hosted encoder across cache roots, builder drops a tied head and builds on the CPU without a card [skip ci]
|
Codex Review: Didn't find any major issues. Delightful! 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". |
….cpp release cannot cover the scene (#14007) ## Summary `studiobench CI / Real-path session, every action ran` failed on #13986 and #14000, which are unrelated. On the same base (a1d4daa) it passed on two other PRs a few minutes later. Both failures are the same click timeout: ``` cell FAILED: TimeoutError: ElementHandle.click: Timeout 8000ms exceeded. - <div class="mt-4 flex shrink-0 flex-wrap items-center gap-x-1 gap-y-2 justify-between">... from <div data-testid="overlay-rail" ...> subtree intercepts pointer events ``` That element is the action row of `LlamaUpdateBanner`, the "llama.cpp update available" card in the bottom-right overlay rail. | run | llama.cpp installed | start (UTC) | result | |---|---|---|---| | #14000 | b11669 | 13:07 | click intercepted | | #13986 | b11669 | 13:06 | click intercepted | | studio-video-unsloth-mirrors | b11681 | 13:09 | pass | | studio-flux3-klein | b11681 | 13:13 | pass | `unslothai/llama.cpp` published b11681 at 13:07:33, between the install and the session. The two failing runs were then one release behind, so Studio offered the update over the controls the scene clicks. Nothing in Studio or in either PR is wrong: any run that straddles a llama.cpp release hits it. ## Change - The `liveness` job boots Studio with `UNSLOTH_DISABLE_UPDATE_CHECK=1`. The backend's llama, whisper and audio update status already honours it and reports `update_checks_disabled`, so no card is offered. The session measures chat rendering against its own pacer, so update UI is not part of what it checks. - `tests/studio/test_studiobench_ci_update_checks_off.py` requires every studiobench job that boots Studio to set it, and checks that the name still matches what `utils/update_status.py` reads. It runs in `workflow-trigger-lint`, as `test_workflow_guards_run_unfiltered.py` requires of workflow-reading guards. ## Testing - New guard: 2 passed. With the workflow change reverted it fails. - `test_workflow_guards_run_unfiltered.py` plus the other tests that read `workflow-trigger-lint.yml`: 176 passed.
|
Two reds on this branch, from the run on a1d4daa:
|
_cast_fp8 imports diffusers' layerwise casting hooks, and the CPU rest shard does not install diffusers, so the test failed with ModuleNotFoundError there. Skip it like the sibling fp8 cast test does.
…miss, MPS Wan int8, exact LTX-2.5 base, claimed repo - An automatic encoder pick whose hosted file is not injected keeps the released encoder instead of casting it at runtime (what video_te_quant_request documents). - An explicit Wan int8 on MPS reaches the hosted ConvRot file instead of being rewritten to fp8 and refused. - The hosted encoder repo is claimed in asset_repos while a load fetches it. - LTX-2.5's hosted encoder replaces only the exact official base (or its HF cache snapshot), not a pack that shares the folder name. - The ConvRot builder also quantizes a non-gated T5 feed-forward (wi). [skip ci]
…e and stays off under Speed off - Only an exactly identified official base (or its HF cache snapshot, or a verified equivalent) takes the hosted encoder by default; a custom pack that shares the folder name keeps its own weights. - Speed="off" is bit-exact: an unset encoder request keeps the released encoder, LTX-2.5's int8 default included. Explicit schemes are unchanged. [skip ci]
…r, keep tied heads LTX-2.5 prices the int8 encoder only when the hosted file applies; the at-load fallback materializes the dense encoder first. Wan's int8 UMT5 gets its own measured budget factor. --drop-tied-copies keeps a tied lm_head, which the loader never fills. [skip ci]
|
Codex Review: Didn't find any major issues. Nice work! 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". |
# Conflicts: # studio/backend/core/inference/diffusion.py # studio/backend/core/inference/diffusion_te_prequant.py
…back reads the cache A load planned at the hosted int8 file's size now refuses the dense quantize-at-load fallback when free memory cannot hold the dense encoder, the offline dense fallback still tries the cached Hub id, and the scheme error no longer suggests unset for bf16. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
Adds nvidia/Cosmos3-Nano and nvidia/Cosmos3-Edge to the Video page through diffusers' Cosmos3OmniPipeline (diffusers >= 0.40.0): text-to-video, and image-to-video from a first frame, following the layout of the Wan2.1 families (unslothai#13376) and the image-to-video path of unslothai#13378. Cosmos3 differs from the other video families in three ways the generic path did not handle, and each gets the smallest change that fits: - Its transformer is also its text model, so the pipeline has a tokenizer and no text encoder. A family whose bf16 component table prices the text encoder at 0.0 is now read as having none: sizing requires only transformer and vae, a cached snapshot without a text_encoder/ folder counts as complete, and an explicit text_encoder_quant is refused with the reason (relates to unslothai#14000). - Each card samples with scheduler and call settings that its shipped configs do not hold. New VideoFamily fields scheduler_overrides and call_kwargs carry them; a scheduler that rejects an override keeps its config. - The pipeline takes the first frame through its own image= argument and crops it itself (i2v_fits_first_frame = False; same pipeline class for both modes). Fidelity, measured against the plain diffusers pipeline at the cards' settings, seed 0, with Studio's own encoder on both sides: every frame identical for Nano (189 of 189, four clips) and Edge (121 of 121, four clips). Three settings were needed to get there and are set on both rows: - cudnn.benchmark off: two server processes otherwise rendered one Edge seed 55 dB (t2v) and 30 dB (i2v) apart. - The VAE encoder stays on the stock kernels: Edge image-to-video at the default speed was 29.5 dB from the card's output through the fused encoder, 51.8 dB with the stock one. - Cosmos3 decodes untiled when it fits, on every speed tier, with tiled decode as the out-of-memory fallback: the stock 16x tiles leave a 4-latent edge tile at 480 / 832 px and a faint seam. The seam is recorded as a strict expected failure in the tile-geometry test so a fix forces the entry out. Also in this commit: the local layout check reads a diffusers-library *Tokenizer component as a model, so Nano's sound_tokenizer/ no longer makes a complete local folder look broken; the download planner recognises the text_tokenizer/-without-text_encoder/ listing as Cosmos3's; the Reasoner, Policy, Sim, Transfer and FP8 builds are refused by name with the repo to load instead; Cosmos3-Super gets no family; the Hub catalog reads Cosmos3 pipelines as "Video gen"; a renamed local Cosmos3 folder is refused by the trainer instead of falling to the SDXL path; and the guardrail opt-out is passed through when the cosmos_guardrail package is absent. Components are fetched from the nvidia repos: no unsloth-hosted copies exist, both repos are public and ungated (OpenMDW-1.1), and the allowlist gains the same two lines Wan2.1 has (relates to unslothai#14003). Quantized Cosmos3 checkpoints are a follow-up (unslothai#12851): diffusers has no single-file converter for Cosmos3OmniTransformer, so a quant needs a hosted source and a key-map loader. Tests: family registry and freeze fixtures, component sizing, flow-shift and scheduler overrides, the i2v class invariant, refusals, local-folder detection, routes, mirrors, and opt-in GPU checks that render both models and compare against the diffusers output.
…ai#14737) ## Problem unslothai#14000 flipped an unset LTX-2.5 `text_encoder_quant` from the bf16 Gemma 4 encoder to int8 ConvRot (`video_ltx25.py` `ltx25_te_quant_scheme`). Before that the code kept int8 opt-in on purpose: "LPIPS 0.310 vs bf16, above the 0.256 compile floor". The PR's own re-measurement is 0.270 mean / 0.484 max, still above that floor, and no quality gate was added for the new default. The Studio UI sends nothing for "auto", so this is the default path for every LTX-2.5 load. It also does not get the claimed download or load saving yet: `unsloth/LTX-2.5-FP8` does not have `LTX-2.5-text_encoder-INT8-ConvRot.safetensors` (checked today, repo head `7b40724f`). So every unset load: - tries to fetch the missing file in the plan, and again in the encoder worker; - reads the full 23.9 GB dense encoder anyway; - quantizes it at load and runs int8. ## Change - An unset or `auto` request on LTX-2.5 resolves to bf16 again. - `text_encoder_quant=int8` still picks int8 (hosted file when it resolves, else quantized at load). - `UNSLOTH_LTX25_TE_INT8=1` makes an unset request int8, as before unslothai#14000. `=0` keeps bf16, so anyone who set the unslothai#14000 kill switch is unaffected. - `none` / `off` and Speed=Off are unchanged. Other video families are not touched. ## Tests - `test_video_ltx25_te_int8.py::test_te_quant_tristate`, `::test_budget_prices_the_int8_encoder` - `test_video_ltx25_te_hosted.py::test_unset_request_keeps_the_dense_encoder`, `::test_int8_request_resolves_to_the_hosted_file`, `::test_the_video_planner_stages_the_hosted_file` - `test_video_te_quant_default.py::test_ltx25_budgets_the_dense_peak_unless_the_hosted_encoder_applies` - `test_video_backend.py::test_plan_is_unchanged_when_no_text_encoder_quant_is_requested` (it now prices LTX-2.5 at the bf16 table like every other family) Against main, 5 of the updated tests fail and the explicit-int8 test passes. On this branch all of them pass. Also passing on this branch: `test_video_ltx25.py`, `test_video_ltx25_prequant.py`, `test_video_unsloth_mirrors.py`, `test_diffusion_te_prequant.py`, `test_video_backend.py` and the three LTX-2.5 encoder files (884 tests, CPU). ## Not covered - No GPU A/B was run here. The quality numbers above are the ones in the code and in unslothai#14000. - Encode speed and peak VRAM of int8 vs bf16 on a real card are not measured. - Once the hosted int8 encoder is published and gated on quality, the default can be revisited.
Adds `nvidia/Cosmos3-Nano` and `nvidia/Cosmos3-Edge` as Studio video families, following #13376 and #13378: text-to-video and image-to-video through diffusers' `Cosmos3OmniPipeline` (diffusers >= 0.41.0: 0.40.0 resolves a group-offloaded transformer's device as the CPU). **What's different about Cosmos3** - Its transformer is also the text model, so the pipeline has a tokenizer and no text encoder. A family whose bf16 component table prices the text encoder at 0.0 is now read as having none: sizing needs only transformer and VAE, a snapshot without `text_encoder/` counts as complete, and an explicit `text_encoder_quant` is refused with the reason (relates to #14000). - Each card samples with scheduler and call settings its shipped configs don't hold. New `VideoFamily` fields `scheduler_overrides` and `call_kwargs` carry them. - The pipeline takes the first frame through its own `image=` and crops it itself. - Components come from the nvidia repos: no unsloth-hosted copies exist, both are public and ungated (OpenMDW-1.1), allowlist gains the same two lines Wan2.1 has (relates to #14003). **Fidelity**: Studio output is frame-for-frame identical to the plain diffusers pipeline for both models (Nano 189/189 frames, Edge 121/121, four clips each, seed 0). Three settings were needed: `cudnn.benchmark` off, the VAE encoder on stock kernels, and untiled decode when it fits, including at speed off and under model / group / streaming offload (the stock 16x tiles leave a 4-latent edge tile at 480/832 px). When untiled does not fit, and on CPU / MPS, the tiled decode uses per-canvas strides that keep every edge tile at 8 or more latents (stock strides wherever they already do). **Also in this PR** (separate commits, can be split out; the root-index prefetch fix moved to #15184) - The latest-transformers offer in the UI covers the `cosmos3` / `cosmos3_edge` model types (the `unsloth run` prompt for it is left to a separate PR). - Frontend: picker rows, Hub "Video gen" label, page defaults; bundle budget raised by the bytes the rows add. **Tests**: backend and frontend suites show no new failures against main (same failing ids on both trees, all environment-related); typecheck clean. Real-weight renders were checked against plain diffusers outside the test suite (Edge on a B200: bit-identical, t2v and i2v; Edge on a T4: valid fp32 output). **Not in this PR**: training support, and quantized Cosmos3 checkpoints (#12851); diffusers has no single-file converter for `Cosmos3OmniTransformer`, so a quant needs a hosted source and a key-map loader. `cosmos_guardrail` is not required: Nano's `model_index.json` enables the safety checker by default, so the load either passes the opt-out or refuses with a message naming the package. Edge ships with it off. **Download and offload**: a Nano download skips `sound_tokenizer/` (1.99 GB, passed as None), a local Nano folder without `sound_tokenizer/` or `vision_encoder/` validates, and under `low_vram` the VAE goes back to the CPU after the conditioning encode for both t2v and i2v (real Edge: VAE on `cuda:0` at every transformer step before, `cpu` after). ## Screenshots Video page model picker on the merge base (left) and this branch (right): the branch lists Cosmos3 Edge after the HunyuanVideo rows.  The Hub pair below is harness state, not this PR: the two sides read the live Hub listing at different times, so the trending rows differ (the masked shot is otherwise identical). macOS and Windows legs: 41 of 41 steps identical. <!-- studio-regress:start --> ### Studio UI regression check Base `c9e5d4ab0` vs head `4aa1f7b91`. Functional: **NO_REGRESSION**, UI coverage 89%, 1 visual change(s), 0 text-only change(s). Only steps whose screenshots differ are shown. **crawl/r_hub**: masks cover 37% of the shot | reproduced on confirm (VISUAL_DIFF) Facts: `missing`: {'before': ['button:DeepSeek-V#.#-Flash-#-GGUF', 'button:Model hub', 'button:NVIDIA-Nemotron-#.#-Super-VL-#B-A#B-GGUF', 'button:Qwen#.#-#B-A#B-GGUF', 'button:Search', 'button:Show workflows', 'button:gemma-#-#B-A#B-it-GGUF'], 'after': ['button:Filters', 'button:MiniMax-H#-GGUF', 'button:NVIDIA-Nemotron-#.#-Super-VL-#B-A#B-GGUF', 'button:Show workflows']}  <!-- studio-regress:end --> --------- Co-authored-by: Daniel Han <[email protected]>
Studio: video families default to a hosted quantized text encoder
An unset
text_encoder_quanton a video load now takes a hosted pre-quantized text encoder, the scheme ComfyUI's official workflow template uses for that family.none/offstill pin the released dense encoder, and an explicit scheme pins itself.unsloth/Wan2.2-TI2V-5B-FP8/Wan2.2-TI2V-5B-text_encoder-FP8.safetensors(new, one file for all four)unsloth/LTX-2-FP8/LTX-2-text_encoder-FP8.safetensors(existing)unsloth/LTX-2.5-FP8/LTX-2.5-text_encoder-INT8-ConvRot.safetensors(new)unsloth/HunyuanVideo-1.5-FP8/HunyuanVideo-1.5-text_encoder-FP8.safetensors(new)What changed
VideoFamily.te_quant_auto, resolved once per load (video_te_quant_request) inload_pipeline, the load worker's plan anddownload_plan, so the memory budget, the staged files and the injection agree. An automatic pick the host cannot run (no CUDA bf16) or that does not engage (file not published, offline) keeps the dense encoder instead of refusing the load. The status badge reports the raw request with sourceauto.text_encoder_quant=int8).encoder.block, no lm_head,_keep_in_fp32_modulesstay float32) and fills a tied alias the file stores once.convert_prequant_to_safetensors.py --drop-tied-copiesstores a tied embedding once; the UMT5 fp8 file is 7.74 GB instead of 9.84 GB.build_te_int8_convrot_checkpoint.pyhandles UMT5.Quality (encoder is the only variable; DiT, VAE, seeds and noise fixed; dense A/A in separate processes is bit-identical)
Subject, scene and composition are preserved in every clip; the differences are sampled motion, pose and framing, with no artefacts. The hosted LTX-2.5 file is bit-identical to the existing at-load int8 path (all 1005 tensors and the packed hidden states).
Through
VideoBackendon Wan2.2 TI2V-5B (640x352, 33 frames): unset loads the hosted fp8 encoder (7.21 GiB resident, status sourceauto),noneloads the dense one (10.58 GiB); peak 20.8 vs 24.1 GiB.VAE (fp8 layerwise vs dense, same latents)
Kept dense: ComfyUI uses dense VAEs, the saving is small next to the DiT and encoder, and fp8 is not lossless.
Tests
tests/test_video_te_quant_default.py(defaults resolve to the hosted file, none/off pin dense, equivalence groups, UMT5 int8 ConvRot build, tied alias fill, converter), plus a load-path test that an automatic pick that does not engage loads dense without a refusal while an explicit fp8 is still refused.