[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:
2026-10-09 19:43:53 +07:00
co-authored by Hinata
parent 66b3d8c108
commit 41f6691c26
4 changed files with 231 additions and 3 deletions
+16 -2
View File
@@ -29,8 +29,10 @@ from vllm.model_executor.layers.layernorm import GemmaRMSNorm
from vllm.model_executor.layers.linear import ColumnParallelLinear
from vllm.model_executor.layers.logits_processor import LogitsProcessor
from vllm.model_executor.layers.vocab_parallel_embedding import (
PinnedHostVocabParallelEmbedding,
ParallelLMHead,
VocabParallelEmbedding,
should_use_host_embed_table,
)
from vllm.model_executor.model_loader.utils import configure_quant_config
from vllm.model_executor.models.interfaces import (
@@ -183,7 +185,20 @@ class Qwen4ExpMultiTokenPredictor(nn.Module):
self.hidden_size = config.hidden_size
self.hc_count = config.hc_count
self.embed_tokens = VocabParallelEmbedding(self.vocab_size, self.hidden_size)
self.uses_host_embed_table = 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"
)
embedding_cls = (
PinnedHostVocabParallelEmbedding
if self.uses_host_embed_table
else VocabParallelEmbedding
)
self.embed_tokens = embedding_cls(self.vocab_size, self.hidden_size)
draft_vllm_config = _make_draft_vllm_config(
vllm_config,
self.mtp_start_layer_idx,
@@ -314,7 +329,6 @@ class Qwen4ExpMultiTokenPredictor(nn.Module):
hidden_states = hidden_states.flatten(-2)
prev_block_output = inputs_embeds
else:
assert intermediate_tensors is not None
hidden_states = intermediate_tensors["hidden_states"]
current_step_idx = spec_step_idx % self.num_mtp_layers