vllm.models.deepseek_v4.amd.mono_decode
¶
DeepSeek-V4-Pro mono decode layer on ROCm CDNA4 (--monokernel).
A decode step's backbone layer -- the attention seam, the attention, its TP
all-reduce, the FFN seam, the MoE and its all-reduce -- runs as two persistent
FlyDSL launches (mono, this directory) on the layer's loaded weights, the
TP reductions inside the kernels. Every layer takes the whole layer: between
its two launches vLLM's compressor runs on K1's normed input (and on a CSA
layer its indexer, from K1's qr, selects the top-k), then K2 builds the key
table -- the CSA layer's top-k through the block table, the HCA layer's every
compressed row (its metadata's slots). The first three layers route by hash:
their tokens' experts are gathered here and handed to the MoE.
A step takes the kernels when it is decode only, at most MAX_TOKENS rows
(eager or a FULL CUDA graph: the model is not torch.compiled), with causal SWA
windows. Anything else runs the layer as before; the paths share every tensor
at the layer boundary, so they interleave freely. Every TP rank must take the
same path at every layer (the kernels wait on each other's pushes): the
conditions read only metadata every rank holds alike.
Classes:
-
MonoDecodeLayer–One DeepSeek-V4-Pro decoder layer's mono path (
create: None when the
MonoDecodeLayer
¶
One DeepSeek-V4-Pro decoder layer's mono path (create: None when the
layer is not eligible). Its weights are taken from the layer at the first
call, after loading and vLLM's preshuffle.
Methods:
-
__call__–The layer's outputs (x, residual, post_mix, res_mix) by the mono
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
__call__(layer, x, positions, input_ids, post_mix, res_mix, residual)
¶
The layer's outputs (x, residual, post_mix, res_mix) by the mono kernels, or None when this step takes the original path.
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_decode_step(layer, rows)
staticmethod
¶
(why this step takes the original path -- None for a decode-only step the kernels take -- the layer's SWA metadata, its compressed cache's).
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_deployment_error(layer, vllm_config)
¶
Why this deployment cannot run the kernels at all, or None (an explicit opt-in that cannot run is an error). They read every routed expert on each rank, TP-sharded, in AITER's A8W4 MXFP4 layout, and vLLM's preshuffled FP8 linears with padded rows.
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_hca_width(vllm_config)
¶
The HCA layers' key table width: vLLM's c128a table's, every compressed
row of the longest context (sparse_mla).
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_mono_runner(device, max_topk)
¶
The process's mono runner (one a TP rank, shared by every layer;
max_topk: its widest key table). Its peer-memory handshake is collective
over the TP group: every rank builds it at the same layer of the same
step.
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_mx_scales(scale)
¶
The checkpoint's 128 x 128 E8M0 weight scales as the kernels' 32 x 32 ones: each code repeated over its block (exact: E8M0 is a power of two).
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_record_view(kv, block)
¶
A layer's fp8_ds_mla cache as [blocks, block, RECORD] bytes (a block's data rows, then its scale words: the kernels index both from it).
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_scale_bytes(scale)
¶
E8M0 scales as their bytes: a float8_e8m0fnu / uint8 tensor's own, or the exponents of a power-of-two fp32 one (vLLM's aiter linears upcast them).
Source code in vllm/models/deepseek_v4/amd/mono_decode.py
_select(layer, positions, normed, qr)
¶
The layer's compressor -- and a CSA layer's indexer, its top-k into the shared top-k buffer -- from K1's normed input and bf16 qr, serial.