[Qwen4Exp] Host-resident token embedding tables (VLLM_HOST_EMBED_TABLE)
Keeps the token embedding table in pinned host memory behind a UVA view for the stage-0 target and the last-stage MTP drafter, freeing GPU memory for KV. TP sharding, masking and the all-reduce are retained. The knob is registered as a compile-cache factor. Co-Authored-By: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -30,8 +30,10 @@ from vllm.model_executor.layers.mamba.mamba_utils import (
|
||||
)
|
||||
from vllm.model_executor.layers.quantization import QuantizationConfig
|
||||
from vllm.model_executor.layers.vocab_parallel_embedding import (
|
||||
PinnedHostVocabParallelEmbedding,
|
||||
ParallelLMHead,
|
||||
VocabParallelEmbedding,
|
||||
should_use_host_embed_table,
|
||||
)
|
||||
from vllm.model_executor.models.interfaces import (
|
||||
HasInnerState,
|
||||
@@ -487,7 +489,31 @@ class Qwen4ExpModel(nn.Module):
|
||||
if layer_type in _QSA_LAYER_TYPES
|
||||
and getattr(config, "indexer_n_heads", None) is not None
|
||||
)
|
||||
self.embed_tokens = VocabParallelEmbedding(self.vocab_size, config.hidden_size)
|
||||
self.uses_host_embed_table = (
|
||||
get_pp_group().is_first_rank
|
||||
and should_use_host_embed_table()
|
||||
)
|
||||
if self.uses_host_embed_table and getattr(
|
||||
config, "tie_word_embeddings", False
|
||||
):
|
||||
raise ValueError(
|
||||
"VLLM_HOST_EMBED_TABLE=1 is incompatible with "
|
||||
"tie_word_embeddings=True"
|
||||
)
|
||||
# PP ownership: the input embedding runs on
|
||||
# the first stage only (see forward); later stages carried an unused
|
||||
# 248320 x 2560 bf16 table (0.59 GiB per GPU at TP2) beside the MTP
|
||||
# drafter's own copy. PP=1 ownership is unchanged, and the PLE offload
|
||||
# worker retains meta construction.
|
||||
if get_pp_group().is_first_rank:
|
||||
embedding_cls = (
|
||||
PinnedHostVocabParallelEmbedding
|
||||
if self.uses_host_embed_table
|
||||
else VocabParallelEmbedding
|
||||
)
|
||||
self.embed_tokens = embedding_cls(self.vocab_size, config.hidden_size)
|
||||
else:
|
||||
self.embed_tokens = PPMissingLayer()
|
||||
|
||||
def get_layer(prefix: str) -> Qwen4ExpDecoderLayer:
|
||||
layer_idx = extract_layer_index(prefix)
|
||||
|
||||
Reference in New Issue
Block a user