Skip to content

fix(wan): use device-agnostic default for get_i2v_mask - #14765

Closed
li-lizhe wants to merge 1 commit into
huggingface:mainfrom
li-lizhe:fix/wan-animate-device-default
Closed

li-lizhe wants to merge 1 commit into
huggingface:mainfrom
li-lizhe:fix/wan-animate-device-default

Conversation

@li-lizhe

@li-lizhe li-lizhe commented Sep 14, 2026 •

Copy link
Copy Markdown

Fixes #14881

Description: Fix the get_i2v_mask method's device="cuda" default parameter which causes a crash on non-CUDA accelerators (Ascend NPU, Intel XPU, Apple MPS, etc.) when called without an explicit device argument.

Change:

  • Default device from "cuda" to None
  • Add device = device or self._execution_device at the function top
  • Follows the established pattern used in prepare_reference_image_latents, encode_image, and other pipeline methods

Verification on Ascend 910B NPU (torch 2.14.0a0 + torch_npu):

  • Old code: torch.zeros(1, device="cuda") crashes with AssertionError: Torch not compiled with CUDA enabled
  • Fix: device = device or self._execution_device resolves to npu:0, tensor created successfully on NPU

Scope note (see #14881): the two in-tree call sites in this file already pass device explicitly, so this is a latent default / API-hygiene fix rather than a fix for a currently-failing in-tree path. The same CUDA default also exists in the module-level helper get_i2v_mask at src/diffusers/modular_pipelines/wan_animate_2/encoders.py:84 - happy to extend this PR to cover that one too if maintainers prefer.

The `get_i2v_mask` method had a hardcoded `device="cuda"` default,
which crashes on non-CUDA accelerators (Ascend NPU, etc.) with
"Torch not compiled with CUDA enabled" when called without an
explicit device argument.

Change the default to None and resolve via `self._execution_device`,
matching the pattern used across other pipeline methods.

Verified on Ascend 910B NPU: torch.zeros(device="cuda") crashes,
fix with device-agnostic resolution creates tensors on the correct
device.
@github-actions github-actions Bot added pipelines size/S PR with diff < 50 LOC labels Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Hi @li-lizhe, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice.

Once the PR links an issue (or gets the no-issue-needed label), you can ignore this message — it stays here as a comment, but it no longer applies.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically closed because it does not link an issue and the reminder above was not addressed within 10 days. If this PR is still relevant, please link the issue it fixes (e.g. Fixes #1234) or ask a maintainer to add the no-issue-needed label, and it can be reopened.

We are experimenting with this process to keep the review queue manageable, and it will sometimes get it wrong. If you think this PR should stay open, please just say so here and we will reopen it — no need to justify it at length.

Thanks again for contributing, and sorry for the noise if we closed this by mistake!

@li-lizhe

Copy link
Copy Markdown
Author

Superseded by #14883 — same commit, unchanged content.

Context: the issue-link reminder bot auto-closed this PR on 2026-09-25 because it had no linked issue, and GitHub refuses to reopen it (REST PATCH /pulls/14765 returns 422 Validation Failed; GraphQL reopenPullRequest returns Could not open the pull request.) even though the fork and the head branch still exist and point at this PR's head commit. The replacement PR links the tracked issue, so the reminder no longer applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pipelines size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)

1 participant