Describe the issue
Problem:
The shader code used by WebGPU's softmax currently always uses the naive safe softmax algorithm.
For some hardware with faster exp, using online safe softmax (as described in https://arxiv.org/abs/1805.02867) can improve the inference time.
Still, for hardware with slower exp, naive safe softmax might perform better than online safe softmax.
Proposal:
Add a per-session or per-context WebGPU EP option to allow selecting the softmax algorithm used (say, "naive" and "online").
Use online safe softmax shader code if the online algorithm is selected.
Possible changes involved for C++:
- In webgpu_provider_options.h, add a new option - say -
"ep.webgpuexecutionprovider.softmaxAlgorithm" and 2 constant strings for the values - say - "naive" and "online".
- In webgpu_provider_factory.cc, parse the option and add it to the logs.
- Add shader code for online safe softmax
- Per-session or per-context changes to configure the softmax algorithm
- Software-architecture dependent changes to use the selected algorithm
To reproduce
- Write WebGPU shader code for online safe softmax.
- Compare the performance between using naive safe softmax and using online safe softmax with a model with the softmax op.
- Depending on the hardware and model, there may be performance gain or loss when using online safe softmax.
Urgency
No response
Platform
Other / Unknown
OS Version
Custom
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.26.0
ONNX Runtime API
C++
Architecture
Other / Unknown
Execution Provider
Other / Unknown
Execution Provider Library Version
No response
Model File
No response
Is this a quantized model?
Unknown
Describe the issue
Problem:
The shader code used by WebGPU's softmax currently always uses the naive safe softmax algorithm.
For some hardware with faster exp, using online safe softmax (as described in https://arxiv.org/abs/1805.02867) can improve the inference time.
Still, for hardware with slower exp, naive safe softmax might perform better than online safe softmax.
Proposal:
Add a per-session or per-context WebGPU EP option to allow selecting the softmax algorithm used (say, "naive" and "online").
Use online safe softmax shader code if the online algorithm is selected.
Possible changes involved for C++:
"ep.webgpuexecutionprovider.softmaxAlgorithm"and 2 constant strings for the values - say -"naive"and"online".To reproduce
Urgency
No response
Platform
Other / Unknown
OS Version
Custom
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.26.0
ONNX Runtime API
C++
Architecture
Other / Unknown
Execution Provider
Other / Unknown
Execution Provider Library Version
No response
Model File
No response
Is this a quantized model?
Unknown