vllm.models.deepseek_v41.amd.mono_decode
¶
DeepSeek-V4.1 mono decode layer on ROCm CDNA4 and CDNA3 (--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 backbone layer of the
checkpoint runs whole (compress ratio 0, 1 or 2 over fp8_ds_mla records):
the first layer and the Engram layers hand K1 a settled residual, and an index
source runs vLLM's compressor and indexer between the two launches. A layer
outside that (an MXFP8 KV cache, another indexer) keeps vLLM's attention seam
and attention and runs the rest as one launch, the FFN launch, from wo_b's
unreduced output. A step takes the kernels when it is decode only, at most
MAX_ROWS rows (eager or a FULL CUDA graph: the model is not torch.compiled);
a whole layer also needs its SWA rows as the kernels read them (causal windows;
for the DSpark draft's layers, the block's non-causal rows). Anything else runs
the layer as before; the paths share every tensor at the layer boundary, so they
interleave freely.
On CDNA3 (gfx942) the kernels compute the same layer on their own copies of
the weights (mono/weights942.py), at TP 4 and on steps of up to
MAX_ROWS_GFX942 rows. An index source's keys are written by
mono/keylist.py between vLLM's indexer and K2 there, and the DSpark draft
layers also take the FFN launch, built for the draft's routing.
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 decoder layer's mono path (
create: None when the layer is not
MonoDecodeLayer
¶
One decoder layer's mono path (create: None when the layer is not
eligible): the whole layer (__call__) or, with ffn_only, the FFN
launch after vLLM's attention (ffn). Its weights are taken from the
layer at the first call, after loading.
Methods:
-
__call__–The layer's outputs (x, residual, post_mix, res_mix, pre_mix) by the
-
ffn–The layer's outputs by the FFN launch from
part, wo_b's unreduced
Attributes:
-
unfolded_entry(bool) –gfx942: when this whole first layer runs vLLM's path, its entry seam
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
unfolded_entry
property
¶
gfx942: when this whole first layer runs vLLM's path, its entry seam projects the expanded residual with the unfolded hc_attn_fn, as K1 does, and not the embedding with the folded copy (model.py). The folded form has no AITER kernel on gfx942.
__call__(layer, x, positions, residual, post_mix, res_mix, pre_mix, engram_hashes=None, engram_mask=None)
¶
The layer's outputs (x, residual, post_mix, res_mix, pre_mix) by the
mono kernels, or None when this step takes the original path (always for
an ffn_only layer).
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | |
_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_v41/amd/mono_decode.py
_weights_942(layer)
¶
gfx942: the layer's tensors as the gfx942 kernels read them. The
dense MXFP8 linears and the routed experts as the copies made at load
(_copy_942_at_load).
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
ffn(layer, part, residual, post_mix, res_mix, pre_mix)
¶
The layer's outputs by the FFN launch from part, wo_b's unreduced
output, and the attention seam's outputs; None when this step takes the
original path (the caller then reduces part itself).
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_capture_plain_experts(experts)
¶
gfx942: vLLM converts the routed experts to its Triton kernels' format
when the weights are loaded and frees the plain scales. Wrap that step so
the gfx942 copies (weights942.moe_copies) are made from the
plain tensors first.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_copy_942_at_load(layer, ffn_only)
¶
gfx942: the kernels read their own copies of the layer's weights. Make
them when vLLM processes the weights at load, so that they count as model
memory when vLLM sizes the KV cache. Copies made at the first decode step
would count only when that step is also the CUDA graph memory profile, so
with that profile off or with enforce_eager they would not count. A
layer that takes only the FFN launch needs no attention copies.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_copy_linear_at_load(linear)
¶
gfx942: make the dense MXFP8 linear's weights942.linear_copy right
after vLLM has processed its weights at load. By default
(VLLM_MXFP8_EMULATION_DEQUANT_AT_LOAD) vLLM dequantizes them to bf16
there, and the copy re-encodes them as the gfx942 kernels read them.
Weights that stay e4m3 are copied as they are.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_gpu_arch()
¶
The GPU's architecture without its feature flags, for example gfx942.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_keep_copies(layer, copies)
¶
Store a layer's gfx942 copies as layer.mono942. A reload of the
weights (reload_weights, or a weight update in RL) runs
process_weights_after_loading again, and the kernels and captured
CUDA graphs read the first copies by their addresses. So the copies of a
reload are written into the first copies in place.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_mono_runner(device, draft=None)
¶
The process's mono runner (one a TP rank, shared by every layer of the target; the DSpark draft's layers share one of their own, as its routing and SWA rows differ). 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_v41/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_v41/amd/mono_decode.py
_select(layer, positions, normed, qr)
¶
An index source's compressor and top-k selection, from K1's normed input
and bf16 qr: _forward_csa2_full / _forward_csa2_reindex and the
indexer op, serial.
Source code in vllm/models/deepseek_v41/amd/mono_decode.py
_unsupported_moe(layer, vllm_config)
¶
Why the kernels cannot run this deployment's MoE, or None. They read every one of the 384 experts on each rank, TP-sharded, in AITER's A8W4 MXFP4 layout.