sync 4385228f788d
Browse filesFiles changed (6)
11 unmodified lines12131415151617183 unmodified lines22232425252627287 unmodified lines363738394041426 unmodified lines49505151525354555652535455565758596060616263646566676864656667686970717273737475767778798081828182838485868788899091929394959697989910010110210310411 unmodified lines
## Description
Gated RMS normalization as used by Mamba2 and gated DeltaNet attention outputs: `Y = X * rsqrt(mean(X^2) + epsilon) * scale * SiLU(gate)`. The mean of squares is taken over each contiguous group of `C` elements, where `C` is the element count of `scale`, so a per-head norm runs on a packed `(..., H * C)` tensor with no surrounding reshape. Rows are counted flat as the element count of `X` divided by `C` and any rank of at least 1 is accepted. Every intermediate including SiLU is float32 whatever the tensor type; only the store narrows. Bfloat16 is not implemented.Gated RMS normalization: `Y = X * rsqrt(mean(X^2) + epsilon) * scale * gate_activation(gate)`. Activation defaults to `silu` (`swish` alias); `sigmoid` applies the sigmoid alone. Each contiguous group has C elements, equal to the number of scale values, so packed per-head inputs need no reshape. Accepts any input rank of at least one and counts rows by dividing the input element count by C. All intermediates, including gate activation, use float32; only the output store narrows. Bfloat16 is unsupported.
See the [ONNX Runtime `GatedRMSNorm` contrib-operator spec](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.GatedRMSNorm) for the reference semantics.
3 unmodified lines| --- | --- | --- | --- | --- | --- | --- || `xT` | `X` | `T` | — | — | Input activations with shape `(..., H * C)`. Any rank of at least 1 is accepted and the leading axes are folded into the row count. | required || `scaleT` | `scale` | `T` | — | — | Normalization weight. Its element count is the normalization span `C`; the standard spelling is `(C)`, and the reshaped `(1, C)` and `(C, 1)` spellings of the same vector are accepted because upstream measures the span as an element count. | required || `gateT` | `gate` | `T` | — | — | Gate activations with exactly the same shape as `X`; SiLU is applied to them internally. | required || `gateT` | `gate` | `T` | — | — | Gate activations with exactly the same shape as `X`; the selected SiLU/swish or sigmoid activation is applied internally in float32. | required |
## Outputs
7 unmodified lines
| Attribute | Default | Description || --- | --- | --- || `activation` | `"silu"` | Gate activation: `silu` (default) and its `swish` alias compute `z * sigmoid(z)`; `sigmoid` computes only `sigmoid(z)`. The activation stays in float32 for both float32 and float16 tensors, and sigmoid uses a stable logistic in both tails. || `epsilon` | `0.00001` | Constant added to the mean of squares before the reciprocal square root. The standard default is `1e-5`; note that the Hugging Face gated-RMS archetype defaults to `1e-6` instead, so a value must be carried explicitly when porting between the two. |
## Type constraints6 unmodified lines
One implementation is selected per call from the device capabilities, the request shapes and the dtypes; these notes say what each one covers.
- `subgroup_rows_vec4` — One aligned lane group per normalization row inside a subgroup, with the row held in registers. The fold is a segmented butterfly over the low lane bits, so several rows share a subgroup with no workgroup memory, no barrier and no idle lanes beyond the row's own power-of-two padding.- `packed_rows_vec4` — Portable vec4 route: the workgroup is split into a power-of-two lane group per row and each group folds its own contiguous slice of the shared array, so a short row does not idle the workgroup and no subgroup support is required. It also carries rows too wide to stage in registers, which it walks twice.- `subgroup_rows_scalar` — The barrier-free lane-group schedule for a normalization span that is not a multiple of four: the same segmented butterfly over scalar loads.- `packed_rows_scalar` — Scalar fallback for a span that is not a multiple of four, and the route every device can select. It keeps the lane-group-per-row schedule so a narrow span still fills the workgroup.- `subgroup_wide_rows_vec4` — Subgroup partials for a row spanning several whole subgroups; every lane reads the short row sum after one barrier.- `subgroup_wide_rows_scalar` — Subgroup partials for a row spanning several whole subgroups; every lane reads the short row sum after one barrier.- `subgroup_rows_vec4` — Proves complete native subgroup lane groups before using a subgroup row collective. Other legal partitions use the synchronized local-ID row tree, with the same f32 accumulation and store precision.- `packed_rows_vec4` — `vec4` variant that runs on any device: the workgroup is split into a power-of-two lane group per row and each group folds its own contiguous slice of the shared array, so a short row does not idle the workgroup and no subgroup support is required. It also carries rows too wide to stage in registers, which it walks twice.- `subgroup_rows_scalar` ��� Proves complete native subgroup lane groups before using a subgroup row collective. Other legal partitions use the synchronized local-ID row tree, with the same f32 accumulation and store precision.- `packed_rows_scalar` — Scalar fallback for a span that is not a multiple of four, and the variant every device can run. It keeps the lane-group-per-row schedule so a narrow span still fills the workgroup.- `subgroup_wide_rows_vec4`, `subgroup_wide_rows_scalar` — Proves full fixed-width subgroup populations before mapping rows through subgroup IDs and combining native row partials. Other legal populations use a local-ID row tree.
## Device requirements
Some implementation variants require `subgroups`. These are route-specific capabilities, not package-wide requirements; availability also depends on the request shape and dtype.Some implementation variants require `subgroups`. Other variants run without it; which variant runs also depends on the request's shapes and dtypes.
## Files
- [`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- [`gated-rms-norm-rows.wgsl.jinja`](build/webgpu/gated-rms-norm-rows.wgsl.jinja)- [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.GatedRMSNorm/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)- [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.GatedRMSNorm/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)- [`test.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.GatedRMSNorm/blob/v1/build/webgpu/test.json) — correctness cases- [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.GatedRMSNorm/blob/v1/build/webgpu/bench.json) — benchmark cases- [`gated-rms-norm-rows.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.GatedRMSNorm/blob/v1/build/webgpu/gated-rms-norm-rows.wgsl.jinja)
## Use with `@huggingface/kernels`
```shnpm install --save-exact @huggingface/kernels@0.0.1-preview.3npm install --save-exact @huggingface/kernels@0.0.1-preview.4```
Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
Replace each `*Data` placeholder with a typed array containing the corresponding input data.
```jsimport { getKernel } from "@huggingface/kernels";
const kernel = await getKernel("webgpu-kernels/com.microsoft.GatedRMSNorm", { version: 1 });
const xTData = Float32Array.of( 0.33235988, 0.43006405, 0.45976323, 0.4104722, 0.290668, 0.12620091, -0.04620629, -0.18821806, -0.26954928, -0.2755744, -0.2109471, -0.0983117,);const scaleTData = Float32Array.of(1.75);const gateTData = Float32Array.of( -0.04278836, -0.34751478, -0.26068854, 0.30176142, 1.2277768, 2.2484548, 3.0381744, 3.337231, 3.0499835, 2.2808857, 1.29459, 0.4154394,);
const { yT } = await kernel({ xT: { data: xTData, shape: [3, 4] }, scaleT: { data: scaleTData, shape: [1] }, gateT: { data: gateTData, shape: [3, 4] },});console.log({ yT });```5 unmodified lines6789910111211 unmodified lines242526272728293030 unmodified lines616263646465666728 unmodified lines96979899991001011029 unmodified lines11211311411511611711511611711825 unmodified lines14414514614914714814915011 unmodified lines16216316416716516616716810 unmodified lines17918018118418218318418510 unmodified lines19619719820119920020120210 unmodified lines21321421521821621721821927 unmodified lines24724824925225025125225310 unmodified lines2642652662692672682692705 unmodified lines "preset": "smoke", "provenance": { "model": "Qwen3.5 / Qwen3-Next gated linear attention output norm", "notes": "One decoded token: 16 value heads of 128. The whole operator is 24 KB of traffic, so the measurement is launch latency rather than bandwidth." "notes": "One decoded token with 16 value heads of 128 float32 channels, a small workload that exposes dispatch overhead." }, "vars": { "dtype": "float32", "count": 2048, "span": 128 }, "inputs": {11 unmodified lines "preset": "smoke", "provenance": { "model": "Qwen3.5 / Qwen3-Next gated linear attention output norm", "notes": "The float16 decode step, the dtype the shipped model graphs use." "notes": "One decoded token with 16 value heads of 128 float16 channels." }, "vars": { "dtype": "float16", "count": 2048, "span": 128 }, "inputs": {30 unmodified lines "preset": "smoke", "provenance": { "model": "Qwen3.5 / Qwen3-Next gated linear attention output norm", "notes": "The float16 prefill of the same 8192 spans." "notes": "A 512-token prefill with 8192 rows of 128 float16 channels each." }, "vars": { "dtype": "float16", "count": 1048576, "span": 128 }, "inputs": {28 unmodified lines "name": "gated-rmsnorm-single-group-d5120-f32", "preset": "smoke", "provenance": { "notes": "A 5120-wide span: wide enough that the row no longer fits in registers at this workgroup width, so the statistic and the store each walk it." "notes": "Measures gated RMS normalization over 256 rows of 5120 float32 channels each, normalized as a single group." }, "vars": { "dtype": "float32", "count": 1310720, "span": 5120 }, "inputs": {9 unmodified lines { "name": "gated-rmsnorm-small-span-d48-f16", "preset": "smoke", "provenance": { "notes": "A 48-element span over the same tensor: 16384 very short rows, where a workgroup-per-row schedule would leave most of every workgroup idle." }, "provenance": { "notes": "16384 rows of 48 float16 channels exercise short normalization spans." }, "vars": { "dtype": "float16", "count": 786432, "span": 48 }, "inputs": { "xT": { "shape": [1, 512, 1536], "dtype": "float16", "dist": "normal", "seed": 541, "scale": 1 },25 unmodified lines "preset": "model", "provenance": { "model": "Qwen3.5 / Qwen3-Next gated linear attention output norm", "notes": "A 4096-token prefill: 65536 spans, a working set far past cache so the bandwidth figure is a DRAM figure." "notes": "A 4096-token prefill with 65536 normalization spans provides a large working set for measuring memory throughput." }, "vars": { "dtype": "float16", "count": 8388608, "span": 128 }, "inputs": {11 unmodified lines "preset": "model", "provenance": { "model": "Qwen3.5 / Qwen3-Next gated linear attention output norm", "notes": "The float32 counterpart at the same 48 MB working set." "notes": "A 2048-token prefill with 16 heads and 128 float32 channels per head." }, "vars": { "dtype": "float32", "count": 4194304, "span": 128 }, "inputs": {10 unmodified lines "name": "gated-rmsnorm-short-c5-r8193-float32", "preset": "smoke", "provenance": { "notes": "Measures gated RMS normalization over 8193 rows of 5 channels in float32, one row past a full 256-row group. Its smaller row count sets an overhead baseline against the float32 131,073-row sibling." "notes": "Measures gated RMS normalization over 8193 rows of 5 channels in float32, one row past a full 256-row group." }, "vars": { "dtype": "float32", "count": 40965, "span": 5 }, "inputs": {10 unmodified lines "name": "gated-rmsnorm-short-c5-r131073-float32", "preset": "smoke", "provenance": { "notes": "Measures gated RMS normalization over 131,073 rows of 5 channels in float32, one row past a full 256-row group. Its larger row count isolates per-row cost from the 8193-row float32 sibling's per-dispatch overhead." "notes": "Measures gated RMS normalization over 131,073 rows of 5 channels in float32, one row past a full 256-row group." }, "vars": { "dtype": "float32", "count": 655365, "span": 5 }, "inputs": {10 unmodified lines "name": "gated-rmsnorm-short-c5-r131073-float16", "preset": "smoke", "provenance": { "notes": "Measures gated RMS normalization over 131,073 rows of 5 channels in float16, one row past a full 256-row group; compares against its float32 counterpart at the same shape." "notes": "Measures gated RMS normalization over 131,073 rows of 5 channels in float16, one row past a full 256-row group." }, "vars": { "dtype": "float16", "count": 655365, "span": 5 }, "inputs": {27 unmodified lines "name": "gated-rmsnorm-short-c7-r131073-float32", "preset": "smoke", "provenance": { "notes": "Measures gated RMS normalization over 131,073 rows of 7 channels in float32, one row past a full 256-row group; compares against its float16 counterpart at the same shape." "notes": "Measures gated RMS normalization over 131,073 rows of 7 channels in float32, one row past a full 256-row group." }, "vars": { "dtype": "float32", "count": 917511, "span": 7 }, "inputs": {10 unmodified lines "name": "gated-rmsnorm-short-c7-r131073-float16", "preset": "smoke", "provenance": { "notes": "Measures gated RMS normalization over 131,073 rows of 7 channels in float16, one row past a full 256-row group; compares against its float32 counterpart at the same shape." "notes": "Measures gated RMS normalization over 131,073 rows of 7 channels in float16, one row past a full 256-row group." }, "vars": { "dtype": "float16", "count": 917511, "span": 7 }, "inputs": {1123456778910111 unmodified line13141515161718191 unmodified line2122232324242526272628293031323334353637382829303940414243444546474849505152535455565758596061626364656667686 unmodified lines7576777879808182838446478586874988899091929394959697989910010110210342 unmodified lines146147148149150151152991531541551561031571581591051601611621081091631641651661671681691701711722 unmodified lines17517617711817817918018118218318418518618718818919019119219319419519619719819920020 unmodified lines2212222231452242251472262272282291 unmodified line231232233155234235157236237238239{% if foldKind == "subgroup_full" or foldKind == "subgroup_butterfly" or foldKind == "subgroup_tree" %}{% set subgroupRowFold = foldKind == "subgroup_full" or foldKind == "subgroup_butterfly" or foldKind == "subgroup_tree" %}{% if subgroupRowFold %}enable subgroups;{% endif %}{{ env.wgsl.resourceDeclarations }}
// Gated RMS normalization over each contiguous group of C elements of a row:// Y = X * inverseSqrt(mean(X^2) + epsilon) * scale * SiLU(gate)// Y = X * inverseSqrt(mean(X^2) + epsilon) * scale * {{ "sigmoid" if sigmoidGate else "SiLU" }}(gate)// C is the scale length, so a per-head norm runs on a packed (..., H * C) tensor// with no surrounding reshape. Every intermediate is float32 and only the store// narrows, so an f16 tensor keeps an f32 statistic.1 unmodified line// Each normalization group owns a fixed LANE GROUP rather than a whole workgroup:// a 128-element group would otherwise leave most of a workgroup idle and still pay// a full-width fold. LANES_PER_ROW is the smallest power of two that covers the// row, capped by the workgroup (and, on the subgroup routes, by the subgroup) so// row, capped by the workgroup (and, on the subgroup variants, by the subgroup) so// several rows are resident at once.const ROW_WORDS: u32 = {{ rowWords }}u;const NORM_SIZE: f32 = {{ normSize }}.0;1 unmodified lineconst WG: u32 = {{ workgroupSize }}u;const LANES_PER_ROW: u32 = {{ lanesPerRow }}u;const ROWS_PER_GROUP: u32 = {{ rowsPerGroup }}u;{% if foldKind == "subgroup_tree" %}var<workgroup> partials: array<f32, {{ (workgroupSize / subgroupWidth) | int }}>;{% if subgroupRowFold or foldKind == "workgroup_tree" %}// Native folds retain a complete local-ID row tree for rejected layouts.var<workgroup> partials: array<f32, WG>;{% endif %}{% if foldKind == "workgroup_tree" %}{% if subgroupRowFold %}// One entry-point proof for algorithms that assign data using local-ID lane// blocks. Every subgroup checks all active members; the workgroup accepts only// when every subgroup has a valid complete layout. Call once in uniform flow.// The rejection flag starts zero through WGSL workgroup initialization.// Some Adreno 6xx drivers cannot create a pipeline that calls subgroupAll; a ballot builds wherever subgroups do.// A subgroup is valid when no active member is invalid. That is subgroupAll, expressed as a ballot so the shader// does not depend on subgroupAll.var<workgroup> subgroupLocalLayoutRejected: atomic<u32>;var<workgroup> subgroupLocalLayoutAcceptedState: u32;
// One contiguous LANES_PER_ROW slice per row. The fold never crosses a slice// boundary, so the rows sharing this array do not interfere.var<workgroup> partials: array<f32, WG>;fn subgroupLocalLayoutAccepted(localIndex: u32, memberValid: bool) -> bool { let valid = all(subgroupBallot(!memberValid) == vec4<u32>(0u)); if (subgroupElect() && !valid) { atomicStore(&subgroupLocalLayoutRejected, 1u); } workgroupBarrier(); if (localIndex == 0u) { subgroupLocalLayoutAcceptedState = select(0u, 1u, atomicLoad(&subgroupLocalLayoutRejected) == 0u); } return workgroupUniformLoad(&subgroupLocalLayoutAcceptedState) != 0u;}{% endif %}{% if sigmoidGate %}fn sigmoid_safe(x: f32) -> f32 { if (x >= 0.0) { let z = exp(-x); return 1.0 / (1.0 + z); } let z = exp(x); return z / (1.0 + z);}{% if useVec4 %}fn sigmoid4(v: vec4<f32>) -> vec4<f32> { return vec4<f32>(sigmoid_safe(v.x), sigmoid_safe(v.y), sigmoid_safe(v.z), sigmoid_safe(v.w));}{% endif %}{% elif useVec4 %}
fn silu4(v: vec4<f32>) -> vec4<f32> { return v / (vec4<f32>(1.0) + exp(-v));6 unmodified lines{% endif %}
@compute @workgroup_size(WG)fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>{% if subgroupRowFold %}, @builtin(subgroup_size) sg_size: u32, @builtin(subgroup_invocation_id) sg_lane: u32{% if foldKind == "subgroup_tree" %}, @builtin(subgroup_id) sg_id: u32{% endif %}{% endif %}) {{% if subgroupRowFold %} let populationCount = dot(countOneBits(subgroupBallot(true)), vec4<u32>(1u));{% if foldKind == "subgroup_tree" %}fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(subgroup_invocation_id) sg_lane: u32, @builtin(subgroup_id) sg_id: u32) { let tid = sg_id * {{ subgroupWidth }}u + sg_lane; // Full fixed-width groups make subgroup-id coordinates a complete WG layout. let memberValid = sg_size == {{ subgroupWidth }}u && populationCount == sg_size;{% else %}fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>) { let physicalWidth = max(sg_size, 1u); let firstLocalIndex = subgroupBroadcastFirst(lid.x); let memberValid = populationCount == sg_size && sg_size > 0u && WG % physicalWidth == 0u && {% if foldKind == "subgroup_full" %}sg_size == LANES_PER_ROW{% else %}physicalWidth >= LANES_PER_ROW && physicalWidth % LANES_PER_ROW == 0u{% endif %} && lid.x / physicalWidth == firstLocalIndex / physicalWidth && sg_lane == lid.x % physicalWidth;{% endif %} let nativeLayout = subgroupLocalLayoutAccepted(lid.x, memberValid);{% endif %}{% if foldKind == "subgroup_tree" %} var tid = lid.x; if (nativeLayout) { tid = sg_id * {{ subgroupWidth }}u + sg_lane; }{% endif %} let lane = {{ "tid" if foldKind == "subgroup_tree" else "lid.x" }} % LANES_PER_ROW; let localRow = {{ "tid" if foldKind == "subgroup_tree" else "lid.x" }} / LANES_PER_ROW;42 unmodified lines{% endif %} }{% endif %}{% if subgroupRowFold %} var sumSq = 0.0; if (nativeLayout) {{% if foldKind == "subgroup_full" %} let sumSq = subgroupAdd(acc); sumSq = subgroupAdd(acc);{% elif foldKind == "subgroup_butterfly" %} // Segmented butterfly: only the low bits of the lane index are exchanged, so each // aligned group of LANES_PER_ROW lanes folds its own row and one subgroup carries // several rows without a barrier or any workgroup memory. // several rows through the proven native layout.{% set shuffleSteps = 4 if foldSteps > 4 and (device.adapterInfo.subgroupMinSize | default(0)) > 32 else foldSteps %} var folded = acc;{% for step in range(foldSteps) %}{% for step in range(shuffleSteps) %} folded = folded + subgroupShuffleXor(folded, 1u << {{ step }}u);{% endfor %} let sumSq = folded;{% elif foldKind == "subgroup_tree" %}{% if foldSteps > shuffleSteps %} partials[lid.x] = folded; workgroupBarrier(); folded = {% for i in range(pow(2, foldSteps - shuffleSteps) | int) %}{{ " + " if not loop.first else "" }}partials[localRow * LANES_PER_ROW + {{ i * 16 }}u]{% endfor %};{% endif %} sumSq = folded;{% else %} // Subgroup IDs define the row coordinates independently of local invocation // ordering. Only subgroup leaders publish; the row's short final sum is read // by every lane, avoiding a second broadcast barrier.2 unmodified lines partials[sg_id] = subgroupPartial; } workgroupBarrier(); let sumSq = {% for i in range(subgroupsPerRow) %}{{ "+ " if not loop.first else "" }}partials[localRow * {{ subgroupsPerRow }}u + {{ i }}u]{% endfor %}; sumSq = {% for i in range(subgroupsPerRow) %}{{ "+ " if not loop.first else "" }}partials[localRow * {{ subgroupsPerRow }}u + {{ i }}u]{% endfor %};{% endif %} } else { partials[lid.x] = acc; workgroupBarrier(); // LANES_PER_ROW is a power of two, so the halving stride is uniform across the // whole workgroup and every lane reaches every barrier. var stride = LANES_PER_ROW / 2u; loop { if (stride == 0u) { break; } if (lane < stride) { partials[lid.x] = partials[lid.x] + partials[lid.x + stride]; } workgroupBarrier(); stride = stride / 2u; } sumSq = partials[localRow * LANES_PER_ROW]; }{% elif foldKind == "workgroup_tree" %} partials[lid.x] = acc; workgroupBarrier();20 unmodified lines{% for i in range(wordsPerLane) %} if (c{{ i }} < limit) {{% if useVec4 %} y[base + c{{ i }}] = {{ vectorScalar }}(xv{{ i }} * inv * vec4<f32>(scale[c{{ i }}]) * silu4(gv{{ i }})); y[base + c{{ i }}] = {{ vectorScalar }}(xv{{ i }} * inv * vec4<f32>(scale[c{{ i }}]) * {{ "sigmoid4" if sigmoidGate else "silu4" }}(gv{{ i }}));{% else %} y[base + c{{ i }}] = {{ scalar }}(xv{{ i }} * inv * f32(scale[c{{ i }}]) * silu(gv{{ i }})); y[base + c{{ i }}] = {{ scalar }}(xv{{ i }} * inv * f32(scale[c{{ i }}]) * {{ "sigmoid_safe" if sigmoidGate else "silu" }}(gv{{ i }}));{% endif %} }{% endfor %}1 unmodified line for (var c = lane; c < limit; c = c + LANES_PER_ROW) { let idx = base + c;{% if useVec4 %} y[idx] = {{ vectorScalar }}(vec4<f32>(x[idx]) * inv * vec4<f32>(scale[c]) * silu4(vec4<f32>(gate[idx]))); y[idx] = {{ vectorScalar }}(vec4<f32>(x[idx]) * inv * vec4<f32>(scale[c]) * {{ "sigmoid4" if sigmoidGate else "silu4" }}(vec4<f32>(gate[idx])));{% else %} y[idx] = {{ scalar }}(f32(x[idx]) * inv * f32(scale[c]) * silu(f32(gate[idx]))); y[idx] = {{ scalar }}(f32(x[idx]) * inv * f32(scale[c]) * {{ "sigmoid_safe" if sigmoidGate else "silu" }}(f32(gate[idx])));{% endif %} }{% endif %}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372381{ "domain": "com.microsoft", "name": "GatedRMSNorm", "sinceVersion": 1, "inputs": { "xT": { "onnx": "X", "dtype": "T" }, "scaleT": { "onnx": "scale", "dtype": "T" }, "gateT": { "onnx": "gate", "dtype": "T" } }, "outputs": { "yT": { "onnx": "Y", "dtype": "T", "rank": "ranks.xT", "shape": "shapes.xT" } }, "attributes": { "epsilon": { "default": 0.00001 } }, "typeConstraints": { "T": ["float32", "float16"] }, "tunables": { "WORKGROUP_SIZE": { "default": 256 }, "LANE_WORDS": { "default": 2 } }, "derive": { "deviceWorkgroupCap": "min(device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)", "foldedDispatchCapacity": "min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)", "normSize": "numel(shapes.scaleT)", "lastDim": "dim(shapes.xT, ranks.xT - 1)", "elementCount": "numel(shapes.xT)", "rowCount": "elementCount / max(1, normSize)", "dtypeOk": "tensorDtypes.xT == tensorDtypes.scaleT and tensorDtypes.xT == tensorDtypes.gateT and tensorDtypes.xT == tensorDtypes.yT and f16Ok(dtypes.T)", "shapeOk": "ranks.xT >= 1 and ranks.scaleT >= 1 and normSize > 0 and lastDim % normSize == 0 and sameShape(shapes.gateT, shapes.xT) and sameShape(shapes.yT, shapes.xT)", "contractOk": "dtypeOk and shapeOk", "workgroupOk": "tunables.WORKGROUP_SIZE > 0 and tunables.WORKGROUP_SIZE <= deviceWorkgroupCap and pow2ceil(tunables.WORKGROUP_SIZE) == tunables.WORKGROUP_SIZE and tunables.WORKGROUP_SIZE * 4 <= device.limits.maxComputeWorkgroupStorageSize and tunables.LANE_WORDS > 0", "vec4Ok": "normSize % 4 == 0", "vecWords": "normSize / 4", "vecPreferredLanes": "max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))", "vecWideLanes": "max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))", "vecLanesPerRow": "pick([[ceilDiv(vecWords, vecPreferredLanes) <= 8, vecPreferredLanes]], vecWideLanes)", "vecRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, vecLanesPerRow)", "vecWordsPerLane": "ceilDiv(vecWords, max(1, vecLanesPerRow))", "vecRowGroups": "ceilDiv(rowCount, max(1, vecRowsPerGroup))", "scalarPreferredLanes": "1 if normSize <= 8 else (max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(normSize, max(1, tunables.LANE_WORDS)))))))", "scalarWideLanes": "max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(normSize, max(1, tunables.LANE_WORDS))))))", "scalarLanesPerRow": "pick([[ceilDiv(normSize, scalarPreferredLanes) <= 8, scalarPreferredLanes]], scalarWideLanes)", "scalarRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, scalarLanesPerRow)", "scalarWordsPerLane": "ceilDiv(normSize, max(1, scalarLanesPerRow))", "scalarRowGroups": "ceilDiv(rowCount, max(1, scalarRowsPerGroup))", "subgroupShapeKnown": "device.features.has(\"subgroups\") and has(device.adapterInfo, \"subgroupMinSize\") and has(device.adapterInfo, \"subgroupMaxSize\") and device.adapterInfo.subgroupMinSize > 0 and device.adapterInfo.subgroupMinSize <= device.adapterInfo.subgroupMaxSize and device.adapterInfo.subgroupMaxSize <= tunables.WORKGROUP_SIZE and tunables.WORKGROUP_SIZE % device.adapterInfo.subgroupMaxSize == 0", "sgMin": "device.adapterInfo.subgroupMinSize if subgroupShapeKnown else 0", "sgFullWidth": "subgroupShapeKnown and device.adapterInfo.subgroupMinSize == device.adapterInfo.subgroupMaxSize", "sgVecLanesPerRow": "min(sgMin, vecLanesPerRow) if subgroupShapeKnown else 1", "sgVecRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, sgVecLanesPerRow)", "sgVecWordsPerLane": "ceilDiv(vecWords, max(1, sgVecLanesPerRow))", "sgVecRowGroups": "ceilDiv(rowCount, max(1, sgVecRowsPerGroup))", "sgScalarLanesPerRow": "min(sgMin, scalarLanesPerRow) if subgroupShapeKnown else 1", "sgScalarRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, sgScalarLanesPerRow)", "sgScalarWordsPerLane": "ceilDiv(normSize, max(1, sgScalarLanesPerRow))", "sgScalarRowGroups": "ceilDiv(rowCount, max(1, sgScalarRowsPerGroup))", "vectorElement": "\"vec4<\" ~ dtypes.T ~ \">\"", "workgroupSize": "tunables.WORKGROUP_SIZE", "epsilon": "attrs.epsilon", "scalar": "dtypes.T", "vectorScalar": "vectorElement" }, "when": ["contractOk", "workgroupOk"], "bindings": { "x": { "arg": "xT", "elementType": "$vectorElement" }, "scale": { "arg": "scaleT", "elementType": "$vectorElement" }, "gate": { "arg": "gateT", "elementType": "$vectorElement" }, "y": { "arg": "yT", "elementType": "$vectorElement" }, "x_x_t": { "arg": "xT", "name": "x", "elementType": "$scalar" }, "scale_main": { "arg": "scaleT", "name": "scale", "elementType": "$scalar" }, "gate_main": { "arg": "gateT", "name": "gate", "elementType": "$scalar" }, "y_y_t": { "arg": "yT", "name": "y", "elementType": "$scalar" }, "params": { "struct": [{ "name": "rows", "type": "u32", "value": "rowCount" }] } }, "variants": [ { "id": "subgroup_rows_vec4", "priority": 30, "when": ["vec4Ok", "subgroupShapeKnown", "sgVecWordsPerLane >= 1", "sgVecWordsPerLane <= 8", "sgVecRowGroups <= foldedDispatchCapacity"], "requires": { "features": ["subgroups"] }, "derive": { "foldKind": "\"none\" if sgVecLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgVecLanesPerRow == sgMin) else \"subgroup_butterfly\")", "foldSteps": "log2ceil(sgVecLanesPerRow)", "useVec4": "true", "stageRow": "true", "rowWords": "vecWords", "wordsPerLane": "sgVecWordsPerLane", "lanesPerRow": "sgVecLanesPerRow", "rowsPerGroup": "sgVecRowsPerGroup" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.SubgroupRowsVec4", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x", "scale", "gate", "y", "params"], "dispatch": { "x": "min(sgVecRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(sgVecRowGroups, DISPATCH_FOLD_WIDTH)" } } ] }, { "id": "packed_rows_vec4", "priority": 20, "when": ["vec4Ok", "vecRowGroups <= foldedDispatchCapacity"], "derive": { "foldKind": "\"none\" if vecLanesPerRow <= 1 else \"workgroup_tree\"", "foldSteps": "log2ceil(vecLanesPerRow)", "useVec4": "true", "stageRow": "vecWordsPerLane <= 8", "rowWords": "vecWords", "wordsPerLane": "vecWordsPerLane", "lanesPerRow": "vecLanesPerRow", "rowsPerGroup": "vecRowsPerGroup" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.PackedRowsVec4", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x", "scale", "gate", "y", "params"], "dispatch": { "x": "min(vecRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(vecRowGroups, DISPATCH_FOLD_WIDTH)" } } ] }, { "id": "subgroup_rows_scalar", "priority": 10, "when": ["subgroupShapeKnown", "sgScalarWordsPerLane >= 1", "sgScalarWordsPerLane <= 8", "sgScalarRowGroups <= foldedDispatchCapacity"], "requires": { "features": ["subgroups"] }, "derive": { "foldKind": "\"none\" if sgScalarLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgScalarLanesPerRow == sgMin) else \"subgroup_butterfly\")", "foldSteps": "log2ceil(sgScalarLanesPerRow)", "useVec4": "false", "stageRow": "true", "rowWords": "normSize", "wordsPerLane": "sgScalarWordsPerLane", "lanesPerRow": "sgScalarLanesPerRow", "rowsPerGroup": "sgScalarRowsPerGroup" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.SubgroupRowsScalar", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x_x_t", "scale_main", "gate_main", "y_y_t", "params"], "dispatch": { "x": "min(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)" } } ] }, { "id": "packed_rows_scalar", "priority": 0, "when": ["scalarRowGroups <= foldedDispatchCapacity"], "derive": { "foldKind": "\"none\" if scalarLanesPerRow <= 1 else \"workgroup_tree\"", "foldSteps": "log2ceil(scalarLanesPerRow)", "useVec4": "false", "stageRow": "scalarWordsPerLane <= 8", "rowWords": "normSize", "wordsPerLane": "scalarWordsPerLane", "lanesPerRow": "scalarLanesPerRow", "rowsPerGroup": "scalarRowsPerGroup" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.PackedRowsScalar", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x_x_t", "scale_main", "gate_main", "y_y_t", "params"], "dispatch": { "x": "min(scalarRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(scalarRowGroups, DISPATCH_FOLD_WIDTH)" } } ] }, { "id": "subgroup_wide_rows_vec4", "priority": 25, "when": ["vec4Ok", "vecRowGroups <= foldedDispatchCapacity", "dtypes.T == \"f32\"", "sgFullWidth", "device.wgslLanguageFeatures.has(\"subgroup_id\")", "vecLanesPerRow > sgMin", "vecLanesPerRow % max(1, sgMin) == 0"], "requires": { "features": ["subgroups"] }, "derive": { "foldKind": "\"subgroup_tree\"", "useVec4": "true", "stageRow": "vecWordsPerLane <= 8", "rowWords": "vecWords", "wordsPerLane": "vecWordsPerLane", "lanesPerRow": "vecLanesPerRow", "rowsPerGroup": "vecRowsPerGroup", "subgroupWidth": "sgMin", "subgroupsPerRow": "vecLanesPerRow / max(1, sgMin)" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.SubgroupWideRowsVec4", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x", "scale", "gate", "y", "params"], "dispatch": { "x": "min(vecRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(vecRowGroups, DISPATCH_FOLD_WIDTH)" } } ] }, { "id": "subgroup_wide_rows_scalar", "priority": 5, "when": ["scalarRowGroups <= foldedDispatchCapacity", "dtypes.T == \"f32\"", "sgFullWidth", "device.wgslLanguageFeatures.has(\"subgroup_id\")", "scalarLanesPerRow > sgMin", "scalarLanesPerRow % max(1, sgMin) == 0"], "requires": { "features": ["subgroups"] }, "derive": { "foldKind": "\"subgroup_tree\"", "useVec4": "false", "stageRow": "scalarWordsPerLane <= 8", "rowWords": "normSize", "wordsPerLane": "scalarWordsPerLane", "lanesPerRow": "scalarLanesPerRow", "rowsPerGroup": "scalarRowsPerGroup", "subgroupWidth": "sgMin", "subgroupsPerRow": "scalarLanesPerRow / max(1, sgMin)" }, "passes": [ { "id": "main", "name": "GatedRMSNorm.SubgroupWideRowsScalar", "shader": "gated-rms-norm-rows.wgsl.jinja", "bindings": ["x_x_t", "scale_main", "gate_main", "y_y_t", "params"], "dispatch": { "x": "min(scalarRowGroups, DISPATCH_FOLD_WIDTH)", "y": "ceilDiv(scalarRowGroups, DISPATCH_FOLD_WIDTH)" } } ] } ]}{"domain":"com.microsoft","name":"GatedRMSNorm","sinceVersion":1,"inputs":{"xT":{"onnx":"X","dtype":"T"},"scaleT":{"onnx":"scale","dtype":"T"},"gateT":{"onnx":"gate","dtype":"T"}},"outputs":{"yT":{"onnx":"Y","dtype":"T","rank":"ranks.xT","shape":"shapes.xT"}},"attributes":{"activation":{"default":"silu"},"epsilon":{"default":0.00001}},"attributeConstraints":{"activation":{"values":["silu","swish","sigmoid"]}},"typeConstraints":{"T":["float32","float16"]},"tunables":{"WORKGROUP_SIZE":{"default":256},"LANE_WORDS":{"default":2}},"derive":{"deviceWorkgroupCap":"min(device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)","foldedDispatchCapacity":"min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)","normSize":"numel(shapes.scaleT)","lastDim":"dim(shapes.xT, ranks.xT - 1)","elementCount":"numel(shapes.xT)","rowCount":"elementCount / max(1, normSize)","dtypeOk":"tensorDtypes.xT == tensorDtypes.scaleT and tensorDtypes.xT == tensorDtypes.gateT and tensorDtypes.xT == tensorDtypes.yT and f16Ok(dtypes.T)","shapeOk":"ranks.xT >= 1 and ranks.scaleT >= 1 and normSize > 0 and lastDim % normSize == 0 and sameShape(shapes.gateT, shapes.xT) and sameShape(shapes.yT, shapes.xT)","contractOk":"dtypeOk and shapeOk","workgroupOk":"tunables.WORKGROUP_SIZE > 0 and tunables.WORKGROUP_SIZE <= deviceWorkgroupCap and pow2ceil(tunables.WORKGROUP_SIZE) == tunables.WORKGROUP_SIZE and tunables.WORKGROUP_SIZE * 4 <= device.limits.maxComputeWorkgroupStorageSize and tunables.LANE_WORDS > 0","vec4Ok":"normSize % 4 == 0","vecWords":"normSize / 4","vecPreferredLanes":"max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))","vecWideLanes":"max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))","vecLanesPerRow":"pick([[ceilDiv(vecWords, vecPreferredLanes) <= 8, vecPreferredLanes]], vecWideLanes)","vecRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, vecLanesPerRow)","vecWordsPerLane":"ceilDiv(vecWords, max(1, vecLanesPerRow))","vecRowGroups":"ceilDiv(rowCount, max(1, vecRowsPerGroup))","scalarPreferredLanes":"1 if normSize <= 8 else max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(normSize, max(1, tunables.LANE_WORDS))))))","scalarWideLanes":"max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(normSize, max(1, tunables.LANE_WORDS))))))","scalarLanesPerRow":"pick([[ceilDiv(normSize, scalarPreferredLanes) <= 8, scalarPreferredLanes]], scalarWideLanes)","scalarRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, scalarLanesPerRow)","scalarWordsPerLane":"ceilDiv(normSize, max(1, scalarLanesPerRow))","scalarRowGroups":"ceilDiv(rowCount, max(1, scalarRowsPerGroup))","subgroupShapeKnown":"device.features.has(\"subgroups\") and has(device.adapterInfo, \"subgroupMinSize\") and has(device.adapterInfo, \"subgroupMaxSize\") and device.adapterInfo.subgroupMinSize > 0 and device.adapterInfo.subgroupMinSize <= device.adapterInfo.subgroupMaxSize and device.adapterInfo.subgroupMaxSize <= tunables.WORKGROUP_SIZE and tunables.WORKGROUP_SIZE % device.adapterInfo.subgroupMaxSize == 0","sgMin":"device.adapterInfo.subgroupMinSize if subgroupShapeKnown else 0","sgFullWidth":"subgroupShapeKnown and device.adapterInfo.subgroupMinSize == device.adapterInfo.subgroupMaxSize","sgVecLanesPerRow":"min(sgMin, vecLanesPerRow) if subgroupShapeKnown else 1","sgVecRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, sgVecLanesPerRow)","sgVecWordsPerLane":"ceilDiv(vecWords, max(1, sgVecLanesPerRow))","sgVecRowGroups":"ceilDiv(rowCount, max(1, sgVecRowsPerGroup))","sgScalarLanesPerRow":"min(sgMin, scalarLanesPerRow) if subgroupShapeKnown else 1","sgScalarRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, sgScalarLanesPerRow)","sgScalarWordsPerLane":"ceilDiv(normSize, max(1, sgScalarLanesPerRow))","sgScalarRowGroups":"ceilDiv(rowCount, max(1, sgScalarRowsPerGroup))","vectorElement":"\"vec4<\" ~ dtypes.T ~ \">\"","workgroupSize":"tunables.WORKGROUP_SIZE","epsilon":"attrs.epsilon","sigmoidGate":"attrs.activation == \"sigmoid\"","scalar":"dtypes.T","vectorScalar":"vectorElement","subgroupFoldFits":"tunables.WORKGROUP_SIZE * 4 + 8 <= device.limits.maxComputeWorkgroupStorageSize"},"when":["contractOk","workgroupOk"],"bindings":{"x":{"arg":"xT","elementType":"$vectorElement"},"scale":{"arg":"scaleT","elementType":"$vectorElement"},"gate":{"arg":"gateT","elementType":"$vectorElement"},"y":{"arg":"yT","elementType":"$vectorElement"},"x_x_t":{"arg":"xT","name":"x","elementType":"$scalar"},"scale_main":{"arg":"scaleT","name":"scale","elementType":"$scalar"},"gate_main":{"arg":"gateT","name":"gate","elementType":"$scalar"},"y_y_t":{"arg":"yT","name":"y","elementType":"$scalar"},"params":{"struct":[{"name":"rows","type":"u32","value":"rowCount"}]}},"variants":[{"id":"subgroup_rows_vec4","priority":30,"when":["vec4Ok","subgroupShapeKnown","sgVecWordsPerLane >= 1","sgVecWordsPerLane <= 8","sgVecRowGroups <= foldedDispatchCapacity","sgVecLanesPerRow <= 1 or subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"foldKind":"\"none\" if sgVecLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgVecLanesPerRow == sgMin) else \"subgroup_butterfly\")","foldSteps":"log2ceil(sgVecLanesPerRow)","useVec4":"true","stageRow":"true","rowWords":"vecWords","wordsPerLane":"sgVecWordsPerLane","lanesPerRow":"sgVecLanesPerRow","rowsPerGroup":"sgVecRowsPerGroup"},"passes":[{"id":"main","name":"GatedRMSNorm.SubgroupRowsVec4","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x","scale","gate","y","params"],"dispatch":{"x":"min(sgVecRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(sgVecRowGroups, DISPATCH_FOLD_WIDTH)"}}]},{"id":"packed_rows_vec4","priority":20,"when":["vec4Ok","vecRowGroups <= foldedDispatchCapacity"],"derive":{"foldKind":"\"none\" if vecLanesPerRow <= 1 else \"workgroup_tree\"","foldSteps":"log2ceil(vecLanesPerRow)","useVec4":"true","stageRow":"vecWordsPerLane <= 8","rowWords":"vecWords","wordsPerLane":"vecWordsPerLane","lanesPerRow":"vecLanesPerRow","rowsPerGroup":"vecRowsPerGroup"},"passes":[{"id":"main","name":"GatedRMSNorm.PackedRowsVec4","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x","scale","gate","y","params"],"dispatch":{"x":"min(vecRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(vecRowGroups, DISPATCH_FOLD_WIDTH)"}}]},{"id":"subgroup_rows_scalar","priority":10,"when":["subgroupShapeKnown","sgScalarWordsPerLane >= 1","sgScalarWordsPerLane <= 8","sgScalarRowGroups <= foldedDispatchCapacity","sgScalarLanesPerRow <= 1 or subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"foldKind":"\"none\" if sgScalarLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgScalarLanesPerRow == sgMin) else \"subgroup_butterfly\")","foldSteps":"log2ceil(sgScalarLanesPerRow)","useVec4":"false","stageRow":"true","rowWords":"normSize","wordsPerLane":"sgScalarWordsPerLane","lanesPerRow":"sgScalarLanesPerRow","rowsPerGroup":"sgScalarRowsPerGroup"},"passes":[{"id":"main","name":"GatedRMSNorm.SubgroupRowsScalar","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x_x_t","scale_main","gate_main","y_y_t","params"],"dispatch":{"x":"min(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)"}}]},{"id":"packed_rows_scalar","priority":0,"when":["scalarRowGroups <= foldedDispatchCapacity"],"derive":{"foldKind":"\"none\" if scalarLanesPerRow <= 1 else \"workgroup_tree\"","foldSteps":"log2ceil(scalarLanesPerRow)","useVec4":"false","stageRow":"scalarWordsPerLane <= 8","rowWords":"normSize","wordsPerLane":"scalarWordsPerLane","lanesPerRow":"scalarLanesPerRow","rowsPerGroup":"scalarRowsPerGroup"},"passes":[{"id":"main","name":"GatedRMSNorm.PackedRowsScalar","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x_x_t","scale_main","gate_main","y_y_t","params"],"dispatch":{"x":"min(scalarRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(scalarRowGroups, DISPATCH_FOLD_WIDTH)"}}]},{"id":"subgroup_wide_rows_vec4","priority":25,"when":["vec4Ok","vecRowGroups <= foldedDispatchCapacity","dtypes.T == \"f32\"","sgFullWidth","device.wgslLanguageFeatures.has(\"subgroup_id\")","vecLanesPerRow > sgMin","vecLanesPerRow % max(1, sgMin) == 0","subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"foldKind":"\"subgroup_tree\"","useVec4":"true","stageRow":"vecWordsPerLane <= 8","rowWords":"vecWords","wordsPerLane":"vecWordsPerLane","lanesPerRow":"vecLanesPerRow","rowsPerGroup":"vecRowsPerGroup","subgroupWidth":"sgMin","subgroupsPerRow":"vecLanesPerRow / max(1, sgMin)"},"passes":[{"id":"main","name":"GatedRMSNorm.SubgroupWideRowsVec4","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x","scale","gate","y","params"],"dispatch":{"x":"min(vecRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(vecRowGroups, DISPATCH_FOLD_WIDTH)"}}]},{"id":"subgroup_wide_rows_scalar","priority":5,"when":["scalarRowGroups <= foldedDispatchCapacity","dtypes.T == \"f32\"","sgFullWidth","device.wgslLanguageFeatures.has(\"subgroup_id\")","scalarLanesPerRow > sgMin","scalarLanesPerRow % max(1, sgMin) == 0","subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"foldKind":"\"subgroup_tree\"","useVec4":"false","stageRow":"scalarWordsPerLane <= 8","rowWords":"normSize","wordsPerLane":"scalarWordsPerLane","lanesPerRow":"scalarLanesPerRow","rowsPerGroup":"scalarRowsPerGroup","subgroupWidth":"sgMin","subgroupsPerRow":"scalarLanesPerRow / max(1, sgMin)"},"passes":[{"id":"main","name":"GatedRMSNorm.SubgroupWideRowsScalar","shader":"gated-rms-norm-rows.wgsl.jinja","bindings":["x_x_t","scale_main","gate_main","y_y_t","params"],"dispatch":{"x":"min(scalarRowGroups, DISPATCH_FOLD_WIDTH)","y":"ceilDiv(scalarRowGroups, DISPATCH_FOLD_WIDTH)"}}]}]}123456789101112131415161718192021222324252627281{ "name": "com.microsoft.GatedRMSNorm", "id": "_com_microsoft_gatedrmsnorm_webgpu_3fd919f", "version": 1, "license": "Apache-2.0", "backend": { "type": "webgpu" }, "digest": { "algorithm": "sha256", "files": { "bench.json": "E5LQpx8I5PNcqbNTX4KyCxcXvNNp3cHMKCbDTk1JlFI=", "gated-rms-norm-rows.wgsl.jinja": "FNlhlwGawl2E/vwWNng/ZX+vThDezoBS43E/hxT1/9k=", "manifest.json": "/o1FvJuHt1tdlx9h75CH1UA2wgYdt880zc3UQmntRrg=", "test.json": "o0Og3R+dIxLG/ZwxG7CgIS7tbiRjxtApNu9xFzFxcZg=" } }, "provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } }, "webgpu": { "manifestSpec": "2.1", "variants": { "subgroup_rows_vec4": ["gated-rms-norm-rows.wgsl.jinja"], "packed_rows_vec4": ["gated-rms-norm-rows.wgsl.jinja"], "subgroup_rows_scalar": ["gated-rms-norm-rows.wgsl.jinja"], "packed_rows_scalar": ["gated-rms-norm-rows.wgsl.jinja"], "subgroup_wide_rows_vec4": ["gated-rms-norm-rows.wgsl.jinja"], "subgroup_wide_rows_scalar": ["gated-rms-norm-rows.wgsl.jinja"] } }}{"name":"com.microsoft.GatedRMSNorm","id":"_com_microsoft_gatedrmsnorm_webgpu_3430cc8","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"bls1HdMv/SVeo1aqyTusvYm2/UuSTtu7Shw6HunqgYs=","gated-rms-norm-rows.wgsl.jinja":"tSDqZIr5pk5bjvaQUcEoIWQVv8WrXncs/kIylKUsohM=","manifest.json":"7Jg5nYBdk5/QH7uggZuQKmUk0QLvAlsrIOtbsZZ41uo=","test.json":"o+zaBx5UPhY70DBWc4POgRnaIxnwbnvfvUGdoJVpO8E="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}870 unmodified lines87187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475870 unmodified lines "provenance": { "notes": "Three rows of 6 float32 channels each, processed one lane per row; checks correctness at the smallest possible per-row lane allocation, below the width where multiple lanes would cooperate on one row." } }, { "name": "activation_silu_span_four_single_word", "inputs": { "xT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [16, 4], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "silu" }, "provenance": { "notes": "Explicit silu must match the default SiLU on the same inputs and tolerances." } }, { "name": "activation_swish_span_four_single_word", "inputs": { "xT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [16, 4], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "swish" }, "provenance": { "notes": "Explicit swish must match the default SiLU on the same inputs and tolerances." } }, { "name": "activation_silu_span_four_single_word_f16", "inputs": { "xT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float16", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [16, 4], "tolerance": 0.0005, "relTolerance": 0.002 } }, "attrs": { "activation": "silu" }, "provenance": { "notes": "Explicit silu must match the default SiLU on the same inputs and tolerances." } }, { "name": "activation_swish_span_four_single_word_f16", "inputs": { "xT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float16", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [16, 4], "tolerance": 0.0005, "relTolerance": 0.002 } }, "attrs": { "activation": "swish" }, "provenance": { "notes": "Explicit swish must match the default SiLU on the same inputs and tolerances." } }, { "name": "activation_sigmoid_span_four_single_word", "inputs": { "xT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float32", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [16, 4], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_span_four_single_word_f16", "inputs": { "xT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.47, "cosStep": 0.23 } }, "scaleT": { "dtype": "float16", "shape": [4], "data": { "kind": "values", "values": [0.5, 1.25, -0.75, 2.0] } }, "gateT": { "dtype": "float16", "shape": [16, 4], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.71, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [16, 4], "tolerance": 0.0005, "relTolerance": 0.002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_span_six_scalar_route", "inputs": { "xT": { "dtype": "float32", "shape": [5, 12], "data": { "kind": "fillFloat32", "sinStep": 0.27, "cosStep": 0.61 } }, "scaleT": { "dtype": "float32", "shape": [6], "data": { "kind": "fillFloat32", "sinStep": 0.44, "cosStep": 0.22, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [5, 12], "data": { "kind": "fillFloat32", "sinStep": 0.35, "cosStep": 0.14, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [5, 12], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_short_scalar_float16_c7_r65_wg64_words4", "inputs": { "xT": { "dtype": "float16", "shape": [65, 7], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/short_scalar_x" } } }, "scaleT": { "dtype": "float16", "shape": [7], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/short_scalar_scale" } } }, "gateT": { "dtype": "float16", "shape": [65, 7], "data": { "kind": "cycle", "values": { "$ref": "#/fixtureArrays/short_scalar_gate" } } } }, "outputs": { "yT": { "dtype": "float16", "shape": [65, 7], "tolerance": 0.0005, "relTolerance": 0.002 } }, "tunables": { "WORKGROUP_SIZE": 64, "LANE_WORDS": 4 }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." }, "attrs": { "activation": "sigmoid" } }, { "name": "activation_sigmoid_ort_float_per_head", "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." }, "attrs": { "epsilon": 0.000001, "activation": "sigmoid" }, "inputs": { "xT": { "dtype": "float32", "shape": [1, 4, 4096], "data": { "kind": "fillFloat32", "sinStep": 0.13, "cosStep": 0.29 } }, "scaleT": { "dtype": "float32", "shape": [128], "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.11, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [1, 4, 4096], "data": { "kind": "fillFloat32", "sinStep": 0.07, "cosStep": 0.19, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [1, 4, 4096], "tolerance": 0.000002, "relTolerance": 0.00002 } } }, { "name": "activation_sigmoid_rank4_batched_multi_group", "inputs": { "xT": { "dtype": "float16", "shape": [2, 3, 4, 256], "data": { "kind": "fillFloat32", "sinStep": 0.067, "cosStep": 0.139 } }, "scaleT": { "dtype": "float16", "shape": [64], "data": { "kind": "fillFloat32", "sinStep": 0.29, "cosStep": 0.17, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float16", "shape": [2, 3, 4, 256], "data": { "kind": "fillFloat32", "sinStep": 0.101, "cosStep": 0.211, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [2, 3, 4, 256], "tolerance": 0.0005, "relTolerance": 0.002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_scale_spelled_leading_one", "inputs": { "xT": { "dtype": "float32", "shape": [8, 128], "data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.09 } }, "scaleT": { "dtype": "float32", "shape": [1, 128], "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.11, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [8, 128], "data": { "kind": "fillFloat32", "sinStep": 0.15, "cosStep": 0.53, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [8, 128], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_scale_spelled_trailing_one", "inputs": { "xT": { "dtype": "float32", "shape": [8, 128], "data": { "kind": "fillFloat32", "sinStep": 0.31, "cosStep": 0.09 } }, "scaleT": { "dtype": "float32", "shape": [128, 1], "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.11, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [8, 128], "data": { "kind": "fillFloat32", "sinStep": 0.15, "cosStep": 0.53, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [8, 128], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_epsilon_dominates_statistic", "attrs": { "epsilon": 100, "activation": "sigmoid" }, "inputs": { "xT": { "dtype": "float32", "shape": [4, 16], "data": { "kind": "fillFloat32", "sinStep": 0.33, "cosStep": 0.77 } }, "scaleT": { "dtype": "float32", "shape": [16], "data": { "kind": "fillFloat32", "sinStep": 0.21, "cosStep": 0.49, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [4, 16], "data": { "kind": "fillFloat32", "sinStep": 0.57, "cosStep": 0.17, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [4, 16], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_gate_saturating_tails", "inputs": { "xT": { "dtype": "float32", "shape": [4, 64], "data": { "kind": "fillFloat32", "sinStep": 0.25, "cosStep": 0.55 } }, "scaleT": { "dtype": "float32", "shape": [64], "data": { "kind": "fillFloat32", "sinStep": 0.15, "cosStep": 0.35, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [4, 64], "data": { "kind": "fillFloat32", "sinStep": 0.45, "cosStep": 0.85, "scale": 12.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [4, 64], "tolerance": 0.000002, "relTolerance": 0.00002 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_span_16384_streaming_route", "inputs": { "xT": { "dtype": "float32", "shape": [2, 16384], "data": { "kind": "fillFloat32", "sinStep": 0.0031, "cosStep": 0.0079 } }, "scaleT": { "dtype": "float32", "shape": [16384], "data": { "kind": "fillFloat32", "sinStep": 0.0011, "cosStep": 0.0023, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [2, 16384], "data": { "kind": "fillFloat32", "sinStep": 0.0043, "cosStep": 0.0017, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [2, 16384], "tolerance": 0.00001, "relTolerance": 0.0001 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_span_16384_streaming_route_f16", "inputs": { "xT": { "dtype": "float16", "shape": [2, 16384], "data": { "kind": "fillFloat32", "sinStep": 0.0031, "cosStep": 0.0079 } }, "scaleT": { "dtype": "float16", "shape": [16384], "data": { "kind": "fillFloat32", "sinStep": 0.0011, "cosStep": 0.0023, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float16", "shape": [2, 16384], "data": { "kind": "fillFloat32", "sinStep": 0.0043, "cosStep": 0.0017, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [2, 16384], "tolerance": 0.0008, "relTolerance": 0.003 } }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_wide_subgroup_span_1026_rows_3_wg_256", "inputs": { "xT": { "dtype": "float32", "shape": [3, 1026], "data": { "kind": "fillFloat32", "sinStep": 0.011, "cosStep": 0.047 } }, "scaleT": { "dtype": "float32", "shape": [1026], "data": { "kind": "fillFloat32", "sinStep": 0.019, "cosStep": 0.007, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [3, 1026], "data": { "kind": "fillFloat32", "sinStep": 0.023, "cosStep": 0.059, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [3, 1026], "tolerance": 0.000004, "relTolerance": 0.00004 } }, "tunables": { "WORKGROUP_SIZE": 256 }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_wide_subgroup_span_1028_rows_3_wg_256", "inputs": { "xT": { "dtype": "float32", "shape": [3, 1028], "data": { "kind": "fillFloat32", "sinStep": 0.011, "cosStep": 0.047 } }, "scaleT": { "dtype": "float32", "shape": [1028], "data": { "kind": "fillFloat32", "sinStep": 0.019, "cosStep": 0.007, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [3, 1028], "data": { "kind": "fillFloat32", "sinStep": 0.023, "cosStep": 0.059, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [3, 1028], "tolerance": 0.000004, "relTolerance": 0.00004 } }, "tunables": { "WORKGROUP_SIZE": 256 }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_wide_subgroup_span_2050_rows_3_wg_64", "inputs": { "xT": { "dtype": "float32", "shape": [3, 2050], "data": { "kind": "fillFloat32", "sinStep": 0.011, "cosStep": 0.047 } }, "scaleT": { "dtype": "float32", "shape": [2050], "data": { "kind": "fillFloat32", "sinStep": 0.019, "cosStep": 0.007, "scale": 0.5, "offset": 1.0 } }, "gateT": { "dtype": "float32", "shape": [3, 2050], "data": { "kind": "fillFloat32", "sinStep": 0.023, "cosStep": 0.059, "scale": 2.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [3, 2050], "tolerance": 0.000004, "relTolerance": 0.00004 } }, "tunables": { "WORKGROUP_SIZE": 64 }, "attrs": { "activation": "sigmoid" }, "provenance": { "notes": "Sigmoid activation multiplies the normalized, scaled values by sigmoid(gate), with float32 intermediates; unlike SiLU it applies no extra raw-gate factor." } }, { "name": "activation_sigmoid_hand_float32", "provenance": { "notes": "Unit input rows and epsilon zero give invRMS exactly one. Negative, zero, positive and saturated gates with signed channel scales distinguish sigmoid from SiLU and pin group-scale reuse." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float32", "shape": [4], "data": { "kind": "values", "values": [1.0, -2.0, 0.5, 3.0] } }, "gateT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "values", "values": [-2.0, -1.0, 0.0, 1.0, 2.0, 20.0, -20.0, 100.0] } } }, "outputs": { "yT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "values", "values": [0.11920291930437088, -0.5378828644752502, 0.25, 2.193175792694092, 0.8807970285415649, -2.0, 1.030576846083875e-9, 3.0] }, "tolerance": 3e-7, "relTolerance": 0.000001 } } }, { "name": "activation_sigmoid_hand_float16", "provenance": { "notes": "Unit input rows and epsilon zero give invRMS exactly one. Negative, zero, positive and saturated gates with signed channel scales distinguish sigmoid from SiLU and pin group-scale reuse." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float16", "shape": [4], "data": { "kind": "values", "values": [1.0, -2.0, 0.5, 3.0] } }, "gateT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "values", "values": [-2.0, -1.0, 0.0, 1.0, 2.0, 20.0, -20.0, 100.0] } } }, "outputs": { "yT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "values", "values": [0.11920291930437088, -0.5378828644752502, 0.25, 2.193175792694092, 0.8807970285415649, -2.0, 1.030576846083875e-9, 3.0] }, "tolerance": 0.0005, "relTolerance": 0.002 } } }, { "name": "activation_sigmoid_stable_negative_tail_f32", "provenance": { "source": "ORT: onnxruntime/test/contrib_ops/linear_attention_gates_op_test.cc", "test": "ContribOpGatedRMSNormTest.Float_Sigmoid_StableSaturation", "notes": "Upstream -20 tail inputs and strict expectation. Positive tiny result must survive; zero is outside tolerance." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float32", "shape": [1, 1, 1], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float32", "shape": [1], "data": { "kind": "constant", "value": 1.0 } }, "gateT": { "dtype": "float32", "shape": [1, 1, 1], "data": { "kind": "constant", "value": -20.0 } } }, "outputs": { "yT": { "dtype": "float32", "shape": [1, 1, 1], "data": { "kind": "values", "values": [2.06115369216775e-9] }, "tolerance": 1e-12, "relTolerance": 1e-12 } } }, { "name": "activation_sigmoid_half_activation_stays_f32", "provenance": { "notes": "A half scale of 65504 amplifies sigmoid(-20) into a representable half output. Narrowing the sigmoid to half before multiplication would incorrectly produce zero." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float16", "shape": [1, 1, 1], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float16", "shape": [1], "data": { "kind": "constant", "value": 65504.0 } }, "gateT": { "dtype": "float16", "shape": [1, 1, 1], "data": { "kind": "constant", "value": -20.0 } } }, "outputs": { "yT": { "dtype": "float16", "shape": [1, 1, 1], "data": { "kind": "values", "values": [0.00013506412506103516] }, "tolerance": 0, "relTolerance": 0, "exactRounding": true } } }, { "name": "activation_sigmoid_extreme_gates_float32", "provenance": { "notes": "Finite gate extremes ±65504 and ±1000 saturate sigmoid to one/zero without NaNs, including f16 tensors with f32 activation arithmetic." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float32", "shape": [1, 4], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float32", "shape": [4], "data": { "kind": "constant", "value": 1.0 } }, "gateT": { "dtype": "float32", "shape": [1, 4], "data": { "kind": "values", "values": [-65504.0, 65504.0, -1000.0, 1000.0] } } }, "outputs": { "yT": { "dtype": "float32", "shape": [1, 4], "data": { "kind": "values", "values": [0.0, 1.0, 0.0, 1.0] }, "tolerance": 0, "relTolerance": 0 } } }, { "name": "activation_sigmoid_extreme_gates_float16", "provenance": { "notes": "Finite gate extremes ±65504 and ±1000 saturate sigmoid to one/zero without NaNs, including f16 tensors with f32 activation arithmetic." }, "attrs": { "activation": "sigmoid", "epsilon": 0 }, "inputs": { "xT": { "dtype": "float16", "shape": [1, 4], "data": { "kind": "constant", "value": 1.0 } }, "scaleT": { "dtype": "float16", "shape": [4], "data": { "kind": "constant", "value": 1.0 } }, "gateT": { "dtype": "float16", "shape": [1, 4], "data": { "kind": "values", "values": [-65504.0, 65504.0, -1000.0, 1000.0] } } }, "outputs": { "yT": { "dtype": "float16", "shape": [1, 4], "data": { "kind": "values", "values": [0.0, 1.0, 0.0, 1.0] }, "tolerance": 0, "relTolerance": 0, "exactRounding": true } } } ], "fixtureArrays": {README.md+29-17
build/webgpu/bench.json+12-14
build/webgpu/gated-rms-norm-rows.wgsl.jinja+101-22
build/webgpu/manifest.json+1-238
build/webgpu/metadata.json+1-28
build/webgpu/test.json+599