Skip to content

vllm.model_executor.models.k2_horizon

Inference-only K2Horizon model compatible with HuggingFace weights.

Functions:

_rope_weight_perm(head_dim, rope_head_dim)

Per-head gather index that folds K2Horizon's partial-RoPE channel reordering.

The K2Horizon checkpoint stores each head's channels in a GPT-J-interleaved convention with rope/nope channels interleaved. Applying this fixed (position-independent) permutation to the q/k weight rows lets the runtime use vLLM's native NeoX partial-RoPE path (head_size = head_dim, rotary_dim = rope_head_dim) with no per-forward permutes/all-gather.

is_rope_weights_folding_supported(qk_proj)

Whether the partial-RoPE weight-fold path is safe for this attention.

Folding permutes the q/k projection's output channels at load time, which only produces correct numerics when the q/k projection is dense/unquantized.

Otherwise we fall back to the runtime channel-permutation RoPE path instead of folding.