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
{{ message }}
Repository navigation
AnimateDiffPipeline performance regression on CPU. #12975
The attn_processor will turn the hidden_states into channel last (NHWC) layout, which will have great benefit on CPU when running matmul.
But the op: .contiguous() will turn the tensor into NCHW layout as the tensor orginal layout, it will make the matmul slower than the NHWC layout (converted by attn processor). Besides, the op .contiguous() also costs too much time on CPU if the tensor layout is bad (just like in this case).
The script to reproduce the error is mentioned in #3809.
I believe this can be resolved by checking if the model is an instance of DistributedDataParallel (DDP) as follows in src/diffusers/models/resnet.py:
Activity
sayakpaul commentedon Jan 14, 2026
Thanks for pointing this out. Running these pipelines on CPU is something unique to us but it's great to see the possibility and practice.
I would suggest you to open a PR in this case.
jiqing-feng commentedon Jan 14, 2026
Yes, I will open a PR to work around it once I know which case breaks if not using
.contiguous()jinc7461 commentedon Jan 14, 2026
The script to reproduce the error is mentioned in #3809.
I believe this can be resolved by checking if the model is an instance of
DistributedDataParallel(DDP) as follows in src/diffusers/models/resnet.py:jiqing-feng commentedon Jan 14, 2026
Thanks! I will reproduce it and check how to fix it.
jiqing-feng commentedon Jan 15, 2026
Fixed in #12977. Please review it. Thanks!