Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: Cosmos3-Nano and Cosmos3-Edge video families (#14554)

sbabamohamadf1a1805217d0
diff --git a/studio/backend/core/inference/diffusion_component_sizes.py b/studio/backend/core/inference/diffusion_component_sizes.py
index 135c2b70b01..497d34738c9 100644
--- a/studio/backend/core/inference/diffusion_component_sizes.py
+++ b/studio/backend/core/inference/diffusion_component_sizes.py
@@ -886,11 +886,21 @@ def video_loaded_roles(
return tuple(dict.fromkeys(roles))
+def video_family_has_no_text_encoder(fam: Any) -> bool:
+ """A family whose bf16 table prices the text encoder at 0.0 has none: its denoiser is its own text model
+ (Cosmos3's omni transformer; the pipeline only tokenizes)."""
+ table = getattr(fam, "bf16_components_gb", None)
+ try:
+ return table is not None and float(table[1]) == 0.0
+ except (TypeError, ValueError, IndexError):
+ return False
+
+
def video_required_roles(fam: Any) -> tuple[str, ...]:
"""Connectors, vocoder, upsampler, a second text encoder are optional: never a reason to go to the Hub."""
denoiser = getattr(fam, "denoiser_attr", None) or "transformer"
roles = [denoiser]
- roles += ["text_encoder", "vae"]
+ roles += ["vae"] if video_family_has_no_text_encoder(fam) else ["text_encoder", "vae"]
if bool(getattr(fam, "has_audio", False)):
roles.append("audio_vae")
return tuple(dict.fromkeys(roles))
@@ -932,7 +942,9 @@ def video_header_parts(
vae_itemsize = 4 if bool(getattr(fam, "vae_force_fp32", False)) else 2
return (
_part((primary, "transformer_2"), lambda n: 2),
- _part(VIDEO_ROLE_TEXT, lambda n: 2),
+ (0.0, True)
+ if video_family_has_no_text_encoder(fam)
+ else _part(VIDEO_ROLE_TEXT, lambda n: 2),
_part(
VIDEO_ROLE_VAE + attached_extras(fam, dev), lambda n: vae_itemsize if n == "vae" else 2
),
diff --git a/studio/backend/core/inference/diffusion_dynamic_text.py b/studio/backend/core/inference/diffusion_dynamic_text.py
index c697cee6951..fef6a368688 100644
--- a/studio/backend/core/inference/diffusion_dynamic_text.py
+++ b/studio/backend/core/inference/diffusion_dynamic_text.py
@@ -89,6 +89,13 @@ _ZIMAGE_SOURCES: tuple[str, ...] = (
r".*\['args'\]\[[0-2]\]$",
)
+# Cosmos3 tokenizes the prompt unpadded (pipeline_cosmos3_omni.py ``_tokenize``): every prompt length is a new shape.
+_COSMOS3_SOURCES: tuple[str, ...] = (
+ "L['und_seq']",
+ "L['rotary_emb'][0]",
+ "L['rotary_emb'][1]",
+)
+
# MOSS-Image: unpadded text (cond and uncond differ), so every prompt is a new length.
_MOSS_IMAGE_SOURCES: tuple[str, ...] = (
"L['x']",
@@ -118,6 +125,7 @@ PROMPT_LENGTH_POLICY: dict[str, Any] = {
"LTX2VideoTransformer3DModel": FIXED_LENGTH, # Gemma left-padded to max_sequence_length 1024
"WanTransformer3DModel": FIXED_LENGTH, # UMT5 padded to max_sequence_length 512
"HunyuanVideo15Transformer3DModel": FIXED_LENGTH, # padded to the tokenizer max length
+ "Cosmos3OmniTransformer": _COSMOS3_SOURCES,
}
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index 486ed945454..55b0570a6ab 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -1782,7 +1782,7 @@ _MIRROR_PAIRS: tuple[tuple[str, str], ...] = _GATED_MIRROR_PAIRS + _UNGATED_MIRR
# canonical_base / prefer_ungated_mirror answer for video ids and nothing image-side changes.
# Absent on purpose: HunyuanVideo-1.5, whose Tencent Hunyuan Community licence is limited to a Territory that excludes
# the EU, UK and South Korea, which a public Hub repo cannot honour (the reason HunyuanImage-2.1 has no mirror either);
-# and Wan2.1-T2V-1.3B / -14B, for which no unsloth repo exists to carry the files.
+# and Wan2.1-T2V-1.3B / -14B and Cosmos3-Nano / -Edge, for which no unsloth repo exists to carry the files.
_VIDEO_GATED_MIRROR_PAIRS: tuple[tuple[str, str], ...] = (
("Lightricks/LTX-2.5-Diffusers", "unsloth/LTX-2.5-FP8"),
# The split single-file release (text_encoders/, vae/, latent_upscale_models/, diffusion_models/ bf16 DiTs). In the
@@ -2522,6 +2522,8 @@ _PIPELINE_MIN_DIFFUSERS: dict[str, str] = {
# the first release that can carry it. ``_version_tuple`` stops at the first non-numeric part,
# so a 0.41.0.dev0 build from main reads as (0, 41, 0) and satisfies this too.
"QwenImage21Pipeline": "0.41.0",
+ # 0.39.0 drops Edge's use_native_flow_schedule; 0.40.0 resolves a group-offloaded transformer's device as the CPU.
+ "Cosmos3OmniPipeline": "0.41.0",
# FLUX.3 Image Klein (huggingface/diffusers#15046) is in no release yet, so the first one that can carry it is
# 0.42.0. Main and the PR branch both report 0.41.0.dev0, which reads as the 0.41.0 release that lacks it, so the
# listing probes the module file instead (``_PIPELINE_PROBE_FILES``).
@@ -2581,7 +2583,13 @@ def _json_dict(path: Path, max_bytes: int = _MAX_PIPELINE_MANIFEST_BYTES) -> Opt
return payload if isinstance(payload, dict) else None
+# Cosmos3 components video never loads: the pipeline takes no vision_encoder, and Studio passes sound_tokenizer=None.
+COSMOS3_UNUSED_COMPONENTS = frozenset({"sound_tokenizer", "vision_encoder"})
_CALLER_SUPPLIED_COMPONENTS = {"HiDreamImagePipeline": frozenset({"text_encoder_4", "tokenizer_4"})}
+_UNLOADED_COMPONENTS = {
+ "Cosmos3OmniPipeline": COSMOS3_UNUSED_COMPONENTS,
+ "Cosmos3OmniDiffusersPipeline": COSMOS3_UNUSED_COMPONENTS,
+}
# Remote-code components loaded via an in-tree port, judged by the layout that port reads (else a config-only
# MOSS-Image transformer/ would pass).
_IN_TREE_PORT_LIBRARIES = {
@@ -2676,6 +2684,9 @@ def _local_pipeline_component_is_complete(
for tokens, config_names in _LOCAL_PIPELINE_METADATA_CONFIGS:
if not any(token in identity for token in tokens):
continue
+ # A diffusers *Tokenizer class is a model with weights (Cosmos3AVAEAudioTokenizer).
+ if tokens[0] == "tokenizer" and library_name == "diffusers":
+ continue
# Configs can exceed the manifest cap: LTX-2's Gemma3 tokenizer_config.json is 1.1 MB.
if not any(
_json_dict(component / name, _MAX_PIPELINE_WEIGHT_INDEX_BYTES) is not None
@@ -2735,6 +2746,7 @@ def local_pipeline_components_are_complete(
except OSError:
return False
caller_supplied = _CALLER_SUPPLIED_COMPONENTS.get(class_name, frozenset())
+ unloaded = _UNLOADED_COMPONENTS.get(class_name, frozenset())
declared = False
twin_only = False
try:
@@ -2748,8 +2760,10 @@ def local_pipeline_components_are_complete(
continue
if name in {"", ".."} or "\\" in name or Path(name).name != name:
return False
- if name in excluded_components or (
- name in caller_supplied and not (base / name).exists()
+ if (
+ name in excluded_components
+ or name in unloaded
+ or (name in caller_supplied and not (base / name).exists())
):
continue
declared = True
diff --git a/studio/backend/core/inference/diffusion_flow_shift.py b/studio/backend/core/inference/diffusion_flow_shift.py
index f6db66a0c8c..58582182838 100644
--- a/studio/backend/core/inference/diffusion_flow_shift.py
+++ b/studio/backend/core/inference/diffusion_flow_shift.py
@@ -76,6 +76,31 @@ def apply_comfy_flow_shift(
return True
+def apply_scheduler_overrides(
+ pipe: Any,
+ overrides: Any,
+ logger: Any = None,
+) -> bool:
+ """Rebuild ``pipe.scheduler`` with a family's ``scheduler_overrides`` (the publisher's sampling config). True when
+ it changed; a scheduler that rejects them keeps the shipped schedule."""
+ pairs = dict(overrides or ())
+ scheduler = getattr(pipe, "scheduler", None)
+ config = getattr(scheduler, "config", None)
+ if not pairs or scheduler is None or config is None:
+ return False
+ if all(config.get(k) == v for k, v in pairs.items()):
+ return False
+ try:
+ pipe.scheduler = type(scheduler).from_config(config, **pairs)
+ except Exception as exc: # noqa: BLE001 - keep the shipped schedule rather than fail the load
+ if logger is not None:
+ logger.warning("scheduler overrides %s not applied: %s", pairs, exc)
+ return False
+ if logger is not None:
+ logger.info("scheduler rebuilt with the family's overrides %s", pairs)
+ return True
+
+
# A pipeline config's fixed sampling grid, terminal sigma excluded (QwenImage21Pipeline, huggingface/diffusers#14950).
SAMPLE_SIGMAS_KEY = "sample_sigmas"
diff --git a/studio/backend/core/inference/diffusion_speed.py b/studio/backend/core/inference/diffusion_speed.py
index cf73200ffe1..2611db15301 100644
--- a/studio/backend/core/inference/diffusion_speed.py
+++ b/studio/backend/core/inference/diffusion_speed.py
@@ -598,7 +598,9 @@ def apply_speed_optims(
# Near-lossless, not bit-identical, so never on "off" (returned above).
applied["vae_fp16_decode"] = _video_vae_half_decode(pipe, target, family, logger)
if on_cuda:
- applied["vae_fused"] = _install_fused_vae(pipe, logger)
+ applied["vae_fused"] = _install_fused_vae(
+ pipe, logger, encoder = getattr(family, "vae_fused_encoder", True)
+ )
if (
on_cuda
@@ -1635,13 +1637,18 @@ def vae_decode_compile_allowed(pipe: Any, speed_mode: str) -> bool:
return _denoiser_unet(pipe) is None and _vae_decode_compile_allowed(pipe, speed_mode)
-def _install_fused_vae(pipe: Any, logger: Any) -> bool:
- """Triton-fused VAE norm passes (diffusion_vae_fused), unless the env forces the VAE decode compile instead."""
+def _install_fused_vae(
+ pipe: Any,
+ logger: Any,
+ encoder: bool = True,
+) -> bool:
+ """Triton-fused VAE norm passes (diffusion_vae_fused), unless the env forces the VAE decode compile instead.
+ ``encoder=False`` leaves the VAE encoder stock (the family's ``vae_fused_encoder``)."""
if os.environ.get(COMPILE_VAE_ENV, "").strip().lower() in _VAE_TRUE_TOKENS:
return False
try:
from . import diffusion_vae_fused # noqa: PLC0415 - Triton import only on CUDA loads
- return diffusion_vae_fused.install(getattr(pipe, "vae", None), logger) > 0
+ return diffusion_vae_fused.install(getattr(pipe, "vae", None), logger, encoder = encoder) > 0
except Exception as exc: # noqa: BLE001 - optimisation only
_warn(logger, "fused vae", exc)
return False
diff --git a/studio/backend/core/inference/diffusion_vae_fused.py b/studio/backend/core/inference/diffusion_vae_fused.py
index 50499f5a4c4..b4a03802d89 100644
--- a/studio/backend/core/inference/diffusion_vae_fused.py
+++ b/studio/backend/core/inference/diffusion_vae_fused.py
@@ -1079,14 +1079,18 @@ def _fast_norm(norm: Any, act: bool) -> Any:
return fast
-def install_group_norm_vae(vae: Any, logger: Any = None) -> int:
+def install_group_norm_vae(
+ vae: Any,
+ logger: Any = None,
+ encoder: bool = True,
+) -> int:
"""Patch every eligible ResnetBlock2D / GroupNorm of a 2-D (AutoencoderKL-family) VAE. Returns patch count."""
torch = _torch()
if vae is None or not runtime_ok():
return 0
n = 0
fused_act_norms = set()
- for part_name in ("encoder", "decoder"):
+ for part_name in ("encoder", "decoder") if encoder else ("decoder",):
part = getattr(vae, part_name, None)
if part is None:
continue
@@ -1377,13 +1381,17 @@ def _fast_wan_residual_up(block: Any) -> Any:
return fast
-def install_wan_vae(vae: Any, logger: Any = None) -> int:
+def install_wan_vae(
+ vae: Any,
+ logger: Any = None,
+ encoder: bool = True,
+) -> int:
"""Patch the residual blocks, causal convs and output heads of a Wan-lineage VAE. Returns patch count."""
torch = _torch()
if vae is None or not runtime_ok():
return 0
n = 0
- for part_name in ("encoder", "decoder"):
+ for part_name in ("encoder", "decoder") if encoder else ("decoder",):
part = getattr(vae, part_name, None)
if part is None:
continue
@@ -1815,12 +1823,16 @@ def _hv_causal_mask(
return mask
-def install_hv15_vae(vae: Any, logger: Any = None) -> int:
+def install_hv15_vae(
+ vae: Any,
+ logger: Any = None,
+ encoder: bool = True,
+) -> int:
torch = _torch()
if vae is None or not runtime_ok():
return 0
n = 0
- for part_name in ("encoder", "decoder"):
+ for part_name in ("encoder", "decoder") if encoder else ("decoder",):
part = getattr(vae, part_name, None)
if part is None:
continue
@@ -2119,16 +2131,20 @@ def install(
vae: Any,
logger: Any = None,
level: str = "fused",
+ encoder: bool = True,
) -> int:
- """Install every fused path that applies to ``vae``'s class. Returns the number of patched modules."""
+ """Install every fused path that applies to ``vae``'s class. Returns the number of patched modules.
+
+ ``encoder=False`` patches the decoder only, for a family whose denoising attends to the encoded conditioning clip at
+ every step, which amplifies the fused passes' rounding into a different sample (video_families.vae_fused_encoder)."""
if vae is None or not will_install(vae):
return 0
done = getattr(vae, "_unsloth_vae_fused_installed", 0)
if done:
return done # idempotent: a dual-DiT family runs the speed layer once per expert over the same VAE
- n = _install(vae, logger)
+ n = _install(vae, logger, encoder)
if not n and type(vae).__name__ not in SUPPORTED_VAES:
- n = install_structural(vae, logger)
+ n = install_structural(vae, logger) # decoder only, so it honours encoder=False as is
if n:
vae._unsloth_vae_fused_structural = True
# Only where measured faster, and only when a fused pass feeds a conv (relaid weights alone slow LTX-2's decode).
@@ -2147,16 +2163,20 @@ def install(
return n
-def _install(vae: Any, logger: Any = None) -> int:
+def _install(
+ vae: Any,
+ logger: Any = None,
+ encoder: bool = True,
+) -> int:
name = type(vae).__name__
if name in ("AutoencoderKL", "AutoencoderKLFlux2"):
- n = install_group_norm_vae(vae, logger)
+ n = install_group_norm_vae(vae, logger, encoder)
return n + (install_vectorised_blend(vae) if n else 0)
if name in _WAN_VAES:
- n = install_wan_vae(vae, logger)
+ n = install_wan_vae(vae, logger, encoder)
return n + (install_vectorised_blend(vae) if n else 0)
if name == "AutoencoderKLHunyuanVideo15":
- n = install_hv15_vae(vae, logger)
+ n = install_hv15_vae(vae, logger, encoder)
return n + (install_vectorised_blend(vae) if n else 0)
if name == "AutoencoderKLLTX2Video":
if not _ltx2_convs_fusable(vae):
diff --git a/studio/backend/core/inference/video.py b/studio/backend/core/inference/video.py
index a694fef82db..33a5bc4254f 100644
--- a/studio/backend/core/inference/video.py
+++ b/studio/backend/core/inference/video.py
@@ -60,7 +60,8 @@ from .diffusion_attention import (
report_attention_run,
select_attention_backend,
)
-from .diffusion_flow_shift import apply_comfy_flow_shift
+from .diffusion_flow_shift import apply_comfy_flow_shift, apply_scheduler_overrides
+from .diffusion_component_sizes import video_family_has_no_text_encoder
from . import hub_reachability
from .diffusion_comfy_quant import (
comfy_fp8_backend,
@@ -245,11 +246,13 @@ from .video_families import (
VIDEO_GENERATION_BUSY_MSG,
VIDEO_MODEL_CHANGED_MSG,
VIDEO_NOT_LOADED_MSG,
+ COSMOS3_FAMILIES,
LTX_FAMILIES,
assert_local_pipeline_family,
assert_ltx_pick_supported,
assert_supported_ltx_version,
ltx_family_by_name,
+ local_cosmos3_pipeline_family,
local_ltx_pipeline_family,
pipeline_available_video_families,
VideoFamily,
@@ -634,6 +637,19 @@ def _ltx23_prequant_pick(
return ltx23_prequant_eligible(checkpoint_filename, checkpoint_repo)
+def _decodes_untiled_when_fits(family: str, offload_policy: str, device: str, speed: str) -> bool:
+ """Untiled when it fits (free memory read at decode time); not under sequential offload, nor on SPEED_OFF
+ (bit-identical) except Cosmos3, whose reference pipeline decodes untiled (stock tiles seam at 480 / 832 px)."""
+ if device != "cuda" or offload_policy not in (
+ OFFLOAD_NONE,
+ OFFLOAD_MODEL,
+ OFFLOAD_GROUP,
+ OFFLOAD_STREAMING,
+ ):
+ return False
+ return speed != SPEED_OFF or family in COSMOS3_FAMILIES
+
+
def _memory_mode_resolved(memory_mode: Any, plan: Any, offload_policy: str) -> tuple:
"""A ``fast`` that had to offload is a fallback valued at the engaged policy ("FAST -> GROUP", not "FAST -> FAST")."""
if plan.requested_mode == MEMORY_MODE_FAST and offload_policy != OFFLOAD_NONE:
@@ -1419,12 +1435,20 @@ def _resolve_load_family_with_source(
or (gguf_filename and detect_video_family(f"{repo_id}/{gguf_filename}"))
or None
)
+ if fam is None and not gguf_filename:
+ local_cosmos3 = local_cosmos3_pipeline_family(repo_id)
+ if local_cosmos3:
+ fam = detect_video_family("", override = local_cosmos3)
if fam is None and gguf_filename:
# A renamed GGUF carries no family token, so resolve via general.architecture. No-backend archs still yield None
# (a 400)
arch = _picked_gguf_arch(repo_id, gguf_filename)
if arch:
fam = detect_video_family(repo_id, override = arch)
+ if fam is not None and fam.name in COSMOS3_FAMILIES and not gguf_filename:
+ by_configs = local_cosmos3_pipeline_family(repo_id)
+ if by_configs and by_configs != fam.name:
+ fam = detect_video_family("", override = by_configs) or fam
if fam is not None and fam.name in LTX_FAMILIES:
# Both LTX families share the "ltx" tokens, so the release decides: a local diffusers folder by its
# model_index.json, else the picked file's own version token, else the display / repo id.
@@ -4744,6 +4768,11 @@ class VideoBackend:
refusal = video_checkpoint_refusal(fam, repo_id, display_repo_id, gguf_filename)
if refusal:
raise ValueError(refusal)
+ if fam.name in COSMOS3_FAMILIES:
+ from .video_cosmos3 import load_request_refusal as cosmos3_load_request_refusal
+ refusal = cosmos3_load_request_refusal(fam.name, kind, text_encoder_quant)
+ if refusal:
+ raise ValueError(refusal)
# ── modular-workflow refusals, before anything heavier. Deliberately the FIRST thing after the family resolves:
# everything below reaches into diffusers (assert_pipeline_class_available, the transformer_class probe), so a
# refusal placed after them would be unreachable on any install whose diffusers cannot even be imported -- and
@@ -4875,6 +4904,12 @@ class VideoBackend:
f"checkpoint; full pipelines and other weight formats load only from unsloth/* "
f"repos, the official family base repos, and local paths."
)
+ # After the trust gate, so an untrusted repo is refused as untrusted.
+ if fam.name in COSMOS3_FAMILIES and kind == "pipeline":
+ from .video_cosmos3 import guardrail_refusal
+ refusal = guardrail_refusal(repo_id)
+ if refusal:
+ raise ValueError(refusal)
# Companions load with from_pretrained, so a base repo is held to the non-GGUF bar: a GGUF pick must not smuggle
# in a remote base.
if base_repo and (base_repo or "").strip() and not _is_trusted_video_repo(base_repo):
@@ -7309,9 +7344,16 @@ class VideoBackend:
siblings = list(info.siblings or [])
ltx25_pack = is_ltx25_pack(s.rfilename for s in siblings)
- # The LTX-2.5 pack ships a modular_model_index.json beside its model_index.json; it is not H3's layout.
- is_h3_modular = not ltx25_pack and any(
- s.rfilename == "modular_model_index.json" for s in siblings
+ # LTX-2.5 and Cosmos3 also ship a modular_model_index.json; neither is H3's layout.
+ from .video_cosmos3 import NONE_COMPONENTS as COSMOS3_NONE_COMPONENTS, is_cosmos3_listing
+
+ cosmos3 = is_cosmos3_listing(s.rfilename for s in siblings)
+ # Only None-passed components: diffusers' hub-id load demands every other listed weight.
+ cosmos3_unused = tuple(f"{c}/" for c in COSMOS3_NONE_COMPONENTS) if cosmos3 else ()
+ is_h3_modular = (
+ not ltx25_pack
+ and not cosmos3
+ and any(s.rfilename == "modular_model_index.json" for s in siblings)
)
h3_is_references = is_h3_modular and (h3_task or "").strip().lower() == H3_TASK_REFERENCES
h3_denoiser_prefix = "transformer_ref/" if h3_is_references else "transformer/"
@@ -7364,6 +7406,8 @@ class VideoBackend:
continue
if name.startswith("text_encoder/diffusion_pytorch_model"):
continue
+ if cosmos3_unused and name.startswith(cosmos3_unused):
+ continue
if ltx23 and "/" in name and not name.startswith(VideoBackend._LTX23_BASE_PREFIXES):
continue
if skip_te_components and is_prequant_covered_weight(name, skip_te_components):
@@ -9333,6 +9377,9 @@ class VideoBackend:
# The encoder runs in the worker; the enhancer, processor and duration head are never used.
pipe_kwargs.update({name: None for name in LTX25_NONE_COMPONENTS})
+ if kind == "pipeline" and fam.name in COSMOS3_FAMILIES:
+ from .video_cosmos3 import pipeline_kwargs as cosmos3_pipeline_kwargs
+ pipe_kwargs.update(cosmos3_pipeline_kwargs(str(repo_id)))
cast_writes = None
native_writes = None
if kind == "pipeline":
@@ -10323,12 +10370,10 @@ class VideoBackend:
speed_optims += ("vae_wide_tiles",)
except Exception as exc: # noqa: BLE001 - keep the stock tiled decode
logger.warning("video.vae_wide_tiles: not installed: %s", exc)
- # Untiled when it fits (free memory read at decode time); not on SPEED_OFF (bit-identical) or sequential offload.
- if (
- offload_policy in (OFFLOAD_NONE, OFFLOAD_MODEL, OFFLOAD_GROUP, OFFLOAD_STREAMING)
- and target.device == "cuda"
- and effective_speed != SPEED_OFF
- ):
+ if vae_tiling and fam.name in COSMOS3_FAMILIES:
+ from .video_cosmos3 import install_untiled_encode
+ install_untiled_encode(pipe, logger = logger)
+ if _decodes_untiled_when_fits(fam.name, offload_policy, target.device, effective_speed):
from .video_vae_untiled import install_untiled_decode
if install_untiled_decode(pipe, fam.name, logger = logger):
speed_optims += ("vae_untiled_when_fits",)
@@ -10462,6 +10507,8 @@ class VideoBackend:
or (
"dense text encoder quantised in place"
if text_encoder_quant_engaged is not None
+ else "not applicable (no separate text encoder)"
+ if video_family_has_no_text_encoder(fam)
else "not engaged (dense bf16 text encoder loaded)"
),
text_encoder_outcome.status,
@@ -10480,6 +10527,7 @@ class VideoBackend:
autoopt.finalize(load_audit, speed_optims, resolved)
apply_comfy_flow_shift(pipe, getattr(fam, "comfy_flow_shift", None), logger)
+ apply_scheduler_overrides(pipe, getattr(fam, "scheduler_overrides", ()), logger)
if ltx25_client is not None:
# The worker loaded the Gemma 4 encoder while the DiT loaded; a failure there fails this load.
ltx25_client.wait_ready(self._cancel_event if _load_token is not None else None)
@@ -12829,6 +12877,13 @@ class VideoBackend:
if bg_eager:
# LTX-2 i2v passes a per-token timestep (t2v: per sample), so it must not seed the compile.
i2v_swap.enter_context(bg_compile.no_record())
+ if fam.name in COSMOS3_FAMILIES:
+ from .video_cosmos3 import seam_safe_tile_strides
+ from .video_i2v import offload_vae_after_encode
+
+ # Every Cosmos3 call (t2v too) encodes a clip first; nothing else offloads the VAE after it.
+ i2v_swap.enter_context(offload_vae_after_encode(pipe))
+ i2v_swap.enter_context(seam_safe_tile_strides(pipe, height, width))
call_params = inspect.signature(pipe.__call__).parameters
kwargs: dict[str, Any] = {
"prompt": prompt,
@@ -12879,6 +12934,11 @@ class VideoBackend:
# LTX-2 takes frame_rate (shapes audio length); others fix their rate, fps only at export
if "frame_rate" in call_params:
kwargs["frame_rate"] = float(out_fps)
+ if fam.name in COSMOS3_FAMILIES and "fps" in call_params:
+ kwargs["fps"] = float(out_fps)
+ for key, value in getattr(fam, "call_kwargs", ()) or ():
+ if key in call_params:
+ kwargs[key] = value
# Dual-DiT MoE: pass the low-noise expert guidance only when the family declares it AND the signature
# accepts it (WanPipeline raises with boundary_ratio=None)
if fam.cfg2_kwarg and fam.cfg2_kwarg in call_params and guidance_2 is not None:
@@ -13244,6 +13304,12 @@ class VideoBackend:
audio = output.get("audio")
audio_track = audio[0] if audio is not None else None
audio_sample_rate = output.get("sampling_rate")
+ elif fam.name in COSMOS3_FAMILIES:
+ video_frames = (
+ output.video
+ ) # Cosmos3OmniPipelineOutput: one clip, already unbatched
+ audio_track = None
+ audio_sample_rate = None
else:
video_frames = output.frames[0]
audio = getattr(output, "audio", None)
@@ -13400,11 +13466,10 @@ class VideoBackend:
width or default_w,
height or default_h,
)
- # Fit once so both engines condition on identical pixels.
- if first is not None and i2v_pipeline:
- first = fit_h3_keyframe(first, width, height, anchor = H3_ANCHOR_LAST)
- elif first is not None:
- first = fit_h3_keyframe(first, width, height, anchor = H3_ANCHOR_FIRST)
+ # Fit once so both engines condition on identical pixels, unless the pipeline fits the frame itself.
+ if first is not None and fam.i2v_fits_first_frame:
+ anchor = H3_ANCHOR_LAST if i2v_pipeline else H3_ANCHOR_FIRST
+ first = fit_h3_keyframe(first, width, height, anchor = anchor)
if last is not None:
last = fit_h3_keyframe(last, width, height, anchor = H3_ANCHOR_LAST)
conditioning = h3_conditioning_mode(has_first = first is not None, has_last = last is not None)
diff --git a/studio/backend/core/inference/video_cosmos3.py b/studio/backend/core/inference/video_cosmos3.py
new file mode 100644
index 00000000000..e7509fe2cf6
--- /dev/null
+++ b/studio/backend/core/inference/video_cosmos3.py
@@ -0,0 +1,215 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Cosmos3 (nvidia/Cosmos3-Nano, nvidia/Cosmos3-Edge) on diffusers' ``Cosmos3OmniPipeline``.
+
+The guardrail (``cosmos_guardrail``) is built whenever ``model_index.json`` enables it and raises ``ImportError``
+without the package, so Studio refuses the load up front; ``UNSLOTH_COSMOS3_SAFETY_CHECKER=0`` opts out.
+"""
+
+from __future__ import annotations
+
+import contextlib
+import importlib.util
+import json
+import os
+from pathlib import Path
+from typing import Any, Iterable, Optional
+
+from loggers import get_logger
+
+logger = get_logger(__name__)
+
+SAFETY_CHECKER_ENV = "UNSLOTH_COSMOS3_SAFETY_CHECKER"
+# Passed as None to from_pretrained: Studio renders video only.
+NONE_COMPONENTS = ("sound_tokenizer",)
+GUARDRAIL_PACKAGE = "cosmos_guardrail"
+# Fallback when the index is not on disk yet (validation is network-free).
+_BASE_SAFETY_CHECKER = {
+ "nvidia/cosmos3-nano": True,
+ "nvidia/cosmos3-edge": False,
+}
+
+
+def is_cosmos3_listing(names: Iterable[str]) -> bool:
+ """Whether a Diffusers repo listing has Cosmos3's layout: a ``text_tokenizer/`` and no ``text_encoder/``."""
+ names = list(names)
+ return any(n.startswith("text_tokenizer/") for n in names) and not any(
+ n.startswith("text_encoder/") for n in names
+ )
+
+
+def safety_checker_opted_out() -> bool:
+ return os.environ.get(SAFETY_CHECKER_ENV, "").strip().lower() in ("0", "false", "no", "off")
+
+
+def guardrail_installed() -> bool:
+ try:
+ return importlib.util.find_spec(GUARDRAIL_PACKAGE) is not None
+ except (ImportError, ValueError):
+ return False
+
+
+def _cached_model_index(repo_id: str) -> Optional[dict]:
+ """The pipeline index from a local folder or the Hub cache; never the network."""
+ path: Optional[Path] = None
+ local = Path(repo_id).expanduser()
+ if local.is_dir():
+ path = local / "model_index.json"
+ else:
+ try:
+ from huggingface_hub import try_to_load_from_cache
+ found = try_to_load_from_cache(repo_id, "model_index.json")
+ path = Path(found) if isinstance(found, str) else None
+ except Exception: # noqa: BLE001 -- a cache miss falls back to the base repo's known setting
+ path = None
+ if path is None:
+ return None
+ try:
+ data = json.loads(path.read_text(encoding = "utf-8"))
+ except (OSError, ValueError):
+ return None
+ return data if isinstance(data, dict) else None
+
+
+def checkpoint_enables_safety_checker(repo_id: str, index: Optional[dict] = None) -> bool:
+ """``enable_safety_checker`` from the model_index.json, else the base repo's shipped value; on when unknown."""
+ if index is None:
+ index = _cached_model_index(repo_id)
+ if index is not None:
+ value = index.get("enable_safety_checker", True)
+ return bool(value) if isinstance(value, bool) else True
+ return _BASE_SAFETY_CHECKER.get(str(repo_id or "").strip().lower(), True)
+
+
+_TE_QUANT_UNSET = frozenset({"", "auto", "none", "off"})
+
+
+def load_request_refusal(
+ family: str, kind: str, text_encoder_quant: Optional[str]
+) -> Optional[str]:
+ """Refuse non-pipeline picks (no ``from_single_file``) and an explicit text-encoder precision (none exists)."""
+ if kind != "pipeline":
+ return (
+ f"{family} loads only as its full Diffusers pipeline (nvidia/Cosmos3-Nano or nvidia/Cosmos3-Edge): "
+ "Cosmos3OmniTransformer has no single-file loader, so GGUF and single .safetensors checkpoints cannot run."
+ )
+ scheme = str(text_encoder_quant or "").strip().lower()
+ if scheme not in _TE_QUANT_UNSET:
+ return (
+ f"text_encoder_quant '{text_encoder_quant}' does not apply to {family}: Cosmos3 has no separate text "
+ "encoder (its transformer reads the prompt tokens itself). Leave text_encoder_quant unset."
+ )
+ return None
+
+
+def guardrail_refusal(repo_id: str, index: Optional[dict] = None) -> Optional[str]:
+ """Why this load cannot start, or None: the checkpoint enables the guardrail and the package is missing."""
+ if safety_checker_opted_out() or guardrail_installed():
+ return None
+ if not checkpoint_enables_safety_checker(repo_id, index):
+ return None
+ return (
+ f"'{repo_id}' runs NVIDIA's Cosmos guardrail (its model_index.json does not turn enable_safety_checker off, and "
+ f"the pipeline's default is on), which needs the cosmos_guardrail package: pip install cosmos-guardrail into "
+ f"Studio's Python environment, restart Studio, and retry. To run without it, set {SAFETY_CHECKER_ENV}=0; the "
+ f"model card's terms and safe use stay your responsibility."
+ )
+
+
+def pipeline_kwargs(repo_id: str, index: Optional[dict] = None) -> dict[str, Any]:
+ """``from_pretrained`` kwargs: no sound tokenizer; guardrail off only on the explicit opt-out."""
+ kwargs: dict[str, Any] = dict.fromkeys(NONE_COMPONENTS)
+ if safety_checker_opted_out():
+ kwargs["enable_safety_checker"] = False
+ if checkpoint_enables_safety_checker(repo_id, index):
+ logger.warning(
+ "video.cosmos3: %s=0, so '%s' loads without the Cosmos guardrail its checkpoint runs by default",
+ SAFETY_CHECKER_ENV,
+ repo_id,
+ )
+ return kwargs
+
+
+def install_untiled_encode(pipe: Any, logger: Any = None) -> bool:
+ """Run ``pipe.vae.encode`` untiled, tiled only on out-of-memory: every step attends to the encoded i2v clip,
+ so tiling's small shift grows across it (Nano i2v vs diffusers: 24.7 dB tiled)."""
+ vae = getattr(pipe, "vae", None)
+ encode = getattr(vae, "encode", None)
+ if vae is None or not callable(encode):
+ return False
+ if getattr(encode, "_unsloth_untiled_encode", False):
+ return True
+
+ def untiled_encode(*args: Any, **kwargs: Any) -> Any:
+ tiling = bool(getattr(vae, "use_tiling", False))
+ if not tiling:
+ return encode(*args, **kwargs)
+ from .diffusion_batched import is_oom_error
+
+ vae.use_tiling = False
+ try:
+ return encode(*args, **kwargs)
+ except Exception as exc: # noqa: BLE001
+ if not is_oom_error(exc):
+ raise
+ finally:
+ vae.use_tiling = tiling
+ # Retried outside the handler so the failed attempt's tensors (held by the traceback) are gone first.
+ import torch
+
+ torch.cuda.empty_cache()
+ if logger is not None:
+ logger.warning("video.cosmos3: untiled VAE encode ran out of memory; encoding tiled")
+ return encode(*args, **kwargs)
+
+ untiled_encode._unsloth_untiled_encode = True
+ vae.encode = untiled_encode
+ if logger is not None:
+ logger.info(
+ "video.cosmos3: VAE encodes the conditioning clip untiled (tiled on out-of-memory)"
+ )
+ return True
+
+
+# Wan@16x seam audit floor (test_vae_tile_geometry): >= 4-latent overlaps, >= 8-latent edge tiles.
+_MIN_OVERLAP_LATENTS = 4
+_MIN_EDGE_LATENTS = 8
+
+
+def seam_safe_tile(length: int, tile: int, stride: int) -> tuple[int, int]:
+ """(tile, stride) latents over ``length`` whose last tile keeps >= 8 latents: stock when it does, else the smallest
+ tile (up to 8 past stock) with the largest stride that does; stock if none."""
+ if length <= tile:
+ return tile, stride
+ for t in range(tile, min(length - 1, tile + 8) + 1):
+ for s in range(min(stride + t - tile, t - _MIN_OVERLAP_LATENTS), t // 2 - 1, -1):
+ if length - (length - 1) // s * s >= _MIN_EDGE_LATENTS:
+ return t, s
+ return tile, stride
+
+
+def seam_safe_tile_strides(pipe: Any, height: int, width: int):
+ """Tiles for this canvas while tiling runs: stock Wan@16x tiles leave a 4-latent edge tile at 480 / 832 px."""
+ vae = getattr(pipe, "vae", None)
+ keys = (
+ ("tile_sample_min_height", "tile_sample_stride_height"),
+ ("tile_sample_min_width", "tile_sample_stride_width"),
+ )
+ try:
+ ratio = int(vae.spatial_compression_ratio)
+ old = tuple((int(getattr(vae, t)), int(getattr(vae, s))) for t, s in keys)
+ except (AttributeError, TypeError, ValueError):
+ yield
+ return
+ for (tile_key, stride_key), side, (tile, stride) in zip(keys, (height, width), old):
+ t, s = seam_safe_tile(int(side) // ratio, tile // ratio, stride // ratio)
+ setattr(vae, tile_key, t * ratio)
+ setattr(vae, stride_key, s * ratio)
+ try:
+ yield
+ finally:
+ for (tile_key, stride_key), (tile, stride) in zip(keys, old):
+ setattr(vae, tile_key, tile)
+ setattr(vae, stride_key, stride)
diff --git a/studio/backend/core/inference/video_families.py b/studio/backend/core/inference/video_families.py
index 7c99a8bf145..ccd7f22f1b2 100644
--- a/studio/backend/core/inference/video_families.py
+++ b/studio/backend/core/inference/video_families.py
@@ -284,6 +284,8 @@ class VideoFamily:
vae_force_fp32: bool = False
# False holds cudnn.benchmark off: its per-process conv pick makes servers decode the same latents differently.
cudnn_benchmark: bool = True
+ # False: stock VAE encoder (decoder stays fused); fused rounding changes samples that attend to the encoded clip.
+ vae_fused_encoder: bool = True
# One config per reduction instead of a per-process benchmark that can change the render (diffusion_speed.
# pin_reduction_configs). Off by default: it can keep a slower config (HunyuanVideo-1.5 ~2% per step).
filter_reduction_configs: bool = False
@@ -343,6 +345,10 @@ class VideoFamily:
default_flow_shift: Optional[float] = None
# ComfyUI's static sigma shift (None = shipped); unlike default_flow_shift, no user control.
comfy_flow_shift: Optional[float] = None
+ # Publisher's scheduler config, applied once at load as (key, value) pairs.
+ scheduler_overrides: tuple[tuple[str, object], ...] = field(default_factory = tuple)
+ # Fixed __call__ kwargs per request; keys missing from the pipeline signature are skipped.
+ call_kwargs: tuple[tuple[str, object], ...] = field(default_factory = tuple)
default_audio_flow_shift: Optional[float] = None
# First/last-frame conditioning: the request may carry keyframe images.
supports_keyframes: bool = False
@@ -350,6 +356,8 @@ class VideoFamily:
accepts_last_frame: bool = True
# Diffusers class serving a first-frame request over the loaded pipeline's components (video_i2v).
i2v_pipeline_class: Optional[str] = None
+ # False: the pipeline fits the first frame itself, so Studio passes the source image.
+ i2v_fits_first_frame: bool = True
i2v_pipeline_config: tuple[tuple[str, object], ...] = field(default_factory = tuple)
# (identifier regex, ((kwarg, value), ...)); first matching row applies.
i2v_call_kwargs: tuple[tuple[str, tuple[tuple[str, object], ...]], ...] = field(
@@ -416,6 +424,77 @@ _HV15_I2V_REFUSAL = (
)
+# Cosmos3 (diffusers >= 0.41): Nano and Edge are separate families (different card sampling and hidden_size).
+COSMOS3_NANO_FAMILY = "cosmos3-nano"
+COSMOS3_EDGE_FAMILY = "cosmos3-edge"
+COSMOS3_FAMILIES = (COSMOS3_NANO_FAMILY, COSMOS3_EDGE_FAMILY)
+# No single-file or GGUF loader exists, so only a pipeline index is the generator.
+PIPELINE_ONLY_VIDEO_FAMILIES = frozenset(COSMOS3_FAMILIES)
+# Nano's index names the pre-release class.
+_COSMOS3_INDEX_CLASSES = frozenset({"Cosmos3OmniPipeline", "Cosmos3OmniDiffusersPipeline"})
+_COSMOS3_MODEL_TYPES = {
+ "cosmos3_omni": {4096: COSMOS3_NANO_FAMILY},
+ "cosmos3_edge": {2048: COSMOS3_EDGE_FAMILY},
+}
+_COSMOS3_TRANSFORMER_SIZES = {
+ size: family for sizes in _COSMOS3_MODEL_TYPES.values() for size, family in sizes.items()
+}
+# Last path segment only, as for the other refusals: an owner or folder name decides nothing.
+_COSMOS3_VARIANT = r"(?<![a-z0-9])cosmos3[-_. ]?(?:nano|edge)[-_. ]"
+_COSMOS3_REASONER_RE = _COSMOS3_VARIANT + r"reasoner(?![a-z0-9])(?=[^/\\|]*[/\\]*\s*(?:$|\|))"
+_COSMOS3_REASONER_REFUSAL = (
+ "This is a Cosmos3 Reasoner checkpoint, a vision-language model that answers in text rather than generating "
+ "video. Load it from Chat, or load nvidia/Cosmos3-Nano or nvidia/Cosmos3-Edge here."
+)
+_COSMOS3_CONDITIONED_RE = (
+ _COSMOS3_VARIANT + r"(?:policy|sim|transfer|fp8)(?![a-z0-9])(?=[^/\\|]*[/\\]*\s*(?:$|\|))"
+)
+_COSMOS3_CONDITIONED_REFUSAL = (
+ "This Cosmos3 checkpoint is a Policy, Sim, Transfer or FP8 build. The first three need action or control "
+ "inputs (and their own Diffusers pipelines) that Studio's Video page does not provide, and the FP8 builds are "
+ "untested here. Load nvidia/Cosmos3-Nano or nvidia/Cosmos3-Edge instead."
+)
+_COSMOS3_UNSUPPORTED = (
+ (_COSMOS3_REASONER_RE, _COSMOS3_REASONER_REFUSAL),
+ (_COSMOS3_CONDITIONED_RE, _COSMOS3_CONDITIONED_REFUSAL),
+)
+# Wan2.2-TI2V-5B VAE: stock tiles leave a 4-latent edge tile at 480 / 832 px; priced at its measured 2.5 MiB/latent px.
+_COSMOS3_PROFILE = FamilyProfile(
+ untiled_vae = UntiledVae(bytes_per_latent_pixel = 2.5 * 2**20, output_scale = (16, 4))
+)
+# Model-card sampling; the shipped scheduler_config.json's flow_shift 1.0 is used by neither card.
+_COSMOS3_NANO_SCHEDULER = (("flow_shift", 10.0),)
+_COSMOS3_EDGE_SCHEDULER = (("flow_shift", 12.0), ("use_karras_sigmas", False))
+
+
+def local_cosmos3_pipeline_family(path: Optional[str]) -> Optional[str]:
+ """The Cosmos3 family of a local diffusers folder from its configs, or None."""
+ import json
+ from pathlib import Path
+
+ def _read(name: str) -> Optional[dict]:
+ try:
+ data = json.loads((Path(str(path)).expanduser() / name).read_text(encoding = "utf-8"))
+ except (OSError, ValueError, TypeError):
+ return None
+ return data if isinstance(data, dict) else None
+
+ if not path:
+ return None
+ index = _read("model_index.json")
+ if index is None or index.get("_class_name") not in _COSMOS3_INDEX_CLASSES:
+ return None
+ transformer = _read("transformer/config.json") or {}
+ hidden = transformer.get("hidden_size")
+ if (Path(str(path)).expanduser() / "config.json").exists():
+ sizes = _COSMOS3_MODEL_TYPES.get(str((_read("config.json") or {}).get("model_type") or ""))
+ elif transformer.get("_class_name") == "Cosmos3OmniTransformer":
+ sizes = _COSMOS3_TRANSFORMER_SIZES
+ else:
+ sizes = None
+ return sizes.get(hidden) if sizes and isinstance(hidden, int) else None
+
+
# --- Shared FamilyProfile data (see family_profile.FamilyProfile) ---
# int8 small-M exclusions (on top of diffusion_transformer_quant._INT8_EXCLUDE_NAME_TOKENS); baked into the published
@@ -1002,6 +1081,67 @@ _FAMILIES: tuple[VideoFamily, ...] = (
fp16_guard = "native",
cudnn_benchmark = False,
),
+ VideoFamily(
+ name = "cosmos3-nano",
+ pipeline_class = "Cosmos3OmniPipeline",
+ transformer_class = "Cosmos3OmniTransformer",
+ base_repo = "nvidia/Cosmos3-Nano",
+ profile = _COSMOS3_PROFILE,
+ has_audio = False,
+ default_steps = 35,
+ default_guidance = 6.0,
+ default_num_frames = 189,
+ default_fps = 24,
+ frame_step = 4,
+ min_num_frames = 5,
+ max_num_frames = 397,
+ resolution_multiple = 16,
+ resolution_presets = (
+ (1280, 720),
+ (720, 1280),
+ (960, 960),
+ (1104, 832),
+ (832, 1104),
+ (832, 480), # faster
+ (480, 832), # faster
+ ),
+ duration_presets = (2.0, 5.0, 7.875),
+ bf16_components_gb = (30.4, 0.0, 1.4),
+ supports_torch_compile = False,
+ i2v_pipeline_class = "Cosmos3OmniPipeline",
+ i2v_fits_first_frame = False,
+ scheduler_overrides = _COSMOS3_NANO_SCHEDULER,
+ cudnn_benchmark = False,
+ vae_fused_encoder = False,
+ ),
+ VideoFamily(
+ name = "cosmos3-edge",
+ pipeline_class = "Cosmos3OmniPipeline",
+ transformer_class = "Cosmos3OmniTransformer",
+ base_repo = "nvidia/Cosmos3-Edge",
+ profile = _COSMOS3_PROFILE,
+ has_audio = False,
+ default_steps = 20,
+ default_guidance = 6.0,
+ default_num_frames = 121,
+ default_fps = 24,
+ frame_step = 4,
+ min_num_frames = 53,
+ max_num_frames = 149,
+ resolution_multiple = 16,
+ resolution_presets = ((832, 480), (480, 832), (640, 640), (736, 544), (544, 736)),
+ duration_presets = (3.0, 5.0, 6.0),
+ bf16_components_gb = (6.7, 0.0, 1.4),
+ supports_torch_compile = False,
+ i2v_pipeline_class = "Cosmos3OmniPipeline",
+ i2v_fits_first_frame = False,
+ scheduler_overrides = _COSMOS3_EDGE_SCHEDULER,
+ call_kwargs = (("add_resolution_template", False), ("add_duration_template", False)),
+ # cudnn.benchmark made renders differ across processes; bit-identical off.
+ cudnn_benchmark = False,
+ # The fused encoder moved I2V renders off the card's call (every step attends to the encoded clip).
+ vae_fused_encoder = False,
+ ),
)
@@ -1047,15 +1187,17 @@ _UNSUPPORTED_VIDEO_CHECKPOINTS: tuple[tuple[str, str], ...] = (
"pipeline does not provide, so Unsloth cannot run it. Load a plain Wan2.1 text-to-video "
"checkpoint instead.",
),
+ # Cosmos3 non-generators: here, not on the family rows, so detection names no family for them.
+ *_COSMOS3_UNSUPPORTED,
)
def unsupported_video_checkpoint_reason(
*identifiers: Optional[str], wan21_checkpoint: Optional[str] = None
) -> Optional[str]:
- """Why a Wan 2.1 / FastWan / AnyFlow pick cannot load, or None. ``wan21_checkpoint``: the selected checkpoint of a
- pick that already resolved to a Wan2.1 family, whose last segment may omit the Wan2.1 token
- (``i2v-14b-480p-Q4_K_M.gguf``) and is judged as if it carried it; containers never are."""
+ """Why a Wan 2.1 / FastWan / AnyFlow pick, or a Cosmos3 checkpoint that is not a generator, cannot load, or None.
+ ``wan21_checkpoint``: the selected checkpoint of a pick that already resolved to a Wan2.1 family, whose last segment
+ may omit the Wan2.1 token (``i2v-14b-480p-Q4_K_M.gguf``) and is judged as if it carried it; containers never are."""
needles = [normalize_family_name(str(identifier)) for identifier in identifiers if identifier]
if wan21_checkpoint:
needle = normalize_family_name(str(wan21_checkpoint))
@@ -1670,6 +1812,8 @@ def validate_video_reference_conditioning(
# Default (steps, guidance) per checkpoint variant, matched by substring (picked id then base repo), most specific
# first.
_VIDEO_GENERATION_DEFAULTS: tuple[tuple[str, int, float], ...] = (
+ ("cosmos3-nano", 35, 6.0),
+ ("cosmos3-edge", 20, 6.0),
# MiniMax-H3 PDD baked checkpoints: ComfyUI's recipe is 8 Euler steps on the simple schedule at CFG 1 (shifts 12 / 3
# are the family defaults). Its head bank was distilled for that partition.
("pdd", 8, 1.0),
@@ -1693,7 +1837,9 @@ _VIDEO_GENERATION_DEFAULTS: tuple[tuple[str, int, float], ...] = (
# The Wan and FusionX keys count only in the model / file name, so an owner or folder spelling one cannot outrank the family the
# checkpoint itself names.
_NAME_SEGMENT_DEFAULT_KEYS = frozenset(
- k for k, _s, _g in _VIDEO_GENERATION_DEFAULTS if k.startswith(("wan", "fusionx", "pdd"))
+ k
+ for k, _s, _g in _VIDEO_GENERATION_DEFAULTS
+ if k.startswith(("wan", "fusionx", "pdd", "cosmos3"))
)
# A PDD recipe on another family's checkpoint (a Wan file under /models/pdd/) would silently run 8 steps at CFG 1.
_FAMILY_SCOPED_DEFAULT_KEYS = {"pdd": "minimax-h3"}
diff --git a/studio/backend/core/inference/video_i2v.py b/studio/backend/core/inference/video_i2v.py
index 4fdb615534d..a234d82e06c 100644
--- a/studio/backend/core/inference/video_i2v.py
+++ b/studio/backend/core/inference/video_i2v.py
@@ -124,7 +124,7 @@ def first_frame_pipeline(
_restore(pipe, saved)
raise
try:
- with _offload_vae_after_encode(pipe):
+ with offload_vae_after_encode(pipe):
yield pipe
finally:
pipe.__class__ = original_cls
@@ -133,7 +133,7 @@ def first_frame_pipeline(
@contextlib.contextmanager
-def _offload_vae_after_encode(pipe: Any) -> Iterator[None]:
+def offload_vae_after_encode(pipe: Any) -> Iterator[None]:
"""Model offload chains vae after the transformer (the t2v order), so the first-frame encode would leave the VAE
resident through denoising; send it back once the encode returns."""
vae = getattr(pipe, "vae", None)
diff --git a/studio/backend/core/inference/video_vae_untiled.py b/studio/backend/core/inference/video_vae_untiled.py
index a99dda5a5b3..0ff44b71575 100644
--- a/studio/backend/core/inference/video_vae_untiled.py
+++ b/studio/backend/core/inference/video_vae_untiled.py
@@ -70,6 +70,25 @@ def _wide_tiles_enabled() -> bool:
return os.environ.get(WIDE_TILES_ENV, "").strip().lower() not in ("0", "false", "no", "off")
+# (longest tile, edge tile) latents a family's wide tiles keep; Cosmos3: the Wan@16x seam audit floor.
+_WIDE_TILE_FLOOR = {"cosmos3-nano": (16, 8), "cosmos3-edge": (16, 8)}
+
+
+def _wide_axis(
+ length: int, n: int, overlap: int, floor: Optional[tuple]
+) -> Optional[tuple[int, int]]:
+ """(tile, stride) latents for ``n`` tiles over ``length``, or None when ``floor`` rules the count out."""
+ if n == 1:
+ return length, length
+ stride = -(-length // n)
+ if floor is None:
+ return min(length, stride + overlap), stride
+ tile_floor, edge_floor = floor
+ if -(-length // stride) != n or length - (n - 1) * stride < edge_floor:
+ return None
+ return min(length, max(stride + overlap, tile_floor)), stride
+
+
def wide_tile_plan(
family: str,
latent_shape: tuple,
@@ -93,10 +112,11 @@ def wide_tile_plan(
for n_w in range(1, width + 1):
if n_h * n_w > max_tiles or (n_h == 1 and n_w == 1):
continue
- stride_h = -(-height // n_h)
- stride_w = -(-width // n_w)
- tile_h = height if n_h == 1 else min(height, stride_h + overlap)
- tile_w = width if n_w == 1 else min(width, stride_w + overlap)
+ axis_h = _wide_axis(height, n_h, overlap, _WIDE_TILE_FLOOR.get(family))
+ axis_w = _wide_axis(width, n_w, overlap, _WIDE_TILE_FLOOR.get(family))
+ if axis_h is None or axis_w is None:
+ continue
+ (tile_h, stride_h), (tile_w, stride_w) = axis_h, axis_w
need = coef * itemsize / 2 * max(1, batch) * tile_h * tile_w + out_bytes
if need * _MARGIN + _MARGIN_BYTES > free:
continue
diff --git a/studio/backend/core/training/diffusion_train_common.py b/studio/backend/core/training/diffusion_train_common.py
index bf2965986bc..0825e1ba961 100644
--- a/studio/backend/core/training/diffusion_train_common.py
+++ b/studio/backend/core/training/diffusion_train_common.py
@@ -370,6 +370,10 @@ def _resolve_trainable_family(base_model: str, model_family: Optional[str] = Non
# Checked here rather than first so an image repo the picker already claims keeps its existing route.
vid = detect_video_family(base_model)
+ if vid is None and is_local_diffusers:
+ from core.inference.video_families import local_cosmos3_pipeline_family
+ local_family = local_cosmos3_pipeline_family(base_model)
+ vid = detect_video_family("", override = local_family) if local_family else None
if vid is not None:
if vid.name not in TRAINABLE_VIDEO_FAMILIES:
_refuse_untrainable_video_family(vid.name)
diff --git a/studio/backend/hub/services/models/catalog_classification.py b/studio/backend/hub/services/models/catalog_classification.py
index d4e0d677a2a..fbf071644b5 100644
--- a/studio/backend/hub/services/models/catalog_classification.py
+++ b/studio/backend/hub/services/models/catalog_classification.py
@@ -133,6 +133,12 @@ def _video_family_buildable(family) -> bool:
return True
+def _pipeline_only_video_family(family) -> bool:
+ """A family (Cosmos3) whose name alone lists nothing: only its pipeline loads, so the artifact must be one."""
+ from core.inference.video_families import PIPELINE_ONLY_VIDEO_FAMILIES
+ return getattr(family, "name", None) in PIPELINE_ONLY_VIDEO_FAMILIES
+
+
def _hint_leaf(hint: str) -> str:
"""The last path segment of *hint*, leaving a bare name or repo id untouched."""
return str(hint).strip().rstrip("/\\").rsplit("/", 1)[-1].rsplit("\\", 1)[-1]
@@ -152,7 +158,8 @@ def _name_hint_media_task(
for hint in name_hints:
family = detect_video_family(hint) if hint else None
- if family is not None:
+ # A GGUF is never a Cosmos3 generator (pipeline only): Cosmos3-Nano-Q4_K_M.gguf is its reasoner.
+ if family is not None and not _pipeline_only_video_family(family):
if moe_pick_pairs(family, *name_hints) and _video_family_buildable(family):
return _VIDEO_GEN_TASK
return _UNSUPPORTED_DIFFUSION_TASK
@@ -516,7 +523,8 @@ def _hf_cache_snapshot_repo_id(path: Optional[str]) -> Optional[str]:
return None
-def _local_family_needles(model) -> tuple[str, ...]:
+def _local_name_needles(model) -> list[Optional[str]]:
+ """The names a local row goes by: model id, display name, folder name, and an HF-cache snapshot's repo id."""
needles = [model.model_id, model.display_name, Path(model.id).name]
try:
needles.append(
@@ -524,6 +532,11 @@ def _local_family_needles(model) -> tuple[str, ...]:
)
except Exception:
pass
+ return needles
+
+
+def _local_family_needles(model) -> tuple[str, ...]:
+ needles = _local_name_needles(model)
try:
from core.inference.diffusion import resolve_local_single_file
single = resolve_local_single_file(model.path)
@@ -531,6 +544,11 @@ def _local_family_needles(model) -> tuple[str, ...]:
needles.append(single)
except Exception:
pass
+ try:
+ from core.inference.video_families import local_cosmos3_pipeline_family
+ needles.append(local_cosmos3_pipeline_family(model.path))
+ except Exception:
+ pass
try:
# A renamed loose checkpoint: its header still names the family.
path = Path(model.path)
@@ -563,10 +581,21 @@ def _local_model_task(model) -> Optional[str]:
return None
try:
from core.inference.video import _is_trusted_video_repo
- from core.inference.video_families import detect_video_family
- for needle in _local_family_needles(model):
- family = detect_video_family(needle)
- if family is not None and _is_trusted_video_repo(path):
+ from core.inference.video_families import (
+ detect_video_family,
+ unsupported_video_checkpoint_reason,
+ )
+
+ # Names are judged before the family, as the loader does.
+ if not unsupported_video_checkpoint_reason(*_local_name_needles(model), path):
+ for needle in _local_family_needles(model):
+ family = detect_video_family(needle)
+ if family is None or not _is_trusted_video_repo(path):
+ continue
+ if _pipeline_only_video_family(family) and not _is_diffusers_pipeline_dir(
+ Path(path)
+ ):
+ continue
return _VIDEO_GEN_TASK if _video_family_buildable(family) else None
except Exception:
pass
@@ -661,8 +690,9 @@ def _local_is_diffusers(model) -> bool:
pass
try:
from core.inference.video_families import detect_video_family
+ families = (detect_video_family(needle) for needle in _local_family_needles(model))
return any(
- detect_video_family(needle) is not None for needle in _local_family_needles(model)
+ family is not None and not _pipeline_only_video_family(family) for family in families
)
except Exception:
return False
@@ -690,7 +720,8 @@ def _repo_is_diffusers(repo_info, selected: Optional[Path] = None) -> bool:
# can_chat set: the video weights reach the text loader.
try:
from core.inference.video_families import detect_video_family
- return detect_video_family(repo_id) is not None
+ family = detect_video_family(repo_id)
+ return family is not None and not _pipeline_only_video_family(family)
except Exception:
return False
@@ -727,9 +758,15 @@ def _cached_repo_task(repo_info, selected: Optional[Path] = None) -> Optional[st
family = detect_video_family(repo_id)
if family is not None:
- trusted = _is_trusted_video_repo(repo_id) or _untrusted_repo_single_files_loadable(
- repo_info, selected
- )
+ if _pipeline_only_video_family(family):
+ # Generator-first: nvidia/Cosmos3-Edge also has a reasoner root config.json but lists as video.
+ trusted = _is_trusted_video_repo(repo_id) and _repo_has_pipeline_index(
+ repo_info, selected
+ )
+ else:
+ trusted = _is_trusted_video_repo(repo_id) or _untrusted_repo_single_files_loadable(
+ repo_info, selected
+ )
if not trusted or not _video_family_buildable(family):
return None
return _VIDEO_GEN_TASK
diff --git a/studio/backend/hub/utils/comfy_models.py b/studio/backend/hub/utils/comfy_models.py
index b14fc36bb51..802d6b38784 100644
--- a/studio/backend/hub/utils/comfy_models.py
+++ b/studio/backend/hub/utils/comfy_models.py
@@ -344,7 +344,9 @@ def _single_file_loadable(image_fam, video_fam, filename: str) -> bool:
return not (
image_fam.pipeline_only or getattr(image_fam, "native_transformer_files_only", False)
)
- if video_fam is None or video_fam.is_moe:
+ from core.inference.video_families import PIPELINE_ONLY_VIDEO_FAMILIES
+
+ if video_fam is None or video_fam.is_moe or video_fam.name in PIPELINE_ONLY_VIDEO_FAMILIES:
return False
if not getattr(video_fam, "modular_workflow", None):
return True
diff --git a/studio/backend/routes/video.py b/studio/backend/routes/video.py
index ac085202b31..240f0c668fc 100644
--- a/studio/backend/routes/video.py
+++ b/studio/backend/routes/video.py
@@ -202,6 +202,7 @@ async def video_download_plan(
model_kind = kind,
base_repo = request.base_repo,
transformer_quant = request.transformer_quant,
+ text_encoder_quant = request.text_encoder_quant,
# And the partition, because one of those quant-keyed refusals is task-keyed. Without it here the plan below
# staged the 66 GB dense transformer_ref/ AND the incompatible fl2va quant first: the hosted pre-quantized
# H3 checkpoints are fl2va denoisers, so a quantized ref2va is rejected.
diff --git a/studio/backend/tests/fixtures/cosmos3_checkpoints.json b/studio/backend/tests/fixtures/cosmos3_checkpoints.json
new file mode 100644
index 00000000000..2c4ff50a193
--- /dev/null
+++ b/studio/backend/tests/fixtures/cosmos3_checkpoints.json
@@ -0,0 +1,328 @@
+{
+ "nvidia/Cosmos3-Edge-Policy-DROID@a7c7288f9b6ac1684e993007b0f9703dd26e58ef": {
+ "config": {
+ "architectures": [
+ "Cosmos3ForConditionalGeneration"
+ ],
+ "model_type": "cosmos3_omni"
+ },
+ "model_index": {
+ "_class_name": "Cosmos3OmniPipeline",
+ "_diffusers_version": "0.40.0.dev0",
+ "default_use_system_prompt": false,
+ "enable_safety_checker": false,
+ "safety_checker": [
+ null,
+ null
+ ],
+ "scheduler": [
+ "diffusers",
+ "UniPCMultistepScheduler"
+ ],
+ "sound_tokenizer": [
+ null,
+ null
+ ],
+ "text_tokenizer": [
+ "transformers",
+ "PreTrainedTokenizerFast"
+ ],
+ "transformer": [
+ "diffusers",
+ "Cosmos3OmniTransformer"
+ ],
+ "use_native_flow_schedule": true,
+ "vae": [
+ "diffusers",
+ "AutoencoderKLWan"
+ ]
+ },
+ "transformer_config": {
+ "_class_name": "Cosmos3OmniTransformer",
+ "action_gen": true,
+ "backbone_type": "cosmos3_edge_nemotron_dense",
+ "hidden_size": 2048,
+ "latent_patch_size": 2,
+ "num_hidden_layers": 28,
+ "sound_gen": false
+ }
+ },
+ "nvidia/Cosmos3-Edge@344d602b128d1bbdacb43b08d0a3626f46343e29": {
+ "config": {
+ "architectures": [
+ "Cosmos3EdgeForConditionalGeneration"
+ ],
+ "model_type": "cosmos3_edge"
+ },
+ "listing": [
+ ["chat_template.jinja", 12158],
+ ["config.json", 1679],
+ ["generation_config.json", 154],
+ ["model.safetensors.index.json", 68564],
+ ["model_index.json", 555],
+ ["modular_model_index.json", 1357],
+ ["preprocessor_config.json", 334],
+ ["processor_config.json", 875],
+ ["scheduler/scheduler_config.json", 889],
+ ["special_tokens_map.json", 563],
+ ["text_tokenizer/chat_template.jinja", 12158],
+ ["text_tokenizer/special_tokens_map.json", 563],
+ ["text_tokenizer/tokenizer.json", 17077500],
+ ["text_tokenizer/tokenizer_config.json", 393],
+ ["tokenizer.json", 17077500],
+ ["tokenizer_config.json", 177253],
+ ["transformer/config.json", 1075],
+ ["transformer/diffusion_pytorch_model-00001-of-00002.safetensors", 5000040072],
+ ["transformer/diffusion_pytorch_model-00002-of-00002.safetensors", 1739335512],
+ ["transformer/diffusion_pytorch_model.safetensors.index.json", 53623],
+ ["vae/config.json", 1755],
+ ["vae/diffusion_pytorch_model.safetensors", 1409400600],
+ ["video_preprocessor_config.json", 367],
+ ["vision_encoder/model.safetensors", 978739880]
+ ],
+ "model_index": {
+ "_class_name": "Cosmos3OmniPipeline",
+ "_diffusers_version": "0.40.0.dev0",
+ "default_use_system_prompt": false,
+ "enable_safety_checker": false,
+ "safety_checker": [
+ null,
+ null
+ ],
+ "scheduler": [
+ "diffusers",
+ "UniPCMultistepScheduler"
+ ],
+ "sound_tokenizer": [
+ null,
+ null
+ ],
+ "text_tokenizer": [
+ "transformers",
+ "PreTrainedTokenizerFast"
+ ],
+ "transformer": [
+ "diffusers",
+ "Cosmos3OmniTransformer"
+ ],
+ "use_native_flow_schedule": true,
+ "vae": [
+ "diffusers",
+ "AutoencoderKLWan"
+ ]
+ },
+ "scheduler_config": {
+ "_class_name": "UniPCMultistepScheduler",
+ "_diffusers_version": "0.40.0.dev0",
+ "beta_end": 0.02,
+ "beta_schedule": "linear",
+ "beta_start": 0.0001,
+ "disable_corrector": [],
+ "dynamic_thresholding_ratio": 0.995,
+ "final_sigmas_type": "zero",
+ "flow_shift": 1.0,
+ "lower_order_final": true,
+ "num_train_timesteps": 1000,
+ "predict_x0": true,
+ "prediction_type": "flow_prediction",
+ "rescale_betas_zero_snr": false,
+ "sample_max_value": 1.0,
+ "shift_terminal": null,
+ "sigma_max": 200.0,
+ "sigma_min": 0.147,
+ "solver_order": 2,
+ "solver_p": null,
+ "solver_type": "bh2",
+ "steps_offset": 0,
+ "thresholding": false,
+ "time_shift_type": "exponential",
+ "timestep_spacing": "linspace",
+ "trained_betas": null,
+ "use_beta_sigmas": false,
+ "use_dynamic_shifting": false,
+ "use_exponential_sigmas": false,
+ "use_flow_sigmas": true,
+ "use_karras_sigmas": true
+ },
+ "transformer_config": {
+ "_class_name": "Cosmos3OmniTransformer",
+ "action_gen": true,
+ "backbone_type": "cosmos3_edge_nemotron_dense",
+ "hidden_size": 2048,
+ "latent_patch_size": 2,
+ "num_hidden_layers": 28,
+ "sound_gen": false
+ },
+ "vae_config": {
+ "_class_name": "AutoencoderKLWan",
+ "scale_factor_spatial": 16,
+ "scale_factor_temporal": 4,
+ "z_dim": 48
+ }
+ },
+ "nvidia/Cosmos3-Nano@e59a53c25979a090fa8706c9acc0c254a6e89b92": {
+ "config": {
+ "architectures": [
+ "Cosmos3ForConditionalGeneration"
+ ],
+ "model_type": "cosmos3_omni"
+ },
+ "listing": [
+ ["chat_template.json", 5499],
+ ["checkpoint.json", 2],
+ ["config.json", 8166],
+ ["generation_config.json", 269],
+ ["merges.txt", 1671839],
+ ["model.safetensors.index.json", 112969],
+ ["model_index.json", 502],
+ ["modular_model_index.json", 1667],
+ ["preprocessor_config.json", 390],
+ ["scheduler/scheduler_config.json", 884],
+ ["sound_tokenizer/config.json", 1310],
+ ["sound_tokenizer/diffusion_pytorch_model.safetensors", 1985176840],
+ ["text_tokenizer/added_tokens.json", 707],
+ ["text_tokenizer/chat_template.jinja", 5292],
+ ["text_tokenizer/merges.txt", 1671853],
+ ["text_tokenizer/special_tokens_map.json", 613],
+ ["text_tokenizer/tokenizer.json", 11422654],
+ ["text_tokenizer/tokenizer_config.json", 5404],
+ ["text_tokenizer/vocab.json", 2776833],
+ ["tokenizer.json", 7032403],
+ ["tokenizer_config.json", 10868],
+ ["transformer/config.json", 1383],
+ ["transformer/diffusion_pytorch_model-00001-of-00007.safetensors", 4902257280],
+ ["transformer/diffusion_pytorch_model-00002-of-00007.safetensors", 4999863656],
+ ["transformer/diffusion_pytorch_model-00003-of-00007.safetensors", 4932719448],
+ ["transformer/diffusion_pytorch_model-00004-of-00007.safetensors", 4983084656],
+ ["transformer/diffusion_pytorch_model-00005-of-00007.safetensors", 4949498576],
+ ["transformer/diffusion_pytorch_model-00006-of-00007.safetensors", 4261644464],
+ ["transformer/diffusion_pytorch_model-00007-of-00007.safetensors", 1318361208],
+ ["transformer/diffusion_pytorch_model.safetensors.index.json", 78854],
+ ["vae/config.json", 1750],
+ ["vae/diffusion_pytorch_model.safetensors", 1409400600],
+ ["video_preprocessor_config.json", 385],
+ ["vision_encoder/config.json", 509],
+ ["vision_encoder/model.safetensors", 1152811416],
+ ["vocab.json", 2776833]
+ ],
+ "model_index": {
+ "_class_name": "Cosmos3OmniDiffusersPipeline",
+ "_diffusers_version": "0.37.1",
+ "scheduler": [
+ "diffusers",
+ "UniPCMultistepScheduler"
+ ],
+ "sound_tokenizer": [
+ "diffusers",
+ "Cosmos3AVAEAudioTokenizer"
+ ],
+ "text_tokenizer": [
+ "transformers",
+ "Qwen2TokenizerFast"
+ ],
+ "transformer": [
+ "diffusers",
+ "Cosmos3OmniTransformer"
+ ],
+ "vae": [
+ "diffusers",
+ "AutoencoderKLWan"
+ ],
+ "vision_encoder": [
+ "transformers",
+ "Qwen3VLVisionModel"
+ ]
+ },
+ "scheduler_config": {
+ "_class_name": "UniPCMultistepScheduler",
+ "_diffusers_version": "0.37.1",
+ "beta_end": 0.02,
+ "beta_schedule": "linear",
+ "beta_start": 0.0001,
+ "disable_corrector": [],
+ "dynamic_thresholding_ratio": 0.995,
+ "final_sigmas_type": "zero",
+ "flow_shift": 1.0,
+ "lower_order_final": true,
+ "num_train_timesteps": 1000,
+ "predict_x0": true,
+ "prediction_type": "flow_prediction",
+ "rescale_betas_zero_snr": false,
+ "sample_max_value": 1.0,
+ "shift_terminal": null,
+ "sigma_max": 200.0,
+ "sigma_min": 0.147,
+ "solver_order": 2,
+ "solver_p": null,
+ "solver_type": "bh2",
+ "steps_offset": 0,
+ "thresholding": false,
+ "time_shift_type": "exponential",
+ "timestep_spacing": "linspace",
+ "trained_betas": null,
+ "use_beta_sigmas": false,
+ "use_dynamic_shifting": false,
+ "use_exponential_sigmas": false,
+ "use_flow_sigmas": true,
+ "use_karras_sigmas": true
+ },
+ "transformer_config": {
+ "_class_name": "Cosmos3OmniTransformer",
+ "action_gen": true,
+ "hidden_size": 4096,
+ "latent_patch_size": 2,
+ "num_hidden_layers": 36,
+ "sound_gen": true
+ },
+ "vae_config": {
+ "_class_name": "AutoencoderKLWan",
+ "scale_factor_spatial": 16,
+ "scale_factor_temporal": 4,
+ "z_dim": 48
+ }
+ },
+ "nvidia/Cosmos3-Super@f543c56225b2e04d0ad141e29655be3a45d9c455": {
+ "config": {
+ "architectures": [
+ "Cosmos3ForConditionalGeneration"
+ ],
+ "model_type": "cosmos3_omni"
+ },
+ "model_index": {
+ "_class_name": "Cosmos3OmniDiffusersPipeline",
+ "_diffusers_version": "0.37.1",
+ "scheduler": [
+ "diffusers",
+ "UniPCMultistepScheduler"
+ ],
+ "sound_tokenizer": [
+ "diffusers",
+ "Cosmos3AVAEAudioTokenizer"
+ ],
+ "text_tokenizer": [
+ "transformers",
+ "Qwen2TokenizerFast"
+ ],
+ "transformer": [
+ "diffusers",
+ "Cosmos3OmniTransformer"
+ ],
+ "vae": [
+ "diffusers",
+ "AutoencoderKLWan"
+ ],
+ "vision_encoder": [
+ "transformers",
+ "Qwen3VLVisionModel"
+ ]
+ },
+ "transformer_config": {
+ "_class_name": "Cosmos3OmniTransformer",
+ "action_gen": true,
+ "hidden_size": 5120,
+ "latent_patch_size": 2,
+ "num_hidden_layers": 64,
+ "sound_gen": true
+ }
+ }
+}
diff --git a/studio/backend/tests/fixtures/diffusion_autoopt_parity.json b/studio/backend/tests/fixtures/diffusion_autoopt_parity.json
index c61988adbe3..55d45e92190 100644
--- a/studio/backend/tests/fixtures/diffusion_autoopt_parity.json
+++ b/studio/backend/tests/fixtures/diffusion_autoopt_parity.json
@@ -1,5 +1,5 @@
{
- "meta": {"base": "origin/main 5f38afbc2d (before diffusion_autoopt)", "dtypes": ["bfloat16", "float16"], "families": ["image|flux.1", "image|flux.1-kontext", "image|flux.2-dev", "image|flux.2-klein", "image|flux.3-klein", "image|flux.3-klein-base", "image|hidream-i1", "image|hunyuanimage-2.1", "image|ideogram-4", "image|krea-2", "image|lumina-2", "image|moss-image", "image|qwen-image", "image|qwen-image-2.1", "image|qwen-image-edit", "image|qwen-image-layered", "image|sdxl", "image|z-image", "video|hunyuanvideo-1.5", "video|hunyuanvideo-1.5-720p", "video|ltx-2", "video|ltx-2.5", "video|minimax-h3", "video|wan2.1-t2v-1.3b", "video|wan2.1-t2v-14b", "video|wan2.2-t2v-a14b", "video|wan2.2-ti2v-5b"], "speeds": ["off", "eager", "default", "max"]},
+ "meta": {"base": "origin/main 5f38afbc2d (before diffusion_autoopt)", "dtypes": ["bfloat16", "float16"], "families": ["image|flux.1", "image|flux.1-kontext", "image|flux.2-dev", "image|flux.2-klein", "image|flux.3-klein", "image|flux.3-klein-base", "image|hidream-i1", "image|hunyuanimage-2.1", "image|ideogram-4", "image|krea-2", "image|lumina-2", "image|moss-image", "image|qwen-image", "image|qwen-image-2.1", "image|qwen-image-edit", "image|qwen-image-layered", "image|sdxl", "image|z-image", "video|cosmos3-edge", "video|cosmos3-nano", "video|hunyuanvideo-1.5", "video|hunyuanvideo-1.5-720p", "video|ltx-2", "video|ltx-2.5", "video|minimax-h3", "video|wan2.1-t2v-1.3b", "video|wan2.1-t2v-14b", "video|wan2.2-t2v-a14b", "video|wan2.2-ti2v-5b"], "speeds": ["off", "eager", "default", "max"]},
"cases": {
"image|flux.1-kontext|default|bfloat16|offload=0|gguf=0": {"applied":[["compiled","cuda_graph","fp16_accum"]],"graph_after_placement":false,"graph_reason":"eligible","keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":false,"compile_calls":[{"dynamic":true,"fullgraph":true}],"int8_gemm":false,"static":false}},"patches":{"arch_fusions":true,"eager_fusions":true,"flux2_rope":false,"qwenimage21_fast_step":false,"rocm_fused":false}},
"image|flux.1-kontext|default|bfloat16|offload=0|gguf=1": {"applied":[["compiled_dequant","cuda_graph","fp16_accum"]],"graph_after_placement":false,"graph_reason":"eligible","keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":null,"compile_calls":[],"int8_gemm":false,"static":false}},"patches":{"arch_fusions":true,"eager_fusions":true,"flux2_rope":false,"qwenimage21_fast_step":false,"rocm_fused":false}},
@@ -545,6 +545,38 @@
"image|z-image|off|float16|offload=0|gguf=1": {"applied":[[]],"graph_after_placement":false,"graph_reason":null,"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":null,"compile_calls":[],"int8_gemm":false,"static":false}},"patches":{"flux2_rope":false,"qwenimage21_fast_step":false,"rocm_fused":false}},
"image|z-image|off|float16|offload=1|gguf=0": {"applied":[[]],"graph_after_placement":false,"graph_reason":null,"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":null,"compile_calls":[],"int8_gemm":false,"static":false}},"patches":{"flux2_rope":false,"qwenimage21_fast_step":false,"rocm_fused":false}},
"image|z-image|off|float16|offload=1|gguf=1": {"applied":[[]],"graph_after_placement":false,"graph_reason":null,"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":null,"compile_calls":[],"int8_gemm":false,"static":false}},"patches":{"flux2_rope":false,"qwenimage21_fast_step":false,"rocm_fused":false}},
+ "video|cosmos3-edge|default|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|default|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|default|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|default|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|eager|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|eager|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|eager|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|eager|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|max|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|max|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|max|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|max|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|off|bfloat16|offload=0|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|off|bfloat16|offload=1|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|off|float16|offload=0|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-edge|off|float16|offload=1|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|default|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|default|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|default|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|default|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|eager|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|eager|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|eager|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|eager|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|max|bfloat16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|max|bfloat16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|max|float16|offload=0|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|max|float16|offload=1|gguf=0": {"patches":{"wan_fused":false},"applied":[["fp16_accum","tf32"]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":"family opts out","graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|off|bfloat16|offload=0|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|off|bfloat16|offload=1|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|off|float16|offload=0|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
+ "video|cosmos3-nano|off|float16|offload=1|gguf=0": {"patches":{},"applied":[[]],"keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"graph_reason":null,"graph_after_placement":false,"modules":{"transformer":{"compile_calls":[],"static":false,"auto_dynamic":null,"int8_gemm":false}}},
"video|hunyuanvideo-1.5-720p|default|bfloat16|offload=0|gguf=0": {"applied":[["compiled","fp16_accum"]],"graph_after_placement":false,"graph_reason":"family opts out","keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":false,"compile_calls":[{"dynamic":true,"fullgraph":true}],"int8_gemm":false,"static":false}},"patches":{"wan_fused":false}},
"video|hunyuanvideo-1.5-720p|default|bfloat16|offload=1|gguf=0": {"applied":[["compiled","fp16_accum"]],"graph_after_placement":false,"graph_reason":"family opts out","keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":false,"compile_calls":[{"dynamic":true,"fullgraph":false}],"int8_gemm":false,"static":false}},"patches":{"wan_fused":false}},
"video|hunyuanvideo-1.5-720p|default|float16|offload=0|gguf=0": {"applied":[[]],"graph_after_placement":false,"graph_reason":"family opts out","keys":[["channels_last","compiled","compiled_dequant","compiled_vae_decode","cuda_graph","cudnn_benchmark","fp16_accum","fused_qkv","int8_gemm","rocm_query_chunks","tf32","vae_fp16_decode","vae_fused","vae_single_frame"]],"modules":{"transformer":{"auto_dynamic":null,"compile_calls":[],"int8_gemm":false,"static":false}},"patches":{"wan_fused":false}},
diff --git a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
index a034411df4c..e96e6aae0ec 100644
--- a/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
+++ b/studio/backend/tests/fixtures/diffusion_family_data_freeze.json
@@ -1,5 +1,11 @@
{
"auto_static_skip_by_base": {
+ "cosmos3-edge": {
+ "nvidia/Cosmos3-Edge": null
+ },
+ "cosmos3-nano": {
+ "nvidia/Cosmos3-Nano": null
+ },
"flux.1": {
"black-forest-labs/FLUX.1-schnell": null
},
@@ -113,6 +119,26 @@
}
},
"defaults": {
+ "cosmos3-edge": {
+ "fields": [
+ 20,
+ 6.0
+ ],
+ "resolved": [
+ 20,
+ 6.0
+ ]
+ },
+ "cosmos3-nano": {
+ "fields": [
+ 35,
+ 6.0
+ ],
+ "resolved": [
+ 35,
+ 6.0
+ ]
+ },
"flux.1": [
4,
0.0
@@ -277,6 +303,18 @@
]
},
"flags": {
+ "cosmos3-edge": {
+ "cudnn_benchmark": false,
+ "filter_reduction_configs": false,
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": false
+ },
+ "cosmos3-nano": {
+ "cudnn_benchmark": false,
+ "filter_reduction_configs": false,
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": false
+ },
"flux.1": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
@@ -297,7 +335,8 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"flux.1-kontext": {
"cudnn_benchmark": false,
@@ -319,12 +358,14 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"flux.2-dev": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"flux.2-klein": {
"cudnn_benchmark": false,
@@ -334,72 +375,86 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"flux.3-klein": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"flux.3-klein-base": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"hidream-i1": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"hunyuanimage-2.1": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"hunyuanvideo-1.5": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"hunyuanvideo-1.5-720p": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"ideogram-4": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"krea-2": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"ltx-2": {
"cudnn_benchmark": false,
"filter_reduction_configs": true,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"ltx-2.5": {
"cudnn_benchmark": false,
"filter_reduction_configs": true,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"lumina-2": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"minimax-h3": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"moss-image": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"qwen-image": {
"cudnn_benchmark": false,
@@ -421,12 +476,14 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"qwen-image-2.1": {
"cudnn_benchmark": true,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"qwen-image-edit": {
"cudnn_benchmark": false,
@@ -448,7 +505,8 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"qwen-image-layered": {
"cudnn_benchmark": false,
@@ -470,32 +528,38 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
},
"sdxl": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"wan2.1-t2v-1.3b": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"wan2.1-t2v-14b": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"wan2.2-t2v-a14b": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"wan2.2-ti2v-5b": {
"cudnn_benchmark": false,
"filter_reduction_configs": false,
- "filter_reduction_configs_archs": []
+ "filter_reduction_configs_archs": [],
+ "vae_fused_encoder": true
},
"z-image": {
"cudnn_benchmark": false,
@@ -517,7 +581,8 @@
10,
0
]
- ]
+ ],
+ "vae_fused_encoder": true
}
},
"per_family": {
@@ -862,6 +927,182 @@
"preview_key": "qwen_image",
"te_int8_effective": "fp8"
},
+ "cosmos3-edge": {
+ "auto": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "auto_bf16_when_resident": null,
+ "bf16": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "convrot_default_on": false,
+ "fp8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "int8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [
+ "norm",
+ "_mod",
+ "modulation",
+ "timestep_embed",
+ "guidance_embed",
+ "time_text_embed",
+ "pooled",
+ "time_embed"
+ ],
+ "pad": [],
+ "zero_row": []
+ },
+ "mxfp8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "nvfp4": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "page": "video",
+ "preview_key": null,
+ "te_int8_effective": "fp8"
+ },
+ "cosmos3-nano": {
+ "auto": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "auto_bf16_when_resident": null,
+ "bf16": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "convrot_default_on": false,
+ "fp8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "int8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [
+ "norm",
+ "_mod",
+ "modulation",
+ "timestep_embed",
+ "guidance_embed",
+ "time_text_embed",
+ "pooled",
+ "time_embed"
+ ],
+ "pad": [],
+ "zero_row": []
+ },
+ "mxfp8": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "nvfp4": {
+ "convrot_filename": null,
+ "convrot_repo": null,
+ "convrot_spec": [
+ 0,
+ []
+ ],
+ "convrot_variant_repos": [],
+ "exclude": [],
+ "pad": [],
+ "zero_row": []
+ },
+ "page": "video",
+ "preview_key": null,
+ "te_int8_effective": "fp8"
+ },
"flux.1": {
"auto": {
"convrot_filename": null,
@@ -3545,6 +3786,8 @@
}
},
"content_video_families": [
+ "cosmos3-edge",
+ "cosmos3-nano",
"hunyuanvideo-1.5",
"hunyuanvideo-1.5-720p",
"ltx-2",
@@ -3963,6 +4206,8 @@
"lightricks/ltx-2.5",
"lightricks/ltx-2.5-diffusers",
"minimaxai/minimax-h3",
+ "nvidia/cosmos3-edge",
+ "nvidia/cosmos3-nano",
"wan-ai/wan2.1-t2v-1.3b-diffusers",
"wan-ai/wan2.1-t2v-14b-diffusers",
"wan-ai/wan2.2-t2v-a14b-diffusers",
@@ -3973,12 +4218,22 @@
"ltx-2.5": 115343.36
},
"untiled_bytes_per_latent_pixel": {
+ "cosmos3-edge": 2621440.0,
+ "cosmos3-nano": 2621440.0,
"wan2.1-t2v-1.3b": 629145.6,
"wan2.1-t2v-14b": 629145.6,
"wan2.2-t2v-a14b": 629145.6,
"wan2.2-ti2v-5b": 2621440.0
},
"untiled_output_scale": {
+ "cosmos3-edge": [
+ 16,
+ 4
+ ],
+ "cosmos3-nano": [
+ 16,
+ 4
+ ],
"wan2.1-t2v-1.3b": [
8,
4
@@ -4026,6 +4281,22 @@
null,
null
],
+ "cosmos3-edge": [
+ 16683663360,
+ 33367326720,
+ 21071790080,
+ 42143580160,
+ 2471772160,
+ 4943544320
+ ],
+ "cosmos3-nano": [
+ 16683663360,
+ 33367326720,
+ 21071790080,
+ 42143580160,
+ 2471772160,
+ 4943544320
+ ],
"hunyuanvideo-1.5": [
null,
null,
diff --git a/studio/backend/tests/fixtures/vae_tile_configs.json b/studio/backend/tests/fixtures/vae_tile_configs.json
index 44c12696441..ca5a738a341 100644
--- a/studio/backend/tests/fixtures/vae_tile_configs.json
+++ b/studio/backend/tests/fixtures/vae_tile_configs.json
@@ -1617,6 +1617,274 @@
"temporal_compression_ratio": 4,
"upsample_match_channel": true
}
+ },
+ "cosmos3-nano": {
+ "kind": "video",
+ "repo": "nvidia/Cosmos3-Nano",
+ "revision": "e59a53c25979a090fa8706c9acc0c254a6e89b92",
+ "config": {
+ "_class_name": "AutoencoderKLWan",
+ "_diffusers_version": "0.37.1",
+ "_name_or_path": "Wan-AI/Wan2.2-TI2V-5B-Diffusers",
+ "attn_scales": [],
+ "base_dim": 160,
+ "clip_output": false,
+ "decoder_base_dim": 256,
+ "dim_mult": [
+ 1,
+ 2,
+ 4,
+ 4
+ ],
+ "dropout": 0.0,
+ "in_channels": 12,
+ "is_residual": true,
+ "latents_mean": [
+ -0.2289,
+ -0.0052,
+ -0.1323,
+ -0.2339,
+ -0.2799,
+ 0.0174,
+ 0.1838,
+ 0.1557,
+ -0.1382,
+ 0.0542,
+ 0.2813,
+ 0.0891,
+ 0.157,
+ -0.0098,
+ 0.0375,
+ -0.1825,
+ -0.2246,
+ -0.1207,
+ -0.0698,
+ 0.5109,
+ 0.2665,
+ -0.2108,
+ -0.2158,
+ 0.2502,
+ -0.2055,
+ -0.0322,
+ 0.1109,
+ 0.1567,
+ -0.0729,
+ 0.0899,
+ -0.2799,
+ -0.123,
+ -0.0313,
+ -0.1649,
+ 0.0117,
+ 0.0723,
+ -0.2839,
+ -0.2083,
+ -0.052,
+ 0.3748,
+ 0.0152,
+ 0.1957,
+ 0.1433,
+ -0.2944,
+ 0.3573,
+ -0.0548,
+ -0.1681,
+ -0.0667
+ ],
+ "latents_std": [
+ 0.4765,
+ 1.0364,
+ 0.4514,
+ 1.1677,
+ 0.5313,
+ 0.499,
+ 0.4818,
+ 0.5013,
+ 0.8158,
+ 1.0344,
+ 0.5894,
+ 1.0901,
+ 0.6885,
+ 0.6165,
+ 0.8454,
+ 0.4978,
+ 0.5759,
+ 0.3523,
+ 0.7135,
+ 0.6804,
+ 0.5833,
+ 1.4146,
+ 0.8986,
+ 0.5659,
+ 0.7069,
+ 0.5338,
+ 0.4889,
+ 0.4917,
+ 0.4069,
+ 0.4999,
+ 0.6866,
+ 0.4093,
+ 0.5709,
+ 0.6065,
+ 0.6415,
+ 0.4944,
+ 0.5726,
+ 1.2042,
+ 0.5458,
+ 1.6887,
+ 0.3971,
+ 1.06,
+ 0.3943,
+ 0.5537,
+ 0.5444,
+ 0.4089,
+ 0.7468,
+ 0.7744
+ ],
+ "num_res_blocks": 2,
+ "out_channels": 12,
+ "patch_size": 2,
+ "scale_factor_spatial": 16,
+ "scale_factor_temporal": 4,
+ "temperal_downsample": [
+ false,
+ true,
+ true
+ ],
+ "z_dim": 48
+ }
+ },
+ "cosmos3-edge": {
+ "kind": "video",
+ "repo": "nvidia/Cosmos3-Edge",
+ "revision": "344d602b128d1bbdacb43b08d0a3626f46343e29",
+ "config": {
+ "_class_name": "AutoencoderKLWan",
+ "_diffusers_version": "0.40.0.dev0",
+ "_name_or_path": "Wan-AI/Wan2.2-TI2V-5B-Diffusers",
+ "attn_scales": [],
+ "base_dim": 160,
+ "clip_output": false,
+ "decoder_base_dim": 256,
+ "dim_mult": [
+ 1,
+ 2,
+ 4,
+ 4
+ ],
+ "dropout": 0.0,
+ "in_channels": 12,
+ "is_residual": true,
+ "latents_mean": [
+ -0.2289,
+ -0.0052,
+ -0.1323,
+ -0.2339,
+ -0.2799,
+ 0.0174,
+ 0.1838,
+ 0.1557,
+ -0.1382,
+ 0.0542,
+ 0.2813,
+ 0.0891,
+ 0.157,
+ -0.0098,
+ 0.0375,
+ -0.1825,
+ -0.2246,
+ -0.1207,
+ -0.0698,
+ 0.5109,
+ 0.2665,
+ -0.2108,
+ -0.2158,
+ 0.2502,
+ -0.2055,
+ -0.0322,
+ 0.1109,
+ 0.1567,
+ -0.0729,
+ 0.0899,
+ -0.2799,
+ -0.123,
+ -0.0313,
+ -0.1649,
+ 0.0117,
+ 0.0723,
+ -0.2839,
+ -0.2083,
+ -0.052,
+ 0.3748,
+ 0.0152,
+ 0.1957,
+ 0.1433,
+ -0.2944,
+ 0.3573,
+ -0.0548,
+ -0.1681,
+ -0.0667
+ ],
+ "latents_std": [
+ 0.4765,
+ 1.0364,
+ 0.4514,
+ 1.1677,
+ 0.5313,
+ 0.499,
+ 0.4818,
+ 0.5013,
+ 0.8158,
+ 1.0344,
+ 0.5894,
+ 1.0901,
+ 0.6885,
+ 0.6165,
+ 0.8454,
+ 0.4978,
+ 0.5759,
+ 0.3523,
+ 0.7135,
+ 0.6804,
+ 0.5833,
+ 1.4146,
+ 0.8986,
+ 0.5659,
+ 0.7069,
+ 0.5338,
+ 0.4889,
+ 0.4917,
+ 0.4069,
+ 0.4999,
+ 0.6866,
+ 0.4093,
+ 0.5709,
+ 0.6065,
+ 0.6415,
+ 0.4944,
+ 0.5726,
+ 1.2042,
+ 0.5458,
+ 1.6887,
+ 0.3971,
+ 1.06,
+ 0.3943,
+ 0.5537,
+ 0.5444,
+ 0.4089,
+ 0.7468,
+ 0.7744
+ ],
+ "num_res_blocks": 2,
+ "out_channels": 12,
+ "patch_size": 2,
+ "scale_factor_spatial": 16,
+ "scale_factor_temporal": 4,
+ "temperal_downsample": [
+ false,
+ true,
+ true
+ ],
+ "z_dim": 48
+ }
}
}
}
\ No newline at end of file
diff --git a/studio/backend/tests/test_diffusion_component_sizes.py b/studio/backend/tests/test_diffusion_component_sizes.py
index 17ce2d09ad6..cdda2a26af8 100644
--- a/studio/backend/tests/test_diffusion_component_sizes.py
+++ b/studio/backend/tests/test_diffusion_component_sizes.py
@@ -1761,3 +1761,19 @@ def test_transformers_folders_recognise_only_transformers_stems(tmp_path):
_component(tmp_path, "vae", 0.1)
sizes = dcs.local_component_sizes(tmp_path)
assert sizes.get("text_encoder") is None and "text_encoder" in sizes.unknown
+
+
+def test_a_cosmos3_snapshot_prices_a_known_zero_text_term(tmp_path):
+ fam = _fam("cosmos3-edge")
+ entry = json.loads(
+ (Path(__file__).parent / "fixtures" / "cosmos3_checkpoints.json").read_text(
+ encoding = "utf-8"
+ )
+ )["nvidia/Cosmos3-Edge@344d602b128d1bbdacb43b08d0a3626f46343e29"]
+ (tmp_path / "model_index.json").write_text(json.dumps(entry["model_index"]), encoding = "utf-8")
+ denoiser_gb, _text_gb, vae_gb = fam.bf16_components_gb
+ _component(tmp_path, "transformer", denoiser_gb)
+ _component(tmp_path, "vae", vae_gb)
+ sizes = dcs.local_component_sizes(tmp_path)
+ assert dcs.video_header_terms(fam, sizes) == pytest.approx((denoiser_gb, 0.0, vae_gb))
+ assert dcs.video_header_terms(_fam("wan2.2-ti2v-5b"), sizes)[1] is None
diff --git a/studio/backend/tests/test_diffusion_family_data_freeze.py b/studio/backend/tests/test_diffusion_family_data_freeze.py
index 18a9d4f5867..128f0156281 100644
--- a/studio/backend/tests/test_diffusion_family_data_freeze.py
+++ b/studio/backend/tests/test_diffusion_family_data_freeze.py
@@ -117,6 +117,7 @@ def _snapshot() -> dict:
for fam in (*IMAGE, *VIDEO):
flags[fam.name] = {
"cudnn_benchmark": getattr(fam, "cudnn_benchmark", True),
+ "vae_fused_encoder": getattr(fam, "vae_fused_encoder", True),
"filter_reduction_configs": bool(getattr(fam, "filter_reduction_configs", False)),
"filter_reduction_configs_archs": _jsonable(
tuple(getattr(fam, "filter_reduction_configs_archs", None) or ())
diff --git a/studio/backend/tests/test_diffusion_memory.py b/studio/backend/tests/test_diffusion_memory.py
index 52aa320b46f..8cd3cce3d5c 100644
--- a/studio/backend/tests/test_diffusion_memory.py
+++ b/studio/backend/tests/test_diffusion_memory.py
@@ -1387,6 +1387,8 @@ def test_unified_oversize_decision_matrix_for_the_real_video_families():
"wan2.1-t2v-14b": {16, 24, 32, 64},
"hunyuanvideo-1.5": {16, 24, 32},
"hunyuanvideo-1.5-720p": {16, 24, 32},
+ "cosmos3-nano": {16, 24, 32},
+ "cosmos3-edge": set(),
}
assert {f.name for f in _FAMILIES} == set(
expected_refusals
diff --git a/studio/backend/tests/test_diffusion_prompt_length_policy.py b/studio/backend/tests/test_diffusion_prompt_length_policy.py
index bba81ea0f2c..5fafd5a56ad 100644
--- a/studio/backend/tests/test_diffusion_prompt_length_policy.py
+++ b/studio/backend/tests/test_diffusion_prompt_length_policy.py
@@ -20,6 +20,7 @@ VARIABLE = (
"QwenImage21Transformer2DModel",
"ZImageTransformer2DModel",
"MiniMaxH3Transformer3DModel",
+ "Cosmos3OmniTransformer",
"MOSSImageTransformer",
)
diff --git a/studio/backend/tests/test_diffusion_qwenimage21_vae_layout.py b/studio/backend/tests/test_diffusion_qwenimage21_vae_layout.py
index 2c261d107f7..f8c79484adf 100644
--- a/studio/backend/tests/test_diffusion_qwenimage21_vae_layout.py
+++ b/studio/backend/tests/test_diffusion_qwenimage21_vae_layout.py
@@ -41,7 +41,7 @@ def test_qwen_image_21_vae_goes_channels_last_when_the_fused_norms_install():
def test_apply_speed_optims_layout_follows_the_fused_planner(monkeypatch, planned):
vae, calls = _vae("AutoencoderKLQwenImage21")
monkeypatch.setattr(ds_mod, "_fused_vae_planned", lambda pipe: planned)
- monkeypatch.setattr(ds_mod, "_install_fused_vae", lambda pipe, logger: planned)
+ monkeypatch.setattr(ds_mod, "_install_fused_vae", lambda pipe, logger, encoder = True: planned)
monkeypatch.setattr(ds_mod, "_enable_cudnn_benchmark", lambda logger: True)
monkeypatch.setattr(ds_mod, "_compile_repeated_blocks", lambda *a, **k: False)
monkeypatch.setattr(ds_mod, "compile_eligible", lambda *a, **k: False)
diff --git a/studio/backend/tests/test_diffusion_speed.py b/studio/backend/tests/test_diffusion_speed.py
index dd87b980747..b2c8d6ef875 100644
--- a/studio/backend/tests/test_diffusion_speed.py
+++ b/studio/backend/tests/test_diffusion_speed.py
@@ -818,7 +818,11 @@ def test_fused_vae_keeps_its_channels_last_weights(monkeypatch, tier):
monkeypatch.delenv(ds_mod.COMPILE_VAE_ENV, raising = False)
pipe = _Pipe(with_compile = True)
- def fused(p, logger):
+ def fused(
+ p,
+ logger,
+ encoder = True,
+ ):
p.vae._unsloth_vae_fused_cl_weights = True
return True
@@ -828,6 +832,30 @@ def test_fused_vae_keeps_its_channels_last_weights(monkeypatch, tier):
assert applied["channels_last"] is True and pipe.vae.mem_format == torch.channels_last
[email protected]("opt_out", [False, True])
+def test_fused_vae_leaves_the_encoder_stock_for_a_family_that_opts_out(monkeypatch, opt_out):
+ _stub_torch(monkeypatch)
+ monkeypatch.delenv(ds_mod.COMPILE_VAE_ENV, raising = False)
+ seen = []
+
+ def fused(
+ p,
+ logger,
+ encoder = True,
+ ):
+ seen.append(encoder)
+ return True
+
+ monkeypatch.setattr(ds_mod, "_install_fused_vae", fused)
+ family = _family()
+ if opt_out:
+ family.vae_fused_encoder = False
+ apply_speed_optims(
+ _Pipe(with_compile = True), _target(), is_gguf = False, family = family, speed_mode = SPEED_DEFAULT
+ )
+ assert seen == [not opt_out]
+
+
@pytest.mark.parametrize(
"backend, device", [("rocm", "cuda"), ("mps", "mps"), ("xpu", "xpu"), ("cpu", "cpu")]
)
diff --git a/studio/backend/tests/test_diffusion_vae_fused.py b/studio/backend/tests/test_diffusion_vae_fused.py
index 57e98367a13..f3d911a0d10 100644
--- a/studio/backend/tests/test_diffusion_vae_fused.py
+++ b/studio/backend/tests/test_diffusion_vae_fused.py
@@ -542,6 +542,28 @@ def test_wan_attention_oom_retries_stock_for_that_call_only(monkeypatch):
assert not getattr(block, "_unsloth_vae_fused_failed", False)
+def test_fused_install_can_leave_a_wan_encoder_stock(monkeypatch):
+ diffusers = pytest.importorskip("diffusers")
+ monkeypatch.setattr(F, "runtime_ok", lambda: True)
+
+ def patched(part):
+ return sorted(name for name, m in part.named_modules() if "forward" in m.__dict__)
+
+ def tiny():
+ torch.manual_seed(0)
+ return diffusers.AutoencoderKLWan(
+ base_dim = 32, z_dim = 4, dim_mult = [1, 2, 2, 2], num_res_blocks = 1
+ ).eval()
+
+ both, decoder_only = tiny(), tiny()
+ n_both = F.install(both)
+ n_decoder = F.install(decoder_only, encoder = False)
+ assert patched(both.encoder) and patched(both.decoder)
+ assert patched(decoder_only.encoder) == []
+ assert patched(decoder_only.decoder) == patched(both.decoder)
+ assert 0 < n_decoder < n_both
+
+
@pytest.mark.parametrize("frames", [1, 2, 4])
def test_causal_cache_is_a_compact_two_frame_copy(frames):
# a view would pin the whole (frames + 2)-frame conv input per cache slot until the next chunk
diff --git a/studio/backend/tests/test_transformers_latest.py b/studio/backend/tests/test_transformers_latest.py
index 1e03a764c8d..264382a3cd8 100644
--- a/studio/backend/tests/test_transformers_latest.py
+++ b/studio/backend/tests/test_transformers_latest.py
@@ -1079,6 +1079,39 @@ def test_upgrade_check_requires_every_missing_type(monkeypatch):
assert out is not None and out["model_type"] == "zz_new_wrapper"
+def test_upgrade_check_ignores_inert_nested_types(monkeypatch):
+ """Cosmos3-Edge's projector_config model_type is never registered nor built (a plain dict), so
+ it must not veto the offer the way an unknown backbone does."""
+ _shared_setup_2(monkeypatch)
+ cfg = {
+ "model_type": "cosmos3_edge",
+ "projector_config": {"model_type": "cosmos3_edge_projector"},
+ "text_config": {"model_type": "cosmos3_edge_text"},
+ "vision_config": {"model_type": "cosmos3_edge_vision"},
+ }
+ monkeypatch.setattr(tl, "_load_config_json", lambda *a, **k: cfg)
+ asked = []
+
+ unregistered = ("cosmos3_edge_projector", "zz_unknown_projector")
+
+ def supports(mt):
+ asked.append(mt)
+ return {
+ "pypi_version": "5.20.2",
+ "supported_in_pypi": mt not in unregistered,
+ "supported_in_main": mt not in unregistered,
+ }
+
+ monkeypatch.setattr(tl, "latest_transformers_supports", supports)
+ out = tl.check_upgrade_for_model("nvidia/Cosmos3-Edge")
+ assert out is not None and out["model_type"] == "cosmos3_edge"
+ assert out["supported_in_pypi"] is True
+ assert "cosmos3_edge_projector" not in asked
+
+ cfg["projector_config"] = {"model_type": "zz_unknown_projector"}
+ assert tl.check_upgrade_for_model("nvidia/Cosmos3-Edge") is None
+
+
def test_install_success_invalidates_capability_caches(monkeypatch):
"""A successful install must drop tier probes, the latest mapping, and the
vision-detection cache so the new sidecar takes effect without a restart."""
diff --git a/studio/backend/tests/test_vae_tile_geometry.py b/studio/backend/tests/test_vae_tile_geometry.py
index a9b99acf563..c08f84f9e0a 100644
--- a/studio/backend/tests/test_vae_tile_geometry.py
+++ b/studio/backend/tests/test_vae_tile_geometry.py
@@ -93,7 +93,11 @@ SMALLER_GEOMETRY_OK: dict[str, Floor] = {
}
# family -> open seam bug below the floor. Strict xfail, so the fix landing forces the entry out.
-KNOWN_SEAMS: dict[str, str] = {}
+KNOWN_SEAMS: dict[str, str] = {
+ # Stock strides only: generate sets per-canvas ones (test_video_cosmos3 checks them against this floor).
+ "cosmos3-nano": "stock AutoencoderKLWan@16x fallback tiles: 4-latent edge tile at 480 / 832 px",
+ "cosmos3-edge": "stock AutoencoderKLWan@16x fallback tiles: 4-latent edge tile at 480 / 640 / 832 px",
+}
GEOMETRY_PRESERVING = {
"diffusion_vae_fused": "batched stock tiled_decode: the stock attributes' tiles, decoded as one batch",
diff --git a/studio/backend/tests/test_video_backend.py b/studio/backend/tests/test_video_backend.py
index 58a96e7c046..cb300753d69 100644
--- a/studio/backend/tests/test_video_backend.py
+++ b/studio/backend/tests/test_video_backend.py
@@ -660,6 +660,8 @@ def fake_runtime(monkeypatch):
diffusers.WanTransformer3DModel = _FakeTransformer
diffusers.HunyuanVideo15Pipeline = _FakeHV15Pipeline
diffusers.HunyuanVideo15Transformer3DModel = _FakeTransformer
+ diffusers.Cosmos3OmniPipeline = _FakePipeline
+ diffusers.Cosmos3OmniTransformer = _FakeTransformer
# A CLASS named as diffusers names it: the cache layer matches on type(...).__name__.
diffusers.FirstBlockCacheConfig = FirstBlockCacheConfig
@@ -9158,6 +9160,7 @@ def test_plan_is_unchanged_when_no_text_encoder_quant_is_requested(fake_runtime,
from core.inference.video_families import _FAMILIES
_allow_te_prequant(monkeypatch)
+ monkeypatch.setenv("UNSLOTH_COSMOS3_SAFETY_CHECKER", "0")
calls = _capture_plan(monkeypatch)
for fam in _FAMILIES:
if fam.bf16_components_gb is None or fam.name == "wan2.2-t2v-a14b":
@@ -13200,6 +13203,7 @@ def test_cudnn_benchmark_opt_out_families():
fam.vae_force_fp32
or fam.name in ("ltx-2", "ltx-2.5")
or fam.name.startswith("hunyuanvideo-1.5")
+ or fam.name.startswith("cosmos3-")
for fam in _FAMILIES
if not fam.cudnn_benchmark
)
diff --git a/studio/backend/tests/test_video_cosmos3.py b/studio/backend/tests/test_video_cosmos3.py
new file mode 100644
index 00000000000..a789c26cdba
--- /dev/null
+++ b/studio/backend/tests/test_video_cosmos3.py
@@ -0,0 +1,1134 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Cosmos3-Nano / Cosmos3-Edge: families, video_cosmos3 glue, catalog, and VideoBackend's load and render over
+test_video_backend's fake runtime. Hub metadata: fixtures/cosmos3_checkpoints.json at pinned revisions; card values
+from README.md of nvidia/Cosmos3-Nano@e59a53c2 and nvidia/Cosmos3-Edge@344d602b."""
+
+from __future__ import annotations
+
+import ast
+import contextlib
+import dataclasses
+import importlib.machinery
+import importlib.util
+import inspect
+import json
+import shutil
+import math
+import sys
+import types
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+from core.inference import video as video_mod
+from core.inference import video_cosmos3 as vc3
+from core.inference import video_families as vf
+from core.inference.diffusion_component_sizes import (
+ TABLE_ROUNDING_GB,
+ video_family_has_no_text_encoder,
+ video_required_roles,
+)
+from core.inference.diffusion_families import (
+ _installed_at_least,
+ local_pipeline_components_are_complete,
+ pipeline_class_requirement,
+)
+from core.inference.diffusion_flow_shift import apply_scheduler_overrides
+from core.inference.video import VideoBackend
+from hub.services.models import catalog_classification as cc
+from models.models import LocalModelInfo
+
+_TESTS_DIR = str(Path(__file__).resolve().parent)
+if _TESTS_DIR not in sys.path:
+ sys.path.insert(0, _TESTS_DIR)
+
+from test_video_backend import ( # noqa: E402,F401
+ _FakeWanDiT,
+ _FakeWanVae,
+ _assume_the_restricted_load_is_available,
+ _data_url,
+ _pin_video_fetch_to_the_named_repo,
+ _roomy_host_ram,
+ fake_runtime,
+)
+
+NANO, EDGE = "nvidia/Cosmos3-Nano", "nvidia/Cosmos3-Edge"
+SUPER, EDGE_POLICY = "nvidia/Cosmos3-Super", "nvidia/Cosmos3-Edge-Policy-DROID"
+_FAMILY = {NANO: "cosmos3-nano", EDGE: "cosmos3-edge"}
+# The cards' scheduler rebuilds: Nano README.md:887, Edge README.md:759-761.
+_CARD_SCHEDULER = {
+ NANO: {"flow_shift": 10.0},
+ EDGE: {"flow_shift": 12.0, "use_karras_sigmas": False},
+}
+_OPT_OUT_ENV = "UNSLOTH_COSMOS3_SAFETY_CHECKER"
+_REASONER = "Cosmos3 Reasoner checkpoint"
+_CONDITIONED = "Policy, Sim, Transfer or FP8 build"
+_PIPELINE_ONLY = "loads only as its full Diffusers pipeline"
+_CHECKPOINTS = json.loads(
+ (Path(__file__).resolve().parent / "fixtures" / "cosmos3_checkpoints.json").read_text(
+ encoding = "utf-8"
+ )
+)
+
+
+def _pinned(repo):
+ (key,) = [k for k in _CHECKPOINTS if k.partition("@")[0] == repo]
+ return key.partition("@")[2], _CHECKPOINTS[key]
+
+
+def _ckpt(repo):
+ return _pinned(repo)[1]
+
+
+def _fam(name):
+ return vf.detect_video_family("", override = name)
+
+
+def _snapshot_path(repo, root = "/home/me/.cache/huggingface/hub"):
+ return f"{root}/models--{repo.replace('/', '--')}/snapshots/{_pinned(repo)[0]}"
+
+
+def _write_json(path, payload):
+ path.parent.mkdir(parents = True, exist_ok = True)
+ path.write_text(json.dumps(payload), encoding = "utf-8")
+
+
+def _write_configs(folder, repo):
+ entry = _ckpt(repo)
+ _write_json(folder / "model_index.json", entry["model_index"])
+ _write_json(folder / "config.json", entry["config"])
+ _write_json(folder / "transformer" / "config.json", entry["transformer_config"])
+ return folder
+
+
+def _planned_files(repo):
+ info = SimpleNamespace(
+ siblings = [SimpleNamespace(rfilename = n, size = s) for n, s in _ckpt(repo)["listing"]]
+ )
+ return dict(VideoBackend._base_download_files(info, "pipeline"))
+
+
+def _write_planned_tree(root, repo):
+ """The files a pipeline load stages, as stubs: the fixture's configs, shard indexes naming their shards, one byte
+ per weight."""
+ names = sorted(_planned_files(repo))
+ _write_configs(root, repo)
+ _write_json(root / "scheduler" / "scheduler_config.json", _ckpt(repo)["scheduler_config"])
+ for name in names:
+ path, folder = root / name, name.rpartition("/")[0]
+ if path.exists():
+ continue
+ if name.endswith(".index.json"):
+ shards = [
+ n.rpartition("/")[2] for n in names if n.startswith(folder + "/") and "-of-" in n
+ ]
+ _write_json(path, {"weight_map": {f"w{i}": s for i, s in enumerate(shards)}})
+ elif name.endswith(".json"):
+ _write_json(path, {})
+ else:
+ path.parent.mkdir(parents = True, exist_ok = True)
+ path.write_bytes(b"\0")
+ return root
+
+
+def _hub_cache(monkeypatch, answer):
+ lookups = []
+
+ def try_to_load_from_cache(repo_id, filename, *args, **kwargs):
+ lookups.append((repo_id, filename))
+ if isinstance(answer, BaseException):
+ raise answer
+ return answer
+
+ monkeypatch.setattr("huggingface_hub.try_to_load_from_cache", try_to_load_from_cache)
+ return lookups
+
+
+def _set_guardrail(monkeypatch, state):
+ """ "opted out" (env 0, no package), "installed" (package, no env) or "absent" (neither)."""
+ if state == "opted out":
+ monkeypatch.setenv(_OPT_OUT_ENV, "0")
+ else:
+ monkeypatch.delenv(_OPT_OUT_ENV, raising = False)
+ module = None
+ if state == "installed":
+ module = types.ModuleType("cosmos_guardrail")
+ module.__spec__ = importlib.machinery.ModuleSpec("cosmos_guardrail", None)
+ monkeypatch.setitem(sys.modules, "cosmos_guardrail", module)
+
+
+class _Log:
+ def __init__(self):
+ self.lines = []
+
+ def info(self, fmt, *args, **kwargs):
+ self.lines.append(("info", fmt % args))
+
+ def warning(self, fmt, *args, **kwargs):
+ self.lines.append(("warning", fmt % args))
+
+
+ "identifier, override, expected",
+ [
+ ("Wan-AI/Wan2.2-TI2V-5B-Diffusers", None, "wan2.2-ti2v-5b"),
+ ("MiniMaxAI/MiniMax-H3", None, "minimax-h3"),
+ (NANO, None, "cosmos3-nano"),
+ ("NVIDIA/COSMOS3-EDGE", None, "cosmos3-edge"),
+ (_snapshot_path(NANO), None, "cosmos3-nano"),
+ (_snapshot_path(EDGE, "C:\\Users\\me\\hub").replace("/", "\\"), None, "cosmos3-edge"),
+ ("reasoner-lab/Cosmos3-Edge", None, "cosmos3-edge"),
+ ("/srv/cosmos3-edge-fp8/exports/Cosmos3-Edge", None, "cosmos3-edge"),
+ ("/data/Cosmos3-Nano-simple", None, "cosmos3-nano"),
+ (SUPER, None, None),
+ ("nvidia/Cosmos-Reason1-7B", None, None),
+ ("/data/models/Cosmos3", None, None),
+ ("nvidia/Cosmos3-Nano-Reasoner", None, None),
+ (EDGE_POLICY, None, None),
+ ("/models/cosmos3_edge_fp8/", None, None),
+ ("x", " COSMOS3.EDGE ", "cosmos3-edge"),
+ # A bare token would claim Super, the Reasoners and Cosmos-Predict2's "cosmos" GGUF arch alike.
+ ("x", "cosmos", None),
+ ("x", "cosmos3", None),
+ ("x", "cosmos3_omni", None),
+ ],
+)
+def test_detection(identifier, override, expected):
+ fam = vf.detect_video_family(identifier, override = override)
+ assert (fam.name if fam else None) == expected
+ if fam is not None and override is None:
+ assert vf.video_checkpoint_refusal(fam, identifier) is None
+
+
+ "repo, kwargs, reason",
+ [
+ ("/models/Cosmos3-Nano-Reasoner/", {}, _REASONER),
+ ("nvidia/Cosmos3-Nano-Policy-DROID", {}, _CONDITIONED),
+ ("/data/COSMOS3.NANO.FP8", {"model_kind": "pipeline"}, _CONDITIONED),
+ ("nvidia/Cosmos3-Nano-Reasoner", {"family_override": "cosmos3-nano"}, _REASONER),
+ (EDGE_POLICY, {"family_override": "wan2.2-ti2v-5b"}, _CONDITIONED),
+ (EDGE, {"display_repo_id": "nvidia/Cosmos3-Edge-Reasoner"}, _REASONER),
+ (
+ "someone/files",
+ {"gguf_filename": "cosmos3-nano-reasoner-Q4_K_M.gguf", "model_kind": "gguf"},
+ _REASONER,
+ ),
+ (NANO, {"gguf_filename": "cosmos3-edge-Q8_0.gguf"}, _PIPELINE_ONLY),
+ (
+ NANO,
+ {"gguf_filename": "cosmos3_nano.safetensors", "model_kind": "single_file"},
+ _PIPELINE_ONLY,
+ ),
+ ],
+)
+def test_non_generator_builds_are_refused_by_name(repo, kwargs, reason):
+ with pytest.raises(ValueError) as refused:
+ VideoBackend().validate_load_request(repo, **kwargs)
+ assert all(part in str(refused.value) for part in (reason, NANO, EDGE)), refused.value
+
+
+ "folder, repo, expected",
+ [
+ ("my-render-model", NANO, "cosmos3-nano"),
+ ("my-render-model", EDGE, "cosmos3-edge"),
+ ("my-render-model", SUPER, None),
+ ("my-render-model", EDGE_POLICY, None),
+ # The shipped configs outrank a path naming the other size.
+ ("Cosmos3-Nano-exports/checkpoint", EDGE, "cosmos3-edge"),
+ ("cosmos3-edge-runs/checkpoint", NANO, "cosmos3-nano"),
+ ],
+)
+def test_a_local_folder_is_named_by_its_shipped_configs(tmp_path, folder, repo, expected):
+ from core.inference.video import _detect_load_family
+ from core.training.diffusion_train_common import resolve_trainable_family
+
+ path = str(_write_configs(tmp_path / folder, repo))
+ by_name = vf.detect_video_family(path)
+ assert by_name is None if folder == "my-render-model" else by_name.name != expected
+ assert vf.local_cosmos3_pipeline_family(path) == expected
+ fam = _detect_load_family(path, None, None)
+ assert (fam.name if fam else None) == expected
+ if expected:
+ named = folder == "my-render-model"
+ with pytest.raises(ValueError, match = f"{expected}.*ltx-2" if named else "can't train yet"):
+ resolve_trainable_family(path)
+
+
[email protected]("hidden", [4096, 2048, 5120])
[email protected]("model_type", ["cosmos3_omni", "cosmos3_edge", "qwen3_vl", None])
+def test_local_folder_matrix(tmp_path, model_type, hidden):
+ entry = _ckpt(NANO)
+ _write_json(tmp_path / "model_index.json", entry["model_index"])
+ if model_type is not None:
+ _write_json(tmp_path / "config.json", {"model_type": model_type})
+ transformer = {**entry["transformer_config"], "hidden_size": hidden}
+ _write_json(tmp_path / "transformer" / "config.json", transformer)
+ served = {
+ (t, h): f for t, h, f in (("cosmos3_omni", 4096, "nano"), ("cosmos3_edge", 2048, "edge"))
+ }
+ served.update({(None, 4096): "nano", (None, 2048): "edge"})
+ name = served.get((model_type, hidden))
+ assert vf.local_cosmos3_pipeline_family(str(tmp_path)) == (name and f"cosmos3-{name}")
+
+
+ "broken, text",
+ [("model_index.json", None), ("model_index.json", '{"_class_name": "WanPipeline"}')]
+ + [("model_index.json", "[]"), ("transformer/config.json", "4096")],
+)
+def test_an_unreadable_or_foreign_folder_is_not_claimed(tmp_path, broken, text):
+ folder = _write_configs(tmp_path / "renamed", EDGE)
+ if text is None:
+ (folder / broken).unlink()
+ else:
+ (folder / broken).write_text(text, encoding = "utf-8")
+ for path in (str(folder), None, "", str(folder / "config.json"), EDGE):
+ assert vf.local_cosmos3_pipeline_family(path) is None, path
+
+
[email protected]("scheme", ["fp8", "int8"])
[email protected]("repo", [NANO, EDGE])
+def test_an_explicit_text_encoder_quant_is_refused_at_validation(
+ fake_runtime, monkeypatch, repo, scheme
+):
+ _set_guardrail(monkeypatch, "opted out")
+ monkeypatch.setattr(video_mod, "te_quant_supported", lambda *args, **kwargs: True)
+ monkeypatch.setattr(video_mod, "torchao_quantize_importable", lambda: True)
+ with pytest.raises(ValueError) as refused:
+ VideoBackend().validate_load_request(repo, model_kind = "pipeline", text_encoder_quant = scheme)
+ assert "no separate text" in str(refused.value)
+ assert "dense bf16 encoder" not in str(refused.value)
+
+
+ "table, expected",
+ [((30.4, 0.0, 1.4), True), ((30.4, 0, 1.4), True), ((30.4, 0.05, 1.4), False)]
+ + [((30.4, float("nan"), 1.4), False), ((30.4,), False), (None, False)],
+)
+def test_no_text_encoder_is_a_zero_text_term(table, expected):
+ assert video_family_has_no_text_encoder(SimpleNamespace(bf16_components_gb = table)) is expected
+ if table == (30.4, 0.0, 1.4):
+ no_encoder = {f.name for f in vf._FAMILIES if video_family_has_no_text_encoder(f)}
+ assert no_encoder == set(vf.COSMOS3_FAMILIES)
+ assert video_required_roles(_fam("cosmos3-edge")) == ("transformer", "vae")
+ assert "text_encoder" in video_required_roles(_fam("wan2.2-ti2v-5b"))
+
+
+ "value, opted_out",
+ [(v, True) for v in ("0", "FALSE", "no", " Off\n")]
+ + [(v, False) for v in (None, "", "1", "true", "disabled")],
+)
+def test_the_opt_out_takes_only_explicit_off_values(monkeypatch, value, opted_out):
+ if value is None:
+ monkeypatch.delenv(_OPT_OUT_ENV, raising = False)
+ else:
+ monkeypatch.setenv(_OPT_OUT_ENV, value)
+ assert vc3.safety_checker_opted_out() is opted_out
+
+
+ "answer, installed",
+ [(True, True), (False, False), (ImportError("finder"), False), (ValueError("no spec"), False)],
+)
+def test_guardrail_presence_is_find_spec_on_cosmos_guardrail(monkeypatch, answer, installed):
+ real = importlib.util.find_spec
+
+ def find_spec(name, package = None):
+ if name != "cosmos_guardrail":
+ return real(name, package)
+ if isinstance(answer, Exception):
+ raise answer
+ return importlib.machinery.ModuleSpec(name, None) if answer else None
+
+ monkeypatch.setattr(importlib.util, "find_spec", find_spec)
+ assert vc3.guardrail_installed() is installed
+
+
+_NANO_INDEX = json.dumps(_ckpt(NANO)["model_index"])
+_EDGE_INDEX = json.dumps(_ckpt(EDGE)["model_index"])
+_EDGE_ON = json.dumps({**_ckpt(EDGE)["model_index"], "enable_safety_checker": True})
+
+
+ "source, repo, content, enabled",
+ [
+ ("index", NANO, _NANO_INDEX, True),
+ ("index", EDGE, _EDGE_INDEX, False),
+ ("index", EDGE, _EDGE_ON, True),
+ ("index", EDGE, _EDGE_INDEX.replace("false", '"false"'), True),
+ ("folder", None, _NANO_INDEX, True),
+ ("folder", None, _EDGE_INDEX, False),
+ ("folder", None, None, True),
+ ("folder", None, "{not json", True),
+ ("cache", EDGE, _EDGE_ON, True),
+ ("cache", NANO, None, True),
+ ("cache", EDGE.upper(), None, False),
+ ("cache", EDGE, ValueError("bad repo id"), False),
+ ],
+)
+def test_the_checkpoints_index_decides_the_safety_checker(
+ monkeypatch, tmp_path, source, repo, content, enabled
+):
+ monkeypatch.chdir(tmp_path)
+ answer = content if isinstance(content, Exception) else None
+ if source == "cache" and isinstance(content, str):
+ answer = str(tmp_path / "blob.json")
+ Path(answer).write_text(content, encoding = "utf-8")
+ lookups = _hub_cache(monkeypatch, answer)
+ if source == "index":
+ assert vc3.checkpoint_enables_safety_checker(repo, json.loads(content)) is enabled
+ elif source == "folder":
+ folder = tmp_path / "Cosmos3-Edge"
+ folder.mkdir()
+ if content is not None:
+ (folder / "model_index.json").write_text(content, encoding = "utf-8")
+ assert vc3.checkpoint_enables_safety_checker(str(folder)) is enabled
+ else:
+ assert vc3.checkpoint_enables_safety_checker(repo) is enabled
+ assert lookups == ([(repo, "model_index.json")] if source == "cache" else [])
+
+
[email protected]("guardrail", ["opted out", "installed", "absent"])
[email protected]("repo", [NANO, EDGE])
+def test_guardrail_refusal_and_pipeline_kwargs(monkeypatch, repo, guardrail):
+ _hub_cache(monkeypatch, None)
+ _set_guardrail(monkeypatch, guardrail)
+ log = _Log()
+ monkeypatch.setattr(vc3, "logger", log)
+ refusal = vc3.guardrail_refusal(repo)
+ if repo == NANO and guardrail == "absent":
+ for part in (f"'{NANO}'", "pip install cosmos-guardrail", f"{_OPT_OUT_ENV}=0"):
+ assert part in refusal, part
+ assert vc3.guardrail_refusal(NANO, index = _ckpt(EDGE)["model_index"]) is None
+ else:
+ assert refusal is None
+ opted_out = guardrail == "opted out"
+ expected = {"sound_tokenizer": None, **({"enable_safety_checker": False} if opted_out else {})}
+ assert vc3.pipeline_kwargs(repo) == expected
+ warned = [line for level, line in log.lines if level == "warning"]
+ assert len(warned) == (repo == NANO and opted_out)
+ assert all(_OPT_OUT_ENV in line and repo in line for line in warned)
+
+
+def _listing(repo, *extra):
+ return tuple(n for n, _s in _ckpt(repo)["listing"]) + extra
+
+
+ "listing, expected",
+ [
+ (_listing(NANO), True),
+ (_listing(EDGE), True),
+ (("model_index.json", "text_encoder/c.json", "tokenizer/t.json"), False),
+ (("modular_model_index.json", "text_encoder/c.json", "connectors/c.json"), False),
+ (("modular_model_index.json", "text_encoder/m.bin", "transformer_ref/c.json"), False),
+ ((), False),
+ (_listing(EDGE, "text_encoder/model.safetensors"), False),
+ (("model_index.json", "text_tokenizer.json"), False),
+ ],
+)
+def test_is_cosmos3_listing(listing, expected):
+ assert vc3.is_cosmos3_listing(iter(sorted(listing))) is expected
+
+
[email protected]("repo", [NANO, EDGE])
+def test_the_download_plan_stages_every_component_the_pipeline_reads(tmp_path, repo):
+ # The root modular_model_index.json once made the planner read it as H3's layout and drop text_tokenizer/.
+ planned = _planned_files(repo)
+ assert "model_index.json" in planned
+ for folder in ("scheduler/", "text_tokenizer/", "transformer/", "vae/"):
+ wanted = {name for name in _listing(repo) if name.startswith(folder)}
+ assert wanted and wanted <= set(planned), folder
+ root = _write_planned_tree(tmp_path / "snapshot", repo)
+ assert local_pipeline_components_are_complete(root, "model_index.json")
+ # sound_tokenizer is passed as None, so diffusers' hub-id load skips it too; vision_encoder it still demands.
+ assert not any(name.startswith("sound_tokenizer/") for name in planned)
+ vision = {name for name in _listing(repo) if name.startswith("vision_encoder/")}
+ assert vision <= set(planned)
+ for unused in ("sound_tokenizer", "vision_encoder"):
+ shutil.rmtree(root / unused, ignore_errors = True)
+ assert local_pipeline_components_are_complete(root, "model_index.json")
+ _write_json(root / "sound_tokenizer" / "config.json", {})
+ assert local_pipeline_components_are_complete(root, "model_index.json")
+
+
+class _FakeScheduler:
+ def __init__(self, config):
+ self.config = dict(config)
+
+ @classmethod
+ def from_config(cls, config, **kwargs):
+ return cls({**dict(config), **kwargs})
+
+
+class _RejectingScheduler(_FakeScheduler):
+ @classmethod
+ def from_config(cls, config, **kwargs):
+ raise NotImplementedError("bh3 is not implemented")
+
+
[email protected]("repo", [NANO, EDGE])
+def test_scheduler_overrides(repo):
+ shipped = _ckpt(repo)["scheduler_config"]
+ overrides = _fam(_FAMILY[repo]).scheduler_overrides
+ pipe, log = SimpleNamespace(scheduler = _FakeScheduler(shipped)), _Log()
+ assert apply_scheduler_overrides(pipe, overrides, log) is True
+ assert pipe.scheduler.config == {**shipped, **_CARD_SCHEDULER[repo]}
+ rebuilt = pipe.scheduler
+ assert apply_scheduler_overrides(pipe, overrides, log) is False and pipe.scheduler is rebuilt
+ assert [level for level, _ in log.lines] == ["info"]
+ for pipe, given in (
+ (SimpleNamespace(scheduler = _FakeScheduler(shipped)), ()),
+ (SimpleNamespace(scheduler = _FakeScheduler(shipped)), None),
+ (SimpleNamespace(), overrides),
+ (SimpleNamespace(scheduler = object()), overrides),
+ ):
+ before = getattr(pipe, "scheduler", None)
+ assert apply_scheduler_overrides(pipe, given) is False
+ assert getattr(pipe, "scheduler", None) is before
+ pipe, log = SimpleNamespace(scheduler = _RejectingScheduler(shipped)), _Log()
+ assert apply_scheduler_overrides(pipe, overrides, log) is False
+ assert type(pipe.scheduler) is _RejectingScheduler
+ ((level, line),) = log.lines
+ assert level == "warning" and "flow_shift" in line and "not implemented" in line
+
+
[email protected]("repo", [NANO, EDGE])
+def test_the_overrides_sample_the_cards_schedule_on_the_real_unipc(repo):
+ pytest.importorskip("diffusers", reason = "Backend CI installs no diffusers")
+ import numpy as np
+ import torch
+ from diffusers import UniPCMultistepScheduler as UniPC
+
+ shipped, steps = _ckpt(repo)["scheduler_config"], _fam(_FAMILY[repo]).default_steps
+ pipe = SimpleNamespace(scheduler = UniPC.from_config(shipped))
+ assert apply_scheduler_overrides(pipe, _fam(_FAMILY[repo]).scheduler_overrides) is True
+ card = UniPC.from_config(shipped, **_CARD_SCHEDULER[repo])
+ assert dict(pipe.scheduler.config) == dict(card.config)
+ # Under use_native_flow_schedule (Edge's index) the pipeline passes its own linspace sigmas.
+ native = _ckpt(repo)["model_index"].get("use_native_flow_schedule", False)
+ t = np.linspace(1.0 - 1.0 / 1000, 0.0, steps + 1)[:-1]
+
+ def sigmas(scheduler):
+ scheduler.set_timesteps(steps, device = "cpu", **({"sigmas": t} if native else {}))
+ return scheduler.sigmas.clone()
+
+ ours, before = sigmas(pipe.scheduler), sigmas(UniPC.from_config(shipped))
+ if repo == EDGE:
+ expected = torch.from_numpy(12.0 * t / (1.0 + 11.0 * t))
+ assert torch.allclose(ours[:-1].double(), expected, atol = 1e-6)
+ assert not torch.equal(ours, before)
+ else:
+ # Nano's shipped Karras sigmas pre-empt the only branch reading flow_shift: the shift is inert.
+ assert torch.equal(ours, before)
+
+
+class _FakeCosmos3Vae(_FakeWanVae):
+ def __init__(self):
+ super().__init__()
+ self.use_tiling, self.calls, self.encode_raises, self.strides = False, [], [], []
+ self.spatial_compression_ratio, self.tile_sample_min_height, self.tile_sample_min_width = (
+ 16,
+ 256,
+ 256,
+ )
+ self.tile_sample_stride_height = self.tile_sample_stride_width = 192
+
+ def enable_tiling(self):
+ super().enable_tiling()
+ self.use_tiling = True
+
+ def encode(self, *args, **kwargs):
+ self.calls.append("encode tiled" if self.use_tiling else "encode untiled")
+ if self.encode_raises:
+ raise self.encode_raises.pop(0)
+ return ("latents", args, kwargs)
+
+ def decode(self, *args, **kwargs):
+ self.calls.append("decode tiled" if self.use_tiling else "decode untiled")
+ self.strides.append((self.tile_sample_stride_height, self.tile_sample_stride_width))
+ return super().decode(*args, **kwargs)
+
+
+# torch.OutOfMemoryError by class name, without importing torch; a RuntimeError by its message.
+_OOM_CLASS = type("OutOfMemoryError", (RuntimeError,), {})("x")
+_OOM = RuntimeError("CUDA out of memory.")
+_RETRIED = ["encode untiled", "empty_cache", "encode tiled"]
+
+
+ "tiled, raises, calls, fails",
+ [
+ (True, [], ["encode untiled"], False),
+ (False, [], ["encode untiled"], False),
+ (True, [_OOM_CLASS], _RETRIED, False),
+ (True, [_OOM], _RETRIED, False),
+ (True, [_OOM, _OOM], _RETRIED, True),
+ (True, [ValueError("expected a 5-D clip")], ["encode untiled"], True),
+ (False, [_OOM_CLASS], ["encode untiled"], True),
+ ],
+)
+def test_untiled_encode(monkeypatch, tiled, raises, calls, fails):
+ vae = _FakeCosmos3Vae()
+ if tiled:
+ vae.enable_tiling()
+ torch = types.ModuleType("torch")
+ torch.cuda = SimpleNamespace(empty_cache = lambda: vae.calls.append("empty_cache"))
+ monkeypatch.setitem(sys.modules, "torch", torch)
+ log = _Log()
+ assert vc3.install_untiled_encode(SimpleNamespace(vae = vae), logger = log) is True
+ vae.encode_raises = list(raises)
+ clip = object()
+ if fails:
+ with pytest.raises(type(raises[-1])) as raised:
+ vae.encode(clip)
+ assert raised.value is raises[-1]
+ else:
+ assert vae.encode(clip, return_dict = False) == ("latents", (clip,), {"return_dict": False})
+ assert vae.calls == calls
+ assert vae.use_tiling is tiled
+ assert [level for level, _ in log.lines] == ["info"] + ["warning"] * (calls == _RETRIED)
+
+
+def test_untiled_encode_installs_once_and_needs_a_callable_encode():
+ vae = _FakeCosmos3Vae()
+ pipe = SimpleNamespace(vae = vae)
+ assert vc3.install_untiled_encode(pipe) is True
+ wrapped = vae.encode
+ assert vc3.install_untiled_encode(pipe) is True and vae.encode is wrapped
+ bad = SimpleNamespace(use_tiling = True, encode = "encode")
+ for pipe in (SimpleNamespace(), SimpleNamespace(vae = None), SimpleNamespace(vae = bad)):
+ assert vc3.install_untiled_encode(pipe) is False
+
+
+# Cosmos3OmniPipeline.__call__'s parameters (diffusers 0.41); unknown keywords raise TypeError as there.
+_CALL_PARAMS = (
+ "prompt negative_prompt image video condition_frame_indexes_vision condition_video_keep num_frames"
+ " height width fps num_inference_steps guidance_scale enable_sound generator latents sound_latents"
+ " action_latents action output_type return_dict use_system_prompt callback_on_step_end"
+ " callback_on_step_end_tensor_inputs add_resolution_template add_duration_template"
+ " enable_safety_check mixed_precision_format mixed_precision_first_steps mixed_precision_last_steps"
+ " mixed_precision_reasoner_policy"
+).split()
+
+
+class _FakeCosmos3Pipeline:
+ loads: list = []
+
+ def __init__(self, scheduler_config):
+ self.transformer, self.vae = _FakeWanDiT(), _FakeCosmos3Vae()
+ self.scheduler = _FakeScheduler(scheduler_config)
+ self.passed, self.outputs, self.steps_computed = None, [], 0
+ self.on_step, self._interrupt = None, False
+
+ @property
+ def components(self):
+ return {"transformer": self.transformer, "vae": self.vae, "scheduler": self.scheduler}
+
+ @classmethod
+ def from_pretrained(cls, source, **kwargs):
+ cls.loads.append({"source": source, **kwargs})
+ return cls(_ckpt(EDGE if str(source).lower() == EDGE.lower() else NANO)["scheduler_config"])
+
+ def to(self, device):
+ return self
+
+ @contextlib.contextmanager
+ def progress_bar(self, total = None):
+ yield SimpleNamespace(update = lambda n = 1: None)
+
+ def maybe_free_model_hooks(self):
+ pass
+
+ def __call__(self, **kwargs):
+ if set(kwargs) - set(_CALL_PARAMS):
+ raise TypeError(f"unexpected keywords {sorted(set(kwargs) - set(_CALL_PARAMS))}")
+ self.passed, self._interrupt = dict(kwargs), False
+ steps, callback = (
+ int(kwargs.get("num_inference_steps", 35)),
+ kwargs.get("callback_on_step_end"),
+ )
+ self.vae.encode(("clip", kwargs.get("image")))
+ latents = object()
+ with self.progress_bar(total = steps) as bar:
+ for i in range(steps):
+ if self._interrupt:
+ continue
+ self.steps_computed += 1
+ if self.on_step is not None:
+ self.on_step(i)
+ if callback is not None:
+ latents = callback(self, i, 1000.0, {"latents": latents}).pop(
+ "latents", latents
+ )
+ bar.update()
+ self.vae.decode(latents)
+ count = 1 + 4 * ((int(kwargs.get("num_frames") or 189) - 1) // 4)
+ self.outputs.append(SimpleNamespace(video = [object() for _ in range(count)]))
+ return self.outputs[-1]
+
+ __call__.__signature__ = inspect.Signature(
+ [
+ inspect.Parameter(n, inspect.Parameter.POSITIONAL_OR_KEYWORD)
+ for n in ("self", *_CALL_PARAMS)
+ ]
+ )
+
+
+def test_the_fakes_match_the_installed_pipeline():
+ diffusers = pytest.importorskip("diffusers", reason = "Backend CI installs no diffusers")
+ minimum, _ = pipeline_class_requirement("Cosmos3OmniPipeline")
+ if not _installed_at_least(diffusers.__version__, minimum):
+ pytest.skip(f"diffusers {diffusers.__version__} predates Cosmos3OmniPipeline ({minimum})")
+ from diffusers.pipelines.cosmos import pipeline_cosmos3_omni as module
+
+ real = diffusers.Cosmos3OmniPipeline
+ call = inspect.signature(real.__call__).parameters
+ assert list(call)[1:] == _CALL_PARAMS
+ assert call["enable_sound"].default is False
+ assert {"sound_tokenizer", "enable_safety_checker"} <= set(
+ inspect.signature(real.__init__).parameters
+ )
+ assert "sound_tokenizer" in real._optional_components
+ assert "video" in {f.name for f in dataclasses.fields(module.Cosmos3OmniPipelineOutput)}
+ assert not hasattr(diffusers.Cosmos3OmniTransformer, "from_single_file")
+ tree = ast.parse(inspect.getsource(module))
+ imports = {
+ (n.module, a.name) for n in ast.walk(tree) if isinstance(n, ast.ImportFrom) for a in n.names
+ }
+ assert ("cosmos_guardrail", "CosmosSafetyChecker") in imports
+
+
+def cosmos3_runtime(fake_runtime, monkeypatch):
+ diffusers = sys.modules["diffusers"]
+ monkeypatch.setattr(diffusers, "Cosmos3OmniPipeline", _FakeCosmos3Pipeline, raising = False)
+ _FakeCosmos3Pipeline.loads = []
+ _set_guardrail(monkeypatch, "opted out")
+ encoded = []
+
+ def _encode(frames, fps, audio, pipe):
+ encoded.append({"frames": frames, "fps": fps, "audio": audio})
+ return b"MP4"
+
+ monkeypatch.setattr(VideoBackend, "_encode_mp4", staticmethod(_encode))
+ yield encoded
+
+
+def _loaded(repo):
+ backend = VideoBackend()
+ return backend, backend.load_pipeline(repo, model_kind = "pipeline")
+
+
+ "repo, guardrail, safety",
+ [
+ (NANO, "opted out", {"enable_safety_checker": False}),
+ (EDGE, "opted out", {"enable_safety_checker": False}),
+ (NANO, "installed", {}),
+ (EDGE, "absent", {}),
+ ],
+)
+def test_load(cosmos3_runtime, monkeypatch, repo, guardrail, safety):
+ _set_guardrail(monkeypatch, guardrail)
+ backend, status = _loaded(repo)
+ (load,) = _FakeCosmos3Pipeline.loads
+ assert load["source"] == repo and "sound_tokenizer" in load and load["sound_tokenizer"] is None
+ assert {k: v for k, v in load.items() if k == "enable_safety_checker"} == safety
+ pipe = backend._state.pipe
+ assert pipe.scheduler.config == {**_ckpt(repo)["scheduler_config"], **_CARD_SCHEDULER[repo]}
+ steps, frames, canvas = {NANO: (35, 189, [1280, 720]), EDGE: (20, 121, [832, 480])}[repo]
+ got = status["defaults"]
+ assert (got["steps"], got["guidance"], got["num_frames"], got["fps"]) == (
+ steps,
+ 6.0,
+ frames,
+ 24,
+ )
+ assert got["resolution_presets"][0] == canvas
+ assert status["family"] == _FAMILY[repo] and status["has_audio"] is False
+ assert status["supports_first_frame"] is True and status["supports_last_frame"] is False
+ assert status["vae_tiling"] is True
+ assert getattr(pipe.vae.encode, "_unsloth_untiled_encode", False) is True
+ reason = status["resolved"]["text_encoder_quant"]["reason"]
+ assert reason == "not applicable (no separate text encoder)"
+
+
+def test_a_wan_load_keeps_the_stock_encode(cosmos3_runtime, monkeypatch):
+ monkeypatch.setattr(_FakeWanVae, "encode", lambda self, *a, **k: a, raising = False)
+ backend, status = _loaded("Wan-AI/Wan2.2-TI2V-5B-Diffusers")
+ assert status["vae_tiling"] is True
+ assert not getattr(backend._state.pipe.vae.encode, "_unsloth_untiled_encode", False)
+
+
+def test_nano_without_the_guardrail_is_refused_before_the_load_starts(cosmos3_runtime, monkeypatch):
+ _set_guardrail(monkeypatch, "absent")
+ started = []
+ monkeypatch.setattr(VideoBackend, "_run_load", lambda self, **kwargs: started.append(kwargs))
+ backend = VideoBackend()
+ with pytest.raises(ValueError, match = f"{_OPT_OUT_ENV}=0"):
+ backend.begin_load(NANO, model_kind = "pipeline")
+ assert started == [] and backend.loading_repo_ids() == ()
+ with pytest.raises(ValueError, match = "cosmos_guardrail"):
+ backend.load_pipeline(NANO, model_kind = "pipeline")
+ assert _FakeCosmos3Pipeline.loads == []
+ with pytest.raises(ValueError, match = "limited to"):
+ backend.validate_load_request("someone/cosmos3-nano-repack", model_kind = "pipeline")
+
+
[email protected]("folder", ["named", "renamed", "export", "snapshot"])
[email protected]("repo", [NANO, EDGE])
+def test_a_local_pipeline_folder_validates(
+ cosmos3_runtime, monkeypatch, tmp_path_factory, repo, folder
+):
+ names = {"named": repo.partition("/")[2], "snapshot": _snapshot_path(repo, "hub")}
+ root = _write_planned_tree(tmp_path_factory.mktemp("m") / names.get(folder, "my-model"), repo)
+ if folder == "export":
+ (root / "config.json").unlink()
+ _set_guardrail(monkeypatch, "absent" if repo == EDGE else "opted out")
+ assert VideoBackend().validate_load_request(str(root)).name == _FAMILY[repo]
+
+
+def _first_frame(size):
+ return {"first_frame": _data_url(*size)} if size else {}
+
+
+ "repo, first_frame, steps, frames, size, stride",
+ [
+ (NANO, None, 35, 189, (1280, 720), 12),
+ (NANO, (1920, 1080), 35, 189, (1280, 720), 12),
+ (EDGE, None, 20, 121, (832, 480), 11),
+ (EDGE, (1080, 1920), 20, 121, (480, 832), 11),
+ ],
+)
+def test_generate(cosmos3_runtime, monkeypatch, repo, first_frame, steps, frames, size, stride):
+ from core.inference import diffusion as diffusion_mod
+ from core.inference import video_i2v
+
+ decoded, decode = [], diffusion_mod.decode_b64_image
+ monkeypatch.setattr(
+ diffusion_mod,
+ "decode_b64_image",
+ lambda *a, **k: decoded.append(decode(*a, **k)) or decoded[-1],
+ )
+ offloaded, offload = [], video_i2v.offload_vae_after_encode
+ monkeypatch.setattr(
+ video_i2v, "offload_vae_after_encode", lambda p: offloaded.append(p) or offload(p)
+ )
+ backend, _status = _loaded(repo)
+ pipe, seen = backend._state.pipe, []
+ pipe.on_step = lambda i: seen.append(backend.generate_progress())
+ result = backend.generate(prompt = "a robot arm", **_first_frame(first_frame))
+ passed = pipe.passed
+ assert (passed["num_inference_steps"], passed["guidance_scale"], passed["fps"]) == (
+ steps,
+ 6.0,
+ 24.0,
+ )
+ assert (passed["width"], passed["height"], passed["num_frames"]) == (*size, frames)
+ assert (result["width"], result["height"], result["num_frames"]) == (*size, frames)
+ assert result["conditioning"] == ("i2va" if first_frame else "t2va")
+ if first_frame:
+ (image,) = decoded
+ assert passed["image"] is image and image.size == first_frame
+ assert [(g["phase"], g["total_steps"]) for g in seen] == [("denoise", steps)] * steps
+ (export,) = cosmos3_runtime
+ assert export["frames"] is pipe.outputs[-1].video and export["audio"] is None
+ assert offloaded == [pipe] and pipe.vae.calls == ["encode untiled", "decode tiled"]
+ assert pipe.vae.strides == [(stride * 16, stride * 16)]
+ assert (pipe.vae.tile_sample_stride_height, pipe.vae.tile_sample_stride_width) == (192, 192)
+
+ pipe.on_step = None
+ request = {"negative_prompt": "blurry", "steps": 2, "fps": 16, "guidance_2": 3.5}
+ result = backend.generate(prompt = "a robot arm", **request, **_first_frame(first_frame))
+ passed = pipe.passed
+ expected = {"prompt", "negative_prompt", "num_inference_steps", "guidance_scale", "width"}
+ expected |= {"height", "num_frames", "fps", "generator", "callback_on_step_end"}
+ expected |= {"image"} if first_frame else set()
+ off = {"add_resolution_template": False, "add_duration_template": False} if repo == EDGE else {}
+ assert set(passed) == expected | set(off) and {k: passed[k] for k in off} == off
+ assert passed["fps"] == 16.0 and type(passed["fps"]) is float
+ assert passed["negative_prompt"] == "blurry"
+ assert result["fps"] == 16 and cosmos3_runtime[-1]["fps"] == 16
+ backend.generate(prompt = "p", steps = 1)
+ assert "image" not in pipe.passed
+
+
[email protected]("first_frame, recorded", [(None, True), ((1920, 1080), False)])
+def test_a_pending_background_compile_records_only_text_to_video(
+ cosmos3_runtime, monkeypatch, first_frame, recorded
+):
+ from core.inference import diffusion_bg_compile as bg_compile
+
+ skipped = []
+
+ @contextlib.contextmanager
+ def no_record():
+ skipped.append(True)
+ yield
+
+ monkeypatch.setattr(bg_compile, "no_record", no_record)
+ backend, _status = _loaded(EDGE)
+ bg = bg_compile.BackgroundCompile(object())
+ assert bg.pending()
+ backend._state = dataclasses.replace(backend._state, bg_compile = bg)
+ backend.generate(prompt = "a robot arm", steps = 1, **_first_frame(first_frame))
+ assert (not skipped) is recorded
+
+
+ "repo, requested, frames", [(NANO, 400, 397), (EDGE, 30, 53), (EDGE, 200, 149)]
+)
+def test_generate_snaps_frames_and_size_onto_the_family_lattice(
+ cosmos3_runtime, repo, requested, frames
+):
+ backend, _status = _loaded(repo)
+ backend.generate(prompt = "p", steps = 1, num_frames = requested, width = 1000, height = 700)
+ passed = backend._state.pipe.passed
+ assert _ckpt(repo)["vae_config"]["scale_factor_spatial"] == 16
+ assert (passed["num_frames"], passed["width"], passed["height"]) == (frames, 992, 688)
+
+
+def test_call_kwargs_skip_a_key_the_pipeline_does_not_take(cosmos3_runtime):
+ backend, _status = _loaded(NANO)
+ extra = (("use_resolution_template", False), ("add_duration_template", False))
+ family = dataclasses.replace(backend._state.family, call_kwargs = extra)
+ backend._state = dataclasses.replace(backend._state, family = family)
+ backend.generate(prompt = "p", steps = 2)
+ passed = backend._state.pipe.passed
+ assert "use_resolution_template" not in passed and passed["add_duration_template"] is False
+
+
+def test_a_last_frame_is_refused_and_a_cancel_interrupts_the_denoise(cosmos3_runtime):
+ from core.inference.video_families import VIDEO_CANCELLED_MSG
+
+ backend, _status = _loaded(EDGE)
+ pipe = backend._state.pipe
+ frames = {"first_frame": _data_url(64, 64), "last_frame": _data_url(64, 64)}
+ for call in (backend.begin_generate, backend.generate):
+ with pytest.raises(ValueError, match = "no last frame"):
+ call(prompt = "p", steps = 2, **frames)
+ assert pipe.passed is None and backend.generate_progress()["active"] is False
+ pipe.on_step = lambda i: backend.cancel_generate() if i == 0 else None
+ with pytest.raises(RuntimeError, match = VIDEO_CANCELLED_MSG):
+ backend.generate(prompt = "p", steps = 4)
+ assert pipe.steps_computed == 1 and cosmos3_runtime == []
+ assert backend.generate_progress()["active"] is False
+ pipe.on_step = None
+ backend.generate(prompt = "p", steps = 3)
+ assert pipe.steps_computed == 4
+
+
+# Nano card :887-898, :113 (5-400 frames); Edge card :759-776, :102 (50-150). Windows: the 4k+1 counts inside.
+_CARD = {"cosmos3-nano": (NANO, (5, 397)), "cosmos3-edge": (EDGE, (53, 149))}
+
+
[email protected]("name", sorted(_CARD))
+def test_rows_follow_the_card_and_the_shipped_checkpoint(name):
+ repo, window = _CARD[name]
+ fam, vae, listing = _fam(name), _ckpt(repo)["vae_config"], _ckpt(repo)["listing"]
+ assert (fam.pipeline_class, fam.i2v_pipeline_class) == ("Cosmos3OmniPipeline",) * 2
+ assert fam.base_repo == repo and (fam.min_num_frames, fam.max_num_frames) == window
+ assert (fam.frame_step, fam.resolution_multiple) == (
+ vae["scale_factor_temporal"],
+ vae["scale_factor_spatial"],
+ )
+ assert fam.trainable is False and fam.i2v_fits_first_frame is False
+ for term, folder in ((0, "transformer/"), (2, "vae/")):
+ folder_gb = sum(s for n, s in listing if n.startswith(folder)) / 1e9
+ assert abs(fam.bf16_components_gb[term] - folder_gb) <= TABLE_ROUNDING_GB, folder
+ vf.validate_video_request_shape(fam, *fam.resolution_presets[0], fam.default_num_frames)
+
+
+ "name, shape, fragment",
+ [
+ ("cosmos3-nano", {"num_frames": 188}, "185 and 189"),
+ ("cosmos3-nano", {"num_frames": 1}, "5 to 397"),
+ ("cosmos3-edge", {"width": 840, "height": 480}, "multiples of 16"),
+ ("cosmos3-edge", {"width": 1280, "height": 720}, "409,600 pixels"),
+ ],
+)
+def test_shapes_off_the_lattice_window_or_grid_are_refused(name, shape, fragment):
+ with pytest.raises(vf.VideoShapeError, match = fragment):
+ vf.validate_video_request_shape(_fam(name), **shape)
+
+
[email protected]("fam", vf._FAMILIES, ids = lambda f: f.name)
+def test_every_window_end_and_duration_preset_is_a_valid_count(fam):
+ from routes.video import _frames_for_seconds
+
+ step, offset = max(1, fam.frame_step), max(1, fam.frame_offset)
+ floor = max(offset, fam.min_num_frames)
+ for end in (floor,) if fam.max_num_frames is None else (floor, fam.max_num_frames):
+ assert (end - offset) % step == 0, end
+ vf.validate_video_request_shape(fam, num_frames = end)
+ defaults = {"fps": fam.default_fps, "frame_step": step, "frame_offset": fam.frame_offset}
+ for seconds in fam.duration_presets:
+ page = max(1, math.floor((seconds * fam.default_fps - offset) / step + 0.5)) * step + offset
+ for frames in {_frames_for_seconds(seconds, defaults), page}:
+ vf.validate_video_request_shape(fam, num_frames = frames)
+
+
+ "ids, expected",
+ [
+ ((None, None, None, _snapshot_path(NANO)), (35, 6.0)),
+ ((None, EDGE), (20, 6.0)),
+ (("/data/fusionx/Cosmos3-Edge",), (20, 6.0)),
+ (("/data/hunyuanvideo/Cosmos3-Nano",), (35, 6.0)),
+ (("/models/Cosmos3-Nano/wan2.1-t2v-14b-Q4_K_M.gguf",), (20, 6.0)),
+ (("/data/cosmos3-edge/LTX-2",), (40, 4.0)),
+ ],
+)
+def test_generation_defaults(ids, expected):
+ assert vf.default_video_generation_params(*ids) == expected
+
+
+ "installed, available",
+ [("0.39.0", False), ("0.40.0", False), ("0.41.0", True), ("0.41.0.dev0", True)],
+)
+def test_rows_hide_on_a_diffusers_without_edges_native_flow_schedule(
+ monkeypatch, installed, available
+):
+ from core.inference import diffusion_families as df
+
+ assert _ckpt(EDGE)["model_index"]["use_native_flow_schedule"] is True
+ monkeypatch.delitem(sys.modules, "diffusers", raising = False)
+ monkeypatch.setattr(df, "_installed_diffusers_version", lambda: installed)
+ assert {df.family_pipeline_available(_fam(n)) for n in vf.COSMOS3_FAMILIES} == {available}
+
+
+_PIPELINE = ("model_index.json", "transformer/diffusion_pytorch_model.safetensors")
+_SHARDS = ("config.json", "model.safetensors.index.json", "model-00001-of-00002.safetensors")
+
+
+ "repo_id, files, video",
+ [
+ (EDGE, _PIPELINE, True),
+ ("unsloth/Cosmos3-Edge", _PIPELINE, True),
+ ("someone/Cosmos3-Edge", _PIPELINE, False),
+ (SUPER, _PIPELINE, False),
+ (EDGE, _SHARDS, False),
+ ("unsloth/Cosmos3-Nano-unsloth-bnb-4bit", _SHARDS, False),
+ ("nvidia/Cosmos3-Edge-Reasoner", _SHARDS, False),
+ ],
+)
+def test_the_cached_listing_offers_only_trusted_generator_pipelines_as_video(repo_id, files, video):
+ entries = [SimpleNamespace(file_name = n, size_on_disk = 1, blob_path = None) for n in files]
+ repo = SimpleNamespace(
+ repo_id = repo_id,
+ repo_type = "model",
+ repo_path = Path("/hf-cache/x"),
+ revisions = [SimpleNamespace(files = entries)],
+ )
+ assert cc._cached_repo_task(repo) == (cc._VIDEO_GEN_TASK if video else None)
+ assert cc._repo_is_diffusers(repo) is (files == _PIPELINE)
+
+
+def test_the_local_listing_offers_only_generator_pipelines_as_video(tmp_path):
+ def row(path, model_id = None):
+ kwargs = {"display_name": path.name, "path": str(path), "model_id": model_id}
+ return LocalModelInfo(id = str(path), source = "models_dir", **kwargs)
+
+ def shards(path):
+ for name in _SHARDS:
+ _write_json(path / name, {})
+ return path
+
+ video = cc._VIDEO_GEN_TASK
+ assert cc._local_model_task(row(_write_planned_tree(tmp_path / "Cosmos3-Edge", EDGE))) == video
+ renamed = _write_configs(tmp_path / "my-render-model", NANO)
+ assert cc._local_model_task(row(renamed)) == video
+ reasoner = shards(tmp_path / "Cosmos3-Nano-Reasoner")
+ assert cc._local_model_task(row(reasoner, "nvidia/Cosmos3-Nano-Reasoner")) is None
+ assert cc._local_is_diffusers(row(reasoner)) is False
+ assert cc._local_model_task(row(shards(tmp_path / "Cosmos3-Nano-finetune"))) is None
+ fp8 = _write_planned_tree(tmp_path / "Cosmos3-Edge-FP8", EDGE)
+ assert cc._local_model_task(row(fp8)) is None
+
+
+def test_no_cosmos3_gguf_or_loose_file_is_offered_as_video(tmp_path):
+ from hub.utils import comfy_models
+
+ assert (
+ cc._unhydrated_gguf_task(("unsloth/Cosmos3-Nano-GGUF", "Cosmos3-Nano-Q4_K_M.gguf")) is None
+ )
+ unsupported = cc._UNSUPPORTED_DIFFUSION_TASK
+ assert cc._name_hint_media_task(("Cosmos3-Edge-Q8_0.gguf",), unsupported) == unsupported
+ for name, offered in (
+ ("cosmos3_edge_bf16.safetensors", False),
+ ("wan2.1_t2v_1.3B.safetensors", True),
+ ):
+ (tmp_path / name).write_bytes(b"weights")
+ assert comfy_models._offer_loose_checkpoint(tmp_path / name) is offered, name
+
+
[email protected]("policy", ["none", "model", "group", "streaming", "sequential"])
[email protected]("speed", ["off", "default"])
+def test_cosmos3_decodes_untiled_when_it_fits_even_at_speed_off(policy, speed):
+ gate = video_mod._decodes_untiled_when_fits
+ placed = policy != "sequential"
+ for family in ("cosmos3-edge", "cosmos3-nano"):
+ assert gate(family, policy, "cuda", speed) is placed
+ assert gate(family, policy, "cpu", speed) is False
+ assert gate("wan2.2-ti2v-5b", policy, "cuda", speed) is (placed and speed != "off")
+
+
+def _diffusers_tiles(length, tile, stride):
+ """AutoencoderKLWan.tiled_decode's slices along one axis, in latents."""
+ return [(a, min(a + tile, length)) for a in range(0, length, stride)]
+
+
[email protected]("family", sorted(vf.COSMOS3_FAMILIES))
+def test_seam_safe_tiles_clear_the_wan_seam_floor(family):
+ import test_vae_tile_geometry as G
+
+ _, config = G._family_configs()[family]
+ vae, _ = G.build_vae(config, None)
+ floor = G.SMALLER_GEOMETRY_OK["AutoencoderKLWan@16x"]
+ stock = (vae.tile_sample_min_height, vae.tile_sample_stride_height)
+ # Every preset side through the stock tiled decoder; 400 px (25 latents) needs a wider tile.
+ for side in sorted({*G._sides(family), 400}):
+ with vc3.seam_safe_tile_strides(SimpleNamespace(vae = vae), side, side):
+ tiles = G.probe_axis(vae, config, side // 16, G.MIN_SIDE // 16, True)
+ assert G.check_axis(tiles, floor) == [], (side, tiles)
+ assert (vae.tile_sample_min_height, vae.tile_sample_stride_height) == stock
+ for length in range(17, 161):
+ tile, stride = vc3.seam_safe_tile(length, 16, 12)
+ assert G.check_axis(_diffusers_tiles(length, tile, stride), floor) == [], length
+ assert vc3.seam_safe_tile(45, 16, 12) == vc3.seam_safe_tile(80, 16, 12) == (16, 12)
+ assert vc3.seam_safe_tile(25, 16, 12) == (17, 13)
+
+
+def test_wide_tiles_keep_the_seam_floor_for_cosmos3():
+ import test_vae_tile_geometry as G
+ from core.inference import video_vae_untiled as U
+
+ floor, planned = G.SMALLER_GEOMETRY_OK["AutoencoderKLWan@16x"], 0
+ for family in sorted(vf.COSMOS3_FAMILIES):
+ for width, height in ((640, 640), (832, 480), (480, 832), (1280, 720), (400, 640)):
+ for free_gib in (2, 4, 8, 16, 32):
+ shape = (1, 48, 31, height // 16, width // 16)
+ plan = U.wide_tile_plan(family, shape, 16, free_gib * 2**30)
+ if plan is None:
+ continue
+ planned += 1
+ tile_h, stride_h, tile_w, stride_w = (v // 16 for v in plan)
+ for length, tile, stride in (
+ (height // 16, tile_h, stride_h),
+ (width // 16, tile_w, stride_w),
+ ):
+ if tile < length:
+ tiles = _diffusers_tiles(length, tile, stride)
+ assert G.check_axis(tiles, floor) == [], (family, width, height, plan)
+ assert planned
diff --git a/studio/backend/tests/test_video_families.py b/studio/backend/tests/test_video_families.py
index ca6e9d1993e..42465f873da 100644
--- a/studio/backend/tests/test_video_families.py
+++ b/studio/backend/tests/test_video_families.py
@@ -175,6 +175,8 @@ def test_supported_names():
"wan2.1-t2v-14b",
"hunyuanvideo-1.5",
"hunyuanvideo-1.5-720p",
+ "cosmos3-nano",
+ "cosmos3-edge",
)
diff --git a/studio/backend/tests/test_video_i2v.py b/studio/backend/tests/test_video_i2v.py
index 7b5090a97c1..c3f37727820 100644
--- a/studio/backend/tests/test_video_i2v.py
+++ b/studio/backend/tests/test_video_i2v.py
@@ -61,10 +61,10 @@ def test_text_only_families_take_no_frame(name):
def test_i2v_class_is_never_the_t2v_class():
# A family naming its own t2v class as the i2v one would "swap" to the same class and pass the image to a
- # __call__ that ignores it.
+ # __call__ that ignores it, unless that class takes the frame itself (Cosmos3OmniPipeline's image=).
for fam in _FAMILIES:
if fam.i2v_pipeline_class:
- assert fam.i2v_pipeline_class != fam.pipeline_class
+ assert fam.i2v_pipeline_class != fam.pipeline_class or not fam.i2v_fits_first_frame
assert fam.i2v_pipeline_class.endswith("Pipeline")
diff --git a/studio/backend/tests/test_video_routes.py b/studio/backend/tests/test_video_routes.py
index d647a080af7..b7aab0cabb6 100644
--- a/studio/backend/tests/test_video_routes.py
+++ b/studio/backend/tests/test_video_routes.py
@@ -1122,6 +1122,37 @@ def test_video_download_plan_forwards_the_encoder_policy(client, monkeypatch):
assert seen["hf_token"] == "hf_secret"
+def test_video_download_plan_validates_with_the_encoder_precision(client, monkeypatch):
+ backend = video_module.get_video_backend()
+ seen: dict = {}
+
+ def _validate(model_path, **kwargs):
+ seen.update(kwargs)
+ raise ValueError("refused at validation")
+
+ monkeypatch.setattr(backend, "validate_load_request", _validate, raising = False)
+ planned: list = []
+ monkeypatch.setattr(
+ backend,
+ "download_plan",
+ lambda *a, **k: planned.append(k) or {"entries": []},
+ raising = False,
+ )
+
+ resp = client.post(
+ "/api/inference/video/download-plan",
+ json = {
+ "model_path": "nvidia/Cosmos3-Edge",
+ "model_kind": "pipeline",
+ "text_encoder_quant": "fp8",
+ },
+ )
+
+ assert seen.get("text_encoder_quant") == "fp8"
+ assert 400 <= resp.status_code < 500, resp.text
+ assert planned == []
+
+
def test_the_video_plan_refuses_an_impossible_precision_before_anything_is_staged(
client, monkeypatch
):
diff --git a/studio/backend/tests/test_video_te_quant_default.py b/studio/backend/tests/test_video_te_quant_default.py
index 48f3bb185e3..431d2914215 100644
--- a/studio/backend/tests/test_video_te_quant_default.py
+++ b/studio/backend/tests/test_video_te_quant_default.py
@@ -50,9 +50,15 @@ HV15_BASES = (
def test_every_generic_path_video_family_has_a_default():
- """Every family that casts its own encoder in place defaults to a hosted one; only H3 and LTX-2.5 resolve theirs."""
+ """Every family that casts its own encoder in place defaults to a hosted one; only H3 and LTX-2.5 resolve theirs,
+ and Cosmos3 has no text encoder."""
assert {f.name for f in _FAMILIES if f.te_quant_auto} == set(EXPECTED_DEFAULTS)
- assert {f.name for f in _FAMILIES if not f.te_quant_auto} == {"minimax-h3", "ltx-2.5"}
+ assert {f.name for f in _FAMILIES if not f.te_quant_auto} == {
+ "minimax-h3",
+ "ltx-2.5",
+ "cosmos3-nano",
+ "cosmos3-edge",
+ }
def test_the_two_hunyuanvideo_repacks_share_one_encoder_and_not_qwen_images():
@@ -120,6 +126,22 @@ def test_families_with_their_own_tristate_get_the_raw_request(name):
assert video_te_quant_request(fam, raw) == (raw, False)
[email protected]("name", ["cosmos3-nano", "cosmos3-edge"])
+def test_a_cosmos3_family_has_no_text_encoder_to_default(name):
+ fam = _family(name)
+ for raw in (None, "", "auto", "none", "fp8"):
+ for speed_mode in ("default", "off"):
+ got = video_te_quant_request(fam, raw, base = fam.base_repo, speed_mode = speed_mode)
+ assert got == (raw, False), (raw, speed_mode)
+ for mode in (None, "fp8", "int8"):
+ assert (
+ tpq.te_prequant_sources_for_base(
+ fam, fam.base_repo, te_quant_mode = mode, target = CUDA_BF16
+ )
+ == {}
+ )
+
+
def test_unsupported_hardware_gets_no_hosted_encoder_for_the_default():
fam = _family("wan2.2-ti2v-5b")
mps = types.SimpleNamespace(device = "mps", dtype = torch.bfloat16)
diff --git a/studio/backend/tests/test_video_unsloth_mirrors.py b/studio/backend/tests/test_video_unsloth_mirrors.py
index 89c5faadd96..c09099ccfbc 100644
--- a/studio/backend/tests/test_video_unsloth_mirrors.py
+++ b/studio/backend/tests/test_video_unsloth_mirrors.py
@@ -47,6 +47,8 @@ NO_UNSLOTH_REPO = frozenset(
{
"wan-ai/wan2.1-t2v-1.3b-diffusers",
"wan-ai/wan2.1-t2v-14b-diffusers",
+ "nvidia/cosmos3-nano",
+ "nvidia/cosmos3-edge",
}
)
diff --git a/studio/backend/tests/test_video_wan21_families.py b/studio/backend/tests/test_video_wan21_families.py
index a93616a26d9..c91dacb7557 100644
--- a/studio/backend/tests/test_video_wan21_families.py
+++ b/studio/backend/tests/test_video_wan21_families.py
@@ -204,7 +204,7 @@ def test_generation_defaults(ids, expected):
def test_registry_lists_the_new_families_after_the_existing_ones():
names = vf.supported_video_family_names()
- assert names[-2:] == ("hunyuanvideo-1.5", "hunyuanvideo-1.5-720p")
+ assert names[-4:-2] == ("hunyuanvideo-1.5", "hunyuanvideo-1.5-720p")
assert "wan2.1-t2v-1.3b" in names and "wan2.1-t2v-14b" in names
for fam in ("wan2.1-t2v-1.3b", "wan2.1-t2v-14b"):
assert dc.family_page(fam) == dc.PAGE_VIDEO
diff --git a/studio/backend/utils/transformers_latest.py b/studio/backend/utils/transformers_latest.py
index 1bbaebe695f..0766231d2e3 100644
--- a/studio/backend/utils/transformers_latest.py
+++ b/studio/backend/utils/transformers_latest.py
@@ -452,6 +452,10 @@ def _hardcoded_model_types() -> frozenset[str]:
_TIER_ROUTED_WITHOUT_MODEL = frozenset({"diffusion_gemma"})
+# Nested model_types the wrapper config never builds (Cosmos3-Edge's projector_config), so they must not veto an offer.
+_INERT_NESTED_MODEL_TYPES = frozenset({"cosmos3_edge_projector"})
+
+
def _hardcoded_tier_ships(model_type: str) -> bool:
"""A hardcoded tier counts as handling *model_type* unless that sidecar is installed and its
CONFIG_MAPPING lacks it: DiffusionGemma is routed to 5.5 for the mlx-vlm processor, but 5.5 has
@@ -503,6 +507,7 @@ def check_upgrade_for_model(model_name: str, hf_token: str | None = None) -> dic
for candidate in candidates
if not _hardcoded_tier_ships(candidate)
and not any(candidate in _config_model_types(tier) for tier in _TIER_RANK)
+ and candidate not in _INERT_NESTED_MODEL_TYPES
]
if not missing:
return None
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.ts
index dd930f18b6a..0d345348312 100644
--- a/studio/frontend/scripts/check-bundle-budget.ts
+++ b/studio/frontend/scripts/check-bundle-budget.ts
@@ -439,8 +439,9 @@ export const BUDGET = {
// Settings and the row menu on the loaded model in Recommended (#15249) add 82 B raw / 176 B transfer to the eager
// model picker (6,960,469 -> 6,960,551 B raw, 2,100,277 -> 2,100,453 B transfer against c9ddc5ab5e, one machine and
// build, Node 26, 105 chunks). Raised by that growth.
- transferBytes: 2_100_497,
- rawBytes: 6_971_572,
+ // Cosmos3 video families (#14554): +466 B raw / +218 B transfer. Raised by that.
+ transferBytes: 2_100_715,
+ rawBytes: 6_972_038,
};
// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering the
diff --git a/studio/frontend/src/features/hub/lib/model-capabilities.ts b/studio/frontend/src/features/hub/lib/model-capabilities.ts
index 3003738c4ad..4f1d9255f4f 100644
--- a/studio/frontend/src/features/hub/lib/model-capabilities.ts
+++ b/studio/frontend/src/features/hub/lib/model-capabilities.ts
@@ -45,8 +45,9 @@ const VIDEO_GEN_TAGS = new Set([
"image-to-video",
"image-text-to-video",
]);
+// Cosmos3 counts only as its Nano and Edge generators, not the Reasoner / Policy / Sim / Transfer / FP8 repos.
const VIDEO_GEN_ID_RE =
- /(?:^|[-_.])wan2|hunyuan[-_]?video|\bltx(?:[-_]?video|v|[-_]?\d)|minimax[-_]?h\d|cogvideo|mochi|skyreels|[-_]t2v\b|[-_]i2v\b/;
+ /(?:^|[-_.])wan2|hunyuan[-_]?video|\bltx(?:[-_]?video|v|[-_]?\d)|minimax[-_]?h\d|cogvideo|mochi|skyreels|[-_]t2v\b|[-_]i2v\b|(?:^|[-_.])cosmos3[-_.](?:nano|edge)(?![a-z0-9]|[-_.](?:reasoner|policy|sim|transfer|fp8)(?![a-z0-9]))/;
const NEITHER_GEN_TASKS = new Set([
"video-to-video",
diff --git a/studio/frontend/src/features/hub/lib/unsloth-support.ts b/studio/frontend/src/features/hub/lib/unsloth-support.ts
index dce29724b31..f093ac8d8c7 100644
--- a/studio/frontend/src/features/hub/lib/unsloth-support.ts
+++ b/studio/frontend/src/features/hub/lib/unsloth-support.ts
@@ -155,6 +155,9 @@ const VIDEO_PAGE_TASKS: ReadonlySet<string> = new Set([
"image-text-to-video",
]);
+// Video page repos whose Hub card names no pipeline task. Not Cosmos3-Nano: its guardrail package is not installed.
+const VIDEO_PAGE_REPOS: ReadonlySet<string> = new Set(["nvidia/cosmos3-edge"]);
+
/** Which Unsloth page runs this pipeline task, if any. */
export function studioPageForTask(
pipelineTag?: string | null,
@@ -284,11 +287,16 @@ export function classifyUnslothSupport({
supportedIn: studioPageForTask(pipeline),
};
}
+ const videoPage =
+ modelId && VIDEO_PAGE_REPOS.has(modelId.trim().toLowerCase())
+ ? { supportedIn: "video" as const }
+ : {};
for (const tag of lowerTags) {
if (UNSUPPORTED_LIBRARY_TAGS.has(tag)) {
return {
status: "unsupported",
reason: `Library: ${tag}.`,
+ ...videoPage,
};
}
}
@@ -296,6 +304,7 @@ export function classifyUnslothSupport({
return {
status: "unsupported",
reason: `Library: ${library}.`,
+ ...videoPage,
};
}
const formatKey = detectUnsupportedFormatKey(modelId, lowerTags, formatTags);
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/family-override.ts b/studio/frontend/src/features/model-picker/components/model-selector/family-override.ts
index b7752612fd8..306b42a5fa6 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/family-override.ts
+++ b/studio/frontend/src/features/model-picker/components/model-selector/family-override.ts
@@ -33,6 +33,8 @@ const LABELS: Readonly<Record<string, string>> = {
"wan2.1-t2v-14b": "Wan2.1 T2V 14B",
"hunyuanvideo-1.5": "HunyuanVideo 1.5 (480p)",
"hunyuanvideo-1.5-720p": "HunyuanVideo 1.5 (720p)",
+ "cosmos3-nano": "Cosmos3-Nano",
+ "cosmos3-edge": "Cosmos3-Edge",
};
export const FAMILY_OVERRIDE_HINT =
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.check.ts b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.check.ts
index 5984600add2..6d653700fa5 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.check.ts
+++ b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.check.ts
@@ -360,6 +360,24 @@ for (const id of [
]) {
assert.ok(videoOptionIds.has(id), `video option missing: ${id}`);
}
+for (const id of ["nvidia/Cosmos3-Edge"]) {
+ const group = groupForRepoId(id, VIDEO_CATALOG);
+ assert.ok(group, id);
+ assert.equal(groupForRepoId(id.toLowerCase(), VIDEO_CATALOG), group, id);
+ assert.equal(loadSpecFor(id, VIDEO_CATALOG)?.kind, "pipeline", id);
+ assert.ok(videoOptionIds.has(id), `video option missing: ${id}`);
+}
+for (const id of [
+ "nvidia/Cosmos3-Nano",
+ "nvidia/Cosmos3-Nano-Reasoner",
+ "nvidia/Cosmos3-Edge-Reasoner",
+ "nvidia/Cosmos3-Edge-Policy-DROID",
+ "nvidia/Cosmos3-Nano-Sim-Transfer",
+ "nvidia/Cosmos3-Nano-FP8",
+]) {
+ assert.equal(artifactForRepoId(id, VIDEO_CATALOG), null, id);
+ assert.equal(loadSpecFor(id, VIDEO_CATALOG), null, id);
+}
// H3 publishes both denoiser partitions officially. One artifact lets the lister's
// partition-aware labels expose both without a community mirror.
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts
index df7131df8b2..a6e628cc590 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts
+++ b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts
@@ -753,6 +753,14 @@ export const VIDEO_CATALOG: CatalogGroup[] = [
}),
],
},
+ // Not Cosmos3 Nano: its checkpoint enables the guardrail, whose package Studio does not install.
+ {
+ canonicalId: "nvidia/Cosmos3-Edge",
+ displayName: "Cosmos3 Edge",
+ description: "Text and image to video 480p, small",
+ scope: "video",
+ artifacts: [bf16Pipeline("nvidia/Cosmos3-Edge", 9, { totalParams: 3858999728 })],
+ },
];
// The Audio page's curated list. tts groups load into the main slot via /api/inference/load (Orpheus
diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsx
index 19794b5cf26..59b0acdce69 100644
--- a/studio/frontend/src/features/video/video-page.tsx
+++ b/studio/frontend/src/features/video/video-page.tsx
@@ -274,6 +274,8 @@ const DEFAULT_GEN = { steps: 8, guidance: 1 };
const MODEL_DEFAULTS: Array<{ match: string; steps: number; guidance: number }> = [
{ match: "minimax-h3", steps: 30, guidance: 1 },
+ { match: "cosmos3-nano", steps: 35, guidance: 6 },
+ { match: "cosmos3-edge", steps: 20, guidance: 6 },
// "distilled" before the generic "ltx": the distilled model runs at 8 steps, guidance 1.
{ match: "distilled", steps: 8, guidance: 1 },
// Wan2.1 14B FusionX merge (CausVid / AccVideo distilled): its card asks for CFG 1 and 8-10 steps.
@@ -329,9 +331,17 @@ function defaultsFor(repoId: string, family?: string): { steps: number; guidance
}
return { steps: 8, guidance: 1 };
}
+ // An HF-cache snapshot path ends in a commit hash, so its name is the models--<owner>--<name> folder.
+ const snapshot = repoId.replace(/\\/g, "/").match(/models--[^/]+?--([^/]+)\/snapshots\/[^/]+\/?$/);
+ const modelName = snapshot ? fold(snapshot[1]) : name;
return (
MODEL_DEFAULTS.find((d) =>
- (d.match.startsWith("wan") || d.match === "fusionx" ? name : id).includes(d.match),
+ (d.match.startsWith("wan") || d.match === "fusionx"
+ ? name
+ : d.match.startsWith("cosmos3")
+ ? modelName
+ : id
+ ).includes(d.match),
) ?? DEFAULT_GEN
);
}
diff --git a/studio/frontend/tests/dense-quant-prequant-routing.test.ts b/studio/frontend/tests/dense-quant-prequant-routing.test.ts
index f7cca67d29a..50076c6bfc1 100644
--- a/studio/frontend/tests/dense-quant-prequant-routing.test.ts
+++ b/studio/frontend/tests/dense-quant-prequant-routing.test.ts
@@ -351,3 +351,11 @@ test("the Wan2.1 rows are sized by the bf16 weights the backend keeps resident",
assert.equal(curatedArtifactFitsDevice(WAN21_1_3B, VIDEO_CATALOG, onCard(24)), true);
assert.equal(curatedArtifactFitsDevice(WAN21_1_3B, VIDEO_CATALOG, onCard(16)), false);
});
+
+test("the Cosmos3 rows are sized by the bf16 weights the backend keeps resident", () => {
+ const EDGE = "nvidia/Cosmos3-Edge";
+ assert.equal(artifactForRepoId("nvidia/Cosmos3-Nano", VIDEO_CATALOG), null);
+ assert.equal(artifactForRepoId(EDGE, VIDEO_CATALOG)?.artifact.approxSizeGb, 9);
+ assert.equal(curatedArtifactFitsDevice(EDGE, VIDEO_CATALOG, onCard(16)), true);
+ assert.equal(curatedArtifactFitsDevice(EDGE, VIDEO_CATALOG, onCard(12)), false);
+});
diff --git a/studio/frontend/tests/family-override.test.ts b/studio/frontend/tests/family-override.test.ts
index c6370ba746d..888b49d778f 100644
--- a/studio/frontend/tests/family-override.test.ts
+++ b/studio/frontend/tests/family-override.test.ts
@@ -58,10 +58,19 @@ test("family options follow the backend registry, deduplicated, and every backen
["flux.1", "FLUX.1"],
]);
const root = new URL("../../backend/core/inference/", import.meta.url);
- const names = ["diffusion_families.py", "video_families.py"].flatMap((f) =>
- [...readFileSync(new URL(f, root), "utf8").matchAll(/^\s+name = "([^"]+)"/gm)].map((m) => m[1]),
- );
+ const names = ["diffusion_families.py", "video_families.py"].flatMap((f) => {
+ const source = readFileSync(new URL(f, root), "utf8");
+ const constant = (key: string) => {
+ const value = source.match(new RegExp(`^${key} = "([^"]+)"$`, "m"));
+ assert.ok(value, `${f}: ${key} is not a family-name string constant`);
+ return value[1];
+ };
+ return [
+ ...source.matchAll(/^\s+name = (?:"([^"]+)"|([A-Z][A-Z0-9_]*),$)/gm),
+ ].map(([, literal, key]) => literal ?? constant(key));
+ });
assert.ok(names.includes("flux.1") && names.includes("ltx-2"));
+ assert.ok(names.includes("cosmos3-nano") && names.includes("cosmos3-edge"));
const unlabeled = familyOverrideOptions(names).slice(1).filter(([value, label]) => value === label);
assert.deepEqual(unlabeled, []);
});
diff --git a/studio/frontend/tests/hub-capability-split.test.ts b/studio/frontend/tests/hub-capability-split.test.ts
index 0089ba179eb..c80627fb0b5 100644
--- a/studio/frontend/tests/hub-capability-split.test.ts
+++ b/studio/frontend/tests/hub-capability-split.test.ts
@@ -11,9 +11,12 @@ import { readSrc, registerBundlerResolver } from "./helpers/kit.ts";
registerBundlerResolver();
-const { detectCapabilities, generationKinds, HUB_CAPABILITY_FILTERS } = await import(
- "../src/features/hub/lib/model-capabilities.ts"
-);
+const {
+ detectCapabilities,
+ generationKinds,
+ HUB_CAPABILITY_FILTERS,
+ isVideoFamilyName,
+} = await import("../src/features/hub/lib/model-capabilities.ts");
test("video models are video gen, image models image gen", () => {
assert.deepEqual(generationKinds(["diffusers"], "text-to-video", "Wan-AI/Wan2.2-T2V"), { image: false, video: true });
@@ -202,3 +205,26 @@ test("back/forward between models and datasets drops the other kind's hidden bou
test("capabilities light the filter dot only where they apply", () => {
assert.match(readSrc("features/hub/catalog/model-search-filters.tsx"), /\(modelSections && capabilities\.length > 0\)/);
});
+
+test("Cosmos3's Nano and Edge are video gen; its Reasoner, Policy, Sim / Transfer and FP8 repos are not", () => {
+ const tags = ["diffusers", "safetensors", "cosmos3", "cosmos3_edge"];
+ for (const id of ["nvidia/Cosmos3-Nano", "nvidia/Cosmos3-Edge", "someone/cosmos3_edge"]) {
+ assert.equal(isVideoFamilyName(id), true, id);
+ assert.deepEqual(generationKinds(tags, undefined, id), { image: false, video: true }, id);
+ const diffusion = detectCapabilities(tags, undefined, id).find((c) => c.key === "diffusion");
+ assert.deepEqual(diffusion, { key: "diffusion", label: "Video gen" }, id);
+ }
+ for (const id of [
+ "nvidia/Cosmos3-Nano-Reasoner",
+ "unsloth/Cosmos3-Nano-Reasoner-GGUF",
+ "nvidia/Cosmos3-Edge-Policy-DROID",
+ "nvidia/Cosmos3-Nano-Sim-Transfer",
+ "nvidia/Cosmos3-Nano-FP8",
+ "nvidia/Cosmos3-Super",
+ "nvidia/Cosmos3-Edgeless",
+ "cosmos3-edge-lab/some-model",
+ ]) {
+ assert.equal(isVideoFamilyName(id), false, id);
+ assert.equal(generationKinds(["diffusers"], undefined, id).video, false, id);
+ }
+});
diff --git a/studio/frontend/tests/unsloth-support-cosmos3.test.ts b/studio/frontend/tests/unsloth-support-cosmos3.test.ts
new file mode 100644
index 00000000000..a8bac132d01
--- /dev/null
+++ b/studio/frontend/tests/unsloth-support-cosmos3.test.ts
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { classifyUnslothSupport } from "../src/features/hub/lib/unsloth-support.ts";
+
+// nvidia/Cosmos3-* cards name no pipeline task (library "cosmos") and tag diffusers.
+const HUB_CARD = {
+ pipelineTag: null,
+ libraryName: "cosmos",
+ tags: ["diffusers", "safetensors", "cosmos3", "cosmos3_omni", "license:other"],
+};
+const UNSUPPORTED = { status: "unsupported", reason: "Library: diffusers." };
+
+test("only nvidia's Cosmos3 Edge is routed to the Video page; Nano, siblings and copies stay unsupported", () => {
+ const cases: Array<[string, object]> = [
+ ["nvidia/Cosmos3-Edge", { ...UNSUPPORTED, supportedIn: "video" }],
+ ["NVIDIA/cosmos3-edge", { ...UNSUPPORTED, supportedIn: "video" }],
+ ["nvidia/Cosmos3-Nano", UNSUPPORTED],
+ ["nvidia/Cosmos3-Nano-FP8", UNSUPPORTED],
+ ["nvidia/Cosmos3-Edge-Policy-DROID", UNSUPPORTED],
+ ["nvidia/Cosmos3-Nano-Reasoner", UNSUPPORTED],
+ ["someone/Cosmos3-Edge", UNSUPPORTED],
+ ];
+ for (const [modelId, expected] of cases) {
+ assert.deepEqual(classifyUnslothSupport({ modelId, ...HUB_CARD }), expected, modelId);
+ }
+});
diff --git a/studio/frontend/tests/video-model-defaults.test.ts b/studio/frontend/tests/video-model-defaults.test.ts
index 432f05dee57..15d69e05581 100644
--- a/studio/frontend/tests/video-model-defaults.test.ts
+++ b/studio/frontend/tests/video-model-defaults.test.ts
@@ -115,6 +115,15 @@ test("the other families keep their recipes", () => {
["fusionx-lab/HunyuanVideo-1.5-Diffusers-480p_t2v", 20, 6],
["/models/FusionX/wan2.1-t2v-14b-Q4_K_M.gguf", 20, 6],
["/home/user/ComfyUI/models/diffusion_models/wan2.2_ti2v_5B_fp16.safetensors", 20, 5],
+ ["/models/ltx/Cosmos3-Nano", 35, 6],
+ ["/home/distilled/Cosmos3-Nano", 35, 6],
+ ["/data/fusionx/Cosmos3-Edge", 20, 6],
+ ["/models/a14b/Cosmos3-Edge", 20, 6],
+ ["/models/hunyuanvideo/Cosmos3-Nano", 35, 6],
+ ["cosmos3-nano-lab/HunyuanVideo-1.5-Diffusers-480p_t2v", 20, 6],
+ ["/home/cosmos3-nano/models/HunyuanVideo-1.5-Diffusers-480p_t2v", 20, 6],
+ ["/models/Cosmos3-Nano/wan2.1_t2v_14B_bf16.safetensors", 20, 6],
+ ["cosmos3-edge-lab/Wan2.1-T2V-1.3B-Diffusers", 30, 6],
];
for (const [id, steps, guidance] of cases) {
assert.deepEqual(defaultsFor(id), { steps, guidance }, id);
@@ -127,3 +136,37 @@ test("an explicit LTX-2.5 family still reads the variant from the file and repo
assert.deepEqual(defaultsFor("/models/opaque/model.safetensors", "ltx-2.5"), { steps: 8, guidance: 1 });
assert.deepEqual(defaultsFor("/models/opaque/model.safetensors"), { steps: 8, guidance: 1 });
});
+
+test("every Cosmos3 spelling seeds the recipe its backend family reports: Nano 35 steps, Edge 20, CFG 6", () => {
+ const families = readText("../../backend/core/inference/video_families.py");
+ const backend = (constant: string) => {
+ const row = families.slice(families.indexOf(`name = "${constant}",`));
+ const steps = row.match(/default_steps = (\d+),/);
+ const guidance = row.match(/default_guidance = ([\d.]+),/);
+ assert.ok(steps && guidance, constant);
+ return { steps: Number(steps[1]), guidance: Number(guidance[1]) };
+ };
+ const nano = backend("cosmos3-nano");
+ const edge = backend("cosmos3-edge");
+ // The cards' Diffusers examples (nvidia/Cosmos3-Nano@e59a53c2, nvidia/Cosmos3-Edge@344d602b).
+ assert.deepEqual([nano, edge], [{ steps: 35, guidance: 6 }, { steps: 20, guidance: 6 }]);
+ const spellings: Array<[string, typeof nano]> = [
+ ["nvidia/Cosmos3-Nano", nano],
+ ["NVIDIA/COSMOS3-NANO", nano],
+ ["someone/Cosmos3_Nano", nano],
+ ["Cosmos3 Nano", nano],
+ ["/home/me/.cache/huggingface/hub/models--nvidia--Cosmos3-Nano/snapshots/e59a53c25979a090fa8706c9acc0c254a6e89b92", nano],
+ ["/data/models/Cosmos3-Nano/", nano],
+ ["~/models/cosmos3_nano", nano],
+ ["cosmos3-nano", nano],
+ ["nvidia/Cosmos3-Edge", edge],
+ ["someone/cosmos3_edge", edge],
+ ["COSMOS3.EDGE", edge],
+ ["/home/u/.cache/huggingface/hub/models--nvidia--Cosmos3-Edge/snapshots/344d602b128d1bbdacb43b08d0a3626f46343e29", edge],
+ ["C:\\models\\Cosmos3-Edge", edge],
+ ["cosmos3-edge", edge],
+ ];
+ for (const [id, recipe] of spellings) {
+ assert.deepEqual(defaultsFor(id), recipe, id);
+ }
+});