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]: align Wan/Cosmos T5 encoding to diffusers canonical recipe (gated on use_batched_cfg)
Diffusers' WanPipeline._get_t5_prompt_embeds (pipeline_wan.py:173-190)
and CosmosTextToWorldPipeline._get_t5_prompt_embeds (pipeline_cosmos_
text2world.py:197-237) both:
(a) tokenize(padding="max_length", max_length=N)
(b) T5 encoder forward (sees padded input)
(c) trim T5 output to per-sample real length
(d) re-pad with EXPLICIT ZEROS to max_length
Wan and Cosmos were trained against this recipe. FV's current
variable-length T5 output deviates. This change replicates the
canonical recipe — but only when use_batched_cfg=True, so users who
don't opt in see zero behaviour change.
HunyuanVideo's diffusers pipeline (pipeline_hunyuan_video.py
_get_llama_prompt_embeds) does NOT do (c)+(d) — uses encoder output
as-is, padded positions retain T5's natural bias-driven values.
Gated on dit_config MRO matching {WanVideoConfig, CosmosVideoConfig,
Cosmos25VideoConfig} so HunyuanVideo and every other DiT bypass the
recipe entirely.
Long-term: the right fix is to wire context_lens through to Wan's
attention layer so it can mask padding directly (rather than relying
on training-distribution-zero positions). That would let batched-CFG
pad to max(real_lens) instead of max_length and become bit-equivalent
across more configs. Out of scope for this PR; tracked as a follow-up
(see PR body and ground_truth W3e).
0 commit comments