Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
99d5517
Add Engram contrib op schemas
Copilot Aug 25, 2026
b44523f
Add CPU Engram contrib kernels
Copilot Aug 25, 2026
819e695
Add CUDA Engram contrib kernels
Copilot Aug 25, 2026
608c54f
Add WebGPU Engram contrib kernels
Copilot Aug 25, 2026
3ad3490
Add Engram contrib op tests
Copilot Aug 25, 2026
3fd904b
Fix Engram CPU threadpool usage
Copilot Aug 25, 2026
1c82a47
Split Engram ops into standalone files
Copilot Aug 25, 2026
b8a41e7
Add CPU FP16 Engram kernels, shared EP helpers, and docs
Copilot Aug 25, 2026
fcb7ca0
Rename NgramHashMapping to NGramHashMapping
Copilot Aug 25, 2026
2ddc306
Address PR review: shared-gate/RMS passes and sign(0) fix for Engram ops
Copilot Aug 25, 2026
e22b5c8
Fix CI failures: CUDA GetComputeStream, WebGPU namespace, test skip trap
Copilot Aug 26, 2026
7bb11f3
Merge remote-tracking branch 'origin/copilot/add-op-support-for-deeps…
Copilot Aug 26, 2026
9eecb7d
Extend GatedRMSNorm with configurable silu/sigmoid gate activation
Copilot Aug 26, 2026
08546f9
Extend NGramHashMapping with past/present tokens, EOS reset, segment_…
Copilot Aug 26, 2026
01454fd
Extend EngramGate with conv_norm_scale input and gated_value_normed o…
Copilot Aug 26, 2026
9c60b27
Fix NGramHashMapping generated docs
Copilot Aug 27, 2026
cf85ec4
Clarify ShortConv activation flag
Copilot Aug 27, 2026
bc2732f
Fix NGram segment reset review comments
Copilot Aug 27, 2026
a13d68a
Fix lint formatting issues
Copilot Aug 27, 2026
23048f8
Extend GatedRMSNorm with configurable silu/sigmoid gate activation
Copilot Aug 26, 2026
a17b7a2
Extend NGramHashMapping with past/present tokens, EOS reset, segment_…
Copilot Aug 26, 2026
1e8ad6c
Extend EngramGate with conv_norm_scale input and gated_value_normed o…
Copilot Aug 26, 2026
751a6d0
Update Engram generated kernel docs
Copilot Sep 2, 2026
410de12
Format Qwen Engram updates
Copilot Sep 2, 2026
f7dda34
Update Qwen PR for merged DeepSeek Engram changes
Copilot Sep 2, 2026
d49cbde
Fix EngramGate test MSVC shadow warning
Copilot Sep 3, 2026
bee7447
Update generated contrib operator docs
Copilot Sep 4, 2026
dcf54dc
Fix CUDA plugin user stream graph test lifetime
Copilot Sep 5, 2026
a132d05
Add GatherQuantized contrib op (CPU EP) for FP8 block-scaled gather
Copilot Sep 8, 2026
39ba0cc
Rename GatherQuantized to GatherFpQuantized and add FP4 (Float4E2M1x2…
Copilot Sep 8, 2026
c7f63c3
Document GatherFpQuantized in ContribOperators.md and OperatorKernels.md
Copilot Sep 8, 2026
0095b3b
Add eos_token_id segment-reset to NGramHashMapping (CPU/CUDA/WebGPU)
Copilot Sep 8, 2026
0fb86e8
Apply lintrunner formatting fixes
Copilot Sep 8, 2026
e661b8a
Support broadcastable (per-tensor) scales in GatherFpQuantized
Copilot Sep 8, 2026
188cf5d
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 8, 2026
e9b317b
Merge remote-tracking branch 'origin/main' into copilot/add-op-suppor…
Copilot Sep 8, 2026
26d11e7
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 8, 2026
7a7f0cc
Address PR review comments: guard FP8 tests, fix block_size validatio…
Copilot Sep 8, 2026
c2a76dd
Fix CI failures: WASM -Wshorten-64-to-32 in GatherFpQuantized kernel,…
Copilot Sep 8, 2026
d1d90df
Merge remote-tracking branch 'origin/main' into copilot/add-op-suppor…
Copilot Sep 10, 2026
d2f974e
Merge remote-tracking branch 'origin/main' into copilot/research-onnx…
Copilot Sep 10, 2026
d41fbdb
Revert "Merge remote-tracking branch 'origin/main' into copilot/resea…
Copilot Sep 10, 2026
03ad2f9
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 10, 2026
f89b2a6
Remove GatedRMSNorm activation changes
Copilot Sep 11, 2026
da2b617
Merge remote-tracking branch 'origin/main' into copilot/add-op-suppor…
Copilot Sep 11, 2026
b792d55
Resolve merge conflicts: rebuild tree onto latest copilot/add-op-supp…
Copilot Sep 11, 2026
e961436
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 11, 2026
038990a
Merge GatherFpQuantized schema into GatherBlockQuantized
Copilot Sep 11, 2026
d678bd0
Add FP8/FP4 support to WebGPU GatherBlockQuantized
Copilot Sep 11, 2026
359d32b
Fix OpTester::Run excluded-provider type in migrated GatherBlockQuant…
Copilot Sep 12, 2026
1b927f2
Apply remaining changes
Copilot Sep 12, 2026
902685f
Fix WebGPU GatherBlockQuantized FP8/FP4 dtype and broadcast-scale han…
Copilot Sep 12, 2026
356d3ce
Remove stale GatherFpQuantized doc entries; merge into GatherBlockQua…
Copilot Sep 12, 2026
388be7b
Apply remaining changes
Copilot Sep 13, 2026
b874d73
Fix unrelated GEMM_FLOAT8_TYPES formatting drift flagged by bot review
Copilot Sep 13, 2026
ef3ccd7
Fix CI: exclude WebGPU from FP8/FP4 GatherBlockQuantized tests; fix s…
Copilot Sep 13, 2026
47f185a
Fix CUDA GatherBlockQuantized FP8/FP4 bugs and wire up kernel registr…
Copilot Sep 14, 2026
a46941f
Fix WebGPU divide-by-zero, withhold FP8/FP4 type registration, adjust…
Copilot Sep 14, 2026
82ebc35
Fix CUDA build error: qualify TArray as onnxruntime::cuda::TArray in …
Copilot Sep 14, 2026
0477f8c
Address GatherBlockQuantized review feedback
Copilot Sep 14, 2026
dc04cd6
Handle empty tensors and high-rank WebGPU scales
Copilot Sep 14, 2026
2a9e812
Restore canonical schema macro formatting
Copilot Sep 14, 2026
ff695e1
Apply remaining changes
Copilot Sep 14, 2026
fac8b71
Merge remote-tracking branch 'origin/main' into copilot/add-op-suppor…
Copilot Sep 14, 2026
34502f9
Clean up generated docs whitespace
Copilot Sep 14, 2026
e5f2b15
Remove NGramHashMapping docs trailing whitespace
Copilot Sep 14, 2026
1dfac6d
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 14, 2026
33b8c7d
Clean up NGramHashMapping review fixes
Copilot Sep 14, 2026
a853e5d
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 14, 2026
c0a37f4
Fix NGramHashMapping shape inference docs
Copilot Sep 15, 2026
dc635da
Fix GatherBlockQuantized CI failures
Copilot Sep 15, 2026
b063ff7
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 15, 2026
a03c05a
Update generated contrib docs
Copilot Sep 15, 2026
4a58ce1
Merge remote-tracking branch 'origin/copilot/add-op-support-for-qwen-…
Copilot Sep 15, 2026
afe5688
Sync target and fix formatting
Copilot Sep 15, 2026
8d992e8
Fix WebGPU FP8 lookup shader
Copilot Sep 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 53 additions & 16 deletions docs/ContribOperators.md
Original file line number Diff line number Diff line change
Expand Up @@ -1811,8 +1811,10 @@ This version of the operator has been available since version 1 of the 'com.micr
gate = sigmoid(sign(dot) * sqrt(max(abs(dot), 1e-6))) where
dot = sum(RMSNorm(key) * RMSNorm(query)) / sqrt(hidden_size).

The output is gate * value, broadcast across the hyper-connections. The final Engram residual
value + short_conv(value) is then expressed with RMSNorm, CausalConvWithState and Add.
The output is gate * value, broadcast across the hyper-connections. The optional gated_value_normed
output applies RMSNorm to gate * value with conv_norm_scale, which can feed a following
CausalConvWithState. The final Engram residual value + short_conv(value) is then expressed with
RMSNorm, CausalConvWithState and Add.

#### Version

Expand All @@ -1825,7 +1827,7 @@ This version of the operator has been available since version 1 of the 'com.micr
<dd>Epsilon used by both RMS normalization steps. Default is 1e-5.</dd>
</dl>

#### Inputs
#### Inputs (5 - 6)

<dl>
<dt><tt>key</tt> : T</dt>
Expand All @@ -1838,13 +1840,17 @@ This version of the operator has been available since version 1 of the 'com.micr
<dd>RMSNorm scale for keys with shape (hc_mult, hidden_size).</dd>
<dt><tt>query_norm_scale</tt> : T</dt>
<dd>RMSNorm scale for queries with shape (hc_mult, hidden_size).</dd>
<dt><tt>conv_norm_scale</tt> (optional) : T</dt>
<dd>Optional RMSNorm scale for the gated value, with shape (hc_mult, hidden_size). Required when gated_value_normed is requested.</dd>
</dl>

#### Outputs
#### Outputs (1 - 2)

<dl>
<dt><tt>output</tt> : T</dt>
<dd>Gated value tensor with shape (batch_size, sequence_length, hc_mult, hidden_size).</dd>
<dt><tt>gated_value_normed</tt> (optional) : T</dt>
<dd>Optional RMS-normalized gated value tensor with shape (batch_size, sequence_length, hc_mult, hidden_size).</dd>
</dl>

#### Type Constraints
Expand Down Expand Up @@ -2433,13 +2439,22 @@ This version of the operator has been available since version 1 of the 'com.micr
GatherBlockQuantized is a Gather with data quantized. It is similar to Gather (https://github.com/onnx/onnx/blob/main/docs/Operators.md#gather) with differences:
1. Input `data` is a constant. It is quantized block-wise along attribute `quantize_axis` with block size specified by attribute `block_size`.
`block_size` must be a power of 2 and not smaller than 16, like 16, 32, 64, 128, ...
For an FP8 or FP4 `data` type (see point 6 below), `block_size` may also be 0, meaning the entire `quantize_axis`
dimension forms a single block (i.e. one scale per row).
2. Input `data`'s scale and zero point are specified by input `scales` and `zero_points`. `scales` and `zero_points` are also constants.
If `zero_points` is not provided, the default value is 0 for int4/uint4, or 2^(bits-1) for uint8.
`zero_points` must not be provided when `data` is an FP8 or FP4 type: FP8/FP4 quantization is symmetric.
3. During the op execution, `data` and `indices` are first used to generate the quantized output. Then, `scales` and `zero_points` are used
to dequantize the output.
4. The `output` and `scales` have the same type. The `data` and `zero_points` have the same type.
5. For uint8 data, the `gather_axis` must be 0. The supported `bits` values for uint8 data are 2, 4, and 8;
for `bits` < 8 the values are packed along the last dimension (low-order bits first).
6. `data` may also be an FP8 type (float8e4m3fn, float8e4m3fnuz, float8e5m2 or float8e5m2fnuz) or an FP4 type
(float4e2m1), rather than an integer block-quantized type. In that case `bits` is ignored, there is
no `zero_points` input, and dequantization is simply `output[...] = float(data[...]) * scales[block_index(...)]`.
On any axis other than `quantize_axis`, the corresponding `scales` dimension must either equal `data`'s
dimension, or be 1, in which case the scale is broadcast along that axis (e.g. a single scale shared by
every row, as with a per-tensor scale applied to an entire embedding table).

#### Version

Expand All @@ -2449,9 +2464,9 @@ This version of the operator has been available since version 1 of the 'com.micr

<dl>
<dt><tt>bits</tt> : int</dt>
<dd>Number of bits used for weight quantization. Must be 2, 4 or 8. </dd>
<dd>Number of bits used for weight quantization. Must be 2, 4 or 8. Ignored when `data` is an FP8 or FP4 type.</dd>
<dt><tt>block_size</tt> : int</dt>
<dd>(Optional) block size used for weight quantization. It needs to be a power of 2 and not smaller than 16.</dd>
<dd>(Optional) block size used for weight quantization. It needs to be a power of 2 and not smaller than 16, or 0. A value of 0 is only valid for an FP8 or FP4 `data` type and means the entire `quantize_axis` dimension forms a single block.</dd>
<dt><tt>gather_axis</tt> : int</dt>
<dd>(Optional) Which axis to gather on. Negative value means counting dimensions from the back. Accepted range is [-r, r-1] where r = rank(data).</dd>
<dt><tt>quantize_axis</tt> : int</dt>
Expand All @@ -2464,11 +2479,11 @@ This version of the operator has been available since version 1 of the 'com.micr
<dt><tt>data</tt> : T1</dt>
<dd>Tensor of rank r >= 1. Block-wise quantized.</dd>
<dt><tt>indices</tt> : Tind</dt>
<dd>Tensor of int32/int64 indices, of any rank q. All index values are expected to be within bounds [-s, s-1] along axis of size s. It is an error if any of the index values are out of bounds.</dd>
<dd>Tensor of int32/int64 indices, of any rank q. Values in [-s, s-1] select elements along an axis of size s. Unlike ONNX Gather, an out-of-range index produces zeros for the corresponding output slice.</dd>
<dt><tt>scales</tt> : T2</dt>
<dd>quantization scale</dd>
<dd>quantization scale. Same rank as data. On axes other than quantize_axis, a dimension of 1 broadcasts the scale along that axis (e.g. a single per-tensor scale for the whole table); only applicable when `data` is an FP8 or FP4 type.</dd>
<dt><tt>zero_points</tt> (optional) : T1</dt>
<dd>quantization zero points</dd>
<dd>quantization zero points. Must not be provided when `data` is an FP8 or FP4 type.</dd>
</dl>

#### Outputs
Expand All @@ -2481,7 +2496,7 @@ This version of the operator has been available since version 1 of the 'com.micr
#### Type Constraints

<dl>
<dt><tt>T1</tt> : tensor(int4), tensor(uint4), tensor(uint8)</dt>
<dt><tt>T1</tt> : tensor(int4), tensor(uint4), tensor(uint8), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(float4e2m1)</dt>
<dd>Constrain quantized types.</dd>
<dt><tt>T2</tt> : tensor(float), tensor(float16), tensor(bfloat16)</dt>
<dd>Constrain dequantized types.</dd>
Expand Down Expand Up @@ -4280,12 +4295,26 @@ This version of the operator has been available since version 1 of the 'com.micr
across invocations (chunked prefill or autoregressive decode), the optional past_ids input carries
those preceding ids and present_ids returns the ids to pass to the next call. Both have shape
(batch_size, max_ngram_size - 1) and are right-aligned, so the last slot is the most recent id.
Positions before the start of the whole sequence use pad_id. Running the op once over a full sequence
and running it over consecutive chunks while threading present_ids into past_ids produce identical
hash ids. When past_ids is omitted the missing history is pad_id, which matches a fresh sequence.
Positions before the start of the whole sequence use pad_id, or eos_token_id when it is provided.
Running the op once over a full sequence and running it over consecutive chunks while threading
present_ids into past_ids produce identical hash ids, including when reset_on_eos is enabled. When
segment_ids is used, segment boundaries are applied only within the current input_ids chunk and are
not inferred from past_ids. When past_ids is omitted the missing history is pad_id, or eos_token_id
when it is provided.
past_ids and present_ids may use the same allocation. Such in-place execution is transaction-safe
only when the whole operator call is unconditionally committed; a caller that may select a prefix or
roll back must preserve past_ids.

Comment thread
tianleiwu marked this conversation as resolved.
Optional inputs add packed-sequence and Qwen4-Exp-style n-gram embedding support:

- eos_token_id, when provided together with reset_on_eos != 0, causes causal history to reset at EOS
boundaries: any shifted position at or before the most recent EOS strictly before the current
position is replaced with eos_token_id instead of the real token.
- segment_ids, when provided, additionally resets causal history at any position whose segment id
differs from the immediately preceding position's segment id within input_ids. Segment boundaries
are not checked against past_ids history.
- head_offsets, when provided, adds a fixed per-output-head offset after the modulo by the head's
vocabulary size, letting all heads across all n-gram orders share one flat embedding table.

#### Version

Expand All @@ -4300,19 +4329,27 @@ This version of the operator has been available since version 1 of the 'com.micr
<dd>Number of hash heads emitted for each n-gram order.</dd>
<dt><tt>pad_id</tt> : int (required)</dt>
<dd>Compressed tokenizer id used to pad causal shifts before the beginning of a sequence.</dd>
<dt><tt>reset_on_eos</tt> : int</dt>
<dd>When non-zero and the eos_token_id input is provided, reset causal n-gram history at EOS boundaries as described in the op doc. Default is 0 (disabled), which preserves the original pad_id-only behavior.</dd>
</dl>

#### Inputs (3 - 4)
#### Inputs (3 - 7)

<dl>
<dt><tt>input_ids</tt> : M</dt>
<dd>Compressed tokenizer ids with shape (batch_size, sequence_length).</dd>
<dt><tt>multipliers</tt> : M</dt>
<dd>Per-shift hash multipliers with shape (max_ngram_size). Conventionally odd, but any value is accepted.</dd>
<dd>Per-shift hash multipliers with shape at least (max_ngram_size). Conventionally odd, but any value is accepted.</dd>
<dt><tt>vocab_sizes</tt> : M</dt>
<dd>Per-output-head vocabulary sizes, conventionally prime, with shape ((max_ngram_size - 1) * n_head_per_ngram). Every entry must be strictly positive. The CPU implementation rejects a non-positive entry; GPU implementations guard the modulo to avoid a device-side division by zero and emit a hash id of 0 for that head.</dd>
<dt><tt>past_ids</tt> (optional) : M</dt>
<dd>Optional compressed tokenizer ids for the max_ngram_size - 1 positions that precede this call, with shape (batch_size, max_ngram_size - 1). Right-aligned, so the last slot is the most recent id. If omitted the history is pad_id.</dd>
<dd>Optional compressed tokenizer ids for the max_ngram_size - 1 positions that precede this call, with shape (batch_size, max_ngram_size - 1). Right-aligned, so the last slot is the most recent id. If omitted the history is pad_id, or eos_token_id when provided.</dd>
<dt><tt>head_offsets</tt> (optional) : M</dt>
<dd>Optional per-output-head additive offset with shape ((max_ngram_size - 1) * n_head_per_ngram), added after the modulo.</dd>
<dt><tt>eos_token_id</tt> (optional) : M</dt>
<dd>Optional scalar end-of-sequence token id, same type as input_ids. Required for reset_on_eos to take effect and for EOS-based substitution of unavailable prior context; see the op doc.</dd>
<dt><tt>segment_ids</tt> (optional) : tensor(int32)</dt>
<dd>Optional per-token segment id with shape (batch_size, sequence_length), used to reset causal history at packed-sequence boundaries within input_ids.</dd>
</dl>

#### Outputs (1 - 2)
Expand Down
Loading
Loading