Skip to content

vllm.model_executor.layers.hierarchical_lm_head

Centroid-based vocabulary selection with compiled sparse scoring.

Classes:

  • HierarchicalLMHead –

    Route to balanced vocabulary clusters and score selected token rows.

Functions:

  • selected_logits –

    Keep the gather inside compilation so Inductor can fuse the reduction.

HierarchicalLMHead

Bases: Module

Route to balanced vocabulary clusters and score selected token rows.

Methods:

  • forward –

    Return full-vocabulary logits with unselected tokens masked.

  • from_config –

    Build the head when its draft checkpoint enables ordered embeddings.

  • get_top_tokens –

    Return vocabulary argmax IDs without allocating full logits.

  • load_weights –

    Load router tensors through the model's standard checkpoint loader.

forward(hidden_states, lm_head_weight)

Return full-vocabulary logits with unselected tokens masked.

from_config(config, *, hidden_size, vocab_size) classmethod

Build the head when its draft checkpoint enables ordered embeddings.

get_top_tokens(hidden_states, lm_head_weight)

Return vocabulary argmax IDs without allocating full logits.

load_weights(weights)

Load router tensors through the model's standard checkpoint loader.

selected_logits(lm_head_weights, sel, hidden)

Keep the gather inside compilation so Inductor can fuse the reduction.