Skip to content

Add BF16 kernels in several ops for Gemma-3 - #26102

Merged
kunal-vaishnavi merged 15 commits into
microsoft:mainfrom
kunal-vaishnavi:kvaishnavi/gemma3-bf16
Sep 25, 2025
Merged

Add BF16 kernels in several ops for Gemma-3#26102
kunal-vaishnavi merged 15 commits into
microsoft:mainfrom
kunal-vaishnavi:kvaishnavi/gemma3-bf16

Conversation

@kunal-vaishnavi

Copy link
Copy Markdown
Contributor

Description

This PR adds missing kernels for bfloat16 precision across several ops in both the ai.onnx and com.microsoft domains.

  1. SkipLayerNormalization contrib op
  2. Conv for opset 22
  3. Pow for opset 15
  4. AveragePool for opset 22

This PR also enables weight-only quantization of a bfloat16 MatMul op to a bfloat16 MatMulNBits contrib op.

Motivation and Context

This PR enables running ONNX models from the Gemma-3 family that are generated with bfloat16 precision.

@nenad1002 nenad1002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing docs which fails some pipelines

Comment thread onnxruntime/test/providers/cpu/tensor/cast_op_test.cc
Comment thread onnxruntime/core/providers/cuda/cudnn_common.cc Outdated
Comment thread onnxruntime/test/providers/cpu/tensor/cast_op_test.cc
@kunal-vaishnavi
kunal-vaishnavi merged commit 99e10e6 into microsoft:main Sep 25, 2025
92 of 104 checks passed
kunal-vaishnavi added a commit to microsoft/onnxruntime-genai that referenced this pull request Sep 25, 2025
### Description

This PR enables multi-modal models to use bfloat16 precision for other
models besides the text decoder. It requires the changes from this [ORT
PR](microsoft/onnxruntime#26102).

### Motivation and Context

Models from the Gemma-3 family can lose accuracy with float16 precision
and require bfloat16 precision for higher quality output.
hariharans29 added a commit that referenced this pull request Sep 26, 2025
### Description
Fix warnings in non-CUDA EP Windows builds


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
 
Minor fix from #26102
fs-eire pushed a commit that referenced this pull request Oct 24, 2025
### Description

This PR adds missing kernels for bfloat16 precision across several ops
in both the `ai.onnx` and `com.microsoft` domains.

1. `SkipLayerNormalization` [contrib
op](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#commicrosoftskiplayernormalization)
2. `Conv` for [opset 22](https://onnx.ai/onnx/operators/onnx__Conv.html)
3. `Pow` for [opset 15](https://onnx.ai/onnx/operators/onnx__Pow.html)
4. `AveragePool` for [opset
22](https://onnx.ai/onnx/operators/onnx__AveragePool.html)

This PR also enables weight-only quantization of a bfloat16 `MatMul` op
to a bfloat16 `MatMulNBits` [contrib
op](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#commicrosoftmatmulnbits).

### Motivation and Context

This PR enables running ONNX models from the Gemma-3 family that are
generated with bfloat16 precision.
fs-eire pushed a commit that referenced this pull request Oct 24, 2025
### Description
Fix warnings in non-CUDA EP Windows builds


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
 
Minor fix from #26102
naomiOvad pushed a commit to naomiOvad/onnxruntime that referenced this pull request Nov 2, 2025
### Description

This PR adds missing kernels for bfloat16 precision across several ops
in both the `ai.onnx` and `com.microsoft` domains.

1. `SkipLayerNormalization` [contrib
op](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#commicrosoftskiplayernormalization)
2. `Conv` for [opset 22](https://onnx.ai/onnx/operators/onnx__Conv.html)
3. `Pow` for [opset 15](https://onnx.ai/onnx/operators/onnx__Pow.html)
4. `AveragePool` for [opset
22](https://onnx.ai/onnx/operators/onnx__AveragePool.html)

This PR also enables weight-only quantization of a bfloat16 `MatMul` op
to a bfloat16 `MatMulNBits` [contrib
op](https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#commicrosoftmatmulnbits).

### Motivation and Context

This PR enables running ONNX models from the Gemma-3 family that are
generated with bfloat16 precision.
naomiOvad pushed a commit to naomiOvad/onnxruntime that referenced this pull request Nov 2, 2025
### Description
Fix warnings in non-CUDA EP Windows builds


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
 
Minor fix from microsoft#26102
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants