First bucket-B port toward 'support every fastvideo model': Wan2.1-T2V-14B reuses the Wan recipe + torch adapter unchanged (same WanTransformer3DModel/AutoencoderKLWan/UMT5) — only a registry entry + build_wan_t2v_14b_card (720p, flow_shift 5.0) + SamplingDefaults differ. Without the entry the arch fallback would give it the 1.3B 480p defaults; the explicit entry gives 50 steps / 720x1280. Also recorded the full backlog in V2_PORTING_STATUS.md: 63 fastvideo models = 8 ported / 21 bucket-B (reuse Wan/Causal/LTX2 arch — registry+recipe+defaults, no new adapter) / 34 bucket-C (13 new architectures needing a TorchComponent adapter). Updated the stale 'how to add a model' steps to the post-redesign structure (v2/recipes/, torch_backend.py, SamplingDefaults). CPU mini 211 pass, 2 skip.
78 lines
3.4 KiB
Python
78 lines
3.4 KiB
Python
"""Phase 1a: per-model sampling defaults on the card + the kwargs>SamplingParam>card>generic precedence."""
|
|
from types import SimpleNamespace
|
|
|
|
from v2.card import SamplingDefaults
|
|
from v2.recipes.ltx2 import build_ltx2_3_card, build_ltx2_base_card, build_ltx2_card
|
|
from v2.recipes.wan21 import (
|
|
build_wan21_card,
|
|
build_wan22_a14b_card,
|
|
build_wan22_ti2v_card,
|
|
build_wan_t2v_14b_card,
|
|
)
|
|
from v2.recipes.wan_causal import build_wan_causal_card
|
|
from v2.registry import resolve
|
|
from v2.video_generator import _resolve_default
|
|
|
|
|
|
def test_wan_t2v_14b_defaults_and_registry():
|
|
# Bucket-B port: reuses the Wan recipe/adapter, only defaults differ (720p, flow_shift 5.0).
|
|
sd = build_wan_t2v_14b_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width, sd.fps) == (50, 5.0, 720, 1280, 16)
|
|
# the HF id resolves to the 14B card via the shared registry (not the 1.3B fallback defaults)
|
|
build_card, _ = resolve("Wan-AI/Wan2.1-T2V-14B-Diffusers")
|
|
assert build_card().sampling_defaults.height == 720
|
|
|
|
|
|
def test_wan21_defaults():
|
|
sd = build_wan21_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width, sd.num_frames, sd.fps) == (50, 3.0, 480, 832, 81, 16)
|
|
assert "overexposed" in sd.negative_prompt
|
|
|
|
|
|
def test_wan22_ti2v_defaults():
|
|
sd = build_wan22_ti2v_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width, sd.num_frames, sd.fps) == (50, 5.0, 704, 1280, 121, 24)
|
|
|
|
|
|
def test_wan22_a14b_defaults():
|
|
sd = build_wan22_a14b_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.fps) == (40, 4.0, 16)
|
|
|
|
|
|
def test_wan_causal_defaults():
|
|
sd = build_wan_causal_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width, sd.num_frames, sd.fps) == (50, 6.0, 480, 832, 81, 16)
|
|
|
|
|
|
def test_ltx2_two_stage_defaults():
|
|
sd = build_ltx2_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width, sd.num_frames, sd.fps) == (8, 1.0, 1024, 1536, 121, 24)
|
|
assert sd.negative_prompt == "" # distilled: empty negative prompt
|
|
|
|
|
|
def test_ltx2_base_defaults():
|
|
sd = build_ltx2_base_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width) == (40, 3.0, 512, 768)
|
|
assert "blurry" in sd.negative_prompt
|
|
|
|
|
|
def test_ltx2_3_defaults():
|
|
sd = build_ltx2_3_card().sampling_defaults
|
|
assert (sd.num_steps, sd.guidance_scale, sd.height, sd.width) == (30, 3.0, 512, 768)
|
|
assert sd.guidance_per_modality == {"video": 3.0, "audio": 7.0}
|
|
|
|
|
|
def test_resolve_precedence():
|
|
sd = SamplingDefaults(num_steps=8, guidance_scale=1.0, height=1024)
|
|
# card default used when neither kwargs nor SamplingParam set it (note the num_steps alias)
|
|
assert _resolve_default("num_inference_steps", 30, {}, None, sd, "num_steps") == 8
|
|
assert _resolve_default("height", 480, {}, None, sd) == 1024
|
|
# kwargs override card
|
|
assert _resolve_default("num_inference_steps", 30, {"num_inference_steps": 4}, None, sd, "num_steps") == 4
|
|
# SamplingParam override (no kwargs) beats card
|
|
assert _resolve_default("height", 480, {}, SimpleNamespace(height=720), sd) == 720
|
|
# generic fallback when card has no value and nothing else set
|
|
assert _resolve_default("width", 832, {}, None, sd) == 832
|
|
# empty-string negative prompt is a real value, not "unset"
|
|
assert _resolve_default("negative_prompt", None, {}, None, SamplingDefaults(negative_prompt="")) == ""
|