Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions vllm_omni/diffusion/layers/rope.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def apply_rotary_emb_mindiesd(
# (B, S, D/2) -> (S, D/2)
cos = cos[0]
sin = sin[0]

if cos.shape[-1] == x.shape[-1]:
half_head_dim = False
# already expanded to (S, D), just use directly
if interleaved:
# if last dim of sin and cos is D/2, expand to (S, D) to adapt to mindiesd operators
if half_head_dim:
Expand Down Expand Up @@ -97,7 +99,6 @@ def forward_cuda(
# (B, S, D/2) -> (S, D/2)
cos = cos[0]
sin = sin[0]

return apply_rotary_emb(
x,
cos,
Expand Down
12 changes: 10 additions & 2 deletions vllm_omni/diffusion/models/wan2_2/wan2_2_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import math
from collections.abc import Iterable
from importlib.util import find_spec
from typing import Any

import torch
Expand All @@ -29,6 +30,8 @@
SequenceParallelOutput,
)
from vllm_omni.diffusion.forward_context import get_forward_context
from vllm_omni.diffusion.layers.rope import RotaryEmbedding
from vllm_omni.platforms import current_omni_platform

logger = init_logger(__name__)

Expand Down Expand Up @@ -392,6 +395,7 @@ def __init__(
softmax_scale=1.0 / (head_dim**0.5),
causal=False,
)
self.rope = RotaryEmbedding(is_neox_style=False)

def forward(
self,
Expand All @@ -418,8 +422,12 @@ def forward(
# Apply rotary embeddings
if rotary_emb is not None:
freqs_cos, freqs_sin = rotary_emb
query = apply_rotary_emb_wan(query, freqs_cos, freqs_sin)
key = apply_rotary_emb_wan(key, freqs_cos, freqs_sin)
if find_spec("mindiesd") is not None and current_omni_platform.is_npu():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

any better ways to add supports from mindiesd? cc @gcanlin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I prefer not to introduce it here. Will investigate how mindie-sd implement it.

Copy link
Copy Markdown
Collaborator

@gcanlin gcanlin Apr 1, 2026

Choose a reason for hiding this comment

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

This PR #2393 probably has the same effect and provide the general optimization for all platforms.

query = self.rope(query, freqs_cos, freqs_sin)
key = self.rope(key, freqs_cos, freqs_sin)
else:
query = apply_rotary_emb_wan(query, freqs_cos, freqs_sin)
key = apply_rotary_emb_wan(key, freqs_cos, freqs_sin)

# Create attention metadata if mask is provided
attn_metadata = None
Expand Down
Loading