vllm.models.kimi_k3.nvidia.specialized_decode.runtime.hybrid
¶
The specialized decode of the hybrid decomposition: attention (KDA, DSA) and
its BF16 linears TP-sharded over a TP group of G GPUs (with decode context
parallel G over the same ranks), and the routed experts expert-parallel over all
EP = G x DP GPUs (-tp G -dp N --enable-expert-parallel [-dcp G] with
MegaMoE; e.g. DCP8 x EP32 = -tp 8 -dcp 8 -dp 4).
Stock serves this deployment with sequence parallelism: the residual stream is sharded over the TP ranks, every attention all-gathers its rows and reduce-scatters the o-projection, and the MoE runs on the rank's 1/G row shard with the shared expert replicated.
The hybrid step keeps every row on every TP rank instead (the TP8 decode's layout) for attention, and runs the MLPs exactly as stock does:
AttnRes stock, on the group's rows (as the TP8 wide step)
attention the TP-G specialized input projection and core (KDA, DSA; the
wide-step providers of providers.Attention), the stock
o_proj partial, one all-reduce
MoE the stock SP MoE module on this rank's row shard (stock
sp_shard, zero padding marked as padding for MegaMoE),
all-gathered back to the group rows
dense MLP the stock (replicated) dense MLP on all rows
Precision is the stock layer's at every stage (BF16 GEMMs with FP32 accumulation, BF16 all-reduces); only the attention's summation order differs.
Classes:
-
HybridAttention–One KDA / DSA layer's attention in a hybrid step: the TP-G specialized
-
HybridStep–Builds the hybrid providers on a
SpecializedDecodeand runs its steps. -
NoPrefetch–The hybrid step prefetches nothing (
Attention.run_coreforks).
Functions:
-
run_dense–The dense MLP on all rows: the stock replicated weights give every rank the
-
run_stock_moe–A MoE layer the hybrid step does not specialize: the stock SP sequence on
HybridAttention
¶
Bases: Attention
One KDA / DSA layer's attention in a hybrid step: the TP-G specialized
input projection and core of Attention (its wide-step path), then the
stock o_proj partial and one TP all-reduce.
Methods:
-
run_wide–The all-reduced attention output of the normalized group rows
x.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
run_wide(x, caches, metadata, slot_mapping, q)
¶
The all-reduced attention output of the normalized group rows x.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
HybridStep
¶
Builds the hybrid providers on a SpecializedDecode and runs its steps.
Methods:
-
run–A hybrid step: the stock decoder loop over the group's rows with the
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
run(step, input_ids, inputs_embeds)
¶
A hybrid step: the stock decoder loop over the group's rows with the specialized attention and the stock MLPs (module docstring).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
NoPrefetch
¶
The hybrid step prefetches nothing (Attention.run_core forks).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
run_dense(mlp, x)
¶
The dense MLP on all rows: the stock replicated weights give every rank the whole output (all-reduced only if stock loaded them TP-sharded).
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/runtime/hybrid.py
run_stock_moe(module, x)
¶
A MoE layer the hybrid step does not specialize: the stock SP sequence on this rank's shard, all-gathered back to the group rows.