From ee4e21544d23c3dec26488bc54e0e38720a0787e Mon Sep 17 00:00:00 2001 From: SolitaryThinker Date: Sun, 26 Apr 2026 14:52:46 -0700 Subject: [PATCH] fix(api): align public SamplingParam ltx2 defaults with distilled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Internal FastVideo declares two LTX-2 SamplingParam variants: LTX2SamplingParam (mod=3.0/rescale=0.7/stg=1.0 — full LTX-2) and LTX2DistilledSamplingParam (mod=1.0/rescale=0.0/stg=0.0). Dreamverse production runs against LTX2-Distilled-Diffusers, so the distilled defaults are what the runtime should land on. The public package only has the single SamplingParam class, and its class-level defaults for these knobs were the *full* LTX-2 values. Result: when Dreamverse (or any other consumer) called ``SamplingParam.from_pretrained("FastVideo/LTX2-Distilled-Diffusers")``, the LTX2_DISTILLED preset's defaults dict didn't override these fields (it didn't list them) so they fell through to the class defaults — silently picking up *full*-model CFG / modality / rescale / STG instead of the distilled ones. Streamed video output diverged from the internal-ui reference. Switch the class defaults to the distilled values (1.0 / 0.0 / 0.0). The LTX2_BASE preset already overrides them explicitly to 3.0/0.7/1.0 in its ``defaults`` dict, so users selecting the full-LTX-2 preset keep the full-model behavior. The numerical alignment harness still reproduces the same 42.72 dB PSNR / 52.87% exact pixel match because that test pinned the values explicitly via legacy kwargs; this fix moves the *default* path on the public side onto the same numerical track. Co-authored-by: Junda (David) Su <90978028+Davids048@users.noreply.github.com> Co-authored-by: Matthew Noto <99706358+RandNMR73@users.noreply.github.com> Co-authored-by: XOR-op <17672363+XOR-op@users.noreply.github.com> Co-authored-by: Zhang Peiyuan <42993249+jzhang38@users.noreply.github.com> --- fastvideo/api/sampling_param.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/fastvideo/api/sampling_param.py b/fastvideo/api/sampling_param.py index f89d97e20..9ae119152 100644 --- a/fastvideo/api/sampling_param.py +++ b/fastvideo/api/sampling_param.py @@ -98,17 +98,22 @@ class SamplingParam: camera_rotation: str | None = None # LTX-2 multi-modal CFG and STG. - # cfg_scale defaults are 1.0 (CFG off) so ``ForwardBatch.__post_init__`` - # doesn't force ``do_classifier_free_guidance`` on non-LTX-2 models that - # never override these fields. LTX-2 presets that need text-CFG on set - # them in their ``defaults`` dict (e.g. ``ltx2_base``). + # Class-level defaults match the *distilled* LTX-2 schedule + # (mirrors ``FastVideo-internal/.../LTX2DistilledSamplingParam``): + # the distilled model expects neutral guidance scales — modality 1, + # rescale 0, STG 0 — and explicit-CFG callers (full LTX-2) opt back + # in by selecting the ``LTX2_BASE`` preset, which overrides these + # to mod=3.0 / rescale=0.7 / stg=1.0 in its ``defaults`` dict. + # cfg_scale defaults stay at 1.0 (CFG off) so + # ``ForwardBatch.__post_init__`` doesn't force CFG on non-LTX-2 + # models that never override these fields. ltx2_cfg_scale_video: float = 1.0 ltx2_cfg_scale_audio: float = 1.0 - ltx2_modality_scale_video: float = 3.0 - ltx2_modality_scale_audio: float = 3.0 - ltx2_rescale_scale: float = 0.7 - ltx2_stg_scale_video: float = 1.0 - ltx2_stg_scale_audio: float = 1.0 + ltx2_modality_scale_video: float = 1.0 + ltx2_modality_scale_audio: float = 1.0 + ltx2_rescale_scale: float = 0.0 + ltx2_stg_scale_video: float = 0.0 + ltx2_stg_scale_audio: float = 0.0 ltx2_stg_blocks_video: list[int] = field(default_factory=lambda: [29]) ltx2_stg_blocks_audio: list[int] = field(default_factory=lambda: [29])