Skip to content

vllm.model_executor.models.lfm3

Inference-only LFM3 model compatible with HuggingFace weights.

Functions:

get_rotary_embedding(config, layer_type)

RoPE of one attention layer type: proportional rotates the first partial_rotary_factor of the head with frequencies spread over the whole head, as the released full-attention layers do.

Source code in vllm/model_executor/models/lfm3.py
def get_rotary_embedding(config: Lfm3Config, layer_type: str) -> RotaryEmbedding:
    """RoPE of one attention layer type: `proportional` rotates the first
    `partial_rotary_factor` of the head with frequencies spread over the whole
    head, as the released full-attention layers do."""
    rope_parameters = config.rope_parameters[layer_type]
    if (
        rope_parameters.get("partial_rotary_factor", 1.0) != 1.0
        and rope_parameters.get("rope_type", "default") != "proportional"
    ):
        # the other types read the factor from elsewhere or scale the frequencies
        raise NotImplementedError(
            "LFM3 partial rotation is only supported with the proportional RoPE type"
        )
    return get_rope(
        config.head_dim,
        max_position=config.max_position_embeddings,
        is_neox_style=True,
        rope_parameters=rope_parameters,
    )