vllm.models.deepseek_v41.nvidia.specialized_decode.embedding.replicated
¶
A decode step's token embedding from a full copy of the table on every rank.
Under tensor parallelism vLLM shards the token embedding table by vocabulary
(VocabParallelEmbedding): each rank looks up the tokens its shard holds,
writes zeros for the others, and an all-reduce sums the ranks' rows. The
DeepSeek-V4.1 backbone then copies the embedding into its hc_mult
hyper-connection streams ([n, H] -> [n, hc, H]) at the first layer. At a
few rows both are fixed costs on the critical path of every step.
ReplicatedEmbedding keeps a full copy of the table on every rank: the
ranks broadcast their shards into it once, when the decode executor is built
(1.32 GB a GPU for DeepSeek-V4.1-Flash), which is before the KV cache is
sized, so the memory profile counts it. A captured decode step then looks its
tokens up in one launch of StreamEmbedding that writes the embedding (for
the target's first layer, whose pre-mix reads it) and its streams, and needs
no collective. A token outside the vocabulary gets zeros, as the sharded
lookup's sum gives it, so the result equals the all-reduced embedding (up to
the sign of a zero, which the sum makes positive).
The copy serves the table as it was when the executor was built. Loading weights again rewrites the shards in place but not the copy, so a deployment that updates weights at runtime must not use the specialized decode.
Classes:
-
ReplicatedEmbedding–A full copy of a vocabulary-parallel embedding table on every TP rank,
-
StreamEmbedding–Rows of a
[vocab, H]BF16 table into an[n, H]embedding and
Functions:
-
embed_streams–Write
table's rows ofids(int32[n]) intoembedding
ReplicatedEmbedding
¶
A full copy of a vocabulary-parallel embedding table on every TP rank, and a decode step's lookup from it.
Methods:
-
__call__–The embedding
[n, H]and its streams[n, hc, H]of the -
accepts–Whether
__call__takesids: a non-empty int32 vector. -
create–The copy of
embed's table, or None whenembedis not the
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
__call__(ids)
¶
The embedding [n, H] and its streams [n, hc, H] of the
tokens ids.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
accepts(ids)
¶
Whether __call__ takes ids: a non-empty int32 vector.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
create(embed, hc_mult)
classmethod
¶
The copy of embed's table, or None when embed is not the
plain sharded BF16 lookup this replaces. The decision reads only the
configuration, which every TP rank shares; building the copy is
collective.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
StreamEmbedding
¶
Rows of a [vocab, H] BF16 table into an [n, H] embedding and
its [n, hc_mult, H] streams, by 16-byte vectors; a token outside
[0, vocab) gets zeros.
Methods:
-
__call__–Every tensor as int32 words; a row's vector
vis the column -
kernel–Thread t of CTA c takes the (row, vector) items c * THREADS + t,
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
__call__(ids_ptr, table_ptr, embedding_ptr, streams_ptr, rows, vocab, num_ctas, stream)
¶
Every tensor as int32 words; a row's vector v is the column
v of four words.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
kernel(ids, table, embedding, streams, rows, vocab, num_ctas)
¶
Thread t of CTA c takes the (row, vector) items c * THREADS + t, then every num_ctas * THREADS after it.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
_kernel(device_index, hidden, hc_mult)
cached
¶
StreamEmbedding compiled for a device.
Source code in vllm/models/deepseek_v41/nvidia/specialized_decode/embedding/replicated.py
_pointer(address, align=VECTOR_BYTES)
¶
A CuTe DSL global-memory pointer to int32 words.
embed_streams(ids, table, embedding, streams)
¶
Write table's rows of ids (int32 [n]) into embedding
([n, H]) and streams ([n, hc, H]), on the current stream;
zeros for an id outside the table.