sync 6fdf6301e2bb
Browse filesFiles changed (6)
54 unmodified lines555657585960616263646566676854 unmodified lines- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, provenance)- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](build/webgpu/test.json) — correctness cases- [`bench.json`](build/webgpu/bench.json) — benchmark + tuning cases- [`gather-block-quantized-q4-pair.wgsl.jinja`](build/webgpu/gather-block-quantized-q4-pair.wgsl.jinja)- [`gather-block-quantized-q8-vec4.wgsl.jinja`](build/webgpu/gather-block-quantized-q8-vec4.wgsl.jinja)## Use with `@huggingface/kernels````shnpm install --save-exact @huggingface/kernels@0.0.1-preview.2```Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.54 unmodified lines555657585960616263646566676854 unmodified lines- [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, provenance)- [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](build/webgpu/test.json) — correctness cases- [`bench.json`](build/webgpu/bench.json) — benchmark cases- [`gather-block-quantized-q4-pair.wgsl.jinja`](build/webgpu/gather-block-quantized-q4-pair.wgsl.jinja)- [`gather-block-quantized-q8-vec4.wgsl.jinja`](build/webgpu/gather-block-quantized-q8-vec4.wgsl.jinja)## Use with `@huggingface/kernels````shnpm install --save-exact @huggingface/kernels@0.0.1-preview.3```Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
173 unmodified lines17417517617717817918052 unmodified lines233234235236237238239173 unmodified lines}},{"name": "gather-block-q8-alignment-healthy-cols1024-vec4","preset": "smoke","vars": { "rows": 4096, "cols": 1024, "indexCount": 1024, "bits": 8, "blockSize": 32 },"attrs": { "bits": 8, "block_size": 32 },52 unmodified lines}},{"name": "gather-block-q8-dispatch-healthy-idx1024-cols4096-1d","preset": "stress","provenance": {"notes": "Widened uint8 GPU storage gives this capacity stress case a declared footprint of 280 MiB."173 unmodified lines17417517617717817918052 unmodified lines233234235236237238239173 unmodified lines}},{"name": "gather-block-q8-alignment-control-cols1024-vec4","preset": "smoke","vars": { "rows": 4096, "cols": 1024, "indexCount": 1024, "bits": 8, "blockSize": 32 },"attrs": { "bits": 8, "block_size": 32 },52 unmodified lines}},{"name": "gather-block-q8-dispatch-control-idx1024-cols4096-1d","preset": "stress","provenance": {"notes": "Widened uint8 GPU storage gives this capacity stress case a declared footprint of 280 MiB."
123456789101112{{ env.wgsl.resourceDeclarations }}const WG: u32 = {{ workgroupSize }}u;@compute @workgroup_size(WG, 1, 1)fn main(@builtin(global_invocation_id) gid: vec3<u32>) {// 2D-folded flat index: gid.y carries the high bits past the per-axis dispatch fold width.// Reduces to gid.x when the dispatch does not fold.let pair_index = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * WG;let total = params.indexCount * params.packedCols;if (pair_index >= total) {return;123456789101112131415{% macro flat_index_2d(workgroupSize, name="i", bound="params.count", guardInline=false) %}{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}// 2D-folded flat index: gid.y carries the high bits past the dispatch's// per-axis workgroup fold width.let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};{% endmacro %}{{ env.wgsl.resourceDeclarations }}const WG: u32 = {{ workgroupSize }}u;@compute @workgroup_size(WG, 1, 1)fn main(@builtin(global_invocation_id) gid: vec3<u32>) {{{ flat_index_2d("WG", "pair_index", "") }}let total = params.indexCount * params.packedCols;if (pair_index >= total) {return;
123456789101112{{ env.wgsl.resourceDeclarations }}const WG: u32 = {{ workgroupSize }}u;@compute @workgroup_size(WG, 1, 1)fn main(@builtin(global_invocation_id) gid: vec3<u32>) {// 2D-folded flat index: gid.y carries the high bits past the per-axis dispatch fold width.// Reduces to gid.x when the dispatch does not fold.let vec_index = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * WG;{% if scalarTail %}let row_vecs = (params.cols + 3u) / 4u;{% else %}123456789101112131415{% macro flat_index_2d(workgroupSize, name="i", bound="params.count", guardInline=false) %}{% set wgTerm = workgroupSize ~ "u" if workgroupSize is number else workgroupSize %}// 2D-folded flat index: gid.y carries the high bits past the dispatch's// per-axis workgroup fold width.let {{ name }} = gid.x + gid.y * {{ DISPATCH_FOLD_WIDTH }}u * {{ wgTerm }};{% endmacro %}{{ env.wgsl.resourceDeclarations }}const WG: u32 = {{ workgroupSize }}u;@compute @workgroup_size(WG, 1, 1)fn main(@builtin(global_invocation_id) gid: vec3<u32>) {{{ flat_index_2d("WG", "vec_index", "") }}{% if scalarTail %}let row_vecs = (params.cols + 3u) / 4u;{% else %}
42 unmodified lines43444546474849505152535455565758592 unmodified lines6263646566676869702 unmodified lines737475767778798081823 unmodified lines8687888990919293949 unmodified lines1041051061071081091101111121131141151161178 unmodified lines1261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701713 unmodified lines1751761771781791801811821831841851861871881891901911921931941951961971981992003 unmodified lines2042052062072082092102112122132142152162172182192202212226 unmodified lines22923023123223323423523623723823924024124224324424524624724842 unmodified lines"zeroPointsValid": "present.zeroPointsT and ranks.zeroPointsT == 2 and tensorDtypes.zeroPointsT == \"uint8\" and dim(shapes.zeroPointsT, 0) == dim(shapes.dataT, 0) and dim(shapes.zeroPointsT, 1) == zeroPointCols","noZeroMode": "not present.zeroPointsT","zeroMode": "zeroPointsValid","workgroupFits": "workgroupSize > 0","foldedDispatchFits": "ceil(ceil(numel(shapes.outputT) / min(device.limits.maxComputeWorkgroupsPerDimension, 65535)) / workgroupSize) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)"},"when": ["foldedDispatchFits", "workgroupFits"],"bindings": {"data": { "arg": "dataT", "buffer": "read-only-storage", "elementType": "$dataElement" },"indices": { "arg": "indicesT", "buffer": "read-only-storage", "elementType": "$indexScalar" },"scales": { "arg": "scalesT", "buffer": "read-only-storage", "elementType": "$scaleScalar" },"output": { "arg": "outputT", "buffer": "storage", "elementType": "$outputElement" },"params": {"buffer": "uniform","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "cols", "type": "u32", "value": "dim(shapes.outputT, 1)" },2 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"params_2": {"name": "params","buffer": "uniform","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "packedCols", "type": "u32", "value": "dim(shapes.dataT, 1)" },2 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"zero_points": { "arg": "zeroPointsT", "buffer": "read-only-storage", "elementType": "$zeroPointElement" },"params_3": {"name": "params","buffer": "uniform","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "packedCols", "type": "u32", "value": "dim(shapes.dataT, 1)" },3 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"params_4": {"name": "params","buffer": "uniform","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "cols", "type": "u32", "value": "dim(shapes.outputT, 1)" },9 unmodified lines"id": "q8_no_zero_vec4","priority": 10,"when": ["q8ShapeValid", "noZeroMode", "bits == 8", "blockSize % 4 == 0", "dim(shapes.outputT, 1) % 4 == 0"],"derive": {"hasZero": false,"scalarTail": false,"dataElement": "\"vec4<u32>\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"vec4<f32>\""},"passes": [{"id": "main",8 unmodified lines]},{"id": "q4_no_zero_pair","priority": 10,"when": ["q4ShapeValid", "noZeroMode", "bits == 4"],"derive": {"hasZero": false,"dataElement": "\"u32\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"vec2<f32>\""},"passes": [{"id": "main","shader": "gather-block-quantized-q4-pair.wgsl.jinja","bindings": ["data", "indices", "scales", "output", "params_2"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","z": 1}}]},{"id": "q4_zero_pair","priority": 10,"when": ["q4ShapeValid", "zeroMode", "bits == 4"],"derive": {"hasZero": true,"dataElement": "\"u32\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"vec2<f32>\"","zeroPointElement": "\"u32\""},"passes": [{"id": "main","shader": "gather-block-quantized-q4-pair.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params_3"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)",3 unmodified lines]},{"id": "q8_zero_vec4","priority": 10,"when": ["q8ShapeValid", "zeroMode", "bits == 8", "blockSize % 4 == 0", "dim(shapes.outputT, 1) % 4 == 0"],"derive": {"hasZero": true,"scalarTail": false,"dataElement": "\"vec4<u32>\"","zeroPointElement": "\"u32\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"vec4<f32>\""},"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * (dim(shapes.outputT, 1) / 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * (dim(shapes.outputT, 1) / 4)), (workgroupSize)), 65535)","z": 1}}3 unmodified lines"id": "q8_no_zero_tail4","priority": 5,"when": ["q8ShapeValid", "noZeroMode", "bits == 8"],"derive": {"hasZero": false,"scalarTail": true,"dataElement": "\"u32\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"f32\""},"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "output", "params_4"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)",6 unmodified lines"id": "q8_zero_tail4","priority": 5,"when": ["q8ShapeValid", "zeroMode", "bits == 8"],"derive": {"hasZero": true,"scalarTail": true,"dataElement": "\"u32\"","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","outputElement": "\"f32\"","zeroPointElement": "\"u32\""},"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params_4"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)",42 unmodified lines43444546474849505152535455565758596061622 unmodified lines65666768697071722 unmodified lines7576777879808182833 unmodified lines87888990919293949 unmodified lines1041051061071081091108 unmodified lines1191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501513 unmodified lines1551561571581591601611621631641651661671681691701711723 unmodified lines1761771781791801811821831841851861876 unmodified lines19419519619719819920020120220320420542 unmodified lines"zeroPointsValid": "present.zeroPointsT and ranks.zeroPointsT == 2 and tensorDtypes.zeroPointsT == \"uint8\" and dim(shapes.zeroPointsT, 0) == dim(shapes.dataT, 0) and dim(shapes.zeroPointsT, 1) == zeroPointCols","noZeroMode": "not present.zeroPointsT","zeroMode": "zeroPointsValid","hasZero": "zeroMode","indexScalar": "\"u32\"","scaleScalar": "\"f32\"","zeroPointElement": "\"u32\"","workgroupFits": "workgroupSize > 0","foldedDispatchFits": "ceil(ceil(numel(shapes.outputT) / min(device.limits.maxComputeWorkgroupsPerDimension, 65535)) / workgroupSize) <= min(device.limits.maxComputeWorkgroupsPerDimension, 65535)"},"when": ["foldedDispatchFits", "workgroupFits"],"bindings": {"data": { "arg": "dataT", "elementType": "$dataElement" },"indices": { "arg": "indicesT", "elementType": "$indexScalar" },"scales": { "arg": "scalesT", "elementType": "$scaleScalar" },"output": { "arg": "outputT", "elementType": "$outputElement" },"params": {"struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "cols", "type": "u32", "value": "dim(shapes.outputT, 1)" },2 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"params_main": {"name": "params","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "packedCols", "type": "u32", "value": "dim(shapes.dataT, 1)" },2 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"zero_points": { "arg": "zeroPointsT", "elementType": "$zeroPointElement" },"params__uniform": {"name": "params","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "packedCols", "type": "u32", "value": "dim(shapes.dataT, 1)" },3 unmodified lines{ "name": "rows", "type": "u32", "value": "dim(shapes.dataT, 0)" }]},"params_q8_zero_tail4": {"name": "params","struct": [{ "name": "indexCount", "type": "u32", "value": "dim(shapes.indicesT, 0)" },{ "name": "cols", "type": "u32", "value": "dim(shapes.outputT, 1)" },9 unmodified lines"id": "q8_no_zero_vec4","priority": 10,"when": ["q8ShapeValid", "noZeroMode", "bits == 8", "blockSize % 4 == 0", "dim(shapes.outputT, 1) % 4 == 0"],"derive": { "scalarTail": false, "dataElement": "\"vec4<u32>\"", "outputElement": "\"vec4<f32>\"" },"passes": [{"id": "main",8 unmodified lines]},{"id": "q8_zero_vec4","priority": 10,"when": ["q8ShapeValid", "zeroMode", "bits == 8", "blockSize % 4 == 0", "dim(shapes.outputT, 1) % 4 == 0"],"derive": { "scalarTail": false, "dataElement": "\"vec4<u32>\"", "outputElement": "\"vec4<f32>\"" },"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * (dim(shapes.outputT, 1) / 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * (dim(shapes.outputT, 1) / 4)), (workgroupSize)), 65535)","z": 1}}]},{"id": "q4_no_zero_pair","priority": 10,"when": ["q4ShapeValid", "noZeroMode", "bits == 4"],"derive": { "dataElement": "\"u32\"", "outputElement": "\"vec2<f32>\"" },"passes": [{"id": "main","shader": "gather-block-quantized-q4-pair.wgsl.jinja","bindings": ["data", "indices", "scales", "output", "params_main"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)",3 unmodified lines]},{"id": "q4_zero_pair","priority": 10,"when": ["q4ShapeValid", "zeroMode", "bits == 4"],"derive": { "dataElement": "\"u32\"", "outputElement": "\"vec2<f32>\"" },"passes": [{"id": "main","shader": "gather-block-quantized-q4-pair.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params__uniform"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * dim(shapes.dataT, 1)), (workgroupSize)), 65535)","z": 1}}3 unmodified lines"id": "q8_no_zero_tail4","priority": 5,"when": ["q8ShapeValid", "noZeroMode", "bits == 8"],"derive": { "scalarTail": true, "dataElement": "\"u32\"", "outputElement": "\"f32\"" },"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "output", "params_q8_zero_tail4"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)",6 unmodified lines"id": "q8_zero_tail4","priority": 5,"when": ["q8ShapeValid", "zeroMode", "bits == 8"],"derive": { "scalarTail": true, "dataElement": "\"u32\"", "outputElement": "\"f32\"" },"passes": [{"id": "main","shader": "gather-block-quantized-q8-vec4.wgsl.jinja","bindings": ["data", "indices", "scales", "zero_points", "output", "params_q8_zero_tail4"],"dispatch": {"x": "min(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)","y": "ceilDiv(ceilDiv((dim(shapes.indicesT, 0) * ceilDiv(dim(shapes.outputT, 1), 4)), (workgroupSize)), 65535)",
123456789101112131415161718192021222324252627{"name": "com.microsoft.GatherBlockQuantized","id": "_com_microsoft_gatherblockquantized_webgpu_dceac49","version": 1,"license": "Apache-2.0","backend": { "type": "webgpu" },"digest": {"algorithm": "sha256","files": {"bench.json": "iQN5nfNOefh08J/5z4Vc63omCfclP0JZggomZracQjI=","gather-block-quantized-q4-pair.wgsl.jinja": "9LBelD9NWvia8DuYSL/FCXreyJ6mLtpiiddFdbronSM=","gather-block-quantized-q8-vec4.wgsl.jinja": "3RQDkgbVbh8TiZZzROkXVWxlFTYBgz4IqY27DOvuVyY=","manifest.json": "3+GjaCq6H0K41bzVOxcw9rg9vf0MVERgqWjUqBgopq4=","test.json": "+2tkFsiI9bP4xaQI+hw2wX3CbMkCEqUzgTHYrTAL6bg="}},"provenance": { "kernel": { "sha": "91d990483a174128daf7673f3f37a7c890493ae1", "dirty": false } },"webgpu": {"manifestSpec": "2.0","variants": {"q8_no_zero_vec4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q4_no_zero_pair": ["gather-block-quantized-q4-pair.wgsl.jinja"],"q4_zero_pair": ["gather-block-quantized-q4-pair.wgsl.jinja"],"q8_zero_vec4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q8_no_zero_tail4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q8_zero_tail4": ["gather-block-quantized-q8-vec4.wgsl.jinja"]}123456789101112131415161718192021222324252627{"name": "com.microsoft.GatherBlockQuantized","id": "_com_microsoft_gatherblockquantized_webgpu_7698e56","version": 1,"license": "Apache-2.0","backend": { "type": "webgpu" },"digest": {"algorithm": "sha256","files": {"bench.json": "jKDPiApwDuwewTrNn1DOYD7gMVHY+vME4qUAe2kUbsw=","gather-block-quantized-q4-pair.wgsl.jinja": "szEkOKfzt9XFHiIsEiQY0g5efbe36fXYBCE3v4SVo6s=","gather-block-quantized-q8-vec4.wgsl.jinja": "akD5Z/+o9Q/HRnbH8yPrD8Y6Pd0SWPgiDRwgHEqt/YQ=","manifest.json": "1/OD0zneUAu2ddg/neSEu+dpmmWqZiMNA9AVO6AI1W8=","test.json": "+2tkFsiI9bP4xaQI+hw2wX3CbMkCEqUzgTHYrTAL6bg="}},"provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },"webgpu": {"manifestSpec": "2.1","variants": {"q8_no_zero_vec4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q8_zero_vec4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q4_no_zero_pair": ["gather-block-quantized-q4-pair.wgsl.jinja"],"q4_zero_pair": ["gather-block-quantized-q4-pair.wgsl.jinja"],"q8_no_zero_tail4": ["gather-block-quantized-q8-vec4.wgsl.jinja"],"q8_zero_tail4": ["gather-block-quantized-q8-vec4.wgsl.jinja"]}
README.md+2-2
build/webgpu/bench.json+2-2
build/webgpu/gather-block-quantized-q4-pair.wgsl.jinja+6-3
build/webgpu/gather-block-quantized-q8-vec4.wgsl.jinja+6-3
build/webgpu/manifest.json+35-78
build/webgpu/metadata.json+8-8