Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix OOM in WanAnimate BitsAndBytes Training Test#13777

Merged
sayakpaul merged 2 commits into
huggingface:mainfrom
jiqing-feng:mem_2
May 21, 2026
Merged

Fix OOM in WanAnimate BitsAndBytes Training Test#13777
sayakpaul merged 2 commits into
huggingface:mainfrom
jiqing-feng:mem_2

Conversation

@jiqing-feng

@jiqing-feng jiqing-feng commented May 21, 2026

Copy link
Copy Markdown
Contributor

Problem

TestWanAnimateTransformer3DBitsAndBytes::test_bnb_training fails with torch.OutOfMemoryError on CUDA/XPU (24 GB), attempting to allocate ~68.9 GiB.

The root cause is oversized dummy inputs in get_dummy_inputs():

Tensor Original Shape Key Issue
hidden_states (1, 36, 21, 64, 64) Spatial 64×64, 21 frames
pose_hidden_states (1, 16, 20, 64, 64) Spatial 64×64, 20 frames
face_pixel_values (1, 3, 77, 512, 512) 77 frames at 512×512

The training test runs forward + backward with LoRA adapters under autocast, so intermediate activations (especially from the motion encoder's multi-layer Conv2d chain on 512×512 faces) dominate memory.

Fix

Reduce the BnB test dummy input dimensions to match the smaller shapes already used by TestWanAnimateTransformer3DTorchAo:

Tensor New Shape
hidden_states (1, 36, 5, 16, 16)
pose_hidden_states (1, 16, 4, 16, 16)
face_pixel_values (1, 3, 13, 512, 512)

face_pixel_values keeps 512×512 spatial resolution (required by the Hub model's motion_encoder_size=512) but reduces frame count from 77 to 13. Latent spatial dims drop from 64 to 16 and frame counts are similarly reduced.

Signed-off-by: jiqing-feng <[email protected]>
@github-actions github-actions Bot added tests size/S PR with diff < 50 LOC labels May 21, 2026
@jiqing-feng jiqing-feng changed the title reduce input size for tests Fix OOM in WanAnimate BitsAndBytes Training Test May 21, 2026
@jiqing-feng

Copy link
Copy Markdown
Contributor Author

Hi @sayakpaul . Would you please review this PR? Thanks!

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There seems to be some dequant test failures for this model. Would you like to fix them in a separate PR?

FAILED tests/models/transformers/test_models_transformer_wan_animate.py::TestWanAnimateTransformer3DTorchAo::test_torchao_dequantize[int4wo] - NotImplementedError: Int4Tensor dispatch: attempting to run unimplemented operator/function: func=<OpOverload...
FAILED tests/models/transformers/test_models_transformer_wan_animate.py::TestWanAnimateTransformer3DTorchAo::test_torchao_dequantize[int8dq] - NotImplementedError: LinearActivationQuantizedTensor dispatch: attempting to run unimplemented operator/funct...

@jiqing-feng

Copy link
Copy Markdown
Contributor Author
tests/models/transformers/test_models_transformer_wan_animate.py::TestWanAnimateTransformer3DTorchAo::test_torchao_dequantize[int4wo]

I cannot see the tests:

ERROR: file or directory not found: tests/models/transformers/test_models_transformer_wan_animate.py::TestWanAnimateTransformer3DTorchAo::test_torchao_dequantize[int4wo]

https://github.com/huggingface/diffusers/blob/main/tests/models/testing_utils/quantization.py#L936-L939

@sayakpaul

Copy link
Copy Markdown
Member

You can find them in the main of diffusers.

@jiqing-feng

Copy link
Copy Markdown
Contributor Author

You can find them in the main of diffusers.

Still cannot find: https://github.com/huggingface/diffusers/blob/main/tests/models/testing_utils/quantization.py#L936-L939. The link is from main of diffusers, only int8wo was enabled.

@sayakpaul

Copy link
Copy Markdown
Member

Hmm you are right!

@sayakpaul sayakpaul merged commit a362223 into huggingface:main May 21, 2026
11 of 13 checks passed
DN6 pushed a commit that referenced this pull request Jul 1, 2026
reduce input size for tests

Signed-off-by: jiqing-feng <[email protected]>
Co-authored-by: Sayak Paul <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants