Registry / ai-ml / transformer-engine-cu12

transformer-engine-cu12

JSON →
library2.16.0pypypiunverified

Transformer Engine (TE) is a Python library by NVIDIA for accelerating Transformer models on NVIDIA GPUs. It enables lower precision training and inference, notably supporting 8-bit (FP8) and 4-bit (NVFP4) floating point precision on Hopper, Ada, and Blackwell GPUs, leading to better performance and reduced memory utilization. It provides highly optimized building blocks for popular Transformer architectures and an automatic mixed precision-like API for PyTorch and JAX. The current version is 2.13.0, with an active release cadence, often aligning with new NVIDIA hardware and software advancements.

pip install --no-build-isolation transformer-engine-cu12[pytorch]
INSTALL
IMPORT
SIG · TRANSFORMER-ENGINE
T
transformer-engine-cu12
ai-mlpythonv2.16.0
Install
12.8s avg
Import
Disk
394MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.960 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.960 runs
installs and imports cleanly · install 12.8s · import 0.000s · 726MB
394MB installed
● package 394MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Linear
from transformer_engine.pytorch import Linear
LayerNorm
from transformer_engine.pytorch import LayerNorm
TransformerLayer
from transformer_engine.pytorch import TransformerLayer
fp8_autocast
from transformer_engine.pytorch.fp8 import fp8_autocast
from transformer_engine.fp8 import fp8_autocast
The `fp8_autocast` context manager is framework-specific and located within the `pytorch` or `jax` submodule.

This quickstart demonstrates how to use `transformer_engine.pytorch.Linear` with FP8 autocasting. Ensure you have PyTorch and a compatible CUDA environment set up. The `fp8_autocast` context manager automatically handles FP8 quantization for supported operations within its scope.

import torch from transformer_engine.pytorch import Linear, fp8_autocast # Dummy input tensor input_tensor = torch.randn(16, 128, device='cuda', dtype=torch.float16) # Initialize a Transformer Engine Linear layer te_linear_layer = Linear(128, 256, bias=True, dtype=torch.float16).cuda() # Perform a forward pass with FP8 autocasting with fp8_autocast(): output_tensor = te_linear_layer(input_tensor) print(f"Input shape: {input_tensor.shape}, dtype: {input_tensor.dtype}") print(f"Output shape: {output_tensor.shape}, dtype: {output_tensor.dtype}") assert output_tensor.dtype == torch.float8_e4m3fn or output_tensor.dtype == torch.float8_e5m2, "Output should be FP8 or similar based on precision policy." print("Quickstart example ran successfully with FP8 autocasting.")
Debug
Known issues
breakingBreaking changes in `InferenceParams` and removal of the `interval` argument for `DelayedScaling` in PyTorch. `num_heads_kv`, `head_dim_k`, and `dtype` are now required for `InferenceParams` initialization, and `pre_step` must be called.
fix
Review the Transformer Engine 2.2 release notes for `InferenceParams` and `DelayedScaling` API updates. Adjust code to use new required arguments and method calls.
affects: >=2.2.0
breakingThe deprecated packed fused attention C APIs (`nvte_fused_attn_{fwd,bwd}_{qkvpacked,kvpacked}`) have been removed. Users must migrate to the non-packed API variants.
fix
Update C++ code to use the non-packed fused attention APIs. Consult Transformer Engine's C++ API documentation for the correct alternatives.
affects: >=2.13.0
deprecatedThe installation of Transformer Engine now requires the `--no-build-isolation` flag when using PyPI or building from source. Support for installations *with* build isolation will be removed in a future release.
fix
Always include `--no-build-isolation` in your `pip install` commands for Transformer Engine to ensure future compatibility and prevent potential build issues. E.g., `pip install --no-build-isolation transformer-engine-cu12[pytorch]`.
affects: >=2.3.0
gotchaABI compatibility issues can arise if PyTorch and Transformer Engine are built with different C++ ABI settings, especially outside of NGC containers. This leads to `ImportError` with undefined symbols.
fix
Ensure PyTorch and Transformer Engine are built with the same C++ ABI. Rebuilding PyTorch from source with a matching ABI might be necessary, or use NVIDIA NGC Docker containers where these dependencies are pre-configured.
affects: All versions
gotchaInstalling `transformer-engine-cu12` via PyPI may crash in environments with CUDA version < 12.8, despite the `cu12` suffix implying CUDA 12 support generally.
fix
Ensure your CUDA environment is at least 12.8 or higher when installing from PyPI. If you must use an older CUDA 12.x version (e.g., 12.1), consider installing Transformer Engine from source and explicitly managing CUDA paths during the build process, or use an NGC container.
affects: >=2.2.0
Upgrade
Version history
2.16.0latest on PyPI · released Jun 9, 2026
Audit
Dependencies
pythonrequiredRequired for the library to run.
pytorchoptionalRequired for PyTorch integration. Installed as an extra dependency.
jaxoptionalRequired for JAX integration. Installed as an extra dependency.
CUDArequiredNVIDIA CUDA Toolkit 12.1+ (12.8+ for Blackwell GPUs) with compatible NVIDIA drivers.
cuDNNrequiredcuDNN 9.3+ is required for optimal performance.
Agent activity
45 hits · last 30 days
node
40
OpenAI (training)
1
Resources