gpt-oss-20b ONNX Models
This repository hosts the optimized versions of gpt-oss-20b to accelerate inference with ONNX Runtime. Model optimizations refer to techniques and methods used to improve the run time performance, efficiency, and resource utilization of machine learning models.
Optimized models are published here in ONNX format to run with ONNX Runtime with the precision best suited to this target.
To easily get started with the model, you can use Foundry Local. See instructions here.
ONNX Models
Here are some of the optimized configurations we have added:
ONNX model for CPU and mobile using int4 quantization via RTN and block size 32.
ONNX model for CUDA GPU using int4 quantization via k-quant mixed precision and block size 32.
ONNX model for WebGPU using int4 quantization via RTN and block size 32.
Model Run
You can also install ONNX Runtime GenAI to run the model. You can then run the inference example here.
For CPU:
# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/gpt-oss-20b-onnx --include cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4/* --local-dir .
# Install the CPU package of ONNX Runtime GenAI
pip install onnxruntime-genai
# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-chat.py -o model-chat.py
python model-chat.py -m cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4 -e follow_config
For CUDA:
# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/gpt-oss-20b-onnx --include cuda/cuda-int4-kquant-block-32-mixed/* --local-dir .
# Install the CUDA package of ONNX Runtime GenAI
pip install onnxruntime-genai-cuda
# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-chat.py -o model-chat.py
python model-chat.py -m cuda/cuda-int4-kquant-block-32-mixed -e follow_config
For WebGPU:
# Download the model directly using the Hugging Face CLI
huggingface-cli download onnxruntime/gpt-oss-20b-onnx --include webgpu/webgpu-int4-rtn-block-32/* --local-dir .
# Install the WebGPU packages of ONNX Runtime and ONNX Runtime GenAI
pip install onnxruntime-webgpu
pip install onnxruntime-genai --no-deps
# Please adjust the model directory (-m) accordingly
curl https://raw.githubusercontent.com/microsoft/onnxruntime-genai/main/examples/python/model-chat.py -o model-chat.py
python model-chat.py -m webgpu/webgpu-int4-rtn-block-32 -e follow_config
Model Description
- Developed by: Microsoft
- Model type: ONNX
- License: Apache-2.0
- License Description: Use of this model is subject to the terms of the Apache License, Version 2.0, available at https://www.apache.org/licenses/LICENSE-2.0.
- Model Description: This is a conversion of the gpt-oss-20b model for local inference on CPUs and GPUs.
- Disclaimer: Model is only an optimization of the base model, any risk associated with the model is the responsibility of the user of the model. Please verify and test for your scenarios. There may be a slight difference in output from the base model with the optimizations applied. Note that optimizations applied are distinct from fine tuning and thus do not alter the intended uses or capabilities of the model.
Base Model Information
See HF link gpt-oss-20b for details.
- Downloads last month
- 48
Model tree for onnxruntime/gpt-oss-20b-onnx
Base model
openai/gpt-oss-20b