vllm.models.kimi_k3.nvidia.specialized_decode.cutedsl.gemm.ws_gemm
¶
Weight-stationary skinny GEMM for the MoE front: y[M, N] = x[M, K] @ W[N, K]^T.
Each CTA owns rt 16-row N tiles; its rt * kq warps split K into kq ranges.
Weights enter registers and cp.async SMEM stages before the PDL wait. The epilogue
publishes the first valid of split rows (router shard) as FP32 words at BF16
column 3584 + 2 * (slot + row) of a multicast [1, capacity, width] mailbox and the
rest (latent down shard) as sanitized BF16 at column base.
tg 0 is the single pass: warps load x from global and the cluster leader sums the
K partials over DSMEM. tg > 0 streams tokens in groups of tg: warp 0 bulk-copies
the CTA's K slice of x once (one mbarrier per group) for all row tiles, and after each
group's MMAs every warp pushes its 8-token x 16-row partial blocks to their owner CTAs
(block % ks) with st.async; owners sum the ks * kq parts in K order and publish one
group behind, so only the last group's blocks follow the MMA loop.
Classes:
-
WsGemm–
Functions:
-
peer_load–FP32 at the same shared-memory offset in cluster CTA
peer. -
positive_zero–BF16 (low, high) with -0.0 halves made +0.0, so it never equals the sentinel.
-
positive_zero32–FP32 bits of
valuewith -0.0 made +0.0, so it never equals the sentinel.
WsGemm
¶
Methods:
-
gather–Each thread sums one column's K parts in order (the leader also its peers');
-
settle–Owned blocks of token group
g: a warp per block waits for every K part, -
stage_x–Warp 0 bulk-copies every token's K slice; one barrier per token group.
-
tiles–8-token tiles in token group
g.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 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 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 | |
gather(args, red, cta, kpart, tid, lane)
¶
Each thread sums one column's K parts in order (the leader also its peers'); each eight-lane group then gathers the sums for its first lane's 16 B store.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
settle(args, red, recv, owned, cta, kpart, warp, lane, g)
¶
Owned blocks of token group g: a warp per block waits for every K part,
sums them in K order, transposes through red and publishes.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
stage_x(x, xs, bars, kpart, lane)
¶
Warp 0 bulk-copies every token's K slice; one barrier per token group.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
peer_load(pointer, peer)
¶
FP32 at the same shared-memory offset in cluster CTA peer.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
positive_zero(low, high)
¶
BF16 (low, high) with -0.0 halves made +0.0, so it never equals the sentinel.
Source code in vllm/models/kimi_k3/nvidia/specialized_decode/cutedsl/gemm/ws_gemm.py
positive_zero32(value)
¶
FP32 bits of value with -0.0 made +0.0, so it never equals the sentinel.