vllm.models.deepseek_v41.nvidia.ops.mhc_boundary
¶
DeepSeek-V4.1 shifted mHC boundary for decode-size batches (CuTe DSL).
The hidden dimension is split into 16 slices. For every token, a slice's CTA updates its
part of the residual stream, collapses it with the lagged pre-mix, and multiplies the
updated residual with its slice of the mixer weight on BF16 tensor cores. The weight is
rounded to TF32 and split into BF16 high and low parts that sum to it exactly
(prepare_boundary_weight), so every product equals the TF32 product of DeepGEMM's
Mega mHC. A 16-CTA cluster owns a tile of tokens and its CTAs push their partial mixes
and sums of squares to the CTA that owns the token through distributed shared memory.
The weight fragments stream from global memory (L2) straight into the mma operands
instead of being staged in shared memory, so a CTA needs at most ~110 KB of shared
memory and two CTAs share an SM: 14 clusters are co-resident on GB300 and up to
MAX_TOKENS tokens run in one wave of one kernel. Every reduction runs in a fixed
order, so results are deterministic.
Classes:
-
MhcBoundaryKernel–tile(at mostTILE) tokens per 16-CTA cluster; CTArowns hidden `[r
Functions:
-
boundary_tile–Tokens per cluster: the smallest of
TILESthat runstokensin one wave of -
boundary_weight_shape–Shape of
prepare_boundary_weight's int32 fragments forhidden. -
lagged_collapse–BF16 pairs of
li = bf16(sum_j pre[j] * residual_cur[j])for 8 hidden -
ldg_v4_u32–orderedkeeps the load where it is issued (a prefetch), instead of letting -
mbar_wait–Wait for
phase;scope="cluster"acquires data that peers delivered with -
mhc_shifted_post_pre_boundary–mhc_shifted_post_pre_deep_gemmwithweight = prepare_boundary_weight(fn)in -
mma_bf16–mma.sync m16n8k16 BF16 with FP32 accumulation.
-
prepare_boundary_weight–fn [24, 4 * hidden]-> int32 mma A fragments `[16 slices, k16 steps, 3 m16 -
rcp–IEEE reciprocal of a normal input: the fast path of rcp.rn.f32 without its
-
residual_update–BF16 pairs of
bf16(post[s] * x + sum_j comb[j][s] * residual[j])for 8 hidden -
sigmoid–1 / (1 + exp(-v)); the denominator is clamped below 2^126 so the reciprocal -
st_async_v4–Store four words at the same shared-memory offset of CTA
rank, completing on
MhcBoundaryKernel
¶
tile (at most TILE) tokens per 16-CTA cluster; CTA r owns hidden [r
* slice, (r + 1) * slice).
Mixer GEMM per CTA: [48, K slice] x [K slice, tokens] with rows 0-23 the high
and rows 24-47 the low BF16 part of the weight. Warp w < MMA_WARPS takes the k16
steps [w * steps_per_warp, (w + 1) * steps_per_warp); its A fragments stream from
global memory PREFETCH steps ahead.
Methods:
-
coefficients–Pre / post / Sinkhorn comb of token
ttfrom its mixes, in -
col_normalize–Column sums (r0 + r1) + (r2 + r3),
mhc_fused_hc's shuffle order. -
layer_input_words–BF16 pairs of
li * rstd * norm_wfor 8-wide chunkcof tile token -
sinkhorn–A column normalization, then
sinkhorn_iters - 1row and column
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
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 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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | |
coefficients(tot, s_hcw, s_rows, tt, r, t0, valid, pre_out, post_out, comb_out, rms_eps, hc_eps, eps, post_mult)
¶
Pre / post / Sinkhorn comb of token tt from its mixes, in
mhc_fused_hc's order.
Lane r of the token's 16: 0-3 pre, 4-7 post, 8-11 the softmax of comb row
r - 8; lane 12 then runs the Sinkhorn iterations on the four rows.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | |
col_normalize(c, eps)
staticmethod
¶
Column sums (r0 + r1) + (r2 + r3), mhc_fused_hc's shuffle order.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
layer_input_words(s_x, s_rstd, norm_w, hslice, tt, c)
¶
BF16 pairs of li * rstd * norm_w for 8-wide chunk c of tile token
tt.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
sinkhorn(c, eps)
¶
A column normalization, then sinkhorn_iters - 1 row and column
normalizations.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
boundary_tile(tokens)
¶
Tokens per cluster: the smallest of TILES that runs tokens in one wave of
CLUSTERS clusters, so small batches spread over every co-resident cluster.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
boundary_weight_shape(hidden)
¶
Shape of prepare_boundary_weight's int32 fragments for hidden.
lagged_collapse(cur, pre, ssq_rc, ssq_li)
¶
BF16 pairs of li = bf16(sum_j pre[j] * residual_cur[j]) for 8 hidden
elements, with the running sums of squares of residual_cur and li.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
ldg_v4_u32(addr, ordered=False, *, loc=None, ip=None)
¶
ordered keeps the load where it is issued (a prefetch), instead of letting
the compiler sink it to its first use.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
mbar_wait(bar, phase, *, scope='cta', loc=None, ip=None)
¶
Wait for phase; scope="cluster" acquires data that peers delivered with
st.async.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
mhc_shifted_post_pre_boundary(x, residual, pre_mix, post_mix, comb_res_mix, weight, scale, base, hc_norm_eps, hc_pre_eps, hc_post_scale, sinkhorn_eps, num_sinkhorn_iters, norm_weight, norm_eps)
¶
mhc_shifted_post_pre_deep_gemm with weight = prepare_boundary_weight(fn) in
place of fn, or None for more than MAX_TOKENS tokens. Each token tile compiles
on its first call, which vLLM's eager run before each graph capture makes; a
capture that would have to compile returns None too.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
mma_bf16(a, b, c, *, loc=None, ip=None)
¶
mma.sync m16n8k16 BF16 with FP32 accumulation.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
prepare_boundary_weight(fn)
¶
fn [24, 4 * hidden] -> int32 mma A fragments [16 slices, k16 steps, 3 m16
tiles, 32 lanes, 4].
The weight is rounded to TF32 (nearest, ties away, as the TF32 tensor-core path) and
split into BF16 high and low parts whose sum is exact; the 4 words of (m tile, lane)
are the lane's A fragment of that m16 tile of the stacked [high; low] rows, so a
warp loads one m tile of one k16 step as 512 contiguous bytes. k16 step
8 c + kb of a slice is chunk c (hidden [32 c, 32 c + 32)), stream kb
// 2; fragment columns 2q, 2q + 1 and 2q + 8, 2q + 9 hold hidden 8 q + 4
(kb % 2) + {0, 1} and + {2, 3} of the chunk.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
rcp(x, *, loc=None, ip=None)
¶
IEEE reciprocal of a normal input: the fast path of rcp.rn.f32 without its out-of-range branch.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
residual_update(pw, cm, xw, rw)
¶
BF16 pairs of bf16(post[s] * x + sum_j comb[j][s] * residual[j]) for 8 hidden
elements per stream s, mhc_fused_hc's flush-to-zero FMA chain.
Source code in vllm/models/deepseek_v41/nvidia/ops/mhc_boundary.py
sigmoid(v)
¶
1 / (1 + exp(-v)); the denominator is clamped below 2^126 so the reciprocal
is exact.
st_async_v4(addr, w, bar, rank, *, loc=None, ip=None)
¶
Store four words at the same shared-memory offset of CTA rank, completing on
its bar.