File size: 17,953 Bytes
1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 a5f52d3 1afe052 | 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 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | {
"domain": "com.microsoft",
"name": "VarlenCausalConvWithState",
"sinceVersion": 1,
"inputs": {
"inputT": { "onnx": "input", "dtype": "T", "rank": 2 },
"weightT": { "onnx": "weight", "dtype": "T", "rank": 3 },
"cumulativeSequenceLengthT": { "onnx": "cumulative_sequence_length", "dtype": "M", "rank": 1, "storage": "int32" },
"biasT": { "onnx": "bias", "dtype": "T", "rank": 1, "optional": true },
"initialStateT": { "onnx": "initial_state", "dtype": "T", "rank": 3 },
"captureCountT": { "onnx": "capture_count", "dtype": "M", "rank": 1, "optional": true, "storage": "int32" }
},
"outputs": {
"outputT": { "onnx": "output", "dtype": "T", "rank": "ranks.inputT", "shape": "shapes.inputT" },
"finalStateT": { "onnx": "final_state", "dtype": "T", "rank": 3, "shape": "[batchSize, channels, stateLength]" },
"stateUpdateT": {
"onnx": "state_update",
"dtype": "T",
"rank": 3,
"optional": true,
"shape": "[batchSize, stateUpdateCapacity, channels]"
}
},
"attributes": { "activation": { "default": "none" }, "state_update_capacity": { "default": 0 } },
"attributeConstraints": { "activation": { "values": ["none", "silu", "swish"] } },
"typeConstraints": { "T": ["float32", "float16"], "M": ["int32"] },
"tunables": {
"workgroupSize": { "default": 256 },
"streamWorkgroupSize": { "default": 64 },
"streamChunk": { "default": 16 }
},
"derive": {
"totalTokens": "dim(shapes.inputT, 0)",
"channels": "dim(shapes.inputT, 1)",
"batchSize": "dim(shapes.cumulativeSequenceLengthT, 0) - 1",
"weightRankOk": "ranks.weightT == 3 and dim(shapes.weightT, 1) == 1",
"kernelSize": "dim(shapes.weightT, 2)",
"stateLength": "kernelSize - 1",
"stateUpdateCapacity": "attrs.state_update_capacity",
"capturePairOk": "present.captureCountT == (stateUpdateCapacity > 0)",
"stateShape": "ranks.initialStateT == 3 and dim(shapes.initialStateT, 0) == batchSize and dim(shapes.initialStateT, 1) == channels and dim(shapes.initialStateT, 2) == stateLength",
"finalStateShape": "ranks.finalStateT == 3 and dim(shapes.finalStateT, 0) == batchSize and dim(shapes.finalStateT, 1) == channels and dim(shapes.finalStateT, 2) == stateLength",
"captureShape": "not present.captureCountT or (ranks.captureCountT == 1 and dim(shapes.captureCountT, 0) == batchSize and tensorDtypes.captureCountT == \"int32\")",
"stateUpdateShape": "not present.stateUpdateT or (ranks.stateUpdateT == 3 and dim(shapes.stateUpdateT, 0) == batchSize and dim(shapes.stateUpdateT, 1) == stateUpdateCapacity and dim(shapes.stateUpdateT, 2) == channels and tensorDtypes.stateUpdateT == tensorDtypes.inputT)",
"commonContract": "ranks.inputT == 2 and weightRankOk and ranks.outputT == 2 and ranks.cumulativeSequenceLengthT == 1 and channels >= 1 and kernelSize >= 1 and batchSize >= 1 and totalTokens >= batchSize and stateUpdateCapacity >= 0 and stateUpdateCapacity <= 8 and floor(stateUpdateCapacity) == stateUpdateCapacity and capturePairOk and captureShape and stateUpdateShape and (tensorDtypes.inputT == \"float32\" or tensorDtypes.inputT == \"float16\") and tensorDtypes.weightT == tensorDtypes.inputT and tensorDtypes.outputT == tensorDtypes.inputT and tensorDtypes.initialStateT == tensorDtypes.inputT and tensorDtypes.finalStateT == tensorDtypes.inputT and tensorDtypes.cumulativeSequenceLengthT == \"int32\" and f16Ok(dtypes.T) and dim(shapes.weightT, 0) == channels and dim(shapes.outputT, 0) == totalTokens and dim(shapes.outputT, 1) == channels and stateShape and finalStateShape",
"biasOk": "ranks.biasT == 1 and tensorDtypes.biasT == tensorDtypes.inputT and dim(shapes.biasT, 0) == channels",
"plainContract": "commonContract and not present.biasT and (not present.stateUpdateT or stateUpdateCapacity == 0)",
"biasContract": "commonContract and present.biasT and biasOk and (not present.stateUpdateT or stateUpdateCapacity == 0)",
"stateUpdateContract": "commonContract and not present.biasT and present.stateUpdateT and stateUpdateCapacity > 0",
"biasStateUpdateContract": "commonContract and present.biasT and biasOk and present.stateUpdateT and stateUpdateCapacity > 0"
},
"bindings": {
"input": { "arg": "inputT", "buffer": "read-only-storage", "elementType": "$inputScalar" },
"weight": { "arg": "weightT", "buffer": "read-only-storage", "elementType": "$inputScalar" },
"cumulative_sequence_length": {
"arg": "cumulativeSequenceLengthT",
"buffer": "read-only-storage",
"elementType": "i32"
},
"initial_state": { "arg": "initialStateT", "buffer": "read-only-storage", "elementType": "$inputScalar" },
"output": { "arg": "outputT", "buffer": "storage", "elementType": "$outputScalar" },
"final_state": { "arg": "finalStateT", "buffer": "storage", "elementType": "$outputScalar" },
"params": {
"buffer": "uniform",
"struct": [
{ "name": "batchSize", "type": "u32", "value": "batchSize" },
{ "name": "channels", "type": "u32", "value": "channels" },
{ "name": "totalTokens", "type": "u32", "value": "totalTokens" },
{ "name": "kernelSize", "type": "u32", "value": "kernelSize" }
]
},
"bias": { "arg": "biasT", "buffer": "read-only-storage", "elementType": "$inputScalar" },
"capture_count": { "arg": "captureCountT", "buffer": "read-only-storage", "elementType": "i32" },
"state_update": { "arg": "stateUpdateT", "buffer": "storage", "elementType": "$outputScalar" },
"params_2": {
"name": "params",
"buffer": "uniform",
"struct": [
{ "name": "batchSize", "type": "u32", "value": "batchSize" },
{ "name": "channels", "type": "u32", "value": "channels" },
{ "name": "totalTokens", "type": "u32", "value": "totalTokens" },
{ "name": "stateUpdateCapacity", "type": "u32", "value": "stateUpdateCapacity" }
]
}
},
"variants": [
{
"id": "plain_stream",
"priority": 20,
"when": ["plainContract", "kernelSize >= 2", "kernelSize <= 8", "tunables.streamChunk >= 1", "floor(tunables.streamChunk) == tunables.streamChunk", "tunables.streamWorkgroupSize >= 1", "floor(tunables.streamWorkgroupSize) == tunables.streamWorkgroupSize", "tunables.streamWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.streamWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": false,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.streamWorkgroupSize",
"chunkSize": "min(tunables.streamChunk, ceilDiv(totalTokens, batchSize))"
},
"passes": [
{
"id": "main",
"name": "VarlenCausalConvWithState.Stream",
"shader": "varlen-causal-conv-stream.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "bias_stream",
"priority": 20,
"when": ["biasContract", "kernelSize >= 2", "kernelSize <= 8", "tunables.streamChunk >= 1", "floor(tunables.streamChunk) == tunables.streamChunk", "tunables.streamWorkgroupSize >= 1", "floor(tunables.streamWorkgroupSize) == tunables.streamWorkgroupSize", "tunables.streamWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.streamWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": true,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.streamWorkgroupSize",
"chunkSize": "min(tunables.streamChunk, ceilDiv(totalTokens, batchSize))"
},
"passes": [
{
"id": "main",
"name": "VarlenCausalConvWithState.Stream",
"shader": "varlen-causal-conv-stream.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "bias", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "state_update_stream",
"priority": 20,
"when": ["stateUpdateContract", "kernelSize >= 2", "kernelSize <= 8", "tunables.streamChunk >= 1", "floor(tunables.streamChunk) == tunables.streamChunk", "tunables.streamWorkgroupSize >= 1", "floor(tunables.streamWorkgroupSize) == tunables.streamWorkgroupSize", "tunables.streamWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.streamWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": false,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.streamWorkgroupSize",
"chunkSize": "min(tunables.streamChunk, ceilDiv(totalTokens, batchSize))"
},
"passes": [
{
"id": "state_update",
"name": "VarlenCausalConvWithState.StateUpdate",
"shader": "varlen-state-update.wgsl.jinja",
"bindings": ["input", "cumulative_sequence_length", "capture_count", "state_update", "params_2"],
"dispatch": {
"x": "min(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"z": 1
}
},
{
"id": "main",
"name": "VarlenCausalConvWithState.Stream",
"shader": "varlen-causal-conv-stream.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "bias_state_update_stream",
"priority": 20,
"when": ["biasStateUpdateContract", "kernelSize >= 2", "kernelSize <= 8", "tunables.streamChunk >= 1", "floor(tunables.streamChunk) == tunables.streamChunk", "tunables.streamWorkgroupSize >= 1", "floor(tunables.streamWorkgroupSize) == tunables.streamWorkgroupSize", "tunables.streamWorkgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.streamWorkgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": true,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.streamWorkgroupSize",
"chunkSize": "min(tunables.streamChunk, ceilDiv(totalTokens, batchSize))"
},
"passes": [
{
"id": "state_update",
"name": "VarlenCausalConvWithState.StateUpdate",
"shader": "varlen-state-update.wgsl.jinja",
"bindings": ["input", "cumulative_sequence_length", "capture_count", "state_update", "params_2"],
"dispatch": {
"x": "min(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"z": 1
}
},
{
"id": "main",
"name": "VarlenCausalConvWithState.Stream",
"shader": "varlen-causal-conv-stream.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "bias", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((ceilDiv(totalTokens, chunkSize) * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "plain",
"priority": 0,
"when": ["plainContract", "tunables.workgroupSize >= 1", "floor(tunables.workgroupSize) == tunables.workgroupSize", "tunables.workgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.workgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": false,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.workgroupSize"
},
"passes": [
{
"id": "main",
"name": "VarlenCausalConvWithState",
"shader": "varlen-causal-conv.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "bias",
"priority": 0,
"when": ["biasContract", "tunables.workgroupSize >= 1", "floor(tunables.workgroupSize) == tunables.workgroupSize", "tunables.workgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.workgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": true,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.workgroupSize"
},
"passes": [
{
"id": "main",
"name": "VarlenCausalConvWithState",
"shader": "varlen-causal-conv.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "bias", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "state_update",
"priority": 0,
"when": ["stateUpdateContract", "tunables.workgroupSize >= 1", "floor(tunables.workgroupSize) == tunables.workgroupSize", "tunables.workgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.workgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": false,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.workgroupSize"
},
"passes": [
{
"id": "state_update",
"name": "VarlenCausalConvWithState.StateUpdate",
"shader": "varlen-state-update.wgsl.jinja",
"bindings": ["input", "cumulative_sequence_length", "capture_count", "state_update", "params_2"],
"dispatch": {
"x": "min(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"z": 1
}
},
{
"id": "main",
"name": "VarlenCausalConvWithState",
"shader": "varlen-causal-conv.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
},
{
"id": "bias_state_update",
"priority": 0,
"when": ["biasStateUpdateContract", "tunables.workgroupSize >= 1", "floor(tunables.workgroupSize) == tunables.workgroupSize", "tunables.workgroupSize <= device.limits.maxComputeInvocationsPerWorkgroup", "tunables.workgroupSize <= device.limits.maxComputeWorkgroupSizeX"],
"derive": {
"hasBias": true,
"useSilu": "attrs.activation != \"none\"",
"inputScalar": "dtypes.T",
"outputScalar": "dtypes.T",
"workgroupSize": "tunables.workgroupSize"
},
"passes": [
{
"id": "state_update",
"name": "VarlenCausalConvWithState.StateUpdate",
"shader": "varlen-state-update.wgsl.jinja",
"bindings": ["input", "cumulative_sequence_length", "capture_count", "state_update", "params_2"],
"dispatch": {
"x": "min(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((batchSize * stateUpdateCapacity * channels), (workgroupSize)), 65535)",
"z": 1
}
},
{
"id": "main",
"name": "VarlenCausalConvWithState",
"shader": "varlen-causal-conv.wgsl.jinja",
"bindings": ["input", "weight", "cumulative_sequence_length", "initial_state", "bias", "output", "final_state", "params"],
"dispatch": {
"x": "min(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"y": "ceilDiv(ceilDiv((totalTokens * channels), (workgroupSize)), 65535)",
"z": 1
}
}
]
}
]
}
|