vllm.models.inkling2.nvidia.ops.sconv
¶
Inkling2 short convolution over a paged sliding-window conv-state cache.
The cache ([num_blocks, H, N, D], see InklingConvState in
vllm/models/inkling2/nvidia/sconv.py) stores each stream's conv input at every
absolute position. Per token, one launch writes the current input to its slot
and convolves the W taps ending at its position: taps inside this forward
are read from x, earlier taps from the paged cache, and taps before
position 0 are zero.
Static convolution (fp32 accumulate, oldest tap first)::
y = (sum_k w[c, k] * x[t - (W - 1) + k] + x[t]) * (W + 1) ** -0.5
Dynamic convolution (newest tap first, per-token per-head tap weights)::
y = (sum_l (static_w[l, c] + dyn[t, head(c), l]) * x[t - l] + x[t])
* (2 * W + 1) ** -0.5
y is rounded to the input dtype. The K/V variant then L2-clips K and
RMS-normalizes V per head and writes both to the paged KV cache.
Functions:
-
attention_prologue–Attention input processing in one launch.
-
shift_rel_proj–Return the
(8, d_rel + 1, extent + 512)tableattention_prologue -
short_conv–Insert
x(rounded to the cache dtype) into the conv-state cache and
_conv(x_ptr, stride_x, cache_ptr, cache_col, stride_c_blk, stride_c_n, N, weight_ptr, stride_w0, stride_w1, pos_ptr, seq_idx_ptr, slot_ptr, block_table_ptr, stride_bt, max_blocks, qstart_ptr, scale, toff, coff, t_mask, c_mask, W, dyn_ptr=None, stride_dyn=0, HEAD_DIM=1, SKIP_IDLE_CACHE=False, CACHE_FIRST=False, tile_reads_cache=True)
¶
Store the current inputs to the cache; return y in fp32.
With CACHE_FIRST (static W=4 conv), the taps from earlier steps are
loaded before waiting on the producer of x (PDL).
Source code in vllm/models/inkling2/nvidia/ops/sconv.py
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 294 295 296 297 298 | |
_prologue_qr_tokens(num_tokens)
¶
Tokens per program of the separate q/r launch, or 0 to run q/r in the K/V conv launch.
_tap_sum(x_ptr, stride_x, cache_ptr, cache_col, stride_c_blk, stride_c_n, N, weight_ptr, stride_w0, stride_w1, block_table_ptr, stride_bt, max_blocks, toff, coff, c_mask, tc_mask, pos, req, qstart, valid, cur, W, dyn_ptr, stride_dyn, HEAD_DIM, preloaded=None, READ_CACHE=False)
¶
Weighted sum of the W taps; earlier steps' taps come from
preloaded or, with READ_CACHE, from the cache (else they are zero).
Source code in vllm/models/inkling2/nvidia/ops/sconv.py
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 | |
attention_prologue(q, r, k, v, q_scale, r_scale, tau, rel_proj, k_weight, v_weight, k_dynamic, v_dynamic, cache, positions, block_table, seq_idx, slot_mapping, query_start, key_cache, value_cache, kv_slot_mapping, q_out, rel_out, cu_seqlens_q, seq_lens, *, clip_threshold, rel_threshold, norm_eps, clip_eps=1e-06)
¶
Attention input processing in one launch.
Writes the L2-clipped q * q_scale to q_out and the relative logits
of the clipped r * r_scale to rel_out (with tau, clipped values
are rounded, then scaled by the fp32 per-token tau). rel_proj is
the shift_rel_proj table; the logits come out sheared as tml_fa4 reads
them for a varlen launch over all tokens ((T + 128, HQ, extent +
256)) from the per-request cu_seqlens_q and seq_lens. Runs the
K/V short convolutions, clips K, RMS-normalizes V and inserts both into
the KV cache (tokens with kv_slot_mapping < 0 skip the write).
q (T, HQ, D), r (T, HQ, D_rel) and k/v
(T, H * D) may be row-strided; K and V occupy [0, D) and
[D, 2 * D) of each conv-state head. Conv weights are static
(H * D, W) taps, or with (T, H * W) per-token deltas
k/v_dynamic the (W, H * D) static part.
Source code in vllm/models/inkling2/nvidia/ops/sconv.py
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 | |
shift_rel_proj(rel_proj, is_local)
¶
Return the (8, d_rel + 1, extent + 512) table attention_prologue
reads the (d_rel, extent) relative projection from, so that every
sheared output column block is an aligned slice of one of 8 shifts.
out[s, :d_rel, y] is rel_proj[:, d] for distance d = s + extent
+ 256 - y, or zero out of range; row d_rel is the padding added to
the logits: -inf for negative distances and, if is_local, those past
the extent, else zero.
Source code in vllm/models/inkling2/nvidia/ops/sconv.py
short_conv(x, weight, cache, positions, block_table, seq_idx, slot_mapping, query_start, stream_offset, stream_width, addend=None, residual=None, out=None)
¶
Insert x (rounded to the cache dtype) into the conv-state cache and
return the static convolution with (C, W) taps weight.
With addend, returns (residual + addend) + y accumulated in fp32
(residual may alias out).
Source code in vllm/models/inkling2/nvidia/ops/sconv.py
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 | |