vllm_omni.diffusion.layers.rope ¶
RotaryEmbedding ¶
Bases: CustomOp
rotary positional embedding. interleaved: if True, rotate pairs of even and odd dimensions (GPT-J style) instead of 1st half and 2nd half (GPT-NeoX style).
apply_rotary_emb_vllm_flash_attn instance-attribute ¶
apply_rotary_emb_vllm_flash_attn = import_module(
"vllm.vllm_flash_attn.layers.rotary"
).apply_rotary_emb
RotaryEmbeddingS2VGrid ¶
Bases: Module
Grid-based RoPE for S2V motioner/init attention.
Applies complex-valued rotary embeddings using 3D grid sampling (frame, height, width). Used by SimpleSelfAttention, SwinSelfAttention, CausalSelfAttention in motioner blocks.
apply_precomputed staticmethod ¶
Apply precomputed position frequencies to input tensor.
RotaryEmbeddingWan ¶
Bases: RotaryEmbedding
rotary positional embedding for Wan. interleaved: if True, rotate pairs of even and odd dimensions (GPT-J style) instead of 1st half and 2nd half (GPT-NeoX style).
apply_rope_to_qk ¶
apply_rope_to_qk(
rope: RotaryEmbedding,
query: Tensor,
key: Tensor,
image_rotary_emb: tuple[Tensor, Tensor] | None,
) -> tuple[Tensor, Tensor]
Apply rotary positional embeddings to query and key tensors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rope | RotaryEmbedding | RotaryEmbedding instance for applying position embeddings | required |
query | Tensor | Query tensor [B, S, H, D] | required |
key | Tensor | Key tensor [B, S, H, D] | required |
image_rotary_emb | tuple[Tensor, Tensor] | None | Tuple of (cos, sin) tensors or None | required |
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor] | Tuple of (query, key) with RoPE applied if rotary embeddings provided |
apply_rotary_emb_mindiesd ¶
apply_rotary_emb_mindiesd(
x: Tensor,
cos: Tensor,
sin: Tensor,
interleaved: bool = False,
half_head_dim: bool = True,
) -> Tensor
apply_rotary_emb_torch ¶
x: (batch_size, seqlen, nheads, headdim) cos, sin: (seqlen, rotary_dim / 2) or (batch_size, seqlen, rotary_dim / 2)