Repository navigation
[Hardware][Ascend] Optimize Wan VAE spatial padding #8694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
scestola-h
wants to merge
1
commit into
vllm-project:main
Choose a base branch
from
scestola-h:perf/wan-vae-npu-spatial-padding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+212
−44
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project | ||
| """Ascend exactness tests for Wan VAE causal-Conv3D spatial padding.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| import torch | ||
| from diffusers.models.autoencoders import AutoencoderKLWan | ||
| from diffusers.models.autoencoders.autoencoder_kl_wan import WanCausalConv3d | ||
|
|
||
| from tests.helpers.mark import hardware_test | ||
| from vllm_omni.diffusion.distributed.autoencoders.wan_vae_fastpath import forwards as fp | ||
| from vllm_omni.diffusion.distributed.autoencoders.wan_vae_fastpath import install_wan_vae_fastpath | ||
|
|
||
| pytestmark = [pytest.mark.core_model, pytest.mark.diffusion] | ||
|
|
||
| TINY_VAE_CONFIG = dict( | ||
| base_dim=8, | ||
| decoder_base_dim=8, | ||
| z_dim=4, | ||
| dim_mult=[1, 1], | ||
| num_res_blocks=1, | ||
| temperal_downsample=[False, True], | ||
| is_residual=True, | ||
| ) | ||
|
|
||
|
|
||
| @hardware_test(res={"npu": "A3"}, num_cards=1) | ||
| def test_installer_limits_npu_fast_path_to_causal_conv() -> None: | ||
| vae = AutoencoderKLWan(**TINY_VAE_CONFIG).eval().to(device="npu", dtype=torch.float32) | ||
| report = install_wan_vae_fastpath(vae, level="lossless") | ||
|
|
||
| assert report.installed, report.reason | ||
| assert set(report.patched) == {"WanCausalConv3d"} | ||
| assert report.patched["WanCausalConv3d"] > 1 | ||
|
|
||
|
|
||
| @hardware_test(res={"npu": "A3"}, num_cards=1) | ||
| @pytest.mark.parametrize("dtype", [torch.bfloat16, torch.float32]) | ||
| @pytest.mark.parametrize( | ||
| "in_channels,out_channels,frames,height,width,cache_frames", | ||
| [ | ||
| (3, 5, 4, 7, 9, 0), | ||
| (3, 5, 4, 7, 9, 2), | ||
| (16, 32, 1, 48, 80, 0), | ||
| (16, 32, 1, 48, 80, 2), | ||
| (128, 128, 1, 48, 80, 0), | ||
| (128, 128, 1, 48, 80, 2), | ||
| ], | ||
| ) | ||
| @torch.no_grad() | ||
| def test_causal_conv_internal_spatial_padding_is_bitwise_exact( | ||
| dtype: torch.dtype, | ||
| in_channels: int, | ||
| out_channels: int, | ||
| frames: int, | ||
| height: int, | ||
| width: int, | ||
| cache_frames: int, | ||
| ) -> None: | ||
| torch.manual_seed(1101) | ||
| conv = WanCausalConv3d(in_channels, out_channels, kernel_size=3, stride=1, padding=1).to(device="npu", dtype=dtype) | ||
| x = torch.randn(1, in_channels, frames, height, width, device="npu", dtype=dtype) | ||
| cache = ( | ||
| None | ||
| if cache_frames == 0 | ||
| else torch.randn(1, in_channels, cache_frames, height, width, device="npu", dtype=dtype) | ||
| ) | ||
|
|
||
| expected = WanCausalConv3d.forward(conv, x, cache) | ||
| actual = fp.causal_conv_forward(conv, x, cache) | ||
|
|
||
| assert torch.equal(actual, expected) | ||
| verdicts = fp._SPATIAL_PAD_VERDICTS[conv] | ||
| assert len(verdicts) == 1 | ||
| assert next(iter(verdicts.values())) | ||
| assert torch.equal(fp.causal_conv_forward(conv, x, cache), expected) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] CPU diffusion guard for the registry change is not in the reported runs
Evidence and suggested fix
The modified registry test is selected by the ready-pipeline step "Simple · Diffusion Test" in
.buildkite/cuda/test-ready.yml, whose command ispytest -sv tests/diffusion -m 'core_model and cpu'(no--run-level).test_wan_vae_fastpath_install.pyis markedcore_modelandcpu, so that step is the guard for this change. The PR Test Plan and Test Result report the new A3 causal-conv cases and the changed-file pre-commit hooks (Ruff, mypy, markers, SPDX, import and torch.cuda policy, Buildkite schema, typos). They do not report this CPU selector, and they do not say the CPU diffusion suite was left unrun. Please run that command, or state the gap explicitly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The registry coverage is marked
core_model+cpu, so it is selected bypytest -sv tests/diffusion -m 'core_model and cpu'. I attempted that exact selector locally, but the available container has a stale vLLM dependency and collection stops before selection (MultiModalProcessingResultis absent). I have documented that limitation in the PR body rather than claiming a pass; the ready-pipeline Buildkite result is still required before merge.