Repository navigation
Description
Describe the bug
CosmosRotaryPosEmbed scales its temporal frequencies by FPS whenever fps is not None:
if fps is None:
emb_t = torch.outer(seq[: pe_size[0]], temporal_freqs)
else:
emb_t = torch.outer(seq[: pe_size[0]] / fps * self.base_fps, temporal_freqs) # base_fps = 24and Cosmos2VideoToWorldPipeline always feeds it — fps: int = 16 by default:
https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py#L498
https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/cosmos/pipeline_cosmos2_video2world.py#L713
However, in the reference implementation this modulation sits behind an enable_fps_modulation
flag, and the released Cosmos-Predict2 checkpoints ship with it turned off:
- rope implementation (guarded): https://github.com/nvidia-cosmos/cosmos-predict2/blob/main/cosmos_predict2/models/text2image_dit.py#L541-L552
- 2B Video2World net config: https://github.com/nvidia-cosmos/cosmos-predict2/blob/main/cosmos_predict2/configs/base/config_video2world.py#L117 (
rope_enable_fps_modulation=False) - 14B Video2World net config: same file, L207
- Text2Image nets: https://github.com/nvidia-cosmos/cosmos-predict2/blob/main/cosmos_predict2/configs/base/config_text2image.py#L110 (also L231, L309)
So natively these models use raw integer temporal RoPE positions and ignore FPS entirely,
while the diffusers port has no such flag and, with the pipeline default fps=16 against
base_fps=24, runs every denoising step with temporal RoPE positions stretched by
24/16 = 1.5× relative to how the checkpoints were trained. We traced this while
investigating consistently odd motion in default Video2World outputs.
Consequences with the current defaults:
- Every default
Cosmos2VideoToWorldPipelinerun diverges from the reference implementation. - The
fpsargument changes the generated content in diffusers, whereas natively it only
affects the exported container framerate.
Not affected:
Cosmos2TextToImagePipeline— single frame, so the temporal position is 0 either way.Cosmos2_5_PredictBasePipeline/Cosmos2_5_TransferPipeline— they don't take anfps
argument, so the transformer seesfps=Noneand uses raw positions, matching the native
configs (which also disable the modulation).- The Cosmos-Predict1 pipelines are out of scope here; this report is only about the
Cosmos-Predict2 checkpoints.
Suggested fix
Either of:
- Port
enable_fps_modulationintoCosmosTransformer3DModel's config (defaultFalsefor
the converted Cosmos-Predict2 checkpoints), mirroring the reference nets — the faithful fix; or - Stop passing
fpsto the transformer inCosmos2VideoToWorldPipeline(or change the
default tofps=24, which makes the scale factor 1), keepingfpsfor video export only.
Reproduction
import torch
from diffusers import Cosmos2VideoToWorldPipeline
from diffusers.utils import load_image
pipe = Cosmos2VideoToWorldPipeline.from_pretrained(
"nvidia/Cosmos-Predict2-2B-Video2World", torch_dtype=torch.bfloat16
).to("cuda")
image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yellow-scrubber.png"
)
# identical seeds, only fps differs — natively these would be identical, here they are not
common = dict(image=image, prompt="a yellow scrubber cleaning a plate")
video_16 = pipe(**common, fps=16, generator=torch.Generator().manual_seed(1)).frames[0]
video_24 = pipe(**common, fps=24, generator=torch.Generator().manual_seed(1)).frames[0]
# video_24 corresponds to the un-modulated (native) temporal RoPE; video_16 is the defaultLogs
System Info
- diffusers: main (also reproduces on 0.38.0)
- the referenced code is identical on current
main(line links above)
Activity
L4XB commentedon Sep 15, 2026
Reproduced, and I have a branch ready. Asking for an ack before opening a PR, per
CONTRIBUTING.What I verified. The scale factor is real and it is exactly the 1.5x you describe.
base_fpsis24for every converted Cosmos checkpoint —scripts/convert_cosmos_to_diffusers.pynever sets it, so they all take the class default — and
fpsreachesCosmosRotaryPosEmbedfromCosmos2VideoToWorldPipelineand nowhere else in that file. On the repo's own dummy components:So
fpschanges the generated content onmain, which it should not.The strongest argument is one the issue does not make: within the Predict2 family this pipeline is
the odd one out. Of the six pipelines that build a
CosmosTransformer3DModel, exactly three passfpsinto it:fps=fpspipeline_cosmos_text2world.pypipeline_cosmos_video2world.pypipeline_cosmos2_video2world.pypipeline_cosmos2_text2image.pypipeline_cosmos2_5_predict.pypipeline_cosmos2_5_transfer.pyThe split is clean along family lines everywhere except this one file. Predict1 is trained with the
modulation and should keep it; the rest of Predict2 already does not apply it. That reads as an
oversight carried over when the Predict2 pipeline was written from the Predict1 one, not as a
deliberate choice.
Scope I propose: option 2, and I would like to talk you out of option 1. Stop passing
fpsintothe transformer from
Cosmos2VideoToWorldPipeline; keep the argument as the playback property it isupstream. I do not think the
enable_fps_modulationconfig flag can work here, for two reasons:nvidia/Cosmos-Predict2-*config can contain a key that does not exist in the classtoday, so
register_to_confighands every released checkpoint the default. Whatever that defaultis, it is the only value any of them would ever see — the flag would carry no per-checkpoint
information.
CosmosTransformer3DModelis shared with Cosmos-Predict1, which needs the opposite value —cosmos-predict1'sposition_embedding.pyhas no such flag and always appliesself.seq[:T] / fps * self.base_fps. DefaultTrueleaves this bug; defaultFalsesilentlybreaks Predict1.
To be fair to option 1: that flag does already exist in this repo, on
CosmosTransformer3DModel's Cosmos3 sibling (transformer_cosmos3.py:404,enable_fps_modulation: bool = True, read bypipeline_cosmos3_omni.py). So the precedent isthere, and I want to be explicit that I am arguing against it rather than pretending it does not
exist. The difference is that Cosmos3 checkpoints ship a config that can set the key, and the
already-published Predict2 checkpoints cannot: whatever default
CosmosTransformer3DModelpickedwould be the only value any of them ever saw, on a class that also serves Predict1 with the
opposite requirement.
The pipeline class already encodes the model family, so that is where the difference belongs. This
also stays on the right side of
.ai/references/code_style.md, which says not to add "configurationoptions 'just in case'". (Changing the default to
fps=24fixes only the default andleaves an explicit
fps=16still stretching the RoPE.)Branch is ready. Two
fps=fpslines removed, the parameter docstring rewritten, one test added.Identical failure sets on both sides (55 entries, diffed); the extra pass is the new test.
test_inference's golden slice still passes untouched — the 16 sampled elements happen to beunaffected, so please read that as coincidence rather than as the change being inert.
Worth being explicit that this changes the output of every default
Cosmos2VideoToWorldPipelinerun: on the branch,
fps=16reproduces bit-for-bit whatfps=24produced before, which is theun-modulated temporal RoPE the checkpoints were trained with. I have no access to the gated
Cosmos-Predict2 repos, so everything above is on dummy components and the RoPE embeddings directly.
May I open it?
rebel-seinpark commentedon Sep 28, 2026
@L4XB Sure. Please open it.
yiyixuxu commentedon Dec 2, 2026
@L4XB @rebel-seinpark
sorry i'm bit late to see this and thanks for waiting for our feedbacks
feel free to open the PR if you're still interested in contributing