vllm.models.kimi_k3.nvidia.specialized_decode.runtime.logits_gather
¶
The target logits gather of the TP specialized decode on a Lamport mailbox.
LogitsProcessor gathers the vocab-parallel lm_head's [M, V / TP] shards with
tensor_model_parallel_all_gather: NCCL's ring all-gather into [TP, M, V / TP],
then a copy to [M, V]. The target's compute_logits runs eagerly once per decode
step with a few rows (1 + draft tokens per request), so that gather is latency-bound.
For the HEAD_GATHER rows it runs as the DSpark drafter's logits gather does
(drafter.comm.Gather, the same kernel and mailbox class): one kernel multicasts
the rank's shard into row m of every rank's [cap, V] mailbox at columns
rank * V / TP (the layout of NCCL's all-gather), polls the peers' fragments and
copies the row to the [M, V] output, re-arming the mailbox. The bytes are moved
unchanged, but for the BF16 pair (+0, -0) (the sentinel word), which arrives as
(+0, +0): the same values to the sampler (comparisons, sums, exp).
Classes:
-
HeadGather–The vocab-parallel lm_head's gather [M, V / TP] -> [M, V] (BF16) for
rows
Functions:
-
install_logits_gather–Route
model's logits gather (logits_processor._gather_logits, an
HeadGather
¶
The vocab-parallel lm_head's gather [M, V / TP] -> [M, V] (BF16) for rows
on two parities of a Lamport mailbox ([2, max rows, V] BF16, drafter.comm):
rank r's shard lands at columns r * V / TP, the layout of NCCL's all-gather. Bytes
move unchanged but for the sentinel pair (+0, -0), sent as (+0, +0).
The parity alternates per call (every rank calls in the same order): two uses of
one parity are separated by a use of the other, and a rank pushes into that one
only after its previous gather kernel finished reading and re-arming. This
assumes every call on a rank runs on one stream, in call order (the target's
compute_logits on the model runner's stream): calls issued from another
stream could overlap a gather of the other parity. Calls under a graph capture,
and other shapes, take stock.
Construction allocates the mailbox (a collective over group) and arms it;
the caller orders every rank's construction before the first call
(_install_gather's all-reduce).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/logits_gather.py
_install_gather(lp, group, device, tp, rank, shard, rows)
¶
lp's _gather_logits on a HeadGather for rows (NCCL's otherwise);
the rows it serves.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/logits_gather.py
install_logits_gather(model, group, tp, rank, device, dcp=1)
¶
Route model's logits gather (logits_processor._gather_logits, an
instance attribute: other LogitsProcessors keep theirs) through a HeadGather for
the HEAD_GATHER rows of this (TP, DCP) pair. Collective over group (the TP
device group) when a table entry applies: every TP rank runs it at load, before
any capture, in the same order. Returns the rows served (empty: the stock
gather); a processor that already has one keeps it.