File size: 13,093 Bytes
b88d0d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
294
{
  "op": "com.microsoft.MatMulNBitsQkv",
  "tunableSpace": { "TILE_N": [4, 8, 16], "LANES": [4, 8, 16] },
  "cases": [
    {
      "name": "qkv-q4-decode-k2048-nq2048-nkv512",
      "preset": "smoke",
      "vars": { "dtype": "float32" },
      "attrs": { "K": 2048, "Nq": 2048, "Nkv": 512, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [1, 2048], "dtype": "float32", "dist": "normal", "seed": 9101, "scale": 1 },
        "normScaleT": { "shape": [2048], "dtype": "float32", "dist": "normal", "seed": 9102, "scale": 1 },
        "qBT": { "shape": [2048, 64, 16], "dtype": "uint8", "dist": "uniform", "seed": 9103, "scale": 255 },
        "qScalesT": { "shape": [2048, 64], "dtype": "float32", "dist": "normal", "seed": 9104, "scale": 0.05 },
        "kBT": { "shape": [512, 64, 16], "dtype": "uint8", "dist": "uniform", "seed": 9105, "scale": 255 },
        "kScalesT": { "shape": [512, 64], "dtype": "float32", "dist": "normal", "seed": 9106, "scale": 0.05 },
        "vBT": { "shape": [512, 64, 16], "dtype": "uint8", "dist": "uniform", "seed": 9107, "scale": 255 },
        "vScalesT": { "shape": [512, 64], "dtype": "float32", "dist": "normal", "seed": 9108, "scale": 0.05 }
      },
      "outputs": {
        "qT": { "shape": [1, 2048], "dtype": "float32" },
        "kT": { "shape": [1, 512], "dtype": "float32" },
        "vT": { "shape": [1, 512], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(2048 + 512 + 512) * 64 * 16 * 4" }] }
    },
    {
      "name": "qkv-q4-llama-decode-k4096-nq4096-nkv4096",
      "preset": "model",
      "provenance": {
        "notes": "Llama class defaults (hidden_size 4096, num_attention_heads 32, no GQA so num_key_value_heads matches) at a decode step. Bytes are GPU storage, not the packed blob: this backend gives a uint8 tensor one byte per u32 element, so a 4-bit code costs 2 bytes of traffic and the projection moves four times its on-disk size. Counting the blob understated the traffic 4x and reported this kernel at a tenth of the bandwidth rail when it runs at about half."
      },
      "vars": { "dtype": "float32", "tokens": 1, "K": 4096, "Nq": 4096, "Nkv": 4096 },
      "attrs": { "K": 4096, "Nq": 4096, "Nkv": 4096, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [1, 4096], "dtype": "float32", "dist": "normal", "seed": 7100, "scale": 0.5 },
        "normScaleT": {
          "shape": [4096],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7101,
          "scale": 0.1,
          "offset": 1
        },
        "qBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7102, "min": 0, "max": 255 },
        "qScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7103,
          "min": 0.005,
          "max": 0.05
        },
        "kBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7104, "min": 0, "max": 255 },
        "kScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7105,
          "min": 0.005,
          "max": 0.05
        },
        "vBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7106, "min": 0, "max": 255 },
        "vScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7107,
          "min": 0.005,
          "max": 0.05
        }
      },
      "outputs": {
        "qT": { "shape": [1, 4096], "dtype": "float32" },
        "kT": { "shape": [1, 4096], "dtype": "float32" },
        "vT": { "shape": [1, 4096], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(args.Nq + 2 * args.Nkv) * args.K * 2" }] }
    },
    {
      "name": "qkv-q4-mistral-decode-k4096-nq4096-nkv1024",
      "preset": "model",
      "provenance": {
        "notes": "Mistral class defaults (hidden_size 4096, 32 query heads, 8 key/value heads, head_dim 128) -- the GQA case, where K and V projections are a quarter of Q. Bytes are GPU storage, not the packed blob: this backend gives a uint8 tensor one byte per u32 element, so a 4-bit code costs 2 bytes of traffic and the projection moves four times its on-disk size. Counting the blob understated the traffic 4x and reported this kernel at a tenth of the bandwidth rail when it runs at about half."
      },
      "vars": { "dtype": "float32", "tokens": 1, "K": 4096, "Nq": 4096, "Nkv": 1024 },
      "attrs": { "K": 4096, "Nq": 4096, "Nkv": 1024, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [1, 4096], "dtype": "float32", "dist": "normal", "seed": 7200, "scale": 0.5 },
        "normScaleT": {
          "shape": [4096],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7201,
          "scale": 0.1,
          "offset": 1
        },
        "qBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7202, "min": 0, "max": 255 },
        "qScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7203,
          "min": 0.005,
          "max": 0.05
        },
        "kBT": { "shape": [1024, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7204, "min": 0, "max": 255 },
        "kScalesT": {
          "shape": [1024, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7205,
          "min": 0.005,
          "max": 0.05
        },
        "vBT": { "shape": [1024, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7206, "min": 0, "max": 255 },
        "vScalesT": {
          "shape": [1024, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7207,
          "min": 0.005,
          "max": 0.05
        }
      },
      "outputs": {
        "qT": { "shape": [1, 4096], "dtype": "float32" },
        "kT": { "shape": [1, 1024], "dtype": "float32" },
        "vT": { "shape": [1, 1024], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(args.Nq + 2 * args.Nkv) * args.K * 2" }] }
    },
    {
      "name": "qkv-q4-gemma3-decode-k2304-nq2048-nkv1024",
      "preset": "model",
      "provenance": {
        "notes": "Gemma3 class defaults (hidden_size 2304, 8 query heads, 4 key/value heads, head_dim 256); the projection is wider than hidden, so K does not equal Nq. Bytes are GPU storage, not the packed blob: this backend gives a uint8 tensor one byte per u32 element, so a 4-bit code costs 2 bytes of traffic and the projection moves four times its on-disk size. Counting the blob understated the traffic 4x and reported this kernel at a tenth of the bandwidth rail when it runs at about half."
      },
      "vars": { "dtype": "float32", "tokens": 1, "K": 2304, "Nq": 2048, "Nkv": 1024 },
      "attrs": { "K": 2304, "Nq": 2048, "Nkv": 1024, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [1, 2304], "dtype": "float32", "dist": "normal", "seed": 7300, "scale": 0.5 },
        "normScaleT": {
          "shape": [2304],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7301,
          "scale": 0.1,
          "offset": 1
        },
        "qBT": { "shape": [2048, 72, 16], "dtype": "uint8", "dist": "uniform", "seed": 7302, "min": 0, "max": 255 },
        "qScalesT": {
          "shape": [2048, 72],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7303,
          "min": 0.005,
          "max": 0.05
        },
        "kBT": { "shape": [1024, 72, 16], "dtype": "uint8", "dist": "uniform", "seed": 7304, "min": 0, "max": 255 },
        "kScalesT": {
          "shape": [1024, 72],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7305,
          "min": 0.005,
          "max": 0.05
        },
        "vBT": { "shape": [1024, 72, 16], "dtype": "uint8", "dist": "uniform", "seed": 7306, "min": 0, "max": 255 },
        "vScalesT": {
          "shape": [1024, 72],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7307,
          "min": 0.005,
          "max": 0.05
        }
      },
      "outputs": {
        "qT": { "shape": [1, 2048], "dtype": "float32" },
        "kT": { "shape": [1, 1024], "dtype": "float32" },
        "vT": { "shape": [1, 1024], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(args.Nq + 2 * args.Nkv) * args.K * 2" }] }
    },
    {
      "name": "qkv-q4-phi3-decode-k3072-nq3072-nkv3072",
      "preset": "model",
      "provenance": {
        "notes": "Phi-3 class defaults (hidden_size 3072, num_attention_heads 32, no GQA). Bytes are GPU storage, not the packed blob: this backend gives a uint8 tensor one byte per u32 element, so a 4-bit code costs 2 bytes of traffic and the projection moves four times its on-disk size. Counting the blob understated the traffic 4x and reported this kernel at a tenth of the bandwidth rail when it runs at about half."
      },
      "vars": { "dtype": "float32", "tokens": 1, "K": 3072, "Nq": 3072, "Nkv": 3072 },
      "attrs": { "K": 3072, "Nq": 3072, "Nkv": 3072, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [1, 3072], "dtype": "float32", "dist": "normal", "seed": 7400, "scale": 0.5 },
        "normScaleT": {
          "shape": [3072],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7401,
          "scale": 0.1,
          "offset": 1
        },
        "qBT": { "shape": [3072, 96, 16], "dtype": "uint8", "dist": "uniform", "seed": 7402, "min": 0, "max": 255 },
        "qScalesT": {
          "shape": [3072, 96],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7403,
          "min": 0.005,
          "max": 0.05
        },
        "kBT": { "shape": [3072, 96, 16], "dtype": "uint8", "dist": "uniform", "seed": 7404, "min": 0, "max": 255 },
        "kScalesT": {
          "shape": [3072, 96],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7405,
          "min": 0.005,
          "max": 0.05
        },
        "vBT": { "shape": [3072, 96, 16], "dtype": "uint8", "dist": "uniform", "seed": 7406, "min": 0, "max": 255 },
        "vScalesT": {
          "shape": [3072, 96],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7407,
          "min": 0.005,
          "max": 0.05
        }
      },
      "outputs": {
        "qT": { "shape": [1, 3072], "dtype": "float32" },
        "kT": { "shape": [1, 3072], "dtype": "float32" },
        "vT": { "shape": [1, 3072], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(args.Nq + 2 * args.Nkv) * args.K * 2" }] }
    },
    {
      "name": "qkv-q4-llama-spec8-k4096-nq4096-nkv4096",
      "preset": "model",
      "provenance": {
        "notes": "Llama class defaults with 8 rows, the shape speculative decoding verifies in one pass. Bytes are GPU storage, not the packed blob: this backend gives a uint8 tensor one byte per u32 element, so a 4-bit code costs 2 bytes of traffic and the projection moves four times its on-disk size. Counting the blob understated the traffic 4x and reported this kernel at a tenth of the bandwidth rail when it runs at about half."
      },
      "vars": { "dtype": "float32", "tokens": 8, "K": 4096, "Nq": 4096, "Nkv": 4096 },
      "attrs": { "K": 4096, "Nq": 4096, "Nkv": 4096, "block_size": 32 },
      "inputs": {
        "aT": { "shape": [8, 4096], "dtype": "float32", "dist": "normal", "seed": 7500, "scale": 0.5 },
        "normScaleT": {
          "shape": [4096],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7501,
          "scale": 0.1,
          "offset": 1
        },
        "qBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7502, "min": 0, "max": 255 },
        "qScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7503,
          "min": 0.005,
          "max": 0.05
        },
        "kBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7504, "min": 0, "max": 255 },
        "kScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7505,
          "min": 0.005,
          "max": 0.05
        },
        "vBT": { "shape": [4096, 128, 16], "dtype": "uint8", "dist": "uniform", "seed": 7506, "min": 0, "max": 255 },
        "vScalesT": {
          "shape": [4096, 128],
          "dtype": "float32",
          "dist": "uniform",
          "seed": 7507,
          "min": 0.005,
          "max": 0.05
        }
      },
      "outputs": {
        "qT": { "shape": [8, 4096], "dtype": "float32" },
        "kT": { "shape": [8, 4096], "dtype": "float32" },
        "vT": { "shape": [8, 4096], "dtype": "float32" }
      },
      "bench": { "metrics": [{ "type": "bandwidth", "value": "(args.Nq + 2 * args.Nkv) * args.K * 2" }] }
    }
  ]
}