webgpu: add MatMulBnb4 contrib op support#29587
Open
xhcao wants to merge 1 commit into
Open
Conversation
Implement the MatMulBnb4 quantized matmul operator for the WebGPU execution provider, supporting both FP4 (quant_type=0) and NF4 (quant_type=1) blockwise 4-bit weight dequantization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement the MatMulBnb4 quantized matmul operator for the WebGPU execution provider, supporting both FP4 (quant_type=0) and NF4 (quant_type=1) blockwise 4-bit weight dequantization.
Description
Add WebGPU execution provider support for the MatMulBnb4 contrib operator, enabling blockwise 4-bit quantized matmul (bitsandbytes-style FP4 and NF4) to run on WebGPU.
Motivation and Context
Models quantized with bitsandbytes 4-bit weights fell back to CPU when running on WebGPU, causing significant slowdowns, and cannot use graph capture feature.
Adding a native WebGPU kernel keeps these quantized MatMulBnb4 on the GPU, avoiding costly EP fallback and CPU/GPU data transfers.
marqo-fashionSigLIP-text-bnb4: ~30% faster
marqo-fashionSigLIP-vision-bnb4: ~20% faster