vllm.models.kimi_k3.nvidia.low_latency_gemm
¶
Kimi-K3 decode GEMM selection for unquantized BF16 on SM90/SM100/SM103/SM107.
Dispatch is purely by local (N, K) shape and token count M — the module
name plays no role. Each measured shape maps to a :class:ProjectionSpec
holding the winning backend per token count. The static part of the decision is
resolved once per module at install time into a small {M: call} plan, so the
per-forward path is a single dict lookup.
The supported capabilities carry separate measured tables:
:data:KIMI_K3_PROJECTIONS was tuned on B300 (SM103),
:data:KIMI_K3_PROJECTIONS_SM100 on B200 (SM100), and
:data:KIMI_K3_PROJECTIONS_SM90 on H200 (SM90). The per-(shape, M) winners
genuinely differ between the parts, so the tables must not be merged. SM107
(Rubin) reuses the SM103 table: the plan was validated end-to-end on SM107
hardware, but apart from 3584x7168 the per-M crossovers have not been
re-measured there and may deserve their own table once retuned.
Functions:
-
autotune_kda_qkvg–Autotune the supported QKVG GEMM before CUDA graph capture.
-
enable_kimi_k3_low_latency_gemm–Install shape-selected low-latency GEMMs and register CuTe warmups.
-
request_low_latency_warmup–Warm up the measured CuTe configs for a weight that no linear module owns
-
run_kda_projection_overlap–Run the TP8 KDA decode projection branches concurrently.
-
select_kimi_k3_backend–Backend for a local
(N, K)atnum_tokens, or None to fall back. -
try_low_latency_gemm–Run the shape-selected low-latency kernel, or None to fall back.
_KimiK3LowLatencyApply
¶
Mixin: try the precomputed plan, else defer to the base method.
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
_kda_qkvg_flashinfer_backend()
¶
Return the tested FlashInfer backend for the low-M QKVG branch.
FlashInfer's cute-dsl BF16 GEMM supports SM100 and SM103, but rejects
SM90 during backend validation. Other capabilities use torch.mm for
QKVG while retaining the concurrent F_A/beta and F_B branch.
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
_low_latency_table()
¶
Measured dispatch table for the current device, or None if unsupported.
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
autotune_kda_qkvg(model)
¶
Autotune the supported QKVG GEMM before CUDA graph capture.
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
enable_kimi_k3_low_latency_gemm(module, dtype)
¶
Install shape-selected low-latency GEMMs and register CuTe warmups.
Modules are matched purely by type, an exactly-unquantized method, and a
local (N, K) present in the current device's measured table
(:data:KIMI_K3_PROJECTIONS on SM103 and SM107,
:data:KIMI_K3_PROJECTIONS_SM100 on SM100, :data:KIMI_K3_PROJECTIONS_SM90
on SM90).
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 | |
request_low_latency_warmup(weight)
¶
Warm up the measured CuTe configs for a weight that no linear module owns
(enable_kimi_k3_low_latency_gemm only covers modules).
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
run_kda_projection_overlap(hidden_states, packed_weight, f_b_weight, aux_stream, events)
¶
Run the TP8 KDA decode projection branches concurrently.
Parameters:
-
(hidden_states¶Tensor) –Packed BF16 input with shape
[M, 7168]. -
(packed_weight¶Tensor) –Existing Q/K/V/G/F_A/beta/pad weight with shape
[6288, 7168]. -
(f_b_weight¶Tensor) –F_B weight with shape
[1536, 128]. -
(aux_stream¶Stream) –Stream for the F_A/beta then F_B branch.
-
(events¶tuple[Event, Event]) –Start and completion events for the stream fork and join.
Returns:
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
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 | |
select_kimi_k3_backend(num_tokens, n, k, *, has_residual=False)
¶
Backend for a local (N, K) at num_tokens, or None to fall back.
Source code in vllm/models/kimi_k3/nvidia/low_latency_gemm.py
try_low_latency_gemm(x, weight, residual=None)
¶
Run the shape-selected low-latency kernel, or None to fall back.
Resolves the plan from the shape table on each call; production installs a
precomputed plan (see :func:enable_kimi_k3_low_latency_gemm) and does not
use this path.