You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[perf]: batched classifier-free guidance for Wan/Cosmos
Run cond + uncond as a single batch=2 DiT forward per denoise step
instead of two sequential batch=1 forwards. Composable with Adaptive
Guidance (hao-ai-lab#1372).
Mechanism is bit-equivalent to sequential CFG on H100 FA3 eager
(SSIM=1.000000, 5 prompts, Wan 14B 720x1280x49f/30steps). See PR
body for full validation matrix across L40S/H100 and eager/compile.
Changes:
- fastvideo_args.py: new use_batched_cfg: bool = True field +
--use-batched-cfg CLI. Auto-fallback to sequential when V2V/I2V/
TI2V/action/camera conditioning is present (those carry batch=1
conditioning tensors out of scope for this PR).
- entrypoints/video_generator.py: add use_batched_cfg to
_FROM_PRETRAINED_CONVENIENCE_KWARGS so users don't see the
DeprecationWarning from the legacy kwarg path.
- pipelines/stages/denoising.py: gated batched branch in main
DenoisingStage.forward. Cats [neg, pos] along batch dim with
shape-match defensive fallback, single forward, chunk(2),
existing CFG-combine + guidance_rescale math reused. Other
DenoisingStage subclasses (Cosmos25, Dmd, ...) unchanged.
Sequential CFG path preserved bit-for-bit for non-batched callers.
Other DiTs (HunyuanVideo, LongCat, ...) unaffected.
0 commit comments