vllm.model_executor.layers.rotary_embedding.xdrope ¶
XDRotaryEmbedding ¶
Bases: DynamicNTKAlphaRotaryEmbedding
DynamicNTKAlphaRotaryEmbedding extended with MultiModal(XD) Sections.
Based on the original DynamicNTKAlphaRotaryEmbedding implementation.
Source code in vllm/model_executor/layers/rotary_embedding/xdrope.py
__init__ ¶
__init__(
head_size: int,
rotary_dim: int,
max_position_embeddings: int,
base: float,
is_neox_style: bool,
scaling_alpha: float,
dtype: dtype,
xdrope_section: list[int],
) -> None
Source code in vllm/model_executor/layers/rotary_embedding/xdrope.py
forward ¶
forward(
positions: Tensor,
query: Tensor,
key: Tensor | None = None,
offsets: Tensor | None = None,
) -> tuple[Tensor, Tensor | None]
PyTorch-native implementation equivalent to forward().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions | Tensor | [4, num_tokens] (P/W/H/T positions with multimodal inputs) | required |
query | Tensor | [num_tokens, num_heads * head_size] | required |
key | Tensor | None | [num_tokens, num_kv_heads * head_size] | None |