Xenova HF Staff commited on
Commit
163cdd1
·
verified ·
1 Parent(s): 94aaaa3

sync 4385228f788d

Browse files
README.md CHANGED
@@ -12,7 +12,7 @@ tags:
12
 
13
  ## Description
14
 
15
- Fuses the Engram gate. For each `(batch, sequence, hc_mult)` row it RMS-normalizes `key` and `query` with their per-stream scales, forms `dot = sum(RMSNorm(key) * RMSNorm(query)) / sqrt(hidden_size)`, and writes `sigmoid(sign(dot) * sqrt(max(abs(dot), 1e-6))) * value`, broadcasting the value row shared by every hyper-connection. That `1e-6` floor is fixed and is not `epsilon`; a zero dot product gives a gate of exactly `0.5`. Both sums of squares and the scaled cross term accumulate in one float32 pass, and only the store narrows. Bfloat16 is not implemented.
16
 
17
  See the [ONNX Runtime `EngramGate` contrib-operator spec](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.EngramGate) for the reference semantics.
18
 
@@ -25,12 +25,14 @@ See the [ONNX Runtime `EngramGate` contrib-operator spec](https://github.com/mic
25
  | `valueT` | `value` | `T` | `3` | — | Projected Engram value shared by every hyper-connection, with shape `(batch_size, sequence_length, hidden_size)`. Each row of it is gated `hc_mult` times, once per stream. | required |
26
  | `keyNormScaleT` | `key_norm_scale` | `T` | `2` | — | RMSNorm scale for keys with shape `(hc_mult, hidden_size)`: one weight row per hyper-connection stream, selected by the row's stream index. | required |
27
  | `queryNormScaleT` | `query_norm_scale` | `T` | `2` | — | RMSNorm scale for queries with shape `(hc_mult, hidden_size)`, indexed by the same stream index as the key scale. | required |
 
28
 
29
  ## Outputs
30
 
31
  | Name | Upstream name | Logical dtype | Rank | Shape | Description | Presence |
32
  | --- | --- | --- | --- | --- | --- | --- |
33
  | `outputT` | `output` | `T` | `4` | same as `keyT` | The gated value tensor, with the same shape and dtype as `key`. Every element of a row carries the same gate, so the row's stream index is only observable through the scale lookup. | required |
 
34
 
35
  ## Attributes
36
 
@@ -38,7 +40,7 @@ Default values (overridable per request):
38
 
39
  | Attribute | Default | Description |
40
  | --- | --- | --- |
41
- | `epsilon` | `0.00001` | Constant added to both mean-of-squares denominators before the reciprocal square root. It does not reach the gate: the `1e-6` floor under the square root is a separate fixed constant. |
42
 
43
  ## Type constraints
44
 
@@ -50,40 +52,48 @@ Default values (overridable per request):
50
 
51
  One implementation is selected per call from the device capabilities, the request shapes and the dtypes; these notes say what each one covers.
52
 
53
- - `subgroup_rows_vec4` — One aligned lane group per gated row inside a subgroup, with the row's value words held in registers across the fold. The three accumulators travel as one vector through a segmented butterfly over the low lane bits, so several rows share a subgroup with no workgroup memory and no barrier.
54
- - `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 one shared vector 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.
55
- - `subgroup_rows_scalar` — The barrier-free lane-group schedule for a hidden size that is not a multiple of four: the same segmented butterfly over scalar loads.
56
- - `packed_rows_scalar` — Scalar fallback for a hidden size 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 row still fills the workgroup.
57
 
58
  ## Device requirements
59
 
60
- Some implementation variants require `subgroups`. These are route-specific capabilities, not package-wide requirements; availability also depends on the request shape and dtype.
61
 
62
  ## Files
63
 
64
- - [`metadata.json`](build/webgpu/metadata.json) — kernel metadata (id, digests, per-variant templates, provenance)
65
- - [`manifest.json`](build/webgpu/manifest.json) — the op contract (source of truth)
66
- - [`test.json`](build/webgpu/test.json) — correctness cases
67
- - [`bench.json`](build/webgpu/bench.json) — benchmark cases
68
- - [`engram-gate-rows.wgsl.jinja`](build/webgpu/engram-gate-rows.wgsl.jinja)
 
69
 
70
  ## Use with `@huggingface/kernels`
71
 
72
  ```sh
73
- npm install --save-exact @huggingface/kernels@0.0.1-preview.3
74
  ```
75
 
 
 
76
  Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
77
 
78
  The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
79
  It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
80
 
81
- Replace each `*Data` placeholder with a typed array containing the corresponding input data.
82
-
83
  ```js
84
  import { getKernel } from "@huggingface/kernels";
85
 
86
  const kernel = await getKernel("webgpu-kernels/com.microsoft.EngramGate", { version: 1 });
 
 
 
 
 
 
 
87
  const { outputT } = await kernel({
88
  keyT: { data: keyTData, shape: [1, 1, 1, 2] },
89
  queryT: { data: queryTData, shape: [1, 1, 1, 2] },
@@ -91,4 +101,5 @@ const { outputT } = await kernel({
91
  keyNormScaleT: { data: keyNormScaleTData, shape: [1, 2] },
92
  queryNormScaleT: { data: queryNormScaleTData, shape: [1, 2] },
93
  });
 
94
  ```
 
12
 
13
  ## Description
14
 
15
+ RMS-normalizes key/query rows, scales their dot by `1 / sqrt(hidden_size)`, then broadcasts `sigmoid(sign(dot) * sqrt(max(abs(dot), 1e-6))) * value` across the `hc_mult` hyper-connection streams (parallel copies of the residual stream). The fixed floor differs from `epsilon`; a zero dot gives gate `0.5`. Reductions use float32 and only stores narrow. Optional `gated_value_normed` adds RMS normalization with `conv_norm_scale`: float16 primary values round before its float32 reduction. The op runs in one pass, or two with `gated_value_normed`, with no temporary buffer. Bfloat16 is unsupported.
16
 
17
  See the [ONNX Runtime `EngramGate` contrib-operator spec](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.EngramGate) for the reference semantics.
18
 
 
25
  | `valueT` | `value` | `T` | `3` | — | Projected Engram value shared by every hyper-connection, with shape `(batch_size, sequence_length, hidden_size)`. Each row of it is gated `hc_mult` times, once per stream. | required |
26
  | `keyNormScaleT` | `key_norm_scale` | `T` | `2` | — | RMSNorm scale for keys with shape `(hc_mult, hidden_size)`: one weight row per hyper-connection stream, selected by the row's stream index. | required |
27
  | `queryNormScaleT` | `query_norm_scale` | `T` | `2` | — | RMSNorm scale for queries with shape `(hc_mult, hidden_size)`, indexed by the same stream index as the key scale. | required |
28
+ | `convNormScaleT` | `conv_norm_scale` | `T` | `2` | — | Optional post-gate RMSNorm scale with shape `(hc_mult, hidden_size)` and dtype T. Required for `gated_value_normed`; validated even when that output is absent. | optional |
29
 
30
  ## Outputs
31
 
32
  | Name | Upstream name | Logical dtype | Rank | Shape | Description | Presence |
33
  | --- | --- | --- | --- | --- | --- | --- |
34
  | `outputT` | `output` | `T` | `4` | same as `keyT` | The gated value tensor, with the same shape and dtype as `key`. Every element of a row carries the same gate, so the row's stream index is only observable through the scale lookup. | required |
35
+ | `gatedValueNormedT` | `gated_value_normed` | `T` | `4` | same as `keyT` | Optional RMS-normalized gated value, with the key shape and dtype. Reduces each hidden row after the primary output has rounded to T, then multiplies by its per-stream scale in float32 and narrows the final value to T. Requires `conv_norm_scale`; the primary output remains required. | optional |
36
 
37
  ## Attributes
38
 
 
40
 
41
  | Attribute | Default | Description |
42
  | --- | --- | --- |
43
+ | `epsilon` | `0.00001` | Constant added to both mean-of-squares denominators before the reciprocal square root. It does not reach the gate: the `1e-6` floor under the square root is a separate fixed constant. The optional gated-value normalization uses this same epsilon. |
44
 
45
  ## Type constraints
46
 
 
52
 
53
  One implementation is selected per call from the device capabilities, the request shapes and the dtypes; these notes say what each one covers.
54
 
55
+ - `subgroup_rows_vec4` — Loads four channels per word and reduces each row within a subgroup. A workgroup tree handles devices whose lane layout cannot cover the row with a subgroup collective.
56
+ - `packed_rows_vec4` — Loads four channels per word and reduces each row in workgroup memory. Short rows share a workgroup, and rows too wide to stage in registers use a second input walk.
57
+ - `subgroup_rows_scalar` — Loads individual channels and reduces each row within a subgroup. A workgroup tree handles devices whose lane layout cannot cover the row with a subgroup collective.
58
+ - `packed_rows_scalar` — Loads individual channels and reduces each row in workgroup memory. Short rows share a workgroup, and rows too wide to stage in registers use a second input walk.
59
 
60
  ## Device requirements
61
 
62
+ Some implementation variants require `subgroups`. Other variants run without it; which variant runs also depends on the request's shapes and dtypes.
63
 
64
  ## Files
65
 
66
+ - [`metadata.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/metadata.json) — kernel metadata (id, file digests, manifest spec, provenance)
67
+ - [`manifest.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/manifest.json) — the op contract (source of truth)
68
+ - [`test.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/test.json) — correctness cases
69
+ - [`bench.json`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/bench.json) — benchmark cases
70
+ - [`engram-gate-norm-rows.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/engram-gate-norm-rows.wgsl.jinja)
71
+ - [`engram-gate-rows.wgsl.jinja`](https://huggingface.co/kernels/webgpu-kernels/com.microsoft.EngramGate/blob/v1/build/webgpu/engram-gate-rows.wgsl.jinja)
72
 
73
  ## Use with `@huggingface/kernels`
74
 
75
  ```sh
76
+ npm install --save-exact @huggingface/kernels@0.0.1-preview.4
77
  ```
78
 
79
+ Paste the example into a browser app that resolves npm imports. Serve the app over HTTPS or localhost with WebGPU available.
80
+
81
  Required output shapes and logical data types are inferred from the supplied inputs and attributes; result tensors are allocated automatically.
82
 
83
  The `version: 1` option selects the published kernel contract; it is independent of any operator opset, contrib `since_version`, or model version.
84
  It follows the `v1` branch as fixes land. To pin exact artifact bytes, pass a 40-character commit `revision` instead of `version`.
85
 
 
 
86
  ```js
87
  import { getKernel } from "@huggingface/kernels";
88
 
89
  const kernel = await getKernel("webgpu-kernels/com.microsoft.EngramGate", { version: 1 });
90
+
91
+ const keyTData = Float32Array.of(0, 2.5);
92
+ const queryTData = Float32Array.of(3, 4);
93
+ const valueTData = Float32Array.of(2, -1.5);
94
+ const keyNormScaleTData = Float32Array.of(1, 1);
95
+ const queryNormScaleTData = Float32Array.of(1, 1);
96
+
97
  const { outputT } = await kernel({
98
  keyT: { data: keyTData, shape: [1, 1, 1, 2] },
99
  queryT: { data: queryTData, shape: [1, 1, 1, 2] },
 
101
  keyNormScaleT: { data: keyNormScaleTData, shape: [1, 2] },
102
  queryNormScaleT: { data: queryNormScaleTData, shape: [1, 2] },
103
  });
104
+ console.log({ outputT });
105
  ```
build/webgpu/engram-gate-norm-rows.wgsl.jinja ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% set subgroupRowFold = foldKind == "subgroup_full" or foldKind == "subgroup_butterfly" %}
2
+ {% if subgroupRowFold %}
3
+ enable subgroups;
4
+ {% endif %}
5
+ {{ env.wgsl.resourceDeclarations }}
6
+
7
+ // The previous pass stored the primary output in T. Read that materialized
8
+ // value before accumulating in f32, preserving the primary output's storage rounding.
9
+ const ROW_WORDS: u32 = {{ rowWords }}u;
10
+ const HIDDEN: f32 = {{ hidden }}.0;
11
+ const HC_MULT: u32 = {{ hcMult }}u;
12
+ const EPS: f32 = {{ epsilon }};
13
+ const WG: u32 = {{ workgroupSize }}u;
14
+ const LANES_PER_ROW: u32 = {{ lanesPerRow }}u;
15
+ const ROWS_PER_GROUP: u32 = {{ rowsPerGroup }}u;
16
+ {% if subgroupRowFold or foldKind == "workgroup_tree" %}
17
+ // Native folds retain a complete local-ID row tree for rejected layouts.
18
+ var<workgroup> partials: array<f32, WG>;
19
+ {% endif %}
20
+ {% if subgroupRowFold %}
21
+ // One entry-point proof for algorithms that assign data using local-ID lane
22
+ // blocks. Every subgroup checks all active members; the workgroup accepts only
23
+ // when every subgroup has a valid complete layout. Call once in uniform flow.
24
+ // The rejection flag starts zero through WGSL workgroup initialization.
25
+ // Some Adreno 6xx drivers cannot create a pipeline that calls subgroupAll; a ballot builds wherever subgroups do.
26
+ // A subgroup is valid when no active member is invalid. That is subgroupAll, expressed as a ballot so the shader
27
+ // does not depend on subgroupAll.
28
+ var<workgroup> subgroupLocalLayoutRejected: atomic<u32>;
29
+ var<workgroup> subgroupLocalLayoutAcceptedState: u32;
30
+
31
+ fn subgroupLocalLayoutAccepted(localIndex: u32, memberValid: bool) -> bool {
32
+ let valid = all(subgroupBallot(!memberValid) == vec4<u32>(0u));
33
+ if (subgroupElect() && !valid) {
34
+ atomicStore(&subgroupLocalLayoutRejected, 1u);
35
+ }
36
+ workgroupBarrier();
37
+ if (localIndex == 0u) {
38
+ subgroupLocalLayoutAcceptedState = select(0u, 1u, atomicLoad(&subgroupLocalLayoutRejected) == 0u);
39
+ }
40
+ return workgroupUniformLoad(&subgroupLocalLayoutAcceptedState) != 0u;
41
+ }
42
+ {% endif %}
43
+
44
+ @compute @workgroup_size(WG)
45
+ fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>{% if subgroupRowFold %},
46
+ @builtin(subgroup_size) sg_size: u32,
47
+ @builtin(subgroup_invocation_id) sg_lane: u32{% endif %}) {
48
+ {% if subgroupRowFold %}
49
+ let populationCount = dot(countOneBits(subgroupBallot(true)), vec4<u32>(1u));
50
+ let physicalWidth = max(sg_size, 1u);
51
+ let firstLocalIndex = subgroupBroadcastFirst(lid.x);
52
+ let memberValid = populationCount == sg_size && sg_size > 0u
53
+ && WG % physicalWidth == 0u
54
+ && {% if foldKind == "subgroup_full" %}sg_size == LANES_PER_ROW{% else %}physicalWidth >= LANES_PER_ROW && physicalWidth % LANES_PER_ROW == 0u{% endif %}
55
+ && lid.x / physicalWidth == firstLocalIndex / physicalWidth
56
+ && sg_lane == lid.x % physicalWidth;
57
+ let nativeLayout = subgroupLocalLayoutAccepted(lid.x, memberValid);
58
+ {% endif %}
59
+ let lane = lid.x % LANES_PER_ROW;
60
+ let localRow = lid.x / LANES_PER_ROW;
61
+ // 2D-folded row index: wg.y carries the high bits past the dispatch's per-axis
62
+ // workgroup fold width.
63
+ let row = (wg.x + wg.y * {{ DISPATCH_FOLD_WIDTH }}u) * ROWS_PER_GROUP + localRow;
64
+ let rowValid = row < params.rows;
65
+ // A lane group past the last row folds an empty row and stores nothing, so the
66
+ // collectives and barriers below stay in uniform control flow.
67
+ let limit = select(0u, ROW_WORDS, rowValid);
68
+ let base = row * ROW_WORDS;
69
+ let scaleBase = (row % HC_MULT) * ROW_WORDS;
70
+ var acc = 0.0;
71
+ {% if stageRow %}
72
+ {% for i in range(wordsPerLane) %}
73
+ {% if useVec4 %}
74
+ var vv{{ i }} = vec4<f32>(0.0);
75
+ {% else %}
76
+ var vv{{ i }} = 0.0;
77
+ {% endif %}
78
+ let c{{ i }} = lane + {{ i }}u * LANES_PER_ROW;
79
+ if (c{{ i }} < limit) {
80
+ {% if useVec4 %}
81
+ vv{{ i }} = vec4<f32>(gated[base + c{{ i }}]);
82
+ acc = acc + dot(vv{{ i }}, vv{{ i }});
83
+ {% else %}
84
+ vv{{ i }} = f32(gated[base + c{{ i }}]);
85
+ acc = acc + vv{{ i }} * vv{{ i }};
86
+ {% endif %}
87
+ }
88
+ {% endfor %}
89
+ {% else %}
90
+ for (var c = lane; c < limit; c = c + LANES_PER_ROW) {
91
+ {% if useVec4 %}
92
+ let v = vec4<f32>(gated[base + c]);
93
+ acc = acc + dot(v, v);
94
+ {% else %}
95
+ let v = f32(gated[base + c]);
96
+ acc = acc + v * v;
97
+ {% endif %}
98
+ }
99
+ {% endif %}
100
+ {% if subgroupRowFold %}
101
+ var sumSq = 0.0;
102
+ if (nativeLayout) {
103
+ {% if foldKind == "subgroup_full" %}
104
+ sumSq = subgroupAdd(acc);
105
+ {% else %}
106
+ {% set shuffleSteps = 4 if foldSteps > 4 and (device.adapterInfo.subgroupMinSize | default(0)) > 32 else foldSteps %}
107
+ var folded = acc;
108
+ {% for step in range(shuffleSteps) %}
109
+ folded = folded + subgroupShuffleXor(folded, 1u << {{ step }}u);
110
+ {% endfor %}
111
+ {% if foldSteps > shuffleSteps %}
112
+ partials[lid.x] = folded;
113
+ workgroupBarrier();
114
+ folded = {% for i in range(pow(2, foldSteps - shuffleSteps) | int) %}{{ " + " if not loop.first else "" }}partials[localRow * LANES_PER_ROW + {{ i * 16 }}u]{% endfor %};
115
+ {% endif %}
116
+ sumSq = folded;
117
+ {% endif %}
118
+ } else {
119
+ partials[lid.x] = acc;
120
+ workgroupBarrier();
121
+ // LANES_PER_ROW is a power of two, so the halving stride is uniform across the
122
+ // whole workgroup and every lane reaches every barrier.
123
+ var stride = LANES_PER_ROW / 2u;
124
+ loop {
125
+ if (stride == 0u) {
126
+ break;
127
+ }
128
+ if (lane < stride) {
129
+ partials[lid.x] = partials[lid.x] + partials[lid.x + stride];
130
+ }
131
+ workgroupBarrier();
132
+ stride = stride / 2u;
133
+ }
134
+ sumSq = partials[localRow * LANES_PER_ROW];
135
+ }
136
+ {% elif foldKind == "workgroup_tree" %}
137
+ partials[lid.x] = acc;
138
+ workgroupBarrier();
139
+ // LANES_PER_ROW is a power of two, so the halving stride is uniform across the
140
+ // whole workgroup and every lane reaches every barrier.
141
+ var stride = LANES_PER_ROW / 2u;
142
+ loop {
143
+ if (stride == 0u) {
144
+ break;
145
+ }
146
+ if (lane < stride) {
147
+ partials[lid.x] = partials[lid.x] + partials[lid.x + stride];
148
+ }
149
+ workgroupBarrier();
150
+ stride = stride / 2u;
151
+ }
152
+ let sumSq = partials[localRow * LANES_PER_ROW];
153
+ {% else %}
154
+ let sumSq = acc;
155
+ {% endif %}
156
+ let inv = inverseSqrt(sumSq / HIDDEN + EPS);
157
+ {% if stageRow %}
158
+ {% for i in range(wordsPerLane) %}
159
+ if (c{{ i }} < limit) {
160
+ {% if useVec4 %}
161
+ normed[base + c{{ i }}] = {{ vectorScalar }}(vv{{ i }} * inv * vec4<f32>(convscale[scaleBase + c{{ i }}]));
162
+ {% else %}
163
+ normed[base + c{{ i }}] = {{ scalar }}(vv{{ i }} * inv * f32(convscale[scaleBase + c{{ i }}]));
164
+ {% endif %}
165
+ }
166
+ {% endfor %}
167
+ {% else %}
168
+ for (var c = lane; c < limit; c = c + LANES_PER_ROW) {
169
+ {% if useVec4 %}
170
+ normed[base + c] = {{ vectorScalar }}(vec4<f32>(gated[base + c]) * inv * vec4<f32>(convscale[scaleBase + c]));
171
+ {% else %}
172
+ normed[base + c] = {{ scalar }}(f32(gated[base + c]) * inv * f32(convscale[scaleBase + c]));
173
+ {% endif %}
174
+ }
175
+ {% endif %}
176
+ }
build/webgpu/engram-gate-rows.wgsl.jinja CHANGED
@@ -1,4 +1,5 @@
1
- {% if foldKind == "subgroup_full" or foldKind == "subgroup_butterfly" %}
 
2
  enable subgroups;
3
  {% endif %}
4
  {{ env.wgsl.resourceDeclarations }}
@@ -13,7 +14,7 @@ enable subgroups;
13
  //
14
  // Each row owns a fixed LANE GROUP rather than a whole workgroup. LANES_PER_ROW
15
  // is the smallest power of two that covers the row, capped by the workgroup
16
- // (and, on the subgroup routes, by the subgroup) so several rows are resident at
17
  // once, and widened toward the workgroup when there are too few rows to fill the
18
  // dispatch. The value words stay in registers across the fold.
19
  //
@@ -26,13 +27,33 @@ const GATE_FLOOR: f32 = 0.000001;
26
  const WG: u32 = {{ workgroupSize }}u;
27
  const LANES_PER_ROW: u32 = {{ lanesPerRow }}u;
28
  const ROWS_PER_GROUP: u32 = {{ rowsPerGroup }}u;
29
- {% if foldKind == "workgroup_tree" %}
30
-
31
- // One contiguous LANES_PER_ROW slice per row, carrying all three accumulators as
32
- // one vector. The fold never crosses a slice boundary, so the rows sharing this
33
- // array do not interfere.
34
  var<workgroup> partials: array<vec3<f32>, WG>;
35
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  fn sigmoid_safe(x: f32) -> f32 {
38
  if (x >= 0.0) {
@@ -42,16 +63,99 @@ fn sigmoid_safe(x: f32) -> f32 {
42
  let z = exp(x);
43
  return z / (1.0 + z);
44
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  // sign(0.0) is 0.0 in WGSL, so a zero dot product gives an argument of exactly
47
- // zero and therefore a gate of exactly 0.5. A copysign spelling would map it to
48
- // +sqrt(GATE_FLOOR) instead, which is the divergence upstream calls out.
49
  fn engram_gate(dotValue: f32) -> f32 {
50
  return sigmoid_safe(sign(dotValue) * sqrt(max(abs(dotValue), GATE_FLOOR)));
51
  }
52
 
53
  @compute @workgroup_size(WG)
54
- fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>) {
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  let lane = lid.x % LANES_PER_ROW;
56
  let localRow = lid.x / LANES_PER_ROW;
57
  // 2D-folded row index: wg.y carries the high bits past the dispatch's per-axis
@@ -114,18 +218,46 @@ fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid:
114
  {% endif %}
115
  }
116
  {% endif %}
 
 
 
117
  {% if foldKind == "subgroup_full" %}
118
- let sums = subgroupAdd(acc);
119
- {% elif foldKind == "subgroup_butterfly" %}
120
  // Segmented butterfly: only the low bits of the lane index are exchanged, so each
121
  // aligned group of LANES_PER_ROW lanes folds its own row and one subgroup carries
122
- // several rows without a barrier or any workgroup memory. All three accumulators
123
  // ride one shuffle.
 
124
  var folded = acc;
125
- {% for step in range(foldSteps) %}
126
  folded = folded + subgroupShuffleXor(folded, 1u << {{ step }}u);
127
  {% endfor %}
128
- let sums = folded;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  {% elif foldKind == "workgroup_tree" %}
130
  partials[lid.x] = acc;
131
  workgroupBarrier();
@@ -154,18 +286,18 @@ fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid:
154
  {% for i in range(wordsPerLane) %}
155
  if (c{{ i }} < limit) {
156
  {% if useVec4 %}
157
- out[base + c{{ i }}] = {{ vectorScalar }}(vv{{ i }} * gate);
158
  {% else %}
159
- out[base + c{{ i }}] = {{ scalar }}(vv{{ i }} * gate);
160
  {% endif %}
161
  }
162
  {% endfor %}
163
  {% else %}
164
  for (var c = lane; c < limit; c = c + LANES_PER_ROW) {
165
  {% if useVec4 %}
166
- out[base + c] = {{ vectorScalar }}(vec4<f32>(value[valueBase + c]) * gate);
167
  {% else %}
168
- out[base + c] = {{ scalar }}(f32(value[valueBase + c]) * gate);
169
  {% endif %}
170
  }
171
  {% endif %}
 
1
+ {% set subgroupRowFold = foldKind == "subgroup_full" or foldKind == "subgroup_butterfly" %}
2
+ {% if subgroupRowFold %}
3
  enable subgroups;
4
  {% endif %}
5
  {{ env.wgsl.resourceDeclarations }}
 
14
  //
15
  // Each row owns a fixed LANE GROUP rather than a whole workgroup. LANES_PER_ROW
16
  // is the smallest power of two that covers the row, capped by the workgroup
17
+ // (and, on the subgroup variants, by the subgroup) so several rows are resident at
18
  // once, and widened toward the workgroup when there are too few rows to fill the
19
  // dispatch. The value words stay in registers across the fold.
20
  //
 
27
  const WG: u32 = {{ workgroupSize }}u;
28
  const LANES_PER_ROW: u32 = {{ lanesPerRow }}u;
29
  const ROWS_PER_GROUP: u32 = {{ rowsPerGroup }}u;
30
+ {% if subgroupRowFold or foldKind == "workgroup_tree" %}
31
+ // Native folds retain a complete local-ID row tree for rejected layouts.
 
 
 
32
  var<workgroup> partials: array<vec3<f32>, WG>;
33
  {% endif %}
34
+ {% if subgroupRowFold %}
35
+ // One entry-point proof for algorithms that assign data using local-ID lane
36
+ // blocks. Every subgroup checks all active members; the workgroup accepts only
37
+ // when every subgroup has a valid complete layout. Call once in uniform flow.
38
+ // The rejection flag starts zero through WGSL workgroup initialization.
39
+ // Some Adreno 6xx drivers cannot create a pipeline that calls subgroupAll; a ballot builds wherever subgroups do.
40
+ // A subgroup is valid when no active member is invalid. That is subgroupAll, expressed as a ballot so the shader
41
+ // does not depend on subgroupAll.
42
+ var<workgroup> subgroupLocalLayoutRejected: atomic<u32>;
43
+ var<workgroup> subgroupLocalLayoutAcceptedState: u32;
44
+
45
+ fn subgroupLocalLayoutAccepted(localIndex: u32, memberValid: bool) -> bool {
46
+ let valid = all(subgroupBallot(!memberValid) == vec4<u32>(0u));
47
+ if (subgroupElect() && !valid) {
48
+ atomicStore(&subgroupLocalLayoutRejected, 1u);
49
+ }
50
+ workgroupBarrier();
51
+ if (localIndex == 0u) {
52
+ subgroupLocalLayoutAcceptedState = select(0u, 1u, atomicLoad(&subgroupLocalLayoutRejected) == 0u);
53
+ }
54
+ return workgroupUniformLoad(&subgroupLocalLayoutAcceptedState) != 0u;
55
+ }
56
+ {% endif %}
57
 
58
  fn sigmoid_safe(x: f32) -> f32 {
59
  if (x >= 0.0) {
 
63
  let z = exp(x);
64
  return z / (1.0 + z);
65
  }
66
+ {% set pinHalf = scalar == "f16" and normRequested %}
67
+ {% if pinHalf %}
68
+ {% set halfStageVector = useVec4 %}
69
+ fn round_f16_bits_rte(value: f32) -> u32 {
70
+ let bits = bitcast<u32>(value);
71
+ let sign = (bits >> 16u) & 0x8000u;
72
+ let exponent_f32 = (bits >> 23u) & 0xffu;
73
+ let mantissa_f32 = bits & 0x7fffffu;
74
+
75
+ if (exponent_f32 == 0xffu) {
76
+ if (mantissa_f32 != 0u) {
77
+ return 0x7e00u;
78
+ }
79
+ return sign | 0x7c00u;
80
+ }
81
+
82
+ var exponent_f16 = i32(exponent_f32) - 127 + 15;
83
+ if (exponent_f16 >= 0x1f) {
84
+ return sign | 0x7c00u;
85
+ }
86
+
87
+ if (exponent_f16 <= 0) {
88
+ if (exponent_f16 < -10) {
89
+ return sign;
90
+ }
91
+ let significand = mantissa_f32 | 0x800000u;
92
+ let shift = u32(14 - exponent_f16);
93
+ let halfway = 1u << (shift - 1u);
94
+ let discarded = significand & ((1u << shift) - 1u);
95
+ var fraction = significand >> shift;
96
+ if (discarded > halfway || (discarded == halfway && (fraction & 1u) == 1u)) {
97
+ fraction = fraction + 1u;
98
+ }
99
+ return sign | fraction;
100
+ }
101
+
102
+ let halfway = 1u << 12u;
103
+ let discarded = mantissa_f32 & 0x1fffu;
104
+ var mantissa_f16 = mantissa_f32 >> 13u;
105
+ if (discarded > halfway || (discarded == halfway && (mantissa_f16 & 1u) == 1u)) {
106
+ mantissa_f16 = mantissa_f16 + 1u;
107
+ if (mantissa_f16 == 0x400u) {
108
+ mantissa_f16 = 0u;
109
+ exponent_f16 = exponent_f16 + 1;
110
+ }
111
+ }
112
+ if (exponent_f16 >= 0x1f) {
113
+ return sign | 0x7c00u;
114
+ }
115
+ return sign | (u32(exponent_f16) << 10u) | mantissa_f16;
116
+ }
117
+
118
+ fn widen_f16_bits(value: u32) -> f32 {
119
+ return unpack2x16float(value & 0xffffu).x;
120
+ }
121
+
122
+ // Typed ONNX edges must survive arithmetic fusion and narrow/wide casts.
123
+ // Integer rounding also fixes the ties-to-even rule independently of the
124
+ // implementation's floating-point conversion rounding mode.
125
+ fn half_stage(value: f32) -> f32 {
126
+ return widen_f16_bits(round_f16_bits_rte(value));
127
+ }
128
+ {% if halfStageVector | default(false) %}
129
+
130
+ fn half_stage4(value: vec4<f32>) -> vec4<f32> {
131
+ return vec4<f32>(half_stage(value.x), half_stage(value.y),
132
+ half_stage(value.z), half_stage(value.w));
133
+ }
134
+ {% endif %}
135
+ {% endif %}
136
 
137
  // sign(0.0) is 0.0 in WGSL, so a zero dot product gives an argument of exactly
138
+ // zero and therefore a gate of exactly 0.5. Using copysign would produce
139
+ // +sqrt(GATE_FLOOR) and perturb this gate.
140
  fn engram_gate(dotValue: f32) -> f32 {
141
  return sigmoid_safe(sign(dotValue) * sqrt(max(abs(dotValue), GATE_FLOOR)));
142
  }
143
 
144
  @compute @workgroup_size(WG)
145
+ fn main(@builtin(workgroup_id) wg: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>{% if subgroupRowFold %},
146
+ @builtin(subgroup_size) sg_size: u32,
147
+ @builtin(subgroup_invocation_id) sg_lane: u32{% endif %}) {
148
+ {% if subgroupRowFold %}
149
+ let populationCount = dot(countOneBits(subgroupBallot(true)), vec4<u32>(1u));
150
+ let physicalWidth = max(sg_size, 1u);
151
+ let firstLocalIndex = subgroupBroadcastFirst(lid.x);
152
+ let memberValid = populationCount == sg_size && sg_size > 0u
153
+ && WG % physicalWidth == 0u
154
+ && {% if foldKind == "subgroup_full" %}sg_size == LANES_PER_ROW{% else %}physicalWidth >= LANES_PER_ROW && physicalWidth % LANES_PER_ROW == 0u{% endif %}
155
+ && lid.x / physicalWidth == firstLocalIndex / physicalWidth
156
+ && sg_lane == lid.x % physicalWidth;
157
+ let nativeLayout = subgroupLocalLayoutAccepted(lid.x, memberValid);
158
+ {% endif %}
159
  let lane = lid.x % LANES_PER_ROW;
160
  let localRow = lid.x / LANES_PER_ROW;
161
  // 2D-folded row index: wg.y carries the high bits past the dispatch's per-axis
 
218
  {% endif %}
219
  }
220
  {% endif %}
221
+ {% if subgroupRowFold %}
222
+ var sums = vec3<f32>(0.0);
223
+ if (nativeLayout) {
224
  {% if foldKind == "subgroup_full" %}
225
+ sums = subgroupAdd(acc);
226
+ {% else %}
227
  // Segmented butterfly: only the low bits of the lane index are exchanged, so each
228
  // aligned group of LANES_PER_ROW lanes folds its own row and one subgroup carries
229
+ // several rows through the proven native layout. All three accumulators
230
  // ride one shuffle.
231
+ {% set shuffleSteps = 4 if foldSteps > 4 and (device.adapterInfo.subgroupMinSize | default(0)) > 32 else foldSteps %}
232
  var folded = acc;
233
+ {% for step in range(shuffleSteps) %}
234
  folded = folded + subgroupShuffleXor(folded, 1u << {{ step }}u);
235
  {% endfor %}
236
+ {% if foldSteps > shuffleSteps %}
237
+ partials[lid.x] = folded;
238
+ workgroupBarrier();
239
+ folded = {% for i in range(pow(2, foldSteps - shuffleSteps) | int) %}{{ " + " if not loop.first else "" }}partials[localRow * LANES_PER_ROW + {{ i * 16 }}u]{% endfor %};
240
+ {% endif %}
241
+ sums = folded;
242
+ {% endif %}
243
+ } else {
244
+ partials[lid.x] = acc;
245
+ workgroupBarrier();
246
+ // LANES_PER_ROW is a power of two, so the halving stride is uniform across the
247
+ // whole workgroup and every lane reaches every barrier.
248
+ var stride = LANES_PER_ROW / 2u;
249
+ loop {
250
+ if (stride == 0u) {
251
+ break;
252
+ }
253
+ if (lane < stride) {
254
+ partials[lid.x] = partials[lid.x] + partials[lid.x + stride];
255
+ }
256
+ workgroupBarrier();
257
+ stride = stride / 2u;
258
+ }
259
+ sums = partials[localRow * LANES_PER_ROW];
260
+ }
261
  {% elif foldKind == "workgroup_tree" %}
262
  partials[lid.x] = acc;
263
  workgroupBarrier();
 
286
  {% for i in range(wordsPerLane) %}
287
  if (c{{ i }} < limit) {
288
  {% if useVec4 %}
289
+ out[base + c{{ i }}] = {{ vectorScalar }}({% if pinHalf %}half_stage4(vv{{ i }} * gate){% else %}vv{{ i }} * gate{% endif %});
290
  {% else %}
291
+ out[base + c{{ i }}] = {{ scalar }}({% if pinHalf %}half_stage(vv{{ i }} * gate){% else %}vv{{ i }} * gate{% endif %});
292
  {% endif %}
293
  }
294
  {% endfor %}
295
  {% else %}
296
  for (var c = lane; c < limit; c = c + LANES_PER_ROW) {
297
  {% if useVec4 %}
298
+ out[base + c] = {{ vectorScalar }}({% if pinHalf %}half_stage4(vec4<f32>(value[valueBase + c]) * gate){% else %}vec4<f32>(value[valueBase + c]) * gate{% endif %});
299
  {% else %}
300
+ out[base + c] = {{ scalar }}({% if pinHalf %}half_stage(f32(value[valueBase + c]) * gate){% else %}f32(value[valueBase + c]) * gate{% endif %});
301
  {% endif %}
302
  }
303
  {% endif %}
build/webgpu/manifest.json CHANGED
@@ -1,196 +1 @@
1
- {
2
- "domain": "com.microsoft",
3
- "name": "EngramGate",
4
- "sinceVersion": 1,
5
- "inputs": {
6
- "keyT": { "onnx": "key", "dtype": "T", "rank": 4 },
7
- "queryT": { "onnx": "query", "dtype": "T", "rank": 4 },
8
- "valueT": { "onnx": "value", "dtype": "T", "rank": 3 },
9
- "keyNormScaleT": { "onnx": "key_norm_scale", "dtype": "T", "rank": 2 },
10
- "queryNormScaleT": { "onnx": "query_norm_scale", "dtype": "T", "rank": 2 }
11
- },
12
- "outputs": { "outputT": { "onnx": "output", "dtype": "T", "rank": 4, "shape": "shapes.keyT" } },
13
- "attributes": { "epsilon": { "default": 0.00001 } },
14
- "typeConstraints": { "T": ["float32", "float16"] },
15
- "tunables": {
16
- "WORKGROUP_SIZE": { "default": 256 },
17
- "LANE_WORDS": { "default": 8 },
18
- "MIN_ROW_GROUPS": { "default": 8 }
19
- },
20
- "derive": {
21
- "deviceWorkgroupCap": "min(device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)",
22
- "foldedDispatchCapacity": "min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)",
23
- "hcMult": "dim(shapes.keyT, 2)",
24
- "hidden": "dim(shapes.keyT, 3)",
25
- "rowCount": "dim(shapes.keyT, 0) * dim(shapes.keyT, 1) * hcMult",
26
- "dtypeOk": "tensorDtypes.keyT == tensorDtypes.queryT and tensorDtypes.keyT == tensorDtypes.valueT and tensorDtypes.keyT == tensorDtypes.keyNormScaleT and tensorDtypes.keyT == tensorDtypes.queryNormScaleT and tensorDtypes.keyT == tensorDtypes.outputT and f16Ok(dtypes.T)",
27
- "shapeOk": "ranks.keyT == 4 and ranks.valueT == 3 and hidden > 0 and hcMult > 0 and rowCount > 0 and sameShape(shapes.queryT, shapes.keyT) and sameShape(shapes.outputT, shapes.keyT) and sameShape(prefix(shapes.valueT, 2), prefix(shapes.keyT, 2)) and dim(shapes.valueT, 2) == hidden and sameShape(shapes.keyNormScaleT, suffix(shapes.keyT, 2)) and sameShape(shapes.queryNormScaleT, suffix(shapes.keyT, 2))",
28
- "contractOk": "dtypeOk and shapeOk",
29
- "workgroupOk": "tunables.WORKGROUP_SIZE > 0 and tunables.WORKGROUP_SIZE <= deviceWorkgroupCap and pow2ceil(tunables.WORKGROUP_SIZE) == tunables.WORKGROUP_SIZE and tunables.LANE_WORDS > 0 and tunables.MIN_ROW_GROUPS > 0",
30
- "sharedFoldFits": "tunables.WORKGROUP_SIZE * 16 <= device.limits.maxComputeWorkgroupStorageSize",
31
- "vec4Ok": "hidden % 4 == 0",
32
- "vecWords": "hidden / 4",
33
- "vecPreferredLanes": "max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))",
34
- "vecWideLanes": "max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(vecWords, max(1, tunables.LANE_WORDS))))))",
35
- "vecBaseLanes": "pick([[ceilDiv(vecWords, vecPreferredLanes) <= 8, vecPreferredLanes]], vecWideLanes)",
36
- "vecBaseRowGroups": "ceilDiv(rowCount, max(1, tunables.WORKGROUP_SIZE / max(1, vecBaseLanes)))",
37
- "vecFillLanes": "max(1, min(min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, vecWords))), pow2ceil(max(1, ceilDiv(tunables.MIN_ROW_GROUPS * tunables.WORKGROUP_SIZE, max(1, rowCount))))))",
38
- "vecLanesPerRow": "pick([[vecBaseRowGroups < tunables.MIN_ROW_GROUPS, max(vecBaseLanes, vecFillLanes)]], vecBaseLanes)",
39
- "vecRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, vecLanesPerRow)",
40
- "vecWordsPerLane": "ceilDiv(vecWords, max(1, vecLanesPerRow))",
41
- "vecRowGroups": "ceilDiv(rowCount, max(1, vecRowsPerGroup))",
42
- "scalarPreferredLanes": "max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(hidden, max(8, tunables.LANE_WORDS))))))",
43
- "scalarWideLanes": "max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(hidden, max(1, tunables.LANE_WORDS))))))",
44
- "scalarBaseLanes": "pick([[ceilDiv(hidden, scalarPreferredLanes) <= 8, scalarPreferredLanes]], scalarWideLanes)",
45
- "scalarBaseRowGroups": "ceilDiv(rowCount, max(1, tunables.WORKGROUP_SIZE / max(1, scalarBaseLanes)))",
46
- "scalarFillLanes": "max(1, min(min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, hidden))), pow2ceil(max(1, ceilDiv(tunables.MIN_ROW_GROUPS * tunables.WORKGROUP_SIZE, max(1, rowCount))))))",
47
- "scalarLanesPerRow": "pick([[scalarBaseRowGroups < tunables.MIN_ROW_GROUPS, max(scalarBaseLanes, scalarFillLanes)]], scalarBaseLanes)",
48
- "scalarRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, scalarLanesPerRow)",
49
- "scalarWordsPerLane": "ceilDiv(hidden, max(1, scalarLanesPerRow))",
50
- "scalarRowGroups": "ceilDiv(rowCount, max(1, scalarRowsPerGroup))",
51
- "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",
52
- "sgMin": "device.adapterInfo.subgroupMinSize if subgroupShapeKnown else 0",
53
- "sgFullWidth": "subgroupShapeKnown and device.adapterInfo.subgroupMinSize == device.adapterInfo.subgroupMaxSize",
54
- "sgVecLanesPerRow": "min(sgMin, vecLanesPerRow) if subgroupShapeKnown else 1",
55
- "sgVecRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, sgVecLanesPerRow)",
56
- "sgVecWordsPerLane": "ceilDiv(vecWords, max(1, sgVecLanesPerRow))",
57
- "sgVecRowGroups": "ceilDiv(rowCount, max(1, sgVecRowsPerGroup))",
58
- "sgScalarLanesPerRow": "min(sgMin, scalarLanesPerRow) if subgroupShapeKnown else 1",
59
- "sgScalarRowsPerGroup": "tunables.WORKGROUP_SIZE / max(1, sgScalarLanesPerRow)",
60
- "sgScalarWordsPerLane": "ceilDiv(hidden, max(1, sgScalarLanesPerRow))",
61
- "sgScalarRowGroups": "ceilDiv(rowCount, max(1, sgScalarRowsPerGroup))",
62
- "vectorElement": "\"vec4<\" ~ dtypes.T ~ \">\"",
63
- "workgroupSize": "tunables.WORKGROUP_SIZE",
64
- "epsilon": "attrs.epsilon",
65
- "scalar": "dtypes.T",
66
- "vectorScalar": "vectorElement"
67
- },
68
- "when": ["contractOk", "workgroupOk"],
69
- "bindings": {
70
- "key": { "arg": "keyT", "elementType": "$vectorElement" },
71
- "query": { "arg": "queryT", "elementType": "$vectorElement" },
72
- "value": { "arg": "valueT", "elementType": "$vectorElement" },
73
- "kscale": { "arg": "keyNormScaleT", "elementType": "$vectorElement" },
74
- "qscale": { "arg": "queryNormScaleT", "elementType": "$vectorElement" },
75
- "out": { "arg": "outputT", "elementType": "$vectorElement" },
76
- "key_main": { "arg": "keyT", "name": "key", "elementType": "$scalar" },
77
- "query_main": { "arg": "queryT", "name": "query", "elementType": "$scalar" },
78
- "value_main": { "arg": "valueT", "name": "value", "elementType": "$scalar" },
79
- "kscale_main": { "arg": "keyNormScaleT", "name": "kscale", "elementType": "$scalar" },
80
- "qscale_main": { "arg": "queryNormScaleT", "name": "qscale", "elementType": "$scalar" },
81
- "out_main": { "arg": "outputT", "name": "out", "elementType": "$scalar" },
82
- "params": { "struct": [{ "name": "rows", "type": "u32", "value": "rowCount" }] }
83
- },
84
- "variants": [
85
- {
86
- "id": "subgroup_rows_vec4",
87
- "priority": 30,
88
- "when": ["vec4Ok", "subgroupShapeKnown", "sgVecWordsPerLane >= 1", "sgVecWordsPerLane <= 8", "sgVecRowGroups <= foldedDispatchCapacity"],
89
- "requires": { "features": ["subgroups"] },
90
- "derive": {
91
- "foldKind": "\"none\" if sgVecLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgVecLanesPerRow == sgMin) else \"subgroup_butterfly\")",
92
- "foldSteps": "log2ceil(sgVecLanesPerRow)",
93
- "useVec4": "true",
94
- "stageRow": "true",
95
- "rowWords": "vecWords",
96
- "wordsPerLane": "sgVecWordsPerLane",
97
- "lanesPerRow": "sgVecLanesPerRow",
98
- "rowsPerGroup": "sgVecRowsPerGroup"
99
- },
100
- "passes": [
101
- {
102
- "id": "main",
103
- "name": "EngramGate.SubgroupRowsVec4",
104
- "shader": "engram-gate-rows.wgsl.jinja",
105
- "bindings": ["key", "query", "value", "kscale", "qscale", "out", "params"],
106
- "dispatch": {
107
- "x": "min(sgVecRowGroups, DISPATCH_FOLD_WIDTH)",
108
- "y": "ceilDiv(sgVecRowGroups, DISPATCH_FOLD_WIDTH)"
109
- }
110
- }
111
- ]
112
- },
113
- {
114
- "id": "packed_rows_vec4",
115
- "priority": 20,
116
- "when": ["vec4Ok", "sharedFoldFits", "vecRowGroups <= foldedDispatchCapacity"],
117
- "derive": {
118
- "foldKind": "\"none\" if vecLanesPerRow <= 1 else \"workgroup_tree\"",
119
- "foldSteps": "log2ceil(vecLanesPerRow)",
120
- "useVec4": "true",
121
- "stageRow": "vecWordsPerLane <= 8",
122
- "rowWords": "vecWords",
123
- "wordsPerLane": "vecWordsPerLane",
124
- "lanesPerRow": "vecLanesPerRow",
125
- "rowsPerGroup": "vecRowsPerGroup"
126
- },
127
- "passes": [
128
- {
129
- "id": "main",
130
- "name": "EngramGate.PackedRowsVec4",
131
- "shader": "engram-gate-rows.wgsl.jinja",
132
- "bindings": ["key", "query", "value", "kscale", "qscale", "out", "params"],
133
- "dispatch": {
134
- "x": "min(vecRowGroups, DISPATCH_FOLD_WIDTH)",
135
- "y": "ceilDiv(vecRowGroups, DISPATCH_FOLD_WIDTH)"
136
- }
137
- }
138
- ]
139
- },
140
- {
141
- "id": "subgroup_rows_scalar",
142
- "priority": 10,
143
- "when": ["subgroupShapeKnown", "sgScalarWordsPerLane >= 1", "sgScalarWordsPerLane <= 8", "sgScalarRowGroups <= foldedDispatchCapacity"],
144
- "requires": { "features": ["subgroups"] },
145
- "derive": {
146
- "foldKind": "\"none\" if sgScalarLanesPerRow <= 1 else (\"subgroup_full\" if (sgFullWidth and sgScalarLanesPerRow == sgMin) else \"subgroup_butterfly\")",
147
- "foldSteps": "log2ceil(sgScalarLanesPerRow)",
148
- "useVec4": "false",
149
- "stageRow": "true",
150
- "rowWords": "hidden",
151
- "wordsPerLane": "sgScalarWordsPerLane",
152
- "lanesPerRow": "sgScalarLanesPerRow",
153
- "rowsPerGroup": "sgScalarRowsPerGroup"
154
- },
155
- "passes": [
156
- {
157
- "id": "main",
158
- "name": "EngramGate.SubgroupRowsScalar",
159
- "shader": "engram-gate-rows.wgsl.jinja",
160
- "bindings": ["key_main", "query_main", "value_main", "kscale_main", "qscale_main", "out_main", "params"],
161
- "dispatch": {
162
- "x": "min(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)",
163
- "y": "ceilDiv(sgScalarRowGroups, DISPATCH_FOLD_WIDTH)"
164
- }
165
- }
166
- ]
167
- },
168
- {
169
- "id": "packed_rows_scalar",
170
- "priority": 0,
171
- "when": ["sharedFoldFits", "scalarRowGroups <= foldedDispatchCapacity"],
172
- "derive": {
173
- "foldKind": "\"none\" if scalarLanesPerRow <= 1 else \"workgroup_tree\"",
174
- "foldSteps": "log2ceil(scalarLanesPerRow)",
175
- "useVec4": "false",
176
- "stageRow": "scalarWordsPerLane <= 8",
177
- "rowWords": "hidden",
178
- "wordsPerLane": "scalarWordsPerLane",
179
- "lanesPerRow": "scalarLanesPerRow",
180
- "rowsPerGroup": "scalarRowsPerGroup"
181
- },
182
- "passes": [
183
- {
184
- "id": "main",
185
- "name": "EngramGate.PackedRowsScalar",
186
- "shader": "engram-gate-rows.wgsl.jinja",
187
- "bindings": ["key_main", "query_main", "value_main", "kscale_main", "qscale_main", "out_main", "params"],
188
- "dispatch": {
189
- "x": "min(scalarRowGroups, DISPATCH_FOLD_WIDTH)",
190
- "y": "ceilDiv(scalarRowGroups, DISPATCH_FOLD_WIDTH)"
191
- }
192
- }
193
- ]
194
- }
195
- ]
196
- }
 
1
+ {"domain":"com.microsoft","name":"EngramGate","sinceVersion":1,"inputs":{"keyT":{"onnx":"key","dtype":"T","rank":4},"queryT":{"onnx":"query","dtype":"T","rank":4},"valueT":{"onnx":"value","dtype":"T","rank":3},"keyNormScaleT":{"onnx":"key_norm_scale","dtype":"T","rank":2},"queryNormScaleT":{"onnx":"query_norm_scale","dtype":"T","rank":2},"convNormScaleT":{"onnx":"conv_norm_scale","dtype":"T","rank":2,"optional":true}},"outputs":{"outputT":{"onnx":"output","dtype":"T","rank":4,"shape":"shapes.keyT"},"gatedValueNormedT":{"onnx":"gated_value_normed","dtype":"T","rank":4,"shape":"shapes.keyT","optional":true}},"attributes":{"epsilon":{"default":0.00001}},"typeConstraints":{"T":["float32","float16"]},"tunables":{"WORKGROUP_SIZE":{"default":256},"LANE_WORDS":{"default":8},"MIN_ROW_GROUPS":{"default":8}},"derive":{"deviceWorkgroupCap":"min(device.limits.maxComputeInvocationsPerWorkgroup, device.limits.maxComputeWorkgroupSizeX)","foldedDispatchCapacity":"min(device.limits.maxComputeWorkgroupsPerDimension, 65535) * min(device.limits.maxComputeWorkgroupsPerDimension, 65535)","hcMult":"dim(shapes.keyT, 2)","hidden":"dim(shapes.keyT, 3)","rowCount":"dim(shapes.keyT, 0) * dim(shapes.keyT, 1) * hcMult","dtypeOk":"false if not present.outputT else (tensorDtypes.keyT == tensorDtypes.queryT and tensorDtypes.keyT == tensorDtypes.valueT and tensorDtypes.keyT == tensorDtypes.keyNormScaleT and tensorDtypes.keyT == tensorDtypes.queryNormScaleT and tensorDtypes.keyT == tensorDtypes.outputT and f16Ok(dtypes.T))","shapeOk":"false if not present.outputT else (ranks.keyT == 4 and ranks.valueT == 3 and hidden > 0 and hcMult > 0 and rowCount > 0 and sameShape(shapes.queryT, shapes.keyT) and sameShape(shapes.outputT, shapes.keyT) and sameShape(prefix(shapes.valueT, 2), prefix(shapes.keyT, 2)) and dim(shapes.valueT, 2) == hidden and sameShape(shapes.keyNormScaleT, suffix(shapes.keyT, 2)) and sameShape(shapes.queryNormScaleT, suffix(shapes.keyT, 2)))","normRequested":"present.gatedValueNormedT","convScaleOk":"true if not present.convNormScaleT else (ranks.convNormScaleT == 2 and tensorDtypes.convNormScaleT == tensorDtypes.keyT and sameShape(shapes.convNormScaleT, suffix(shapes.keyT, 2)))","normOutputOk":"true if not normRequested else (present.convNormScaleT and ranks.gatedValueNormedT == 4 and tensorDtypes.gatedValueNormedT == tensorDtypes.keyT and sameShape(shapes.gatedValueNormedT, shapes.keyT))","contractOk":"dtypeOk and shapeOk and convScaleOk and normOutputOk","workgroupOk":"tunables.WORKGROUP_SIZE > 0 and tunables.WORKGROUP_SIZE <= deviceWorkgroupCap and pow2ceil(tunables.WORKGROUP_SIZE) == tunables.WORKGROUP_SIZE and tunables.LANE_WORDS > 0 and tunables.MIN_ROW_GROUPS > 0","sharedFoldFits":"tunables.WORKGROUP_SIZE * 16 <= device.limits.maxComputeWorkgroupStorageSize","vec4Ok":"hidden % 4 == 0","vecWords":"hidden / 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))))))","vecBaseLanes":"pick([[ceilDiv(vecWords, vecPreferredLanes) <= 8, vecPreferredLanes]], vecWideLanes)","vecBaseRowGroups":"ceilDiv(rowCount, max(1, tunables.WORKGROUP_SIZE / max(1, vecBaseLanes)))","vecFillLanes":"max(1, min(min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, vecWords))), pow2ceil(max(1, ceilDiv(tunables.MIN_ROW_GROUPS * tunables.WORKGROUP_SIZE, max(1, rowCount))))))","vecLanesPerRow":"pick([[vecBaseRowGroups < tunables.MIN_ROW_GROUPS, max(vecBaseLanes, vecFillLanes)]], vecBaseLanes)","vecRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, vecLanesPerRow)","vecWordsPerLane":"ceilDiv(vecWords, max(1, vecLanesPerRow))","vecRowGroups":"ceilDiv(rowCount, max(1, vecRowsPerGroup))","scalarPreferredLanes":"max(1, min(tunables.WORKGROUP_SIZE / 2, pow2ceil(max(1, ceilDiv(hidden, max(8, tunables.LANE_WORDS))))))","scalarWideLanes":"max(1, min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, ceilDiv(hidden, max(1, tunables.LANE_WORDS))))))","scalarBaseLanes":"pick([[ceilDiv(hidden, scalarPreferredLanes) <= 8, scalarPreferredLanes]], scalarWideLanes)","scalarBaseRowGroups":"ceilDiv(rowCount, max(1, tunables.WORKGROUP_SIZE / max(1, scalarBaseLanes)))","scalarFillLanes":"max(1, min(min(tunables.WORKGROUP_SIZE, pow2ceil(max(1, hidden))), pow2ceil(max(1, ceilDiv(tunables.MIN_ROW_GROUPS * tunables.WORKGROUP_SIZE, max(1, rowCount))))))","scalarLanesPerRow":"pick([[scalarBaseRowGroups < tunables.MIN_ROW_GROUPS, max(scalarBaseLanes, scalarFillLanes)]], scalarBaseLanes)","scalarRowsPerGroup":"tunables.WORKGROUP_SIZE / max(1, scalarLanesPerRow)","scalarWordsPerLane":"ceilDiv(hidden, 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(hidden, max(1, sgScalarLanesPerRow))","sgScalarRowGroups":"ceilDiv(rowCount, max(1, sgScalarRowsPerGroup))","workgroupSize":"tunables.WORKGROUP_SIZE","epsilon":"attrs.epsilon","scalar":"dtypes.T","vectorScalar":"\"vec4<\" ~ dtypes.T ~ \">\"","subgroupFoldFits":"tunables.WORKGROUP_SIZE * 16 + 8 <= device.limits.maxComputeWorkgroupStorageSize"},"when":["present.outputT","contractOk","workgroupOk"],"bindings":{"key":{"arg":"keyT","elementType":"$rowElement"},"query":{"arg":"queryT","elementType":"$rowElement"},"value":{"arg":"valueT","elementType":"$rowElement"},"kscale":{"arg":"keyNormScaleT","elementType":"$rowElement"},"qscale":{"arg":"queryNormScaleT","elementType":"$rowElement"},"out":{"arg":"outputT","elementType":"$rowElement"},"params":{"struct":[{"name":"rows","type":"u32","value":"rowCount"}]},"gated":{"arg":"outputT","elementType":"$rowElement","buffer":"read-only-storage"},"convscale":{"arg":"convNormScaleT","elementType":"$rowElement"},"normed":{"arg":"gatedValueNormedT","elementType":"$rowElement"}},"variants":[{"id":"subgroup_rows_vec4","priority":30,"when":["vec4Ok","subgroupShapeKnown","sgVecWordsPerLane >= 1","sgVecWordsPerLane <= 8","sgVecRowGroups <= foldedDispatchCapacity","sgVecLanesPerRow <= 1 or subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"useVec4":true,"rowElement":"vectorScalar if useVec4 else scalar","rowWords":"vecWords","lanesPerRow":"sgVecLanesPerRow","rowsPerGroup":"sgVecRowsPerGroup","wordsPerLane":"sgVecWordsPerLane","stageRow":true,"foldSteps":"log2ceil(lanesPerRow)","foldKind":"\"none\" if lanesPerRow <= 1 else (\"subgroup_full\" if sgFullWidth and lanesPerRow == sgMin else \"subgroup_butterfly\")"},"passes":[{"id":"main","name":"EngramGate.SubgroupRowsVec4","shader":"engram-gate-rows.wgsl.jinja","bindings":["key","query","value","kscale","qscale","out","params"],"dispatch":{"x":"min(sgVecRowGroups, 65535)","y":"ceilDiv(sgVecRowGroups, 65535)","z":1}},{"repeat":{"index":"normPass","count":"1 if normRequested else 0"},"passes":[{"id":"normalize","name":"EngramGate.Normalize.subgroup_rows_vec4","shader":"engram-gate-norm-rows.wgsl.jinja","bindings":["gated","convscale","normed","params"],"dispatch":{"x":"min(sgVecRowGroups, 65535)","y":"ceilDiv(sgVecRowGroups, 65535)","z":1}}]}]},{"id":"packed_rows_vec4","priority":20,"when":["vec4Ok","sharedFoldFits","vecRowGroups <= foldedDispatchCapacity"],"derive":{"useVec4":true,"rowElement":"vectorScalar if useVec4 else scalar","rowWords":"vecWords","lanesPerRow":"vecLanesPerRow","rowsPerGroup":"vecRowsPerGroup","wordsPerLane":"vecWordsPerLane","stageRow":"wordsPerLane <= 8","foldSteps":"log2ceil(lanesPerRow)","foldKind":"\"none\" if lanesPerRow <= 1 else (\"workgroup_tree\")"},"passes":[{"id":"main","name":"EngramGate.PackedRowsVec4","shader":"engram-gate-rows.wgsl.jinja","bindings":["key","query","value","kscale","qscale","out","params"],"dispatch":{"x":"min(vecRowGroups, 65535)","y":"ceilDiv(vecRowGroups, 65535)","z":1}},{"repeat":{"index":"normPass","count":"1 if normRequested else 0"},"passes":[{"id":"normalize","name":"EngramGate.Normalize.packed_rows_vec4","shader":"engram-gate-norm-rows.wgsl.jinja","bindings":["gated","convscale","normed","params"],"dispatch":{"x":"min(vecRowGroups, 65535)","y":"ceilDiv(vecRowGroups, 65535)","z":1}}]}]},{"id":"subgroup_rows_scalar","priority":10,"when":["subgroupShapeKnown","sgScalarWordsPerLane >= 1","sgScalarWordsPerLane <= 8","sgScalarRowGroups <= foldedDispatchCapacity","sgScalarLanesPerRow <= 1 or subgroupFoldFits"],"requires":{"features":["subgroups"]},"derive":{"useVec4":false,"rowElement":"vectorScalar if useVec4 else scalar","rowWords":"hidden","lanesPerRow":"sgScalarLanesPerRow","rowsPerGroup":"sgScalarRowsPerGroup","wordsPerLane":"sgScalarWordsPerLane","stageRow":true,"foldSteps":"log2ceil(lanesPerRow)","foldKind":"\"none\" if lanesPerRow <= 1 else (\"subgroup_full\" if sgFullWidth and lanesPerRow == sgMin else \"subgroup_butterfly\")"},"passes":[{"id":"main","name":"EngramGate.SubgroupRowsScalar","shader":"engram-gate-rows.wgsl.jinja","bindings":["key","query","value","kscale","qscale","out","params"],"dispatch":{"x":"min(sgScalarRowGroups, 65535)","y":"ceilDiv(sgScalarRowGroups, 65535)","z":1}},{"repeat":{"index":"normPass","count":"1 if normRequested else 0"},"passes":[{"id":"normalize","name":"EngramGate.Normalize.subgroup_rows_scalar","shader":"engram-gate-norm-rows.wgsl.jinja","bindings":["gated","convscale","normed","params"],"dispatch":{"x":"min(sgScalarRowGroups, 65535)","y":"ceilDiv(sgScalarRowGroups, 65535)","z":1}}]}]},{"id":"packed_rows_scalar","priority":0,"when":["sharedFoldFits","scalarRowGroups <= foldedDispatchCapacity"],"derive":{"useVec4":false,"rowElement":"vectorScalar if useVec4 else scalar","rowWords":"hidden","lanesPerRow":"scalarLanesPerRow","rowsPerGroup":"scalarRowsPerGroup","wordsPerLane":"scalarWordsPerLane","stageRow":"wordsPerLane <= 8","foldSteps":"log2ceil(lanesPerRow)","foldKind":"\"none\" if lanesPerRow <= 1 else (\"workgroup_tree\")"},"passes":[{"id":"main","name":"EngramGate.PackedRowsScalar","shader":"engram-gate-rows.wgsl.jinja","bindings":["key","query","value","kscale","qscale","out","params"],"dispatch":{"x":"min(scalarRowGroups, 65535)","y":"ceilDiv(scalarRowGroups, 65535)","z":1}},{"repeat":{"index":"normPass","count":"1 if normRequested else 0"},"passes":[{"id":"normalize","name":"EngramGate.Normalize.packed_rows_scalar","shader":"engram-gate-norm-rows.wgsl.jinja","bindings":["gated","convscale","normed","params"],"dispatch":{"x":"min(scalarRowGroups, 65535)","y":"ceilDiv(scalarRowGroups, 65535)","z":1}}]}]}]}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/webgpu/metadata.json CHANGED
@@ -1,26 +1 @@
1
- {
2
- "name": "com.microsoft.EngramGate",
3
- "id": "_com_microsoft_engramgate_webgpu_e6b4c45",
4
- "version": 1,
5
- "license": "Apache-2.0",
6
- "backend": { "type": "webgpu" },
7
- "digest": {
8
- "algorithm": "sha256",
9
- "files": {
10
- "bench.json": "1AsNY/KLnWqSi3rI1GdriO0bQ5cfQQukYt9WisteVaE=",
11
- "engram-gate-rows.wgsl.jinja": "q9Z+7afQ+9LFxjks9tQw2xX93Dsen47WaPBW26breLM=",
12
- "manifest.json": "m6y59i8jPJFyMB8AbPpNvfd/t3w9MLtG5/L7rfOQBs8=",
13
- "test.json": "OfAVLi7QPYg7OUihAF7HmAdC/xrIq3qziUYSMchd4DQ="
14
- }
15
- },
16
- "provenance": { "kernel": { "sha": "6fdf6301e2bbcc2f03bf1eaf493b7ad55ef33afc", "dirty": false } },
17
- "webgpu": {
18
- "manifestSpec": "2.1",
19
- "variants": {
20
- "subgroup_rows_vec4": ["engram-gate-rows.wgsl.jinja"],
21
- "packed_rows_vec4": ["engram-gate-rows.wgsl.jinja"],
22
- "subgroup_rows_scalar": ["engram-gate-rows.wgsl.jinja"],
23
- "packed_rows_scalar": ["engram-gate-rows.wgsl.jinja"]
24
- }
25
- }
26
- }
 
1
+ {"name":"com.microsoft.EngramGate","id":"_com_microsoft_engramgate_webgpu_720e24a","version":1,"license":"Apache-2.0","backend":{"type":"webgpu"},"digest":{"algorithm":"sha256","files":{"bench.json":"1AsNY/KLnWqSi3rI1GdriO0bQ5cfQQukYt9WisteVaE=","engram-gate-norm-rows.wgsl.jinja":"WQrUEr5FYc2hHgeRX5+/myzUcHZrNm+Q2O6VeGQP7rY=","engram-gate-rows.wgsl.jinja":"KLdwU/nipo+AR1AKRDoe6YEXqnfxzWOHff4bWekwROE=","manifest.json":"VjD6g329WwgmT9qI6TPs1yn27qZaBBwqES0J6ivjCuY=","test.json":"x6l+hDgeCIT+Is/RvVOUmZL+YneppATvFHEkkfXNV/o="}},"provenance":{"kernel":{"sha":"4385228f788ddaa1bd7aec6a80a20f3ddffd8011","dirty":false}},"webgpu":{"manifestSpec":"2.2"}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
build/webgpu/test.json CHANGED
@@ -1,4 +1,13 @@
1
  {
 
 
 
 
 
 
 
 
 
2
  "cases": [
3
  {
4
  "name": "ort_gate_float",
@@ -55,7 +64,7 @@
55
  "provenance": {
56
  "source": "ORT: onnxruntime/test/contrib_ops/engram_ops_test.cc",
57
  "test": "EngramOpsTest.EngramGateZeroDotProduct",
58
- "notes": "Orthogonal key and query make the dot product vanish, and the gate must be exactly 0.5 rather than sigmoid(sqrt(1e-6)). A copysign spelling of the signed square root fails this case and nothing else."
59
  },
60
  "attrs": { "epsilon": 0.00001 },
61
  "inputs": {
@@ -87,18 +96,12 @@
87
  "keyT": {
88
  "dtype": "float32",
89
  "shape": [1, 2, 2, 4],
90
- "data": {
91
- "kind": "values",
92
- "values": [-0.7833269238471985, -0.5646424293518066, -0.295520156621933, 5.960464477539063e-8, 0.29552027583122253, 0.5646424889564514, 0.7833269834518433, 0.9320391416549683, 0.9974949955940247, 0.9738476276397705, 0.8632094264030457, 0.6754631400108337, 0.4273796081542969, 0.14112000167369843, -0.15774588286876678, -0.4425203502178192]
93
- }
94
  },
95
  "queryT": {
96
  "dtype": "float32",
97
  "shape": [1, 2, 2, 4],
98
- "data": {
99
- "kind": "values",
100
- "values": [0.9320390820503235, 0.81341552734375, 0.6442177295684814, 0.434965580701828, 0.19866937398910522, -0.04997912049293518, -0.295520156621933, -0.5226871967315674, -0.7173560857772827, -0.8674232363700867, -0.9635581374168396, -0.9997837543487549, -0.9738476276397705, -0.8873624205589294, -0.745705246925354, -0.5576837658882141]
101
- }
102
  },
103
  "valueT": {
104
  "dtype": "float32",
@@ -129,10 +132,7 @@
129
  "outputT": {
130
  "dtype": "float32",
131
  "shape": [1, 2, 2, 4],
132
- "data": {
133
- "kind": "values",
134
- "values": [0.10116856545209885, 0.17708569765090942, 0.23153036832809448, 0.2579009234905243, 0.1250687837600708, 0.21892069280147552, 0.28622743487358093, 0.3188278377056122, 0.2453785240650177, 0.21087177097797394, 0.15079589188098907, 0.07243525236845016, 0.3465985059738159, 0.2978575527667999, 0.21300002932548523, 0.10231518745422363]
135
- },
136
  "tolerance": 0.000002,
137
  "relTolerance": 0.00002
138
  }
@@ -150,18 +150,12 @@
150
  "keyT": {
151
  "dtype": "float16",
152
  "shape": [1, 2, 2, 4],
153
- "data": {
154
- "kind": "values",
155
- "values": [-0.783203125, -0.564453125, -0.29541015625, 5.960464477539063e-8, 0.29541015625, 0.564453125, 0.783203125, 0.93212890625, 0.99755859375, 0.9736328125, 0.86328125, 0.67529296875, 0.427490234375, 0.14111328125, -0.15771484375, -0.442626953125]
156
- }
157
  },
158
  "queryT": {
159
  "dtype": "float16",
160
  "shape": [1, 2, 2, 4],
161
- "data": {
162
- "kind": "values",
163
- "values": [0.93212890625, 0.8134765625, 0.64404296875, 0.43505859375, 0.1986083984375, -0.04998779296875, -0.29541015625, -0.5224609375, -0.71728515625, -0.8671875, -0.96337890625, -1.0, -0.9736328125, -0.88720703125, -0.74560546875, -0.5576171875]
164
- }
165
  },
166
  "valueT": {
167
  "dtype": "float16",
@@ -192,10 +186,7 @@
192
  "outputT": {
193
  "dtype": "float16",
194
  "shape": [1, 2, 2, 4],
195
- "data": {
196
- "kind": "values",
197
- "values": [0.1011962890625, 0.1771240234375, 0.2315673828125, 0.2578125, 0.125, 0.2188720703125, 0.2861328125, 0.31884765625, 0.245361328125, 0.2109375, 0.15087890625, 0.07244873046875, 0.3466796875, 0.2978515625, 0.213134765625, 0.10235595703125]
198
- },
199
  "tolerance": 0.0005,
200
  "relTolerance": 0.002
201
  }
@@ -204,7 +195,7 @@
204
  {
205
  "name": "ort_multi_iteration_h260_float",
206
  "provenance": {
207
- "notes": "Upstream's multi-iteration reduction geometry: batch 1, sequence 2, hc_mult 2, hidden 260, the smallest multiple of four above both of the upstream accumulation strides. The inputs use a bounded fill rather than upstream's sine wave, so the expectation comes from the reference."
208
  },
209
  "inputs": {
210
  "keyT": {
@@ -285,7 +276,7 @@
285
  {
286
  "name": "nanowhale_decode_h320_f32",
287
  "provenance": {
288
- "notes": "One decoded token of the DeepSeek-V4 nanowhale geometry: four hyper-connection streams of 320 channels. Four rows in the whole dispatch, the launch-bound end of the operator."
289
  },
290
  "inputs": {
291
  "keyT": {
@@ -326,7 +317,7 @@
326
  {
327
  "name": "nanowhale_prefill_s5_hc3_h320_f16",
328
  "provenance": {
329
- "notes": "Fifteen rows of 320 at three streams: neither the row count nor the stream count divides the rows a workgroup carries, so the trailing lane groups fold an empty row."
330
  },
331
  "inputs": {
332
  "keyT": {
@@ -367,9 +358,7 @@
367
  },
368
  {
369
  "name": "v4flash_decode_h4096_f32",
370
- "provenance": {
371
- "notes": "One decoded token of the DeepSeek-V4 v4flash geometry: four streams of 4096 channels, the widest row that still stages in registers."
372
- },
373
  "inputs": {
374
  "keyT": {
375
  "dtype": "float32",
@@ -444,7 +433,7 @@
444
  {
445
  "name": "batched_hc2_h64_f32",
446
  "provenance": {
447
- "notes": "Batch 3, sequence 5, two streams of 64 channels: a row is far narrower than a subgroup here, so several rows fold inside one subgroup and a wrong batch, token or stream index moves the gate."
448
  },
449
  "inputs": {
450
  "keyT": {
@@ -567,9 +556,7 @@
567
  },
568
  {
569
  "name": "wide_h8192_f16",
570
- "provenance": {
571
- "notes": "8192 channels per row: the row fills a whole workgroup and every lane stages the maximum eight vector words."
572
- },
573
  "inputs": {
574
  "keyT": {
575
  "dtype": "float16",
@@ -603,9 +590,7 @@
603
  },
604
  {
605
  "name": "wide_h16384_f32",
606
- "provenance": {
607
- "notes": "16384 channels per row: too wide to stage, so the statistic pass and the store pass each walk the row."
608
- },
609
  "inputs": {
610
  "keyT": {
611
  "dtype": "float32",
@@ -639,9 +624,7 @@
639
  },
640
  {
641
  "name": "scalar_h6_f32",
642
- "provenance": {
643
- "notes": "Six channels per row: not a multiple of four, so the scalar route runs, and narrow enough that one lane group covers three rows of a subgroup."
644
- },
645
  "inputs": {
646
  "keyT": {
647
  "dtype": "float32",
@@ -675,7 +658,9 @@
675
  },
676
  {
677
  "name": "scalar_h130_f16",
678
- "provenance": { "notes": "130 channels per row in float16: the scalar route with several words per lane." },
 
 
679
  "inputs": {
680
  "keyT": {
681
  "dtype": "float16",
@@ -709,9 +694,7 @@
709
  },
710
  {
711
  "name": "scalar_h1_f32",
712
- "provenance": {
713
- "notes": "One channel per row: a single lane owns the whole row, so no fold runs at all and the statistic is the lane's own accumulator."
714
- },
715
  "inputs": {
716
  "keyT": {
717
  "dtype": "float32",
@@ -745,9 +728,7 @@
745
  },
746
  {
747
  "name": "scalar_wide_h2050_f32",
748
- "provenance": {
749
- "notes": "2050 channels per row: an unvectorizable width too wide to stage, the streaming scalar route."
750
- },
751
  "inputs": {
752
  "keyT": {
753
  "dtype": "float32",
@@ -782,7 +763,7 @@
782
  {
783
  "name": "epsilon_dominant_h8_f32",
784
  "provenance": {
785
- "notes": "An epsilon of 1 against key and query rows two orders of magnitude smaller: the epsilon term, not the mean of squares, sets both inverse-RMS factors, which pins epsilon to the normalization denominators and away from the gate's own floor."
786
  },
787
  "attrs": { "epsilon": 1 },
788
  "inputs": {
@@ -1915,7 +1896,7 @@
1915
  "outputT": { "shape": [1, 65, 3, 252], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1916
  },
1917
  "provenance": {
1918
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
1919
  }
1920
  },
1921
  {
@@ -1951,7 +1932,7 @@
1951
  "outputT": { "shape": [1, 65, 3, 260], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1952
  },
1953
  "provenance": {
1954
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
1955
  }
1956
  },
1957
  {
@@ -1987,7 +1968,7 @@
1987
  "outputT": { "shape": [1, 43, 3, 320], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1988
  },
1989
  "provenance": {
1990
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
1991
  }
1992
  },
1993
  {
@@ -2023,7 +2004,7 @@
2023
  "outputT": { "shape": [1, 43, 3, 516], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
2024
  },
2025
  "provenance": {
2026
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2027
  }
2028
  },
2029
  {
@@ -2060,7 +2041,7 @@
2060
  },
2061
  "tunables": { "WORKGROUP_SIZE": 64 },
2062
  "provenance": {
2063
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2064
  }
2065
  },
2066
  {
@@ -2096,7 +2077,7 @@
2096
  "outputT": { "shape": [1, 1, 3, 320], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
2097
  },
2098
  "provenance": {
2099
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2100
  }
2101
  },
2102
  {
@@ -2132,7 +2113,7 @@
2132
  "outputT": { "shape": [1, 65, 3, 252], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2133
  },
2134
  "provenance": {
2135
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2136
  }
2137
  },
2138
  {
@@ -2168,7 +2149,7 @@
2168
  "outputT": { "shape": [1, 65, 3, 260], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2169
  },
2170
  "provenance": {
2171
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2172
  }
2173
  },
2174
  {
@@ -2204,7 +2185,7 @@
2204
  "outputT": { "shape": [1, 43, 3, 320], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2205
  },
2206
  "provenance": {
2207
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2208
  }
2209
  },
2210
  {
@@ -2240,7 +2221,7 @@
2240
  "outputT": { "shape": [1, 43, 3, 516], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2241
  },
2242
  "provenance": {
2243
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2244
  }
2245
  },
2246
  {
@@ -2277,7 +2258,7 @@
2277
  },
2278
  "tunables": { "WORKGROUP_SIZE": 64 },
2279
  "provenance": {
2280
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
2281
  }
2282
  },
2283
  {
@@ -2313,7 +2294,1203 @@
2313
  "outputT": { "shape": [1, 1, 3, 320], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2314
  },
2315
  "provenance": {
2316
- "notes": "Lane-depth boundary with nonuniform affine scales and hyper-connection value reuse; row and vector tails exercise shared row groups at the default dtype tolerance."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2317
  }
2318
  }
2319
  ]
 
1
  {
2
+ "fixtureArrays": {
3
+ "ort_vectorized_h4_float_input_keyT": [-0.7833269238471985, -0.5646424293518066, -0.295520156621933, 5.960464477539063e-8, 0.29552027583122253, 0.5646424889564514, 0.7833269834518433, 0.9320391416549683, 0.9974949955940247, 0.9738476276397705, 0.8632094264030457, 0.6754631400108337, 0.4273796081542969, 0.14112000167369843, -0.15774588286876678, -0.4425203502178192],
4
+ "ort_vectorized_h4_float_input_queryT": [0.9320390820503235, 0.81341552734375, 0.6442177295684814, 0.434965580701828, 0.19866937398910522, -0.04997912049293518, -0.295520156621933, -0.5226871967315674, -0.7173560857772827, -0.8674232363700867, -0.9635581374168396, -0.9997837543487549, -0.9738476276397705, -0.8873624205589294, -0.745705246925354, -0.5576837658882141],
5
+ "ort_vectorized_h4_float_output_outputT": [0.10116856545209885, 0.17708569765090942, 0.23153036832809448, 0.2579009234905243, 0.1250687837600708, 0.21892069280147552, 0.28622743487358093, 0.3188278377056122, 0.2453785240650177, 0.21087177097797394, 0.15079589188098907, 0.07243525236845016, 0.3465985059738159, 0.2978575527667999, 0.21300002932548523, 0.10231518745422363],
6
+ "ort_vectorized_h4_float16_input_keyT": [-0.783203125, -0.564453125, -0.29541015625, 5.960464477539063e-8, 0.29541015625, 0.564453125, 0.783203125, 0.93212890625, 0.99755859375, 0.9736328125, 0.86328125, 0.67529296875, 0.427490234375, 0.14111328125, -0.15771484375, -0.442626953125],
7
+ "ort_vectorized_h4_float16_input_queryT": [0.93212890625, 0.8134765625, 0.64404296875, 0.43505859375, 0.1986083984375, -0.04998779296875, -0.29541015625, -0.5224609375, -0.71728515625, -0.8671875, -0.96337890625, -1, -0.9736328125, -0.88720703125, -0.74560546875, -0.5576171875],
8
+ "ort_vectorized_h4_float16_output_outputT": [0.1011962890625, 0.1771240234375, 0.2315673828125, 0.2578125, 0.125, 0.2188720703125, 0.2861328125, 0.31884765625, 0.245361328125, 0.2109375, 0.15087890625, 0.07244873046875, 0.3466796875, 0.2978515625, 0.213134765625, 0.10235595703125],
9
+ "hand_per_stream_float32_output_gatedValueNormedT": [1, -2, -3, 0, 0.5, 1, 4, -2, -1, 2, 3, 0, -0.5, -1, -4, 2]
10
+ },
11
  "cases": [
12
  {
13
  "name": "ort_gate_float",
 
64
  "provenance": {
65
  "source": "ORT: onnxruntime/test/contrib_ops/engram_ops_test.cc",
66
  "test": "EngramOpsTest.EngramGateZeroDotProduct",
67
+ "notes": "Orthogonal key and query make the dot product vanish, and the gate must be exactly 0.5 rather than sigmoid(sqrt(1e-6))."
68
  },
69
  "attrs": { "epsilon": 0.00001 },
70
  "inputs": {
 
96
  "keyT": {
97
  "dtype": "float32",
98
  "shape": [1, 2, 2, 4],
99
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_input_keyT" } }
 
 
 
100
  },
101
  "queryT": {
102
  "dtype": "float32",
103
  "shape": [1, 2, 2, 4],
104
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_input_queryT" } }
 
 
 
105
  },
106
  "valueT": {
107
  "dtype": "float32",
 
132
  "outputT": {
133
  "dtype": "float32",
134
  "shape": [1, 2, 2, 4],
135
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_output_outputT" } },
 
 
 
136
  "tolerance": 0.000002,
137
  "relTolerance": 0.00002
138
  }
 
150
  "keyT": {
151
  "dtype": "float16",
152
  "shape": [1, 2, 2, 4],
153
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_input_keyT" } }
 
 
 
154
  },
155
  "queryT": {
156
  "dtype": "float16",
157
  "shape": [1, 2, 2, 4],
158
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_input_queryT" } }
 
 
 
159
  },
160
  "valueT": {
161
  "dtype": "float16",
 
186
  "outputT": {
187
  "dtype": "float16",
188
  "shape": [1, 2, 2, 4],
189
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_output_outputT" } },
 
 
 
190
  "tolerance": 0.0005,
191
  "relTolerance": 0.002
192
  }
 
195
  {
196
  "name": "ort_multi_iteration_h260_float",
197
  "provenance": {
198
+ "notes": "Batch 1, sequence 2, two hyper-connection streams and hidden size 260 (a multiple of four above 256). The inputs use a bounded fill rather than upstream's sine wave, so the expectation comes from the reference."
199
  },
200
  "inputs": {
201
  "keyT": {
 
276
  {
277
  "name": "nanowhale_decode_h320_f32",
278
  "provenance": {
279
+ "notes": "One decoded token of the DeepSeek-V4 nanowhale geometry: four hyper-connection streams of 320 channels, four rows in all."
280
  },
281
  "inputs": {
282
  "keyT": {
 
317
  {
318
  "name": "nanowhale_prefill_s5_hc3_h320_f16",
319
  "provenance": {
320
+ "notes": "Five tokens with three hyper-connection streams of 320 channels in float16: 15 rows in all."
321
  },
322
  "inputs": {
323
  "keyT": {
 
358
  },
359
  {
360
  "name": "v4flash_decode_h4096_f32",
361
+ "provenance": { "notes": "One decoded token of the DeepSeek-V4 v4flash geometry: four streams of 4096 channels." },
 
 
362
  "inputs": {
363
  "keyT": {
364
  "dtype": "float32",
 
433
  {
434
  "name": "batched_hc2_h64_f32",
435
  "provenance": {
436
+ "notes": "Batch 3, sequence 5 and two streams of 64 channels; a wrong batch, token or stream index moves the gate."
437
  },
438
  "inputs": {
439
  "keyT": {
 
556
  },
557
  {
558
  "name": "wide_h8192_f16",
559
+ "provenance": { "notes": "8192 channels per row, with two streams in float16." },
 
 
560
  "inputs": {
561
  "keyT": {
562
  "dtype": "float16",
 
590
  },
591
  {
592
  "name": "wide_h16384_f32",
593
+ "provenance": { "notes": "16384 channels per row, with two streams in float32." },
 
 
594
  "inputs": {
595
  "keyT": {
596
  "dtype": "float32",
 
624
  },
625
  {
626
  "name": "scalar_h6_f32",
627
+ "provenance": { "notes": "Six channels per row (not a multiple of four): batch 1, 5 tokens and 3 streams." },
 
 
628
  "inputs": {
629
  "keyT": {
630
  "dtype": "float32",
 
658
  },
659
  {
660
  "name": "scalar_h130_f16",
661
+ "provenance": {
662
+ "notes": "130 channels per row (not a multiple of four) in float16: batch 2, 3 tokens and 2 streams."
663
+ },
664
  "inputs": {
665
  "keyT": {
666
  "dtype": "float16",
 
694
  },
695
  {
696
  "name": "scalar_h1_f32",
697
+ "provenance": { "notes": "One channel per row, so each row's statistic is a single value." },
 
 
698
  "inputs": {
699
  "keyT": {
700
  "dtype": "float32",
 
728
  },
729
  {
730
  "name": "scalar_wide_h2050_f32",
731
+ "provenance": { "notes": "2050 channels per row (not a multiple of four), with two streams." },
 
 
732
  "inputs": {
733
  "keyT": {
734
  "dtype": "float32",
 
763
  {
764
  "name": "epsilon_dominant_h8_f32",
765
  "provenance": {
766
+ "notes": "An epsilon of 1 against key and query rows two orders of magnitude smaller: the epsilon term, not the mean of squares, sets both inverse-RMS factors."
767
  },
768
  "attrs": { "epsilon": 1 },
769
  "inputs": {
 
1896
  "outputT": { "shape": [1, 65, 3, 252], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1897
  },
1898
  "provenance": {
1899
+ "notes": "float32 input with 3 streams of 252 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
1900
  }
1901
  },
1902
  {
 
1932
  "outputT": { "shape": [1, 65, 3, 260], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1933
  },
1934
  "provenance": {
1935
+ "notes": "float32 input with 3 streams of 260 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
1936
  }
1937
  },
1938
  {
 
1968
  "outputT": { "shape": [1, 43, 3, 320], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
1969
  },
1970
  "provenance": {
1971
+ "notes": "float32 input with 3 streams of 320 channels over 43 tokens (129 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
1972
  }
1973
  },
1974
  {
 
2004
  "outputT": { "shape": [1, 43, 3, 516], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
2005
  },
2006
  "provenance": {
2007
+ "notes": "float32 input with 3 streams of 516 channels over 43 tokens (129 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2008
  }
2009
  },
2010
  {
 
2041
  },
2042
  "tunables": { "WORKGROUP_SIZE": 64 },
2043
  "provenance": {
2044
+ "notes": "float32 input with 3 streams of 1028 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2045
  }
2046
  },
2047
  {
 
2077
  "outputT": { "shape": [1, 1, 3, 320], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 }
2078
  },
2079
  "provenance": {
2080
+ "notes": "float32 input with 3 streams of 320 channels over 1 token (3 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2081
  }
2082
  },
2083
  {
 
2113
  "outputT": { "shape": [1, 65, 3, 252], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2114
  },
2115
  "provenance": {
2116
+ "notes": "float16 input with 3 streams of 252 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2117
  }
2118
  },
2119
  {
 
2149
  "outputT": { "shape": [1, 65, 3, 260], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2150
  },
2151
  "provenance": {
2152
+ "notes": "float16 input with 3 streams of 260 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2153
  }
2154
  },
2155
  {
 
2185
  "outputT": { "shape": [1, 43, 3, 320], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2186
  },
2187
  "provenance": {
2188
+ "notes": "float16 input with 3 streams of 320 channels over 43 tokens (129 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2189
  }
2190
  },
2191
  {
 
2221
  "outputT": { "shape": [1, 43, 3, 516], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2222
  },
2223
  "provenance": {
2224
+ "notes": "float16 input with 3 streams of 516 channels over 43 tokens (129 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2225
  }
2226
  },
2227
  {
 
2258
  },
2259
  "tunables": { "WORKGROUP_SIZE": 64 },
2260
  "provenance": {
2261
+ "notes": "float16 input with 3 streams of 1028 channels over 65 tokens (195 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2262
  }
2263
  },
2264
  {
 
2294
  "outputT": { "shape": [1, 1, 3, 320], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
2295
  },
2296
  "provenance": {
2297
+ "notes": "float16 input with 3 streams of 320 channels over 1 token (3 rows), nonuniform affine scales and a value shared across the streams, at the default dtype tolerance."
2298
+ }
2299
+ },
2300
+ {
2301
+ "name": "ort_normed_float32",
2302
+ "provenance": {
2303
+ "source": "ORT: onnxruntime/test/contrib_ops/engram_ops_test.cc",
2304
+ "test": "EngramOpsTest.EngramGateNormedFloat",
2305
+ "notes": "Upstream normalized-output inputs verbatim; expected outputs use float32 arithmetic with the gated output rounded to the tensor type before it is normalized."
2306
+ },
2307
+ "inputs": {
2308
+ "keyT": {
2309
+ "dtype": "float32",
2310
+ "shape": [1, 1, 2, 2],
2311
+ "data": { "kind": "values", "values": [0.5, 1.0, -0.25, 0.75] }
2312
+ },
2313
+ "queryT": {
2314
+ "dtype": "float32",
2315
+ "shape": [1, 1, 2, 2],
2316
+ "data": { "kind": "values", "values": [3.0, 4.0, -1.0, 2.0] }
2317
+ },
2318
+ "valueT": { "dtype": "float32", "shape": [1, 1, 2], "data": { "kind": "values", "values": [2.0, -1.5] } },
2319
+ "keyNormScaleT": {
2320
+ "dtype": "float32",
2321
+ "shape": [2, 2],
2322
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.5, 0.5] }
2323
+ },
2324
+ "queryNormScaleT": {
2325
+ "dtype": "float32",
2326
+ "shape": [2, 2],
2327
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.0, 2.0] }
2328
+ },
2329
+ "convNormScaleT": {
2330
+ "dtype": "float32",
2331
+ "shape": [2, 2],
2332
+ "data": { "kind": "values", "values": [1.0, 2.0, 0.5, 1.0] }
2333
+ }
2334
+ },
2335
+ "outputs": {
2336
+ "outputT": { "dtype": "float32", "shape": [1, 1, 2, 2], "tolerance": 0.000002, "relTolerance": 0.00002 },
2337
+ "gatedValueNormedT": {
2338
+ "dtype": "float32",
2339
+ "shape": [1, 1, 2, 2],
2340
+ "tolerance": 0.000002,
2341
+ "relTolerance": 0.00002
2342
+ }
2343
+ }
2344
+ },
2345
+ {
2346
+ "name": "hand_per_stream_float32",
2347
+ "provenance": {
2348
+ "notes": "Orthogonal nonzero keys and queries give exact gate 0.5; epsilon zero and unit-magnitude stored values make invRMS exactly one. Two tokens with opposite signs and two nonuniform scale rows pin hidden-axis reduction and stream indexing."
2349
+ },
2350
+ "attrs": { "epsilon": 0 },
2351
+ "inputs": {
2352
+ "keyT": {
2353
+ "dtype": "float32",
2354
+ "shape": [1, 2, 2, 4],
2355
+ "data": { "kind": "cycle", "values": [1.0, 0.0, 0.0, 0.0] }
2356
+ },
2357
+ "queryT": {
2358
+ "dtype": "float32",
2359
+ "shape": [1, 2, 2, 4],
2360
+ "data": { "kind": "cycle", "values": [0.0, 1.0, 0.0, 0.0] }
2361
+ },
2362
+ "valueT": {
2363
+ "dtype": "float32",
2364
+ "shape": [1, 2, 4],
2365
+ "data": { "kind": "values", "values": [2.0, -2.0, 2.0, -2.0, -2.0, 2.0, -2.0, 2.0] }
2366
+ },
2367
+ "keyNormScaleT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2368
+ "queryNormScaleT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2369
+ "convNormScaleT": {
2370
+ "dtype": "float32",
2371
+ "shape": [2, 4],
2372
+ "data": { "kind": "values", "values": [1.0, 2.0, -3.0, 0.0, 0.5, -1.0, 4.0, 2.0] }
2373
+ }
2374
+ },
2375
+ "outputs": {
2376
+ "outputT": {
2377
+ "dtype": "float32",
2378
+ "shape": [1, 2, 2, 4],
2379
+ "data": { "kind": "cycle", "values": [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0] },
2380
+ "tolerance": 0,
2381
+ "relTolerance": 0
2382
+ },
2383
+ "gatedValueNormedT": {
2384
+ "dtype": "float32",
2385
+ "shape": [1, 2, 2, 4],
2386
+ "data": {
2387
+ "kind": "values",
2388
+ "values": { "$ref": "#/fixtureArrays/hand_per_stream_float32_output_gatedValueNormedT" }
2389
+ },
2390
+ "tolerance": 0,
2391
+ "relTolerance": 0
2392
+ }
2393
+ }
2394
+ },
2395
+ {
2396
+ "name": "scale_only_float32",
2397
+ "provenance": { "notes": "A valid scale input is supplied without requesting the optional normalized output." },
2398
+ "attrs": { "epsilon": 0 },
2399
+ "inputs": {
2400
+ "keyT": {
2401
+ "dtype": "float32",
2402
+ "shape": [1, 2, 2, 4],
2403
+ "data": { "kind": "cycle", "values": [1.0, 0.0, 0.0, 0.0] }
2404
+ },
2405
+ "queryT": {
2406
+ "dtype": "float32",
2407
+ "shape": [1, 2, 2, 4],
2408
+ "data": { "kind": "cycle", "values": [0.0, 1.0, 0.0, 0.0] }
2409
+ },
2410
+ "valueT": {
2411
+ "dtype": "float32",
2412
+ "shape": [1, 2, 4],
2413
+ "data": { "kind": "values", "values": [2.0, -2.0, 2.0, -2.0, -2.0, 2.0, -2.0, 2.0] }
2414
+ },
2415
+ "keyNormScaleT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2416
+ "queryNormScaleT": { "dtype": "float32", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2417
+ "convNormScaleT": {
2418
+ "dtype": "float32",
2419
+ "shape": [2, 4],
2420
+ "data": { "kind": "values", "values": [1.0, 2.0, -3.0, 0.0, 0.5, -1.0, 4.0, 2.0] }
2421
+ }
2422
+ },
2423
+ "outputs": {
2424
+ "outputT": {
2425
+ "dtype": "float32",
2426
+ "shape": [1, 2, 2, 4],
2427
+ "data": { "kind": "cycle", "values": [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0] },
2428
+ "tolerance": 0,
2429
+ "relTolerance": 0
2430
+ }
2431
+ }
2432
+ },
2433
+ {
2434
+ "name": "ort_normed_float16",
2435
+ "provenance": {
2436
+ "source": "ORT: onnxruntime/test/contrib_ops/engram_ops_test.cc",
2437
+ "test": "EngramOpsTest.EngramGateNormedFloat16",
2438
+ "notes": "Upstream normalized-output inputs verbatim; expected outputs use float32 arithmetic with the gated output rounded to the tensor type before it is normalized."
2439
+ },
2440
+ "inputs": {
2441
+ "keyT": {
2442
+ "dtype": "float16",
2443
+ "shape": [1, 1, 2, 2],
2444
+ "data": { "kind": "values", "values": [0.5, 1.0, -0.25, 0.75] }
2445
+ },
2446
+ "queryT": {
2447
+ "dtype": "float16",
2448
+ "shape": [1, 1, 2, 2],
2449
+ "data": { "kind": "values", "values": [3.0, 4.0, -1.0, 2.0] }
2450
+ },
2451
+ "valueT": { "dtype": "float16", "shape": [1, 1, 2], "data": { "kind": "values", "values": [2.0, -1.5] } },
2452
+ "keyNormScaleT": {
2453
+ "dtype": "float16",
2454
+ "shape": [2, 2],
2455
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.5, 0.5] }
2456
+ },
2457
+ "queryNormScaleT": {
2458
+ "dtype": "float16",
2459
+ "shape": [2, 2],
2460
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.0, 2.0] }
2461
+ },
2462
+ "convNormScaleT": {
2463
+ "dtype": "float16",
2464
+ "shape": [2, 2],
2465
+ "data": { "kind": "values", "values": [1.0, 2.0, 0.5, 1.0] }
2466
+ }
2467
+ },
2468
+ "outputs": {
2469
+ "outputT": { "dtype": "float16", "shape": [1, 1, 2, 2], "tolerance": 0.0005, "relTolerance": 0.002 },
2470
+ "gatedValueNormedT": { "dtype": "float16", "shape": [1, 1, 2, 2], "tolerance": 0.0005, "relTolerance": 0.002 }
2471
+ }
2472
+ },
2473
+ {
2474
+ "name": "hand_per_stream_float16",
2475
+ "provenance": {
2476
+ "notes": "Orthogonal nonzero keys and queries give exact gate 0.5; epsilon zero and unit-magnitude stored values make invRMS exactly one. Two tokens with opposite signs and two nonuniform scale rows pin hidden-axis reduction and stream indexing."
2477
+ },
2478
+ "attrs": { "epsilon": 0 },
2479
+ "inputs": {
2480
+ "keyT": {
2481
+ "dtype": "float16",
2482
+ "shape": [1, 2, 2, 4],
2483
+ "data": { "kind": "cycle", "values": [1.0, 0.0, 0.0, 0.0] }
2484
+ },
2485
+ "queryT": {
2486
+ "dtype": "float16",
2487
+ "shape": [1, 2, 2, 4],
2488
+ "data": { "kind": "cycle", "values": [0.0, 1.0, 0.0, 0.0] }
2489
+ },
2490
+ "valueT": {
2491
+ "dtype": "float16",
2492
+ "shape": [1, 2, 4],
2493
+ "data": { "kind": "values", "values": [2.0, -2.0, 2.0, -2.0, -2.0, 2.0, -2.0, 2.0] }
2494
+ },
2495
+ "keyNormScaleT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2496
+ "queryNormScaleT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2497
+ "convNormScaleT": {
2498
+ "dtype": "float16",
2499
+ "shape": [2, 4],
2500
+ "data": { "kind": "values", "values": [1.0, 2.0, -3.0, 0.0, 0.5, -1.0, 4.0, 2.0] }
2501
+ }
2502
+ },
2503
+ "outputs": {
2504
+ "outputT": {
2505
+ "dtype": "float16",
2506
+ "shape": [1, 2, 2, 4],
2507
+ "data": { "kind": "cycle", "values": [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0] },
2508
+ "tolerance": 0,
2509
+ "relTolerance": 0,
2510
+ "exactRounding": true
2511
+ },
2512
+ "gatedValueNormedT": {
2513
+ "dtype": "float16",
2514
+ "shape": [1, 2, 2, 4],
2515
+ "data": {
2516
+ "kind": "values",
2517
+ "values": { "$ref": "#/fixtureArrays/hand_per_stream_float32_output_gatedValueNormedT" }
2518
+ },
2519
+ "tolerance": 0,
2520
+ "relTolerance": 0,
2521
+ "exactRounding": true
2522
+ }
2523
+ }
2524
+ },
2525
+ {
2526
+ "name": "scale_only_float16",
2527
+ "provenance": { "notes": "A valid scale input is supplied without requesting the optional normalized output." },
2528
+ "attrs": { "epsilon": 0 },
2529
+ "inputs": {
2530
+ "keyT": {
2531
+ "dtype": "float16",
2532
+ "shape": [1, 2, 2, 4],
2533
+ "data": { "kind": "cycle", "values": [1.0, 0.0, 0.0, 0.0] }
2534
+ },
2535
+ "queryT": {
2536
+ "dtype": "float16",
2537
+ "shape": [1, 2, 2, 4],
2538
+ "data": { "kind": "cycle", "values": [0.0, 1.0, 0.0, 0.0] }
2539
+ },
2540
+ "valueT": {
2541
+ "dtype": "float16",
2542
+ "shape": [1, 2, 4],
2543
+ "data": { "kind": "values", "values": [2.0, -2.0, 2.0, -2.0, -2.0, 2.0, -2.0, 2.0] }
2544
+ },
2545
+ "keyNormScaleT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2546
+ "queryNormScaleT": { "dtype": "float16", "shape": [2, 4], "data": { "kind": "constant", "value": 1.0 } },
2547
+ "convNormScaleT": {
2548
+ "dtype": "float16",
2549
+ "shape": [2, 4],
2550
+ "data": { "kind": "values", "values": [1.0, 2.0, -3.0, 0.0, 0.5, -1.0, 4.0, 2.0] }
2551
+ }
2552
+ },
2553
+ "outputs": {
2554
+ "outputT": {
2555
+ "dtype": "float16",
2556
+ "shape": [1, 2, 2, 4],
2557
+ "data": { "kind": "cycle", "values": [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0] },
2558
+ "tolerance": 0,
2559
+ "relTolerance": 0,
2560
+ "exactRounding": true
2561
+ }
2562
+ }
2563
+ },
2564
+ {
2565
+ "name": "round_to_half_before_norm",
2566
+ "provenance": {
2567
+ "notes": "The gated output is rounded to float16 before it is normalized: skipping that rounding yields a normalized first value of 1.021484375 instead of 1.0224609375. Primary values are away from float16 midpoints."
2568
+ },
2569
+ "attrs": { "epsilon": 0.00001 },
2570
+ "inputs": {
2571
+ "keyT": { "dtype": "float16", "shape": [1, 1, 1, 2], "data": { "kind": "values", "values": [0.0, 2.5] } },
2572
+ "queryT": { "dtype": "float16", "shape": [1, 1, 1, 2], "data": { "kind": "values", "values": [3.0, 4.0] } },
2573
+ "valueT": {
2574
+ "dtype": "float16",
2575
+ "shape": [1, 1, 2],
2576
+ "data": { "kind": "values", "values": [0.13037109375, 0.12457275390625] }
2577
+ },
2578
+ "keyNormScaleT": { "dtype": "float16", "shape": [1, 2], "data": { "kind": "values", "values": [1.0, 1.0] } },
2579
+ "queryNormScaleT": { "dtype": "float16", "shape": [1, 2], "data": { "kind": "values", "values": [1.0, 1.0] } },
2580
+ "convNormScaleT": { "dtype": "float16", "shape": [1, 2], "data": { "kind": "constant", "value": 1.0 } }
2581
+ },
2582
+ "outputs": {
2583
+ "outputT": {
2584
+ "dtype": "float16",
2585
+ "shape": [1, 1, 1, 2],
2586
+ "data": { "kind": "values", "values": [0.096923828125, 0.09259033203125] },
2587
+ "tolerance": 0.0005,
2588
+ "relTolerance": 0.002
2589
+ },
2590
+ "gatedValueNormedT": {
2591
+ "dtype": "float16",
2592
+ "shape": [1, 1, 1, 2],
2593
+ "data": { "kind": "values", "values": [1.0224609375, 0.9765625] },
2594
+ "tolerance": 0,
2595
+ "relTolerance": 0,
2596
+ "exactRounding": true
2597
+ }
2598
+ }
2599
+ },
2600
+ {
2601
+ "name": "norm_ort_vectorized_h4_float",
2602
+ "provenance": {
2603
+ "notes": "float32 input [1,2,2,4] with a convNormScaleT of shape [2, 4] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2604
+ },
2605
+ "attrs": { "epsilon": 0.00001 },
2606
+ "inputs": {
2607
+ "keyT": {
2608
+ "dtype": "float32",
2609
+ "shape": [1, 2, 2, 4],
2610
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_input_keyT" } }
2611
+ },
2612
+ "queryT": {
2613
+ "dtype": "float32",
2614
+ "shape": [1, 2, 2, 4],
2615
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_input_queryT" } }
2616
+ },
2617
+ "valueT": {
2618
+ "dtype": "float32",
2619
+ "shape": [1, 2, 4],
2620
+ "data": {
2621
+ "kind": "values",
2622
+ "values": [0.3894183337688446, 0.681638777256012, 0.8912073373794556, 0.9927129745483398, 0.9738476276397705, 0.8368987441062927, 0.5984721779823303, 0.28747788071632385]
2623
+ }
2624
+ },
2625
+ "keyNormScaleT": {
2626
+ "dtype": "float32",
2627
+ "shape": [2, 4],
2628
+ "data": {
2629
+ "kind": "values",
2630
+ "values": [0.5646424889564514, 0.6442177295684814, 0.7173560857772827, 0.7833269238471985, 0.8414710164070129, 0.8912073373794556, 0.9320390820503235, 0.9635581374168396]
2631
+ }
2632
+ },
2633
+ "queryNormScaleT": {
2634
+ "dtype": "float32",
2635
+ "shape": [2, 4],
2636
+ "data": {
2637
+ "kind": "values",
2638
+ "values": [0.9854497313499451, 0.9489846229553223, 0.8912073373794556, 0.8134154677391052, 0.7173560857772827, 0.605186402797699, 0.47942548990249634, 0.3428977131843567]
2639
+ }
2640
+ },
2641
+ "convNormScaleT": {
2642
+ "dtype": "float32",
2643
+ "shape": [2, 4],
2644
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2645
+ }
2646
+ },
2647
+ "outputs": {
2648
+ "outputT": {
2649
+ "dtype": "float32",
2650
+ "shape": [1, 2, 2, 4],
2651
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float_output_outputT" } },
2652
+ "tolerance": 0.000002,
2653
+ "relTolerance": 0.00002
2654
+ },
2655
+ "gatedValueNormedT": {
2656
+ "dtype": "float32",
2657
+ "shape": [1, 2, 2, 4],
2658
+ "tolerance": 0.000002,
2659
+ "relTolerance": 0.00002
2660
+ }
2661
+ }
2662
+ },
2663
+ {
2664
+ "name": "norm_ort_vectorized_h4_float16",
2665
+ "provenance": {
2666
+ "notes": "float16 input [1,2,2,4] with a convNormScaleT of shape [2, 4] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2667
+ },
2668
+ "attrs": { "epsilon": 0.00001 },
2669
+ "inputs": {
2670
+ "keyT": {
2671
+ "dtype": "float16",
2672
+ "shape": [1, 2, 2, 4],
2673
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_input_keyT" } }
2674
+ },
2675
+ "queryT": {
2676
+ "dtype": "float16",
2677
+ "shape": [1, 2, 2, 4],
2678
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_input_queryT" } }
2679
+ },
2680
+ "valueT": {
2681
+ "dtype": "float16",
2682
+ "shape": [1, 2, 4],
2683
+ "data": {
2684
+ "kind": "values",
2685
+ "values": [0.389404296875, 0.681640625, 0.89111328125, 0.99267578125, 0.9736328125, 0.8369140625, 0.5986328125, 0.28759765625]
2686
+ }
2687
+ },
2688
+ "keyNormScaleT": {
2689
+ "dtype": "float16",
2690
+ "shape": [2, 4],
2691
+ "data": {
2692
+ "kind": "values",
2693
+ "values": [0.564453125, 0.64404296875, 0.71728515625, 0.783203125, 0.84130859375, 0.89111328125, 0.93212890625, 0.96337890625]
2694
+ }
2695
+ },
2696
+ "queryNormScaleT": {
2697
+ "dtype": "float16",
2698
+ "shape": [2, 4],
2699
+ "data": {
2700
+ "kind": "values",
2701
+ "values": [0.9853515625, 0.94921875, 0.89111328125, 0.8134765625, 0.71728515625, 0.60498046875, 0.4794921875, 0.343017578125]
2702
+ }
2703
+ },
2704
+ "convNormScaleT": {
2705
+ "dtype": "float16",
2706
+ "shape": [2, 4],
2707
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2708
+ }
2709
+ },
2710
+ "outputs": {
2711
+ "outputT": {
2712
+ "dtype": "float16",
2713
+ "shape": [1, 2, 2, 4],
2714
+ "data": { "kind": "values", "values": { "$ref": "#/fixtureArrays/ort_vectorized_h4_float16_output_outputT" } },
2715
+ "tolerance": 0.0005,
2716
+ "relTolerance": 0.002
2717
+ },
2718
+ "gatedValueNormedT": { "dtype": "float16", "shape": [1, 2, 2, 4], "tolerance": 0.0005, "relTolerance": 0.002 }
2719
+ }
2720
+ },
2721
+ {
2722
+ "name": "norm_ort_multi_iteration_h260_float",
2723
+ "provenance": {
2724
+ "notes": "float32 input [1,2,2,260] with a convNormScaleT of shape [2, 260] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2725
+ },
2726
+ "inputs": {
2727
+ "keyT": {
2728
+ "dtype": "float32",
2729
+ "shape": [1, 2, 2, 260],
2730
+ "data": { "kind": "fillFloat32", "sinStep": 0.12, "cosStep": 0.3, "scale": 1.0 }
2731
+ },
2732
+ "queryT": {
2733
+ "dtype": "float32",
2734
+ "shape": [1, 2, 2, 260],
2735
+ "data": { "kind": "fillFloat32", "sinStep": 0.18, "cosStep": 0.34, "scale": 1.0 }
2736
+ },
2737
+ "valueT": {
2738
+ "dtype": "float32",
2739
+ "shape": [1, 2, 260],
2740
+ "data": { "kind": "fillFloat32", "sinStep": 0.24, "cosStep": 0.39999999999999997, "scale": 1.0 }
2741
+ },
2742
+ "keyNormScaleT": {
2743
+ "dtype": "float32",
2744
+ "shape": [2, 260],
2745
+ "data": { "kind": "fillFloat32", "sinStep": 0.14, "cosStep": 0.42, "scale": 0.5, "offset": 1.0 }
2746
+ },
2747
+ "queryNormScaleT": {
2748
+ "dtype": "float32",
2749
+ "shape": [2, 260],
2750
+ "data": { "kind": "fillFloat32", "sinStep": 0.16, "cosStep": 0.48, "scale": 0.5, "offset": 1.0 }
2751
+ },
2752
+ "convNormScaleT": {
2753
+ "dtype": "float32",
2754
+ "shape": [2, 260],
2755
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2756
+ }
2757
+ },
2758
+ "outputs": {
2759
+ "outputT": { "dtype": "float32", "shape": [1, 2, 2, 260], "tolerance": 0.000002, "relTolerance": 0.00002 },
2760
+ "gatedValueNormedT": {
2761
+ "dtype": "float32",
2762
+ "shape": [1, 2, 2, 260],
2763
+ "tolerance": 0.000002,
2764
+ "relTolerance": 0.00002
2765
+ }
2766
+ }
2767
+ },
2768
+ {
2769
+ "name": "norm_ort_multi_iteration_h260_float16",
2770
+ "provenance": {
2771
+ "notes": "float16 input [1,2,2,260] with a convNormScaleT of shape [2, 260] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2772
+ },
2773
+ "inputs": {
2774
+ "keyT": {
2775
+ "dtype": "float16",
2776
+ "shape": [1, 2, 2, 260],
2777
+ "data": { "kind": "fillFloat32", "sinStep": 0.18000000000000002, "cosStep": 0.36, "scale": 1.0 }
2778
+ },
2779
+ "queryT": {
2780
+ "dtype": "float16",
2781
+ "shape": [1, 2, 2, 260],
2782
+ "data": { "kind": "fillFloat32", "sinStep": 0.24000000000000002, "cosStep": 0.4, "scale": 1.0 }
2783
+ },
2784
+ "valueT": {
2785
+ "dtype": "float16",
2786
+ "shape": [1, 2, 260],
2787
+ "data": {
2788
+ "kind": "fillFloat32",
2789
+ "sinStep": 0.30000000000000004,
2790
+ "cosStep": 0.45999999999999996,
2791
+ "scale": 1.0
2792
+ }
2793
+ },
2794
+ "keyNormScaleT": {
2795
+ "dtype": "float16",
2796
+ "shape": [2, 260],
2797
+ "data": { "kind": "fillFloat32", "sinStep": 0.2, "cosStep": 0.48, "scale": 0.5, "offset": 1.0 }
2798
+ },
2799
+ "queryNormScaleT": {
2800
+ "dtype": "float16",
2801
+ "shape": [2, 260],
2802
+ "data": {
2803
+ "kind": "fillFloat32",
2804
+ "sinStep": 0.22000000000000003,
2805
+ "cosStep": 0.54,
2806
+ "scale": 0.5,
2807
+ "offset": 1.0
2808
+ }
2809
+ },
2810
+ "convNormScaleT": {
2811
+ "dtype": "float16",
2812
+ "shape": [2, 260],
2813
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2814
+ }
2815
+ },
2816
+ "outputs": {
2817
+ "outputT": { "dtype": "float16", "shape": [1, 2, 2, 260], "tolerance": 0.0005, "relTolerance": 0.002 },
2818
+ "gatedValueNormedT": { "dtype": "float16", "shape": [1, 2, 2, 260], "tolerance": 0.0005, "relTolerance": 0.002 }
2819
+ }
2820
+ },
2821
+ {
2822
+ "name": "norm_batched_hc2_h64_f32",
2823
+ "provenance": {
2824
+ "notes": "float32 input [3,5,2,64] with a convNormScaleT of shape [2, 64] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2825
+ },
2826
+ "inputs": {
2827
+ "keyT": {
2828
+ "dtype": "float32",
2829
+ "shape": [3, 5, 2, 64],
2830
+ "data": { "kind": "fillFloat32", "sinStep": 0.42, "cosStep": 0.6, "scale": 1.0 }
2831
+ },
2832
+ "queryT": {
2833
+ "dtype": "float32",
2834
+ "shape": [3, 5, 2, 64],
2835
+ "data": { "kind": "fillFloat32", "sinStep": 0.48, "cosStep": 0.64, "scale": 1.0 }
2836
+ },
2837
+ "valueT": {
2838
+ "dtype": "float32",
2839
+ "shape": [3, 5, 64],
2840
+ "data": { "kind": "fillFloat32", "sinStep": 0.54, "cosStep": 0.7, "scale": 1.0 }
2841
+ },
2842
+ "keyNormScaleT": {
2843
+ "dtype": "float32",
2844
+ "shape": [2, 64],
2845
+ "data": {
2846
+ "kind": "fillFloat32",
2847
+ "sinStep": 0.43999999999999995,
2848
+ "cosStep": 0.72,
2849
+ "scale": 0.5,
2850
+ "offset": 1.0
2851
+ }
2852
+ },
2853
+ "queryNormScaleT": {
2854
+ "dtype": "float32",
2855
+ "shape": [2, 64],
2856
+ "data": {
2857
+ "kind": "fillFloat32",
2858
+ "sinStep": 0.45999999999999996,
2859
+ "cosStep": 0.78,
2860
+ "scale": 0.5,
2861
+ "offset": 1.0
2862
+ }
2863
+ },
2864
+ "convNormScaleT": {
2865
+ "dtype": "float32",
2866
+ "shape": [2, 64],
2867
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2868
+ }
2869
+ },
2870
+ "outputs": {
2871
+ "outputT": { "dtype": "float32", "shape": [3, 5, 2, 64], "tolerance": 0.000002, "relTolerance": 0.00002 },
2872
+ "gatedValueNormedT": {
2873
+ "dtype": "float32",
2874
+ "shape": [3, 5, 2, 64],
2875
+ "tolerance": 0.000002,
2876
+ "relTolerance": 0.00002
2877
+ }
2878
+ }
2879
+ },
2880
+ {
2881
+ "name": "norm_batched_hc3_h128_f16",
2882
+ "provenance": {
2883
+ "notes": "float16 input [2,3,3,128] with a convNormScaleT of shape [3, 128] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2884
+ },
2885
+ "inputs": {
2886
+ "keyT": {
2887
+ "dtype": "float16",
2888
+ "shape": [2, 3, 3, 128],
2889
+ "data": { "kind": "fillFloat32", "sinStep": 0.44, "cosStep": 0.62, "scale": 1.0 }
2890
+ },
2891
+ "queryT": {
2892
+ "dtype": "float16",
2893
+ "shape": [2, 3, 3, 128],
2894
+ "data": { "kind": "fillFloat32", "sinStep": 0.5, "cosStep": 0.66, "scale": 1.0 }
2895
+ },
2896
+ "valueT": {
2897
+ "dtype": "float16",
2898
+ "shape": [2, 3, 128],
2899
+ "data": { "kind": "fillFloat32", "sinStep": 0.56, "cosStep": 0.72, "scale": 1.0 }
2900
+ },
2901
+ "keyNormScaleT": {
2902
+ "dtype": "float16",
2903
+ "shape": [3, 128],
2904
+ "data": {
2905
+ "kind": "fillFloat32",
2906
+ "sinStep": 0.45999999999999996,
2907
+ "cosStep": 0.74,
2908
+ "scale": 0.5,
2909
+ "offset": 1.0
2910
+ }
2911
+ },
2912
+ "queryNormScaleT": {
2913
+ "dtype": "float16",
2914
+ "shape": [3, 128],
2915
+ "data": { "kind": "fillFloat32", "sinStep": 0.48, "cosStep": 0.8, "scale": 0.5, "offset": 1.0 }
2916
+ },
2917
+ "convNormScaleT": {
2918
+ "dtype": "float16",
2919
+ "shape": [3, 128],
2920
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2921
+ }
2922
+ },
2923
+ "outputs": {
2924
+ "outputT": { "dtype": "float16", "shape": [2, 3, 3, 128], "tolerance": 0.0005, "relTolerance": 0.002 },
2925
+ "gatedValueNormedT": { "dtype": "float16", "shape": [2, 3, 3, 128], "tolerance": 0.0005, "relTolerance": 0.002 }
2926
+ }
2927
+ },
2928
+ {
2929
+ "name": "norm_scalar_h6_f32",
2930
+ "provenance": {
2931
+ "notes": "float32 input [1,5,3,6] with a convNormScaleT of shape [3, 6] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2932
+ },
2933
+ "inputs": {
2934
+ "keyT": {
2935
+ "dtype": "float32",
2936
+ "shape": [1, 5, 3, 6],
2937
+ "data": { "kind": "fillFloat32", "sinStep": 0.62, "cosStep": 0.8, "scale": 1.0 }
2938
+ },
2939
+ "queryT": {
2940
+ "dtype": "float32",
2941
+ "shape": [1, 5, 3, 6],
2942
+ "data": { "kind": "fillFloat32", "sinStep": 0.6799999999999999, "cosStep": 0.84, "scale": 1.0 }
2943
+ },
2944
+ "valueT": {
2945
+ "dtype": "float32",
2946
+ "shape": [1, 5, 6],
2947
+ "data": { "kind": "fillFloat32", "sinStep": 0.74, "cosStep": 0.8999999999999999, "scale": 1.0 }
2948
+ },
2949
+ "keyNormScaleT": {
2950
+ "dtype": "float32",
2951
+ "shape": [3, 6],
2952
+ "data": { "kind": "fillFloat32", "sinStep": 0.64, "cosStep": 0.9199999999999999, "scale": 0.5, "offset": 1.0 }
2953
+ },
2954
+ "queryNormScaleT": {
2955
+ "dtype": "float32",
2956
+ "shape": [3, 6],
2957
+ "data": { "kind": "fillFloat32", "sinStep": 0.66, "cosStep": 0.98, "scale": 0.5, "offset": 1.0 }
2958
+ },
2959
+ "convNormScaleT": {
2960
+ "dtype": "float32",
2961
+ "shape": [3, 6],
2962
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
2963
+ }
2964
+ },
2965
+ "outputs": {
2966
+ "outputT": { "dtype": "float32", "shape": [1, 5, 3, 6], "tolerance": 0.000002, "relTolerance": 0.00002 },
2967
+ "gatedValueNormedT": {
2968
+ "dtype": "float32",
2969
+ "shape": [1, 5, 3, 6],
2970
+ "tolerance": 0.000002,
2971
+ "relTolerance": 0.00002
2972
+ }
2973
+ }
2974
+ },
2975
+ {
2976
+ "name": "norm_scalar_h130_f16",
2977
+ "provenance": {
2978
+ "notes": "float16 input [2,3,2,130] with a convNormScaleT of shape [2, 130] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
2979
+ },
2980
+ "inputs": {
2981
+ "keyT": {
2982
+ "dtype": "float16",
2983
+ "shape": [2, 3, 2, 130],
2984
+ "data": { "kind": "fillFloat32", "sinStep": 0.68, "cosStep": 0.8600000000000001, "scale": 1.0 }
2985
+ },
2986
+ "queryT": {
2987
+ "dtype": "float16",
2988
+ "shape": [2, 3, 2, 130],
2989
+ "data": { "kind": "fillFloat32", "sinStep": 0.74, "cosStep": 0.9, "scale": 1.0 }
2990
+ },
2991
+ "valueT": {
2992
+ "dtype": "float16",
2993
+ "shape": [2, 3, 130],
2994
+ "data": { "kind": "fillFloat32", "sinStep": 0.8, "cosStep": 0.96, "scale": 1.0 }
2995
+ },
2996
+ "keyNormScaleT": {
2997
+ "dtype": "float16",
2998
+ "shape": [2, 130],
2999
+ "data": { "kind": "fillFloat32", "sinStep": 0.7000000000000001, "cosStep": 0.98, "scale": 0.5, "offset": 1.0 }
3000
+ },
3001
+ "queryNormScaleT": {
3002
+ "dtype": "float16",
3003
+ "shape": [2, 130],
3004
+ "data": { "kind": "fillFloat32", "sinStep": 0.7200000000000001, "cosStep": 1.04, "scale": 0.5, "offset": 1.0 }
3005
+ },
3006
+ "convNormScaleT": {
3007
+ "dtype": "float16",
3008
+ "shape": [2, 130],
3009
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3010
+ }
3011
+ },
3012
+ "outputs": {
3013
+ "outputT": { "dtype": "float16", "shape": [2, 3, 2, 130], "tolerance": 0.0005, "relTolerance": 0.002 },
3014
+ "gatedValueNormedT": { "dtype": "float16", "shape": [2, 3, 2, 130], "tolerance": 0.0005, "relTolerance": 0.002 }
3015
+ }
3016
+ },
3017
+ {
3018
+ "name": "norm_scalar_h1_f32",
3019
+ "provenance": {
3020
+ "notes": "float32 input [1,4,2,1] with a convNormScaleT of shape [2, 1] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3021
+ },
3022
+ "inputs": {
3023
+ "keyT": {
3024
+ "dtype": "float32",
3025
+ "shape": [1, 4, 2, 1],
3026
+ "data": { "kind": "fillFloat32", "sinStep": 0.72, "cosStep": 0.8999999999999999, "scale": 1.0 }
3027
+ },
3028
+ "queryT": {
3029
+ "dtype": "float32",
3030
+ "shape": [1, 4, 2, 1],
3031
+ "data": { "kind": "fillFloat32", "sinStep": 0.78, "cosStep": 0.94, "scale": 1.0 }
3032
+ },
3033
+ "valueT": {
3034
+ "dtype": "float32",
3035
+ "shape": [1, 4, 1],
3036
+ "data": { "kind": "fillFloat32", "sinStep": 0.84, "cosStep": 1.0, "scale": 1.0 }
3037
+ },
3038
+ "keyNormScaleT": {
3039
+ "dtype": "float32",
3040
+ "shape": [2, 1],
3041
+ "data": { "kind": "fillFloat32", "sinStep": 0.74, "cosStep": 1.02, "scale": 0.5, "offset": 1.0 }
3042
+ },
3043
+ "queryNormScaleT": {
3044
+ "dtype": "float32",
3045
+ "shape": [2, 1],
3046
+ "data": { "kind": "fillFloat32", "sinStep": 0.76, "cosStep": 1.08, "scale": 0.5, "offset": 1.0 }
3047
+ },
3048
+ "convNormScaleT": {
3049
+ "dtype": "float32",
3050
+ "shape": [2, 1],
3051
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3052
+ }
3053
+ },
3054
+ "outputs": {
3055
+ "outputT": { "dtype": "float32", "shape": [1, 4, 2, 1], "tolerance": 0.000002, "relTolerance": 0.00002 },
3056
+ "gatedValueNormedT": {
3057
+ "dtype": "float32",
3058
+ "shape": [1, 4, 2, 1],
3059
+ "tolerance": 0.000002,
3060
+ "relTolerance": 0.00002
3061
+ }
3062
+ }
3063
+ },
3064
+ {
3065
+ "name": "norm_scalar_wide_h2050_f32",
3066
+ "provenance": {
3067
+ "notes": "float32 input [1,1,2,2050] with a convNormScaleT of shape [2, 2050] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3068
+ },
3069
+ "inputs": {
3070
+ "keyT": {
3071
+ "dtype": "float32",
3072
+ "shape": [1, 1, 2, 2050],
3073
+ "data": { "kind": "fillFloat32", "sinStep": 0.74, "cosStep": 0.9199999999999999, "scale": 1.0 }
3074
+ },
3075
+ "queryT": {
3076
+ "dtype": "float32",
3077
+ "shape": [1, 1, 2, 2050],
3078
+ "data": { "kind": "fillFloat32", "sinStep": 0.8, "cosStep": 0.96, "scale": 1.0 }
3079
+ },
3080
+ "valueT": {
3081
+ "dtype": "float32",
3082
+ "shape": [1, 1, 2050],
3083
+ "data": { "kind": "fillFloat32", "sinStep": 0.86, "cosStep": 1.02, "scale": 1.0 }
3084
+ },
3085
+ "keyNormScaleT": {
3086
+ "dtype": "float32",
3087
+ "shape": [2, 2050],
3088
+ "data": { "kind": "fillFloat32", "sinStep": 0.76, "cosStep": 1.04, "scale": 0.5, "offset": 1.0 }
3089
+ },
3090
+ "queryNormScaleT": {
3091
+ "dtype": "float32",
3092
+ "shape": [2, 2050],
3093
+ "data": { "kind": "fillFloat32", "sinStep": 0.78, "cosStep": 1.1, "scale": 0.5, "offset": 1.0 }
3094
+ },
3095
+ "convNormScaleT": {
3096
+ "dtype": "float32",
3097
+ "shape": [2, 2050],
3098
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3099
+ }
3100
+ },
3101
+ "outputs": {
3102
+ "outputT": { "dtype": "float32", "shape": [1, 1, 2, 2050], "tolerance": 0.000002, "relTolerance": 0.00005 },
3103
+ "gatedValueNormedT": {
3104
+ "dtype": "float32",
3105
+ "shape": [1, 1, 2, 2050],
3106
+ "tolerance": 0.000002,
3107
+ "relTolerance": 0.00005
3108
+ }
3109
+ }
3110
+ },
3111
+ {
3112
+ "name": "norm_wide_h16384_f32",
3113
+ "provenance": {
3114
+ "notes": "float32 input [1,1,2,16384] with a convNormScaleT of shape [2, 16384] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3115
+ },
3116
+ "inputs": {
3117
+ "keyT": {
3118
+ "dtype": "float32",
3119
+ "shape": [1, 1, 2, 16384],
3120
+ "data": { "kind": "fillFloat32", "sinStep": 0.6, "cosStep": 0.78, "scale": 1.0 }
3121
+ },
3122
+ "queryT": {
3123
+ "dtype": "float32",
3124
+ "shape": [1, 1, 2, 16384],
3125
+ "data": { "kind": "fillFloat32", "sinStep": 0.6599999999999999, "cosStep": 0.82, "scale": 1.0 }
3126
+ },
3127
+ "valueT": {
3128
+ "dtype": "float32",
3129
+ "shape": [1, 1, 16384],
3130
+ "data": { "kind": "fillFloat32", "sinStep": 0.72, "cosStep": 0.8799999999999999, "scale": 1.0 }
3131
+ },
3132
+ "keyNormScaleT": {
3133
+ "dtype": "float32",
3134
+ "shape": [2, 16384],
3135
+ "data": { "kind": "fillFloat32", "sinStep": 0.62, "cosStep": 0.8999999999999999, "scale": 0.5, "offset": 1.0 }
3136
+ },
3137
+ "queryNormScaleT": {
3138
+ "dtype": "float32",
3139
+ "shape": [2, 16384],
3140
+ "data": { "kind": "fillFloat32", "sinStep": 0.64, "cosStep": 0.96, "scale": 0.5, "offset": 1.0 }
3141
+ },
3142
+ "convNormScaleT": {
3143
+ "dtype": "float32",
3144
+ "shape": [2, 16384],
3145
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3146
+ }
3147
+ },
3148
+ "outputs": {
3149
+ "outputT": { "dtype": "float32", "shape": [1, 1, 2, 16384], "tolerance": 0.000002, "relTolerance": 0.00005 },
3150
+ "gatedValueNormedT": {
3151
+ "dtype": "float32",
3152
+ "shape": [1, 1, 2, 16384],
3153
+ "tolerance": 0.000002,
3154
+ "relTolerance": 0.00005
3155
+ }
3156
+ }
3157
+ },
3158
+ {
3159
+ "name": "norm_wide_h16384_f16",
3160
+ "provenance": {
3161
+ "notes": "float16 input [1,1,2,16384] with a convNormScaleT of shape [2, 16384] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3162
+ },
3163
+ "inputs": {
3164
+ "keyT": {
3165
+ "dtype": "float16",
3166
+ "shape": [1, 1, 2, 16384],
3167
+ "data": { "kind": "fillFloat32", "sinStep": 0.6, "cosStep": 0.78, "scale": 1.0 }
3168
+ },
3169
+ "queryT": {
3170
+ "dtype": "float16",
3171
+ "shape": [1, 1, 2, 16384],
3172
+ "data": { "kind": "fillFloat32", "sinStep": 0.6599999999999999, "cosStep": 0.82, "scale": 1.0 }
3173
+ },
3174
+ "valueT": {
3175
+ "dtype": "float16",
3176
+ "shape": [1, 1, 16384],
3177
+ "data": { "kind": "fillFloat32", "sinStep": 0.72, "cosStep": 0.8799999999999999, "scale": 1.0 }
3178
+ },
3179
+ "keyNormScaleT": {
3180
+ "dtype": "float16",
3181
+ "shape": [2, 16384],
3182
+ "data": { "kind": "fillFloat32", "sinStep": 0.62, "cosStep": 0.8999999999999999, "scale": 0.5, "offset": 1.0 }
3183
+ },
3184
+ "queryNormScaleT": {
3185
+ "dtype": "float16",
3186
+ "shape": [2, 16384],
3187
+ "data": { "kind": "fillFloat32", "sinStep": 0.64, "cosStep": 0.96, "scale": 0.5, "offset": 1.0 }
3188
+ },
3189
+ "convNormScaleT": {
3190
+ "dtype": "float16",
3191
+ "shape": [2, 16384],
3192
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3193
+ }
3194
+ },
3195
+ "outputs": {
3196
+ "outputT": { "dtype": "float16", "shape": [1, 1, 2, 16384], "tolerance": 0.0005, "relTolerance": 0.002 },
3197
+ "gatedValueNormedT": {
3198
+ "dtype": "float16",
3199
+ "shape": [1, 1, 2, 16384],
3200
+ "tolerance": 0.0005,
3201
+ "relTolerance": 0.002
3202
+ }
3203
+ }
3204
+ },
3205
+ {
3206
+ "name": "norm_wide_h8192_f16",
3207
+ "provenance": {
3208
+ "notes": "float16 input [1,1,2,8192] with a convNormScaleT of shape [2, 8192] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3209
+ },
3210
+ "inputs": {
3211
+ "keyT": {
3212
+ "dtype": "float16",
3213
+ "shape": [1, 1, 2, 8192],
3214
+ "data": { "kind": "fillFloat32", "sinStep": 0.54, "cosStep": 0.72, "scale": 1.0 }
3215
+ },
3216
+ "queryT": {
3217
+ "dtype": "float16",
3218
+ "shape": [1, 1, 2, 8192],
3219
+ "data": { "kind": "fillFloat32", "sinStep": 0.6000000000000001, "cosStep": 0.76, "scale": 1.0 }
3220
+ },
3221
+ "valueT": {
3222
+ "dtype": "float16",
3223
+ "shape": [1, 1, 8192],
3224
+ "data": { "kind": "fillFloat32", "sinStep": 0.66, "cosStep": 0.8200000000000001, "scale": 1.0 }
3225
+ },
3226
+ "keyNormScaleT": {
3227
+ "dtype": "float16",
3228
+ "shape": [2, 8192],
3229
+ "data": { "kind": "fillFloat32", "sinStep": 0.56, "cosStep": 0.8400000000000001, "scale": 0.5, "offset": 1.0 }
3230
+ },
3231
+ "queryNormScaleT": {
3232
+ "dtype": "float16",
3233
+ "shape": [2, 8192],
3234
+ "data": { "kind": "fillFloat32", "sinStep": 0.5800000000000001, "cosStep": 0.9, "scale": 0.5, "offset": 1.0 }
3235
+ },
3236
+ "convNormScaleT": {
3237
+ "dtype": "float16",
3238
+ "shape": [2, 8192],
3239
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3240
+ }
3241
+ },
3242
+ "outputs": {
3243
+ "outputT": { "dtype": "float16", "shape": [1, 1, 2, 8192], "tolerance": 0.0005, "relTolerance": 0.002 },
3244
+ "gatedValueNormedT": {
3245
+ "dtype": "float16",
3246
+ "shape": [1, 1, 2, 8192],
3247
+ "tolerance": 0.0005,
3248
+ "relTolerance": 0.002
3249
+ }
3250
+ }
3251
+ },
3252
+ {
3253
+ "name": "norm_epsilon_dominant_h8_f32",
3254
+ "provenance": {
3255
+ "notes": "float32 input [1,3,2,8] with a convNormScaleT of shape [2, 8] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3256
+ },
3257
+ "attrs": { "epsilon": 1 },
3258
+ "inputs": {
3259
+ "keyT": {
3260
+ "dtype": "float32",
3261
+ "shape": [1, 3, 2, 8],
3262
+ "data": { "kind": "fillFloat32", "sinStep": 0.8, "cosStep": 0.98, "scale": 0.01 }
3263
+ },
3264
+ "queryT": {
3265
+ "dtype": "float32",
3266
+ "shape": [1, 3, 2, 8],
3267
+ "data": { "kind": "fillFloat32", "sinStep": 0.8600000000000001, "cosStep": 1.02, "scale": 0.01 }
3268
+ },
3269
+ "valueT": {
3270
+ "dtype": "float32",
3271
+ "shape": [1, 3, 8],
3272
+ "data": { "kind": "fillFloat32", "sinStep": 0.92, "cosStep": 1.08, "scale": 1.0 }
3273
+ },
3274
+ "keyNormScaleT": {
3275
+ "dtype": "float32",
3276
+ "shape": [2, 8],
3277
+ "data": { "kind": "fillFloat32", "sinStep": 0.8200000000000001, "cosStep": 1.1, "scale": 0.5, "offset": 1.0 }
3278
+ },
3279
+ "queryNormScaleT": {
3280
+ "dtype": "float32",
3281
+ "shape": [2, 8],
3282
+ "data": {
3283
+ "kind": "fillFloat32",
3284
+ "sinStep": 0.8400000000000001,
3285
+ "cosStep": 1.1600000000000001,
3286
+ "scale": 0.5,
3287
+ "offset": 1.0
3288
+ }
3289
+ },
3290
+ "convNormScaleT": {
3291
+ "dtype": "float32",
3292
+ "shape": [2, 8],
3293
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3294
+ }
3295
+ },
3296
+ "outputs": {
3297
+ "outputT": { "dtype": "float32", "shape": [1, 3, 2, 8], "tolerance": 0.000002, "relTolerance": 0.00002 },
3298
+ "gatedValueNormedT": {
3299
+ "dtype": "float32",
3300
+ "shape": [1, 3, 2, 8],
3301
+ "tolerance": 0.000002,
3302
+ "relTolerance": 0.00002
3303
+ }
3304
+ }
3305
+ },
3306
+ {
3307
+ "name": "norm_vector_depth_float32_h320_r129_wg256",
3308
+ "inputs": {
3309
+ "keyT": {
3310
+ "shape": [1, 43, 3, 320],
3311
+ "dtype": "float32",
3312
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.71, "scale": 1.0 }
3313
+ },
3314
+ "queryT": {
3315
+ "shape": [1, 43, 3, 320],
3316
+ "dtype": "float32",
3317
+ "data": { "kind": "fillFloat32", "sinStep": 0.48, "cosStep": 0.84, "scale": 1.0 }
3318
+ },
3319
+ "valueT": {
3320
+ "shape": [1, 43, 320],
3321
+ "dtype": "float32",
3322
+ "data": { "kind": "fillFloat32", "sinStep": 0.59, "cosStep": 0.97, "scale": 1.0 }
3323
+ },
3324
+ "keyNormScaleT": {
3325
+ "shape": [3, 320],
3326
+ "dtype": "float32",
3327
+ "data": { "kind": "fillFloat32", "sinStep": 0.7, "cosStep": 1.1, "scale": 0.5, "offset": 1.0 }
3328
+ },
3329
+ "queryNormScaleT": {
3330
+ "shape": [3, 320],
3331
+ "dtype": "float32",
3332
+ "data": { "kind": "fillFloat32", "sinStep": 0.81, "cosStep": 1.23, "scale": 0.5, "offset": 1.0 }
3333
+ },
3334
+ "convNormScaleT": {
3335
+ "dtype": "float32",
3336
+ "shape": [3, 320],
3337
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3338
+ }
3339
+ },
3340
+ "outputs": {
3341
+ "outputT": { "shape": [1, 43, 3, 320], "dtype": "float32", "tolerance": 0.000002, "relTolerance": 0.00002 },
3342
+ "gatedValueNormedT": {
3343
+ "shape": [1, 43, 3, 320],
3344
+ "dtype": "float32",
3345
+ "tolerance": 0.000002,
3346
+ "relTolerance": 0.00002
3347
+ }
3348
+ },
3349
+ "provenance": {
3350
+ "notes": "float32 input [1,43,3,320] with a convNormScaleT of shape [3, 320] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3351
+ }
3352
+ },
3353
+ {
3354
+ "name": "norm_packing_override_float16_h65_wg64_depth1",
3355
+ "inputs": {
3356
+ "keyT": {
3357
+ "shape": [1, 65, 4, 65],
3358
+ "dtype": "float16",
3359
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.71, "scale": 1.0 }
3360
+ },
3361
+ "queryT": {
3362
+ "shape": [1, 65, 4, 65],
3363
+ "dtype": "float16",
3364
+ "data": { "kind": "fillFloat32", "sinStep": 0.48, "cosStep": 0.84, "scale": 1.0 }
3365
+ },
3366
+ "valueT": {
3367
+ "shape": [1, 65, 65],
3368
+ "dtype": "float16",
3369
+ "data": { "kind": "fillFloat32", "sinStep": 0.59, "cosStep": 0.97, "scale": 1.0 }
3370
+ },
3371
+ "keyNormScaleT": {
3372
+ "shape": [4, 65],
3373
+ "dtype": "float16",
3374
+ "data": { "kind": "fillFloat32", "sinStep": 0.7, "cosStep": 1.1, "scale": 0.5, "offset": 1.0 }
3375
+ },
3376
+ "queryNormScaleT": {
3377
+ "shape": [4, 65],
3378
+ "dtype": "float16",
3379
+ "data": { "kind": "fillFloat32", "sinStep": 0.81, "cosStep": 1.23, "scale": 0.5, "offset": 1.0 }
3380
+ },
3381
+ "convNormScaleT": {
3382
+ "dtype": "float16",
3383
+ "shape": [4, 65],
3384
+ "data": { "kind": "fillFloat32", "sinStep": 0.37, "cosStep": 0.19, "scale": 0.75, "offset": 0.5 }
3385
+ }
3386
+ },
3387
+ "outputs": {
3388
+ "outputT": { "shape": [1, 65, 4, 65], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 },
3389
+ "gatedValueNormedT": { "shape": [1, 65, 4, 65], "dtype": "float16", "tolerance": 0.0005, "relTolerance": 0.002 }
3390
+ },
3391
+ "tunables": { "WORKGROUP_SIZE": 64, "LANE_WORDS": 1 },
3392
+ "provenance": {
3393
+ "notes": "float16 input [1,65,4,65] with a convNormScaleT of shape [4, 65] supplied, so the normalized output gatedValueNormedT is checked as well as outputT."
3394
+ }
3395
+ },
3396
+ {
3397
+ "name": "zero_value_float32",
3398
+ "provenance": {
3399
+ "notes": "All-zero gated rows with positive default epsilon normalize to zero. Uniform gatedValueNormedT and outputT values make the result exact."
3400
+ },
3401
+ "inputs": {
3402
+ "keyT": {
3403
+ "dtype": "float32",
3404
+ "shape": [1, 1, 2, 2],
3405
+ "data": { "kind": "values", "values": [0.5, 1.0, -0.25, 0.75] }
3406
+ },
3407
+ "queryT": {
3408
+ "dtype": "float32",
3409
+ "shape": [1, 1, 2, 2],
3410
+ "data": { "kind": "values", "values": [3.0, 4.0, -1.0, 2.0] }
3411
+ },
3412
+ "valueT": { "dtype": "float32", "shape": [1, 1, 2], "data": { "kind": "constant", "value": 0.0 } },
3413
+ "keyNormScaleT": {
3414
+ "dtype": "float32",
3415
+ "shape": [2, 2],
3416
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.5, 0.5] }
3417
+ },
3418
+ "queryNormScaleT": {
3419
+ "dtype": "float32",
3420
+ "shape": [2, 2],
3421
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.0, 2.0] }
3422
+ },
3423
+ "convNormScaleT": {
3424
+ "dtype": "float32",
3425
+ "shape": [2, 2],
3426
+ "data": { "kind": "values", "values": [1.0, 2.0, 0.5, 1.0] }
3427
+ }
3428
+ },
3429
+ "outputs": {
3430
+ "outputT": {
3431
+ "dtype": "float32",
3432
+ "shape": [1, 1, 2, 2],
3433
+ "tolerance": 0,
3434
+ "relTolerance": 0,
3435
+ "data": { "kind": "constant", "value": 0.0 }
3436
+ },
3437
+ "gatedValueNormedT": {
3438
+ "dtype": "float32",
3439
+ "shape": [1, 1, 2, 2],
3440
+ "tolerance": 0,
3441
+ "relTolerance": 0,
3442
+ "data": { "kind": "constant", "value": 0.0 }
3443
+ }
3444
+ }
3445
+ },
3446
+ {
3447
+ "name": "zero_value_float16",
3448
+ "provenance": {
3449
+ "notes": "All-zero gated rows with positive default epsilon normalize to zero. Uniform gatedValueNormedT and outputT values make the result exact."
3450
+ },
3451
+ "inputs": {
3452
+ "keyT": {
3453
+ "dtype": "float16",
3454
+ "shape": [1, 1, 2, 2],
3455
+ "data": { "kind": "values", "values": [0.5, 1.0, -0.25, 0.75] }
3456
+ },
3457
+ "queryT": {
3458
+ "dtype": "float16",
3459
+ "shape": [1, 1, 2, 2],
3460
+ "data": { "kind": "values", "values": [3.0, 4.0, -1.0, 2.0] }
3461
+ },
3462
+ "valueT": { "dtype": "float16", "shape": [1, 1, 2], "data": { "kind": "constant", "value": 0.0 } },
3463
+ "keyNormScaleT": {
3464
+ "dtype": "float16",
3465
+ "shape": [2, 2],
3466
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.5, 0.5] }
3467
+ },
3468
+ "queryNormScaleT": {
3469
+ "dtype": "float16",
3470
+ "shape": [2, 2],
3471
+ "data": { "kind": "values", "values": [1.0, 1.0, 1.0, 2.0] }
3472
+ },
3473
+ "convNormScaleT": {
3474
+ "dtype": "float16",
3475
+ "shape": [2, 2],
3476
+ "data": { "kind": "values", "values": [1.0, 2.0, 0.5, 1.0] }
3477
+ }
3478
+ },
3479
+ "outputs": {
3480
+ "outputT": {
3481
+ "dtype": "float16",
3482
+ "shape": [1, 1, 2, 2],
3483
+ "tolerance": 0,
3484
+ "relTolerance": 0,
3485
+ "data": { "kind": "constant", "value": 0.0 }
3486
+ },
3487
+ "gatedValueNormedT": {
3488
+ "dtype": "float16",
3489
+ "shape": [1, 1, 2, 2],
3490
+ "tolerance": 0,
3491
+ "relTolerance": 0,
3492
+ "data": { "kind": "constant", "value": 0.0 }
3493
+ }
3494
  }
3495
  }
3496
  ]