vllm.models.deepseek_v41.nvidia.ops.mhc
¶
Dispatch DSV4.1 mHC operations and overlap coefficient generation.
Functions:
-
ampere_all_reduce_ready–Whether
init_ampere_all_reducehas built the SM80 two-shot kernel -
ampere_mhc_max_tokens–The most rows an mHC boundary takes the SM80 CuTe DSL kernels for:
-
ampere_projection_splits–The split counts of the SM80 prefill projection (
_mhc_pre_split), -
boundary_all_reduce–The TP all-reduce of a partial sum the model reduces itself (a
-
hc_expand–x.unsqueeze(1).expand(-1, hc_mult, -1).contiguous(), reading -
init_ampere_all_reduce–Build the SM80 boundaries' all-reduce. Collective over the TP group,
-
init_mhc_all_reduce–Build the fused all-reduce + mHC kernel the overlap path reduces with.
-
mhc_all_reduce_max_tokens–The most rows the fused all-reduce takes, and so the most a MoE may
-
mhc_all_reduce_ready–Whether
init_mhc_all_reducehas built the fused all-reduce (the -
mhc_boundary_weight–An empty
prepare_boundary_weightbuffer, or None where the CuTe DSL mHC -
mhc_pre_delayed_ampere–mhc_pre_delayed_tilelangon SM80: the CuTe DSL kernels, with the -
mhc_pre_delayed_overlap–Prepare the input on the caller stream and coefficients on another stream.
-
mhc_shifted_post_pre–Dispatch shifted post/pre to overlap, Mega-mHC, or fused TileLang.
-
prepare_ampere_mhc–Allocate the SM80 mHC kernels' persistent buffers on the current
-
supports_ampere_all_reduce–Whether the SM80 mHC boundaries take the TP all-reduce with their own
-
supports_ampere_mhc_overlap–Whether FULL graphs on SM80 and SM90 compute the mHC coefficients on
-
supports_mhc_all_reduce–Whether the mHC boundaries fuse the TP all-reduce (
AllReduceMHC): -
supports_mhc_overlap–Check kernel requirements and safety of sharing the coefficient stream.
-
use_ampere_mhc–Whether any mHC boundary takes the SM80 CuTe DSL kernels.
_ampere_mhc(residual, norm_weight)
¶
Whether a boundary over residual takes the SM80 CuTe DSL kernels.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
_mhc_pre_split(residual, fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, pre_mix, x, norm_weight, norm_eps, capture_aux=False)
¶
mhc_pre_delayed_tilelang with a norm weight on SM80 prefill: the
projection on the split-k tensor-core kernel (mhc_projection.py), then
the stock epilogue. Returns the post-, comb-mix, layer input, next
pre-mix and the stream mean (empty unless capture_aux).
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
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 | |
_split_projection(residual, width, norm_weight)
¶
Whether a boundary over residual projects its width-wide rows
on the SM80 split-k kernel: on SM80, above the rows the SM80 boundary
kernels take.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
ampere_all_reduce_ready()
¶
Whether init_ampere_all_reduce has built the SM80 two-shot kernel
(the target model does; its DSpark draft model reuses it).
ampere_mhc_max_tokens()
cached
¶
The most rows an mHC boundary takes the SM80 CuTe DSL kernels for: all of them on SM80, small decode batches on SM90, none elsewhere.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
ampere_projection_splits()
¶
The split counts of the SM80 prefill projection (_mhc_pre_split),
for the stock epilogue's warmup: none off SM80.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
boundary_all_reduce(x)
¶
The TP all-reduce of a partial sum the model reduces itself (a sublayer output, the embedding's vocabulary shards): the SM80 two-shot Lamport kernel for the rows it takes, else the TP group's.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
hc_expand(x, hc_mult)
¶
x.unsqueeze(1).expand(-1, hc_mult, -1).contiguous(), reading
x once instead of once per copy.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
init_ampere_all_reduce(vllm_config)
¶
Build the SM80 boundaries' all-reduce. Collective over the TP group,
so every rank must call it, and only when supports_ampere_all_reduce
holds.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
init_mhc_all_reduce(vllm_config)
¶
Build the fused all-reduce + mHC kernel the overlap path reduces with.
Collective over the TP group, so every rank must call it, and only when
supports_mhc_all_reduce holds.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
mhc_all_reduce_max_tokens()
¶
The most rows the fused all-reduce takes, and so the most a MoE may
leave its top-k reduction to it for: SM90_MHC_ALL_REDUCE_MAX_TOKENS
on SM90 (its boundaries up to SM90_MHC_MAX_TOKENS rows all-reduce
first), the two-shot kernel's on SM80, MHC_OVERLAP_MAX_TOKENS on
SM100.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
mhc_all_reduce_ready()
¶
Whether init_mhc_all_reduce has built the fused all-reduce (the
target model does; its DSpark draft model reuses it).
mhc_boundary_weight(hidden_size, hc_mult, device)
¶
An empty prepare_boundary_weight buffer, or None where the CuTe DSL mHC
boundary (mhc_boundary.py) cannot run.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
mhc_pre_delayed_ampere(residual, fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, pre_mix=None, x=None, norm_weight=None, norm_eps=1e-06, *, stream=None)
¶
mhc_pre_delayed_tilelang on SM80: the CuTe DSL kernels, with the
coefficients on stream when given (join it before reading them).
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
mhc_pre_delayed_overlap(residual, fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, pre_mix=None, x=None, norm_weight=None, norm_eps=1e-06, *, stream, layer_input=None)
¶
Prepare the input on the caller stream and coefficients on another stream.
Returns post mix, residual mix, normalized input, and next pre-mix. Only the input is ready on the caller stream; join stream before using coefficients. The caller must retain the weights and coefficient outputs until the join.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
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 | |
mhc_shifted_post_pre(x, residual, post_layer_mix, comb_res_mix, fn, hc_scale, hc_base, rms_eps, hc_pre_eps, hc_sinkhorn_eps, hc_post_mult_value, sinkhorn_repeat, pre_mix=None, norm_weight=None, norm_eps=1e-06, capture_aux=False, *, stream=None, reduce_results=False, boundary_weight=None)
¶
Dispatch shifted post/pre to overlap, Mega-mHC, or fused TileLang.
boundary_weight (fn laid out by prepare_boundary_weight, see
mhc_boundary_weight) runs decode-size Mega-mHC batches on the CuTe DSL kernel.
A MoE output left unfinalized is finalized inside the fused all-reduce. When stream is supplied, join it before consuming the returned coefficients.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
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 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
prepare_ampere_mhc(hidden_size)
¶
Allocate the SM80 mHC kernels' persistent buffers on the current device and compile them, before any capture.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
supports_ampere_all_reduce(vllm_config)
¶
Whether the SM80 mHC boundaries take the TP all-reduce with their own
kernel (AmpereAllReduce, a two-shot all-reduce that stores through
peer mappings): on SM80, which has no NVLink multicast, at TP 2, 4 or 8
where vLLM's custom all-reduce runs, so the GPUs are fully connected
with peer access.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
supports_ampere_mhc_overlap(vllm_config)
¶
Whether FULL graphs on SM80 and SM90 compute the mHC coefficients on a side stream: only for a hidden size the SM80 kernels take (otherwise the TileLang kernels run in order), and not with micro-batching, which the single ticket workspace rules out.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
supports_mhc_all_reduce(vllm_config)
¶
Whether the mHC boundaries fuse the TP all-reduce (AllReduceMHC):
at TP4 on SM100, whose overlap path it serves, and at TP8 on SM90, where
the boundaries of the SM80 kernels' path take it; both need NVLink
multicast.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc.py
supports_mhc_overlap(vllm_config)
¶
Check kernel requirements and safety of sharing the coefficient stream.