Skip to content

vllm.model_executor.layers.rotary_embedding.base

Rotary Positional Embeddings Base Class.

Classes:

RotaryEmbedding

Bases: RotaryEmbeddingBase

Methods:

forward_native(positions, query, key=None)

A PyTorch-native implementation of forward().

forward_static(positions, query, key, head_size, rotary_dim, cos_sin_cache, is_neox_style) staticmethod

A PyTorch-native implementation of forward().

Also the reference for fusion matchers and kernel tests.

RotaryEmbeddingBase

Bases: CustomOp

Original rotary positional embedding.

Attributes:

  • rope_is_inplace (bool) –

    Whether the custom-op forward rotates query/key in place, also under

rope_is_inplace = True class-attribute instance-attribute

Whether the custom-op forward rotates query/key in place, also under torch.compile (forward_native is out-of-place for every subclass).

_compute_cos_sin_cache()

Compute the cos and sin cache.

_compute_inv_freq(base)

Compute the inverse frequency.