PEPs 817, 825, and 850 propose extending the Python wheel format with wheel variants, which would let installers consider additional compatibility properties, like GPU architecture or CPU instruction set extensions, when choosing a build.
What does this mean for your project? This post walks through how to use wheel variants to distribute builds of the same release for different environments.
Before and after wheel variants #
Historically, Python has represented wheel compatibility in the platform tag of the wheel filename.
For example, the filename numpy-2.0.0-cp314-cp314-manylinux2014_x86_64.whl states that the wheel
works with any 64-bit x86 processor.
This format, however, presents two main gaps:
-
It does not capture GPU and TPU requirements.
We know that
torch 2.14.1on PyPI is compatible with CUDA 13.0 and the architecturessm_75,sm_80,sm_86,sm_90,sm_100andsm_120, but there’s nothing in the package that specifies this compatibility.On the PyTorch index, the filename for 2.14.1 is
torch-2.14.1+cu130-cp314-cp314-manylinux_2_28_x86_64.whl, which includes the CUDA version the wheel was built for (13.0), but still doesn’t list the GPU architectures the wheel supports. Even so, this information isn’t standardized across filenames, so installers cannot use these fields to check compatibility. -
It does not capture CPU extensions.
SIMD instructions can speed up C and Rust code by letting a CPU process several values at once. Developers can invoke them manually, or let the compiler generate them with flags such as
clang -march=x86-64-v3. A wheel’s platform tag identifies the CPU architecture (here, a 64-bit x86 processor), but it doesn’t specify the instruction set extensions that the build requires. This makes it difficult for projects to distribute wheels that require newer SIMD instructions, which can crash at runtime on older, incompatible CPUs.
Installing machine learning packages for the correct GPU is one of the most commonly raised uv issues. Currently, a user is responsible for selecting the build that is compatible with their desired CPU and architecture, which is difficult and error-prone.
Suppose a user wants to install PyTorch 2.14.1 on a Linux machine with an NVIDIA H100. To choose a
compatible build of PyTorch 2.14.1, the user checks that their driver supports CUDA 13.0 and that
the build supports their H100 (sm_90). They would then have to manually select the CUDA 13.0 build
from the PyTorch index:
uv add 'torch==2.14.1' --index pytorch=https://download.pytorch.org/whl/cu130If your project targets multiple GPUs, you also have to manually configure uv to handle conflicting PyTorch index URLs, which we cover in a dedicated docs page.
With wheel variants, maintainers can publish multiple builds of the same release, and the installer can automatically select a compatible wheel based on the user’s detected environment.
Installing torch across any environment becomes much simpler:
uv add torchSo, how do maintainers implement variants?
Implementing wheel variants #
Identify different builds #
By extending the wheel format, wheel variants let maintainers record additional compatibility data in binary packages. This enables a project to publish several wheels with different compatibility tags for the same package version.
The first step in implementing wheel variants is deciding which builds of your package to offer based on distinguishing characteristics. For each build variant you want to support, pick a short, free-form variant label. A variant label can describe one or more of these distinguishing build requirements.
For example, you may want to offer two builds of the same PyTorch release. Both require CUDA 13.0
support, but one also uses AVX-512 Foundation instructions; you might select cu130 and
cu130avx512 for the variant labels. Each label identifies a wheel variant. The variant
wheel for cu130 is the .whl file whose name ends in -cu130.whl.
torch-2.14.1-cp314-cp314-manylinux_2_28_x86_64-cu130.whl
torch-2.14.1-cp314-cp314-manylinux_2_28_x86_64-cu130avx512.whlIdentify relevant providers #
Once you know how your builds will differ, identify the providers that describe those differences.
A provider defines a set of properties that maintainers can use to describe a wheel’s requirements. Providers group these properties into categories called namespaces.
Namespaces generally can be any build characteristic that helps the installer choose which wheel to install, including:
- Hardware requirements, like the CPU instruction set extensions in
x86_64. - Library choices, such as OpenBLAS.
- Binary compatibility with a dependency, like a
flash-attnwheel built for the PyTorch 2.8 series, even though the same release can be built against other PyTorch versions.
For example, the NVIDIA provider governs the nvidia namespace, which includes features that
specify CUDA driver compatibility and GPU architecture.
Installers (like uv) may bundle a small set of trusted, essential providers by default. If the installer doesn’t already trust a provider that you want to use, you must explicitly authorize the installer to execute that provider’s code. We’ve already implemented some preliminary providers in the WheelNext repository.
Each provider defines and maintains the properties and values it recognizes. The
NVIDIA provider exposes
get_supported_configs() to list the features and values in the nvidia namespace that the host
machine supports:
configs = plugin.get_supported_configs()
# Returns:
# [
# VariantFeatureConfig(name='cuda_version_lower_bound', values=['12.8', '12.7', ...]),
# VariantFeatureConfig(name='cuda_version_upper_bound', values=[..., '13.0', '12.9']),
# VariantFeatureConfig(name='sm_arch', values=['95_real', ..., '90_real', '90_virtual']),
# ]There are a few types of providers, but the main kind of provider is a provider package, with
functions that the installer calls in an isolated virtual environment, similar to build backends.
The NVIDIA provider is implemented as a Python plugin and distributed in the
nvidia-variant-provider package.
For our cu130avx512 wheel, we’ll use the NVIDIA provider to describe CUDA and GPU requirements,
and the x86-64 provider to describe the AVX-512 Foundation requirement.
Describe each build #
Each variant wheel has a file {name}-{version}.dist-info/variant.json that describes the
requirements of its build. The package index collects these descriptions in
{name}-{version}-variants.json, which the installer uses to compare variants before downloading a
wheel.
In variant.json, the variant wheel will enumerate its variant properties. Throughout the post,
we’ll write variant properties in the shape namespace :: feature :: value. In variant.json,
properties are written as:
"namespace": { "feature": ["value"] }A variant namespace groups related features governed by a provider. A feature names a characteristic within that group, and a value specifies the build’s requirement for that characteristic.
In our cu130 and cu130avx512 example, both builds target the same GPU architectures, but the
cu130avx512 wheel also declares the CPU extension it requires. Its providers and variants
sections of its variant.json might look like:
{
"providers": {
"nvidia": {
"requires": ["nvidia-variant-provider"],
"plugin-api": "nvidia_variant_provider.plugin:NvidiaVariantPlugin"
},
"x86_64": { "requires": ["x86-64-variant-provider"] }
},
"variants": {
"cu130avx512": {
"nvidia": {
"cuda_version_lower_bound": ["13.0"],
"sm_arch": ["80_real", "90_real"]
},
"x86_64": { "avx512f": ["on"] }
}
}
}Here, the providers section identifies the plugin for each namespace. The variants section uses
these namespaces to describe the requirements of the cu130avx512 wheel.
Today, maintainers can add the variant label and metadata themselves or use an experimental tool
like variant-repack. We’re working to finalize the workflow outlined in PEP 817, where you declare
providers and variants in pyproject.toml, and your build tool writes the corresponding
variant.json into each wheel.
Declare variant-specific dependencies #
You can also use variant markers to specify dependencies in .dist-info/METADATA which are
conditional on particular wheel variants. These markers evaluate based on the wheel the installer
selects.
There are four available variant markers: variant_label, variant_namespaces, variant_features
and variant_properties. While the variant_label is a string value and uses == and !=
operators, the other three markers are sets of values and support the in and not in operators.
Suppose you have a package with one GPU and one CPU build per version. The GPU build requires
nvidia-util, while the CPU build can run without it. A variant marker enables you to declare
the nvidia-util dependency for only GPU builds. The associated dependency declaration in
METADATA would look like:
Requires-Dist: nvidia-util>=1,<2; "nvidia" in variant_namespacesThis example means: “install nvidia-util version 1.x only if the selected wheel declares
properties in the nvidia namespace.”
While you can use a marker to decide whether a build needs a package, we recommend against using markers to choose which version of a package each CUDA build requires. For example:
nvidia-cuda-support==13.2; "nvidia :: cuda_version_lower_bound :: 13.2" in variant_properties
nvidia-cuda-support==13.3; "nvidia :: cuda_version_lower_bound :: 13.3" in variant_propertiesSome universal resolvers may not support choosing a dependency’s version based on which wheel is selected, meaning they may fail to generate a lockfile.
Instead, we recommend using variants across the stack. The maintainer would publish two wheels for
v1.0 of nvidia-cuda-support, one for CUDA 13.2, and one for CUDA 13.3, and leave the installer to
determine which to install based on variant metadata. Both CUDA builds of your package would then
declare the same requirement:
nvidia-cuda-support==1.0How an installer chooses a wheel #
Compatibility #
When a user installs your package, the installer first checks the wheel’s Python, ABI, and platform tags. For wheels that match these requirements, the installer will then compare the variant properties declared by the wheel with the values the user’s machine supports.
For a wheel to be compatible, the host must support at least one value for every feature the wheel declares. Suppose the user has an NVIDIA H100 and a driver that supports CUDA 13.0:
The cu130 wheel requires…
nvidia :: cuda_version_lower_bound :: 13.0
nvidia :: sm_arch :: 80_real
nvidia :: sm_arch :: 90_realand the host supports…
nvidia :: cuda_version_lower_bound :: 13.0
nvidia :: cuda_version_lower_bound :: 12.8
nvidia :: cuda_version_lower_bound :: 12.6
nvidia :: cuda_version_lower_bound :: 12.4
nvidia :: sm_arch :: 90_real
nvidia :: sm_arch :: 90_virtualThe features nvidia :: sm_arch and nvidia :: cuda_version_lower_bound are satisfied by the
matches on our cu130 wheel’s values of 90_real and 13.0, respectively.
If the CPU also supported AVX-512 instructions, then both cu130 and cu130avx512 would be
compatible with the host. How would the installer choose between these two wheels?
Ordering #
When more than one wheel is compatible, the installer ranks wheels by their matching variant properties. Maintainers can influence which wheel is selected by choosing which namespaces take priority.
The installer ranks variants first by namespace, then by feature, then by value. A maintainer
defines namespace rankings based on the order they appear in variant.json, but rankings of
features or values are determined by the provider.
If two wheels have the same highest-priority match, the installer will identify the second-best match, and so on. If all wheels rank equally on variant properties, then the platform tag will be considered.
In our example, if the maintainer lists nvidia before x86_64 in default_priorities.namespace,
the installer compares NVIDIA matches first.
{
"$schema": "...",
"default-priorities": {
"namespace": ["nvidia", "x86_64"]
},
"providers": {
"nvidia": {
"requires": ["nvidia-variant-provider"],
"plugin-api": "nvidia_variant_provider.plugin:NvidiaVariantPlugin"
},
"x86_64": { "requires": ["x86-64-variant-provider"] }
},
"variants": {
"cu130": {
"nvidia": { "cuda_version_lower_bound": ["13.0"], "sm_arch": ["80_real", "90_real"] }
},
"cu130avx512": {
"nvidia": { "cuda_version_lower_bound": ["13.0"], "sm_arch": ["80_real", "90_real"] },
"x86_64": { "avx512f": ["on"] }
}
}
}Both cu130 and cu130avx512 wheels match on CUDA 13.0 and GPU architecture 90_real, so their
NVIDIA properties tie. The installer then compares their CPU properties and selects the
cu130avx512 wheel due to its additional match of x86_64 :: avx512f :: on.
Up next #
The variant format described in this post has been provisionally accepted in PEP 825, with the provider implementation (PEP 850) still in draft.
You can try uv’s experimental wheel selection today with the wheel-variants preview feature
enabled in uv version 0.13.8 and above. Currently, you can test preview functionality with packages
from the public WheelNext test index; we’re
working on a standard way to build variant wheels and publish them on PyPI. If there’s something you
need in uv to adopt variants,
let us know!
If you’re considering implementing wheel variants for your package, we’d love to hear how you’d use them and what the proposed standards might be missing.