Skip to content

Studio: run ComfyUI-format video quants on the int8 / fp8 runtimes - #12851

Merged
danielhanchen merged 43 commits into
mainfrom
studio/comfy-format-video
Oct 6, 2026
Merged

danielhanchen merged 43 commits into
mainfrom
studio/comfy-format-video

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Builds on the ComfyUI quant loader already in main. The diff touches only the video path, the shared loader's layout hooks, and the native int8 twin.

Problem

Main loads ComfyUI-format quantized single files correctly on the image side and runs their int8 / fp8 layers on Studio's runtimes for image DiTs. On the video side it only removes the noise: a ComfyUI int8 or fp8 video DiT was dequantized to bf16 on load, because a single-file video load never reaches Studio's int8 / fp8 runtime. So the file loaded, but it ran as a bf16 model of twice the size, at bf16 speed, with the quantization error and none of the savings. Three families did not load at all:

  • HunyuanVideo-1.5. diffusers registers no single-file converter for HunyuanVideo15Transformer3DModel. Every original-layout file (ComfyUI's fp16 and fp8_scaled ones, our INT8 conversion) failed with FromOriginalModelMixin is currently only compatible with ... on the older main and has no single-file converter on current main.
  • LTX-2.3. The 2.3 assembler refuses any DiT with .weight_scale keys as "scaled fp8". That covers our ComfyUI INT8 and FP8 conversions and Lightricks' own ltx-2.3-22b-distilled-fp8.safetensors (an int8 file got the fp8 message too).
  • MiniMax-H3. A modular workflow, so model_kind=single_file is refused outright. ComfyUI's H3 denoisers (minimax_h3_fl2va_pruned_int8_convrot / _fp8_scaled) could not be used at all, and diffusers has no H3 single-file converter either.

Change

int8 / fp8 keep for video single files (video.py). A ComfyUI-quantized Wan / HunyuanVideo-1.5 / LTX-2.3 file keeps its codes, by the same rules Studio's own quant follows on that card and plan:

  • int8_tensorwise layers (with or without ConvRot) go to the torchao Int8Tensor when the DiT is resident, and to the torchao-free native twin when the plan offloads it.
  • float8_e4m3fn layers go to Studio's per-row torchao fp8 weight when resident, built by main's fp8 decoder (a per-tensor scale is the same scale on every row). Under offload on NVIDIA, fp8 is dequantized, as Studio's own fp8 is resident-only there.
  • Precision "Off" dequantizes everything, as asked.
  • The badge and the resolved record name the file and the counts (ComfyUI-quantized checkpoint (X): 303 int8 / 0 fp8 layers kept (torchao runtime), 0 dequantized), and a quantized DiT is compiled like any other (transformer_quant engaged).
  • The memory plan prices the file from its header: kept layers at their stored size plus scales, dequantized ones at bf16. Before, an fp8 file dequantized on load was planned at half its resident size.

HunyuanVideo-1.5 key map (video_hv15_comfy.py). Renames onto the diffusers names plus row-only reshapes (the fused img_attn_qkv / txt_attn_qkv / refiner self_attn_qkv split into q / k / v by thirds; final_layer.adaLN_modulation.1 swaps its shift / scale halves). Rows move whole, so codes and per-row scales stay exact. Checked against the diffusers model: every key and shape of ComfyUI's fp8_scaled file and of our INT8 file maps, none missing or extra. An unquantized original-layout file loads through the same map.

LTX-2.3 (video_ltx2.py). load_ltx23_comfy_transformer reads only the DiT keys of the bundled file, applies the 2.3 pre-rename and the stock converter, and hands the result to the 2.3 assembly as its transformer override; the assembly still reads the connectors, VAEs and vocoder from the same file, or from the extras for a DiT-only file. A quantized layer outside the DiT is refused by name rather than dropped.

MiniMax-H3 (video_minimax_h3_comfy.py, video.py). A minimax_h3_* single file that is a ComfyUI int8 / fp8 (or the dense pruned bf16) denoiser is accepted; the Qwen conditioner, the VAEs and packed w6a8 / nvfp4 / mxfp files are still refused before anything downloads. It is seeded into the modular workflow exactly where a hosted checkpoint is (before load_components, so the released 66 GB denoiser is never fetched), with:

  • a key map (renames, the fused qkv split by thirds, mlp.fc1 halves swapped to SwiGLU's [value; gate], adaln_t_table as time_embedder.table),
  • the pruned curve adaLN installed from the table's shape,
  • the float32 tensors the pruned model keeps,
  • the partition (fl2va / ref2va) read from the file name and checked against h3_task,
  • torchao int8 / fp8 only, since H3's pin / stream / residency path is built on torchao weights; a quantized file with no runtime on the device is refused instead of dequantized to 40 GB.

The base download skips the denoiser partition the file replaces (transformer_ref/ included).

Shared loader (diffusion_comfy_quant.py, on top of main's fp8 keep, comfy_fp8_backend, UNSLOTH_DIFFUSION_COMFY_FP8 switch and comfy_resident_mib):

  • keep_key / pre_convert (bundled files),
  • key_map / prepare_model / keep_dtype (converter-less layouts, with no float64 row tags, so H3's 21 GB file does not need ~108 GB of tags),
  • a lazy registry, so any caller (single file or a hosted ComfyUI-format twin) finds the HunyuanVideo-1.5 / H3 layouts by transformer class,
  • keep_key and int8 exclude tokens on comfy_resident_mib, for the bundled LTX file and the families whose int8 skips some layers.

Main's guard that a local ComfyUI-format prequant override is usable only for an image family is unchanged. Video's hosted prequant loader still reads only Studio's own format, and the video ComfyUI files here load through the single-file route, which that guard does not touch.

Native int8 activation layout (diffusion_native_quant.py). The torchao-free int8 twin used under offload hands its int8 activation to torch._int_mm, and cuBLASLt accepts that operand only row-major. Studio's own int8 always applies ConvRot, whose rotation is a matmul with a row-major output. A ComfyUI int8 file without ConvRot skips the rotation. Fed a transposed view, as HunyuanVideo-1.5 does, its codes reached cuBLASLt column-major and the first step failed with CUBLAS_STATUS_NOT_SUPPORTED. Inductor keeps that layout even through .contiguous(). So on un-rotated layers the codes now go through a small opaque row-major copy (unsloth_studio::native_row_major) when compiling, or when they are not contiguous in eager. Rotated layers are unchanged.

Results

Measured on this branch before main's fp8 decoder was merged in: int8 is unchanged by that merge, while fp8 layers are now built by main's decoder. After the merge, a load-and-render smoke of Wan2.2-5B int8, HunyuanVideo-1.5 int8 and a Z-Image int8 ComfyUI twin passed (see Tests). One B200, torchao 0.17.0 unless marked, two prompts per cell, same seed / frames / size / steps in every arm. LPIPS is the mean over all frames of both clips. "Old main" is main before the ComfyUI quant loader; "main" is the commit that added it, whose video path is the same as current main's (video.py and video_ltx2.py are unchanged since). Re-running a cell gave identical frames for Studio's own int8 and for the Wan ComfyUI int8 file, and LPIPS 0.015 for the HunyuanVideo-1.5 ComfyUI int8 file, so differences smaller than that are noise. Peak VRAM is torch's peak allocation.

Wan2.2-TI2V-5B (1280x704, 49 frames, 20 steps; LPIPS vs Studio bf16)

File old main main This PR Peak VRAM (PR) Host RSS (PR)
ComfyUI int8 (int8_tensorwise) noise, 0.974 dequantized to bf16, 0.063, 29.1 GiB 303 int8 layers kept (torchao), 0.130 24.5 GiB 25.1 GiB
same, Precision Off 303 dequantized, 0.063 29.1 GiB 29.6 GiB
same, torchao 0.18.0 303 kept, 0.138 24.5 GiB 25.0 GiB
same, low VRAM (model offload) 303 kept (native int8), 0.117 10.9 GiB 35.3 GiB
ComfyUI fp8 (float8_e4m3fn scaled) noise, 0.981 dequantized, 0.132, 29.1 GiB 300 fp8 layers kept, 0.142 24.5 GiB 25.1 GiB
Studio int8 (own path) 0.112 24.5 GiB 29.0 GiB
Studio int8, low VRAM 0.077 10.8 GiB 35.6 GiB
Studio fp8 (own path) 0.150 24.5 GiB 29.0 GiB
bf16 reference 29.1 GiB 43.3 GiB

The ComfyUI int8 file now runs in the same VRAM as Studio's own int8 (24.5 GiB, down from 29.1 GiB on main). Its codes are bit-identical to what Studio's runtime quantizer produces. The one-forward error vs bf16 on the same DiT and inputs is about the same: 0.0600 vs 0.0592 relative L2 on torchao 0.17.0, 0.0588 vs 0.0566 on 0.18.0, and the native (offload) twin 0.0591. The 0.130 vs 0.112 video LPIPS comes from two prompts and has no confidence interval.

HunyuanVideo-1.5 480p t2v (848x480, 49 frames, 20 steps)

File old main main This PR Peak VRAM (PR) Host RSS (PR)
ComfyUI-layout int8 (vs bf16) load fails (FromOriginalModelMixin) load fails (no converter) 324 int8 kept, 0.202 (repeat 0.193) 32.9 GiB 27.8 GiB
same, Precision Off dequantized, 0.196 35.5 GiB 35.4 GiB
same, torchao 0.18.0 0.195 33.0 GiB 27.8 GiB
same, low VRAM native int8, 0.185 14.3 GiB 44.9 GiB
Studio int8 (vs bf16) 0.205 32.9 GiB 23.8 GiB
Studio int8, low VRAM 0.168 14.2 GiB 46.8 GiB
Comfy-Org hv15_480p_t2v_cfg_distilled_fp8_scaled (vs Comfy-Org fp16 of the same model) load fails load fails 781 fp8 kept, 0.300 27.7 GiB (fp16: 35.5) 17.5 GiB
Studio fp8 (vs bf16) 0.396 27.7 GiB 23.8 GiB

The ComfyUI int8 and Studio int8 renders are 0.058 LPIPS apart. Comfy-Org's fp8 file is the cfg-distilled checkpoint, a different model from the diffusers 480p_t2v repo, so it is scored against its own fp16 file loaded the same way.

MiniMax-H3 (fl2va pruned, 960x544, 56 frames, 12 steps; LPIPS vs ComfyUI's pruned bf16 denoiser in Studio)

File old main / main This PR Peak VRAM Host RSS
ComfyUI minimax_h3_fl2va_pruned_int8_convrot refused (cannot load from a single .safetensors checkpoint) 300 int8 kept (ConvRot), 0.171; torchao 0.18.0 0.160 54.5 GiB 55.8 GiB
our INT8-ConvRot in ComfyUI format refused 313 int8 kept, 0.197 53.7 GiB 54.6 GiB
Studio hosted INT8-ConvRot (own path) 0.218 54.2 GiB 58.7 GiB
ComfyUI minimax_h3_fl2va_pruned_fp8_scaled refused 300 fp8 kept, 0.270 52.6 GiB 55.8 GiB
our fp8 in ComfyUI format refused 313 fp8 kept, 0.252 51.9 GiB 51.4 GiB
Studio fp8 (own path) 0.166 51.9 GiB 39.9 GiB
ComfyUI pruned bf16 refused reference 70.8 GiB 70.0 GiB

ComfyUI's int8_convrot file comes closer to the bf16 output than Studio's hosted int8, in the same VRAM. The ComfyUI fp8 files carry one scale per tensor, while Studio's fp8 has one per row; that is why they land further from bf16 than Studio's fp8. Studio's H3 low VRAM mode keeps this DiT resident on a 180 GB card, so H3 offload was not exercised.

LTX-2.3 22B distilled (768x512, 49 frames, 8 steps; LPIPS vs Studio on the official bf16 file)

File old main / main This PR Peak VRAM Host RSS
our int8 in ComfyUI format (ltx-2.3-22b-distilled-INT8-comfy) refused ("scaled fp8") 480 int8 kept, 870 audio, audio-video cross-attention and adaLN layers dequantized (Studio's int8 excludes the same names), 0.158 55.6 GiB 92.2 GiB
same, Precision Off refused 1350 dequantized, 0.056 67.6 GiB 99.0 GiB
same, torchao 0.18.0 0.160 55.7 GiB 92.3 GiB
same, low VRAM 0.151 24.7 GiB 114.7 GiB
our fp8 in ComfyUI format refused 1360 fp8 kept, 0.171 50.0 GiB 82.2 GiB
Lightricks ltx-2.3-22b-distilled-fp8 refused 1204 fp8 kept, 258 dequantized, 0.070 52.2 GiB 78.0 GiB
Studio fp8 (hosted unsloth/LTX-2.3-FP8, own path) 0.093 50.0 GiB 46.8 GiB
official bf16 reference 67.6 GiB 46.8 GiB

The 0.056 at Precision Off is the int8 file's own rounding error alone. Our ComfyUI fp8 file has one scale per tensor and Studio's hosted fp8 one per row: same VRAM, 0.171 vs 0.093. Of Lightricks' 1462 fp8 layers, the 258 that Studio's own fp8 would not quantize are dequantized, by the same filter (minimum size, the family excludes, 16-aligned features).

Speed (exclusive B200, one prompt, each arm twice, interleaved; s/step from the long minus the short run)

Model Arm s/step (run 1 / run 2) Clip wall s (run 1 / run 2)
Wan2.2-5B bf16 0.342 / 0.297 7.59 / 7.42
Wan2.2-5B Studio int8 0.311 / 0.304 6.99 / 10.47
Wan2.2-5B ComfyUI int8, main (dequantized) 0.308 / 0.312 7.41 / 7.02
Wan2.2-5B ComfyUI int8, this PR 0.291 / 0.339 6.58 / 8.22
HunyuanVideo-1.5 bf16 0.282 / 0.273 6.73 / 7.19
HunyuanVideo-1.5 Studio int8 0.292 / 0.188 6.74 / 7.51
HunyuanVideo-1.5 ComfyUI int8, this PR 0.291 / 0.300 7.12 / 7.15
LTX-2.3 bf16 0.121 / 0.171 1.42 / 1.81
LTX-2.3 ComfyUI int8, this PR 0.160 / 0.163 1.95 / 1.66
LTX-2.3 Lightricks fp8, this PR 0.170 / 0.166 1.79 / 1.71
MiniMax-H3 Studio int8 0.847 / 0.940 11.91 / 12.76
MiniMax-H3 ComfyUI int8_convrot, this PR 0.923 / 0.943 12.65 / 12.97
MiniMax-H3 Studio fp8 1.023 / 0.907 13.60 / 11.82
MiniMax-H3 ComfyUI fp8_scaled, this PR 1.106 / 0.877 12.55 / 11.79

The same arm repeats with up to 35% spread (the host was shared with other jobs' CPU load), so these show only that the ComfyUI files run at the speed of Studio's own quant path within that noise. They are not a speed claim.

Low VRAM (model offload, the native int8 twin), same card and protocol. HunyuanVideo-1.5: the ComfyUI int8 clip took 9.49 / 8.29 s against 9.79 / 9.51 s for Studio's own int8. Wan2.2-5B swung from 11 to 42 s within one arm, so it shows nothing either way.

The row-major copy costs this much in isolation: a compiled stack of 4 native int8 Linears (no ConvRot), CUDA-event median of 50 forwards x 7, three runs:

Shape (tokens x features) Input Before the fix After the fix
11440 x 3072 (Wan2.2-5B) contiguous 0.654 / 0.674 / 0.659 ms 0.693 / 0.695 / 0.695 ms
11440 x 3072 transposed view 0.659 / 0.662 / 0.660 ms 0.797 / 0.797 / 0.799 ms
20670 x 2048 (HunyuanVideo-1.5) contiguous CUBLAS_STATUS_NOT_SUPPORTED 0.699 ms
20670 x 2048 transposed view CUBLAS_STATUS_NOT_SUPPORTED 0.830 ms

So an un-rotated layer pays about 5% (or 21% after a transposed producer) on its Linear forward, in exchange for not crashing when the token count is not aligned. Studio's own int8 is rotated and does not take this path.

torch.compile. torch._dynamo.explain on one forward of the real DiT gives the same graph count and breaks as Studio's own int8:

  • Wan2.2-5B: 1 graph, 0 breaks for Studio int8, the ComfyUI file on torchao, and the ComfyUI file on the native twin, on both torchao versions.
  • HunyuanVideo-1.5: 3 graphs, 2 breaks in all three. The breaks are the model's own data-dependent is_t2v branch.

The renders themselves did not record graph breaks: TORCH_LOGS output does not reach the cell logs.

Native int8 crash fix. HunyuanVideo-1.5 int8 under low VRAM crashed with CUBLAS_STATUS_NOT_SUPPORTED on the first step. The cause is in the native twin, not the file. A layer without ConvRot that is fed a transposed view hands cuBLASLt a column-major int8 activation. Inductor keeps that layout even through .contiguous(). Studio's own int8 always rotates, so it never reached this. The fix is a small opaque row-major copy of the int8 codes, applied only on un-rotated layers. The new test fails without the fix (eager and compiled) and passes here, on both torchao versions. Wan's low VRAM frames are bit-identical before and after the fix.

Tests

  • New tests/test_video_comfy_quant.py (18 test functions): the H3 and HunyuanVideo-1.5 key maps (every row range, the qkv thirds, the swapped halves, unknown keys refused), H3 file-name acceptance (int8 / fp8 / bf16 accepted; Qwen conditioner, VAE, w6a8, nvfp4 refused), the curve adaLN metadata, key_map on the dequantize / native int8 / torchao int8 backends with codes compared bit for bit, out-of-range rows refused, keep_key / pre_convert on a bundled file (a quantized layer outside the DiT refused), the LTX-2.3 pre-rename, header-only resident size, the backend policy per plan (resident, offload, Precision Off), the layout registry.
  • tests/test_diffusion_comfy_quant.py: unchanged; main's fp8 tests cover the fp8 keep.
  • H3 refusal tests in test_video_prequant.py / test_video_routes.py now use a Qwen conditioner file name, since a minimax_h3_*_int8 denoiser is now accepted on purpose.
  • Video, ComfyUI, prequant and native quant suites (tests/*video*, *comfy*, *ltx*, *h3*, *minimax*, *diffusion_prequant*, *diffusion_native_quant*, *transformer_quant*), CPU only:
Tree torchao Tests Failed Skipped
main's loader commit 0.17.0 3127 1 103
main's loader commit 0.18.0 (latest) 3127 0 116
This PR 0.17.0 3160 1 106
This PR 0.18.0 (latest) 3160 0 119

The one failure on 0.17.0 is the same test on both trees (test_diffusion_native_quant.py::test_unpinned_torchao_host_copy_is_a_distinct_wrapper_over_the_same_data), so it predates this PR. The new test file fails to import there, as expected.

  • tests/test_diffusion_native_quant.py: test_int_mm_takes_a_transposed_activation_without_rotation (eager and compiled), CUDA only. GPU runs of test_diffusion_native_quant.py (with only this test added on main's loader commit), plus test_video_comfy_quant.py and test_diffusion_comfy_quant.py on this PR:
Tree torchao Result
main's loader commit + new test 0.17.0 the new test fails eager and compiled (CUBLAS_STATUS_NOT_SUPPORTED); 2 other failures
main's loader commit + new test 0.18.0 the new test fails eager and compiled; everything else passes
This PR 0.17.0 200 passed; the same 2 other failures
This PR 0.18.0 202 passed

The 2 other failures on 0.17.0 (test_unpinned_torchao_host_copy_is_a_distinct_wrapper_over_the_same_data, test_unpinned_torchao_stream_group_offload_leaves_nothing_resident) fail on both trees.

  • After merging current main (CPU): every tests/*diffusion*, *video*, *comfy*, *ltx*, *h3*, *minimax*, *prequant*, *transformer_quant* file, 12227 tests per venv:
torchao Failed Skipped
0.17.0 2 509
0.18.0 1 518

Both failures also happen without this branch:

  • test_build_prequant_checkpoint.py::test_the_recorded_base_must_be_the_canonical_id_not_just_the_same_tail needs a repo this offline host does not cache.

  • On 0.17.0 only, test_unpinned_torchao_host_copy_is_a_distinct_wrapper_over_the_same_data fails as noted above.

  • GPU smoke after merging main (B200, load plus one short render each):

Smoke Result
Wan2.2-5B ComfyUI int8, 832x480, 17 frames, 4 steps 303 int8 layers kept (torchao), 20.1 GiB peak
HunyuanVideo-1.5 ComfyUI-layout int8, 848x480, 17 frames, 4 steps 324 int8 layers kept (torchao), 30.3 GiB peak
Z-Image-Turbo hosted -ComfyUI int8 twin (image path, from a local mirror), 1024x1024, 8 steps seeded from the twin, 239 int8 layers kept (ConvRot), 14.9 GiB peak

Not covered

  • Wan2.2 A14B. ComfyUI ships it as two expert files, and the single-file route takes one file, so A14B is still refused. Untested.
  • LTX-2.3 file names. The generation recipe for 2.3 (the fixed 8-step sigma curve, STG and modality passes off) is picked from the file name. The 2.3 assembly instead defaults to the distilled companions. So a distilled conversion whose name says neither "distilled" nor "dev" is sampled with the dev recipe. Our first LTX run used LTX-2.3-INT8-comfy.safetensors and scored LPIPS 0.56 against bf16 even with every layer dequantized. Renamed to ltx-2.3-22b-distilled-*, the same bytes give the numbers above. This behaviour is unchanged here; any hosted 2.3 ComfyUI file should keep "distilled" in its name.
  • LTX-2.3 int8 vs Studio. Studio has no int8 path of its own for a 2.3 single file (transformer_quant='int8' is refused there), so the ComfyUI int8 file is compared to bf16 and to Studio's hosted fp8 only.
  • LTX-2.3 host RAM. The ComfyUI DiT is built in host memory. The official bf16 file instead streams its DiT straight to the GPU (UNSLOTH_VIDEO_DIRECT_LOAD), hence the higher peak RSS shown above. Not addressed here.
  • H3 offload. H3 under offload or low VRAM was not run: this card keeps the DiT resident. The fp8 file's input_scale is not used (Studio's fp8 quantizes activations per row, as its own path does).
  • Hosted defaults. Hosted int8 / fp8 rows for the conventional video families are not added. Adding them would switch auto from bf16 to int8 seeding and change today's default. A ComfyUI file from any repo already works through the single-file route.
  • Hardware. Only B200 (sm100) with torch 2.11 / 2.12 was tested. No Ampere / Ada / Hopper, ROCm, Windows or Mac runs. The fp8 keep needs an fp8-capable NVIDIA card and falls back to dequantize elsewhere, by the same rule as Studio's own fp8.
  • Speed. Per-step timings are within the A/A spread on a host shared with other jobs. No speedup or slowdown is claimed beyond that.
  • Graph breaks come from torch._dynamo.explain on one forward of the real DiT, not from the renders.

UI: Video page after loading a ComfyUI int8 file

Loading wan2.2_ti2v_5B_int8.safetensors (ComfyUI int8_tensorwise Wan2.2-TI2V-5B) as a single file, Advanced > Loaded build. Before (merge base fed78103a), the file is dequantized and the Transformer row reads BF16. After (this branch at 534e81756; later commits only touch planning, validation and comments), the int8 codes are kept and it reads INT8, with the reason "ComfyUI-quantized checkpoint (wan2.2_ti2v_5B_int8.safetensors): 300 int8 / 0 fp8 layers kept (torchao runtime), 0 dequantized". The other rows are unchanged.

Loaded build panel, before and after

danielhanchen and others added 30 commits October 5, 2026 11:19
…heir scales

A ComfyUI int8_convrot / fp8_scaled single file stores quantized codes under
the layer's .weight key with .weight_scale (and a comfy_quant format
declaration) beside it. from_single_file cast the codes to bf16 as if they were
weights and reported the scales as unused keys, so the load succeeded and every
quantized layer rendered noise.

Read the declaration from the safetensors header (per-layer comfy_quant,
the _quantization_metadata table, or the legacy scaled_fp8 marker) and:
- map int8_tensorwise layers, ConvRot or not, into Studio's int8 runtime with
  the codes and per-row scales unchanged (torchao Int8Tensor on a resident
  plan, the torchao-free native twin under offload);
- dequantize fp8 layers and the int8 layers Studio keeps in bf16;
- refuse nvfp4, mxfp8, the 4/6-bit int8 packings, unknown formats and
  undeclared scales with an error naming the format, before anything is
  evicted.
Image and video single-file loads both go through it.
…fyUI fp8 on the fp8 path

The hosted resolver now asks for <stem>-ComfyUI.safetensors ahead of each image
artifact (<stem>.safetensors / .pt), the one file ComfyUI also loads, and rebuilds it
into the same torchao Int8Tensor / ConvRot / Float8Tensor weights as Studio's own
checkpoint. Older builds never request the new name and keep resolving the existing
files; a cached own file is kept over an uncached twin, so nobody re-downloads.

ComfyUI float8_e4m3fn layers (scalar or per-row weight_scale) now run on Studio's
per-row fp8 runtime where it runs, the native fp8 twin where Studio's own fp8 quant
takes that path, and are dequantized elsewhere. ComfyUI single files are priced from
their header by what the loader keeps.
The row map was traced on full-width float64 copies of every quantized weight and
decoded with a few tensor ops per weight: 30 to 47 s of CPU for Qwen-Image-2.1 on a
busy host. Trace on 4-column tags first and decode from one list per weight; a
converter that needs the real width gets the full-width pass, and every rebuilt
weight is checked against the model's shape.
…I route

Qwen-Image-2.1's converter is registered by the single-file branch right before its
own call; the hosted prequant route never passed through there, so its ComfyUI twin
failed with 'has no single-file converter' and the load quantized the dense
weights instead.
ComfyUI's fp8 layout carries one scale per tensor, so an fp8 twin is a second,
coarser rounding of Studio's per-row fp8 (weight error 2.6% -> 3.7%; FLUX.2-klein-4B
LPIPS vs bf16 0.12 -> 0.16). The int8 twins hold the same codes and scales and keep
leading; an fp8 twin now trails its artifact and is used only where the repo has no
Studio fp8 file, or where it is the copy already cached.
A ComfyUI-quantized video DiT single file now keeps its codes instead of
being dequantized to bf16:

- Wan2.2 / HunyuanVideo-1.5 single files: int8_tensorwise layers go to
  Studio's int8 runtime (torchao resident, the torchao-free twin under
  offload) and float8_e4m3fn layers to its fp8 GEMM when resident, by the
  same rules Studio's own quant follows. Precision "Off" dequantizes.
- HunyuanVideo-1.5 has no diffusers single-file converter, so no
  original-layout file loaded at all; a key map (renames plus row-only
  qkv splits and the final shift / scale swap) now loads them, quantized
  or not.
- LTX-2.3: a ComfyUI int8 / fp8 file (ours or Lightricks' fp8) was
  refused as "scaled fp8". Its DiT now loads through the same loader and
  goes in as the 2.3 assembly's transformer override, which still reads
  the connectors, VAEs and vocoder from the file or the extras.
- MiniMax-H3: a ComfyUI int8_convrot / fp8_scaled denoiser file (Comfy-Org
  pruned or ours) is accepted as a single file and seeded into the
  modular workflow like a hosted checkpoint, with a key map for the
  converter-less layout and the pruned curve adaLN installed.
- The memory plan prices a ComfyUI file from its header (kept layers at
  stored size, dequantized ones at bf16) instead of the file size.

diffusion_comfy_quant gains fp8 keep (torchao Float8Tensor built from
Studio's own fp8 config), keep_key / pre_convert / key_map /
prepare_model / keep_dtype hooks and a header-only resident size.
…ey map

The pruned bf16 file the hosted and ComfyUI quants are made from now loads
as an H3 single file too (dense, no runtime quant), so it can serve as the
reference those quants are judged against. Packed w6a8 / nvfp4 / mxfp files
stay refused by name.
load_comfy_quant_transformer looks up HunyuanVideo-1.5's and MiniMax-H3's
original-layout hooks itself when no key map is passed, so a hosted
ComfyUI-format twin of either loads through the shared loader without the
caller knowing the family.
# Conflicts:
#	studio/backend/core/inference/diffusion_comfy_quant.py
# Conflicts:
#	studio/backend/tests/test_diffusion_comfy_quant.py
An un-rotated native int8 layer (a ComfyUI int8 file without ConvRot under offload) fed a transposed view
reached cuBLASLt with a column-major int8 operand and failed with CUBLAS_STATUS_NOT_SUPPORTED. Inductor keeps
that layout even through .contiguous(), so the codes go through a small opaque copy when compiling.
…s; format test files to the repo's fixed point
# Conflicts:
#	studio/backend/core/inference/diffusion.py
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 6, 2026
@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. More of your lovely PRs please.

Reviewed commit: f0d1fe9973

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

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 6, 2026
@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. Can't wait for the next one!

Reviewed commit: 2491a99a6a

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

@danielhanchen
danielhanchen merged commit e4911f5 into main Oct 6, 2026
@danielhanchen
danielhanchen deleted the studio/comfy-format-video branch October 6, 2026 17:24
sbabamohamad added a commit to sbabamohamad/unsloth that referenced this pull request Oct 21, 2026
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.
danielhanchen added a commit that referenced this pull request Oct 26, 2026
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.

![Video picker before and after: Cosmos3 Edge row
appears](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14554/pr14554_pair_00-cbaced2e803a.png)

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']}

![crawl/r_hub](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14554/crawl_r_hub-aa425f260167.png)
<!-- studio-regress:end -->

---------

Co-authored-by: Daniel Han <[email protected]>
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