OpenAI has released the GPT‑OSS series of models, featuring novel techniques such as MXFP4 quantization, efficient kernels, and a new chat format. To support these models, the Hugging Face transformers library has been upgraded to load, run, and fine‑tune GPT‑OSS efficiently, including native MXFP4 support and automatic downloading of pre‑built kernels from the Hub. The updates also enable tensor‑parallelism and other performance optimizations that can benefit a wide range of models in the transformers ecosystem.
OpenAI recently released their GPT-OSS series of models . The models feature some novel techniques like MXFP4 quantization, efficient kernels, a brand new chat format, and more. To enable the release of gpt-oss through transformers , we have upgraded the library considerably. The updates make it very efficient to load , run , and fine-tune the models.
In this blog post, we talk about all the upgrades in-depth, and how they become part of the transformers toolkit so other models (current and future) can benefit from them. Providing clean implementations of new methods in transformers also allows the community to quickly understand and adopt them. Frameworks such as MLX , llama.cpp or vLLM can use the transformers code as a reference to build their own implementations.
Best part: Most of these features should work across all major models within transformers !
In addition, the community has created custom kernels for frequent combinations of operations, not just individual PyTorch ops like matmul . For example, Flash Attention was created to optimize the critical attention block that defines the transformers architecture, and is present in many models including most LLMs. By carefully combining all the attention operations inside a single kernel, memory transfers are minimized, memory use is reduced, and speedups can be achieved.
OpenAI gpt-oss models use attention sinks , which improves quality and facilitates the use of longer contexts. The vLLM team added this feature to the latest version of Flash Attention (Flash Attention 3), and the resulting custom kernel is available on the Hub . Currently, this kernel is compatible with the Hopper architecture. If you have one, this is the way to enable it:
Large language models are memory-hungry. Quantization reduces memory footprint by storing weights (and sometimes activations) in lower-precision formats. For reference, FP32 uses 32 bits per number and BF16 uses 16. By reducing bit width, we trade some precision for smaller models and faster memory movement.
Efficient MXFP4 requires kernels that understand 32-element blocks and their scales during GEMMs and fused ops. This is where Kernels from the Hub comes in again. transformers automatically pulls in the MXFP4 -aware Triton kernels from the community repository when you load a model that needs them. The repository will appear in your local cache and will be used during the forward pass. For the MXFP4 kernels one does not need to use the use_kernels=True parameter like before, it is set to default in transformers .
MXFP4 is a 4-bit floating format with E2M1 layout: 1 sign bit, 2 exponent bits, and 1 mantissa bit, as shown in Figure 2 . On its own, E2M1 is very coarse. MXFP4 compensates with blockwise scaling :
transformers now includes native support for MXFP4, leveraging optimized triton (MXFP4) kernels for enhanced performance. This builds on the community-driven kernel distribution discussed earlier , utilizing pre-compiled kernels from the Hub to simplify deployment.
Thanks to this pull request , you can fine-tune gpt-oss models and save them directly to the Hub in MXFP4 format, streamlining deployment with optimized performance.
A kernel is a specialized , compact program that runs on accelerators to execute tasks like matrix multiplications, activations, or normalizations. In eager PyTorch, operations trigger individual kernels sequentially, which is straightforward but can incur extra memory transfers and launch overheads. PyTorch 2.0's torch.compile with backends like TorchInductor addresses this by automatically fusing and optimizing kernels, delivering 2–10× performance gains.
The problem is that all these various kernels are available in separate libraries, which creates a dependency bloat if they were to be added to the transformers library. Furthermore, these kernels are not just Python code, they consist of low-level cuda code, glued together with C++ and exposed through a Python layer. This means they have to be compiled in the target system, which in turn requires whatever build system is required by each kernel library.
The kernels package solves this problem by downloading pre-built binaries of supported kernels from the Hub. You just indicate the kernel you want to use, and kernels will look for a version compatible with your system and download it on first use.
Efficient quantization and kernel management lower the hardware barrier for deploying large language models, accelerating research and commercial deployment across the AI industry.