Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit ed5722d

Browse files
danieldksywangyiMekkCyber
authored
Add Torch 2.9 build variants (#242)
This change adds Torch 2.9 build variants to kernel-builder. Until the final release of Torch 2.9, the Torch 2.7 variants are also still built. The Torch 2.9 support is based on RC5, typically there are no ABI-incompatible changes at this point, but there is no guarantee. --------- Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> Co-authored-by: Wang, Yi <yi.a.wang@intel.com> Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
1 parent bf29eb5 commit ed5722d

11 files changed

Lines changed: 151 additions & 55 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Python package.
1515

1616
This builder is a core component of the larger kernel build/distribution system.
1717

18+
**Torch 2.9 note:** kernel-builder currently builds Torch 2.9 extensions based on
19+
the [fifth release candidate](https://dev-discuss.pytorch.org/t/reminder-calls-for-features-upcoming-branch-cut/3225).
20+
If you upload Torch 2.9 kernels, please validate them against
21+
the final Torch 2.9.0 release. In the unlikely case of an ABI-breaking
22+
change, you can rebuild and upload your kernel once kernel-builder
23+
is updated for the final release
24+
1825
## 🚀 Quick Start
1926

2027
We recommend using [Nix](https://nixos.org/download.html) to build kernels. To speed up builds, first enable the Hugging Face binary cache:

build-variants.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
"aarch64-darwin": {
33
"metal": [
44
"torch27-metal-aarch64-darwin",
5-
"torch28-metal-aarch64-darwin"
5+
"torch28-metal-aarch64-darwin",
6+
"torch29-metal-aarch64-darwin"
67
]
78
},
89
"aarch64-linux": {
910
"cuda": [
1011
"torch27-cxx11-cu128-aarch64-linux",
11-
"torch28-cxx11-cu129-aarch64-linux"
12+
"torch28-cxx11-cu129-aarch64-linux",
13+
"torch29-cxx11-cu126-aarch64-linux",
14+
"torch29-cxx11-cu128-aarch64-linux",
15+
"torch29-cxx11-cu130-aarch64-linux"
1216
]
1317
},
1418
"x86_64-linux": {
@@ -18,16 +22,22 @@
1822
"torch27-cxx11-cu128-x86_64-linux",
1923
"torch28-cxx11-cu126-x86_64-linux",
2024
"torch28-cxx11-cu128-x86_64-linux",
21-
"torch28-cxx11-cu129-x86_64-linux"
25+
"torch28-cxx11-cu129-x86_64-linux",
26+
"torch29-cxx11-cu126-x86_64-linux",
27+
"torch29-cxx11-cu128-x86_64-linux",
28+
"torch29-cxx11-cu130-x86_64-linux"
2229
],
2330
"rocm": [
2431
"torch27-cxx11-rocm63-x86_64-linux",
2532
"torch28-cxx11-rocm63-x86_64-linux",
26-
"torch28-cxx11-rocm64-x86_64-linux"
33+
"torch28-cxx11-rocm64-x86_64-linux",
34+
"torch29-cxx11-rocm63-x86_64-linux",
35+
"torch29-cxx11-rocm64-x86_64-linux"
2736
],
2837
"xpu": [
2938
"torch27-cxx11-xpu20250-x86_64-linux",
30-
"torch28-cxx11-xpu20251-x86_64-linux"
39+
"torch28-cxx11-xpu20251-x86_64-linux",
40+
"torch29-cxx11-xpu20252-x86_64-linux"
3141
]
3242
}
3343
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
["7.0", "7.2", "7.5", "8.0", "8.6", "8.7", "8.9", "9.0", "10.0", "10.1", "12.0"]
1+
[
2+
"7.0",
3+
"7.2",
4+
"7.5",
5+
"8.0",
6+
"8.6",
7+
"8.7",
8+
"8.9",
9+
"9.0",
10+
"10.0",
11+
"10.1",
12+
"11.0",
13+
"12.0"
14+
]

build2cmake/src/templates/cuda/preamble.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ if (NOT TARGET_DEVICE STREQUAL "cuda" AND
3535
endif()
3636

3737
if(DEFINED CMAKE_CUDA_COMPILER_VERSION AND
38+
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
39+
set(CUDA_DEFAULT_KERNEL_ARCHS "7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0+PTX")
40+
elseif(DEFINED CMAKE_CUDA_COMPILER_VERSION AND
3841
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.8)
3942
set(CUDA_DEFAULT_KERNEL_ARCHS "7.0;7.2;7.5;8.0;8.6;8.7;8.9;9.0;10.0;10.1;12.0+PTX")
4043
else()

docs/build-variants.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ available. This list will be updated as new PyTorch versions are released.
99

1010
- `torch27-metal-aarch64-darwin`
1111
- `torch28-metal-aarch64-darwin`
12+
- `torch29-metal-aarch64-darwin`
1213

1314
## CUDA aarch64-linux
1415

1516
- `torch27-cxx11-cu128-aarch64-linux`
1617
- `torch28-cxx11-cu129-aarch64-linux`
18+
- `torch29-cxx11-cu126-aarch64-linux`
19+
- `torch29-cxx11-cu128-aarch64-linux`
20+
- `torch29-cxx11-cu130-aarch64-linux`
1721

1822
## CUDA x86_64-linux
1923

@@ -23,17 +27,23 @@ available. This list will be updated as new PyTorch versions are released.
2327
- `torch28-cxx11-cu126-x86_64-linux`
2428
- `torch28-cxx11-cu128-x86_64-linux`
2529
- `torch28-cxx11-cu129-x86_64-linux`
30+
- `torch29-cxx11-cu126-x86_64-linux`
31+
- `torch29-cxx11-cu128-x86_64-linux`
32+
- `torch29-cxx11-cu130-x86_64-linux`
2633

2734
## ROCm x86_64-linux
2835

2936
- `torch27-cxx11-rocm63-x86_64-linux`
3037
- `torch28-cxx11-rocm63-x86_64-linux`
3138
- `torch28-cxx11-rocm64-x86_64-linux`
39+
- `torch29-cxx11-rocm63-x86_64-linux`
40+
- `torch29-cxx11-rocm64-x86_64-linux`
3241

3342
## XPU x86_64-linux
3443

3544
- `torch27-cxx11-xpu20250-x86_64-linux`
3645
- `torch28-cxx11-xpu20251-x86_64-linux`
46+
- `torch29-cxx11-xpu20252-x86_64-linux`
3747

3848
## Universal
3949

docs/nix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ We recommend installing Nix in the following way:
66

77
- Linux: use the [official Nix installer](https://nixos.org/download/).
88
- macOS: use the [Determinate Nix installer](https://docs.determinate.systems/determinate-nix/).
9+
In addition, Xcode 16.x is currently required to build kernels.
910

1011
## Getting started
1112

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -144,39 +144,35 @@
144144
}) buildSets
145145
);
146146

147-
# Dependencies that should be cached.
147+
# Dependencies that should be cached, the structure of the output
148+
# path is: <build variant>/<dependency>-<output>
148149
forCache =
149150
let
150151
filterDist = lib.filter (output: output != "dist");
151-
# Get all `torch` outputs except for `dist`. Not all outputs
152-
# are dependencies of `out`, but we'll need the `cxxdev` and
153-
# `dev` outputs for kernel builds.
154-
torchOutputs = builtins.listToAttrs (
155-
lib.flatten (
156-
# Map over build sets.
157-
map (
158-
buildSet:
159-
# Map over all outputs of `torch` in a buildset.
160-
map (output: {
161-
name = "${buildVersion buildSet}-${output}";
162-
value = buildSet.torch.${output};
163-
}) (filterDist buildSet.torch.outputs)
164-
) buildSets
165-
)
166-
);
167-
oldLinuxStdenvs = builtins.listToAttrs (
168-
map (buildSet: {
169-
name = "stdenv-${buildVersion buildSet}";
170-
value = buildSet.pkgs.stdenvGlibc_2_27;
171-
}) buildSets
172-
);
152+
# Get all outputs except for `dist` (which is the built wheel for Torch).
153+
allOutputs =
154+
drv:
155+
map (output: {
156+
name = "${drv.pname or drv.name}-${output}";
157+
path = drv.${output};
158+
}) (filterDist drv.outputs or [ "out" ]);
159+
buildSetOutputs =
160+
buildSet:
161+
with buildSet.pkgs;
162+
(
163+
allOutputs buildSet.torch
164+
++ allOutputs build2cmake
165+
++ allOutputs kernel-abi-check
166+
++ allOutputs python3Packages.kernels
167+
++ lib.optionals stdenv.hostPlatform.isLinux (allOutputs stdenvGlibc_2_27)
168+
);
169+
buildSetLinkFarm = buildSet: pkgs.linkFarm (buildVersion buildSet) (buildSetOutputs buildSet);
173170
in
174171
pkgs.linkFarm "packages-for-cache" (
175-
{
176-
inherit build2cmake kernel-abi-check;
177-
}
178-
// torchOutputs
179-
// lib.optionalAttrs nixpkgs.legacyPackages.${system}.stdenv.isLinux oldLinuxStdenvs
172+
map (buildSet: {
173+
name = buildVersion buildSet;
174+
path = buildSetLinkFarm buildSet;
175+
}) buildSets
180176
);
181177
};
182178
}

lib/torch-extension/default.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let
5555
onednn-xpu = xpuPackages.onednn-xpu.override { inherit stdenv oneapi-torch-dev; };
5656

5757
# On Darwin, we need the host's xcrun for `xcrun metal` to compile Metal shaders.
58-
# t's not supported by the nixpkgs shim.
58+
# It's not supported by the nixpkgs shim.
5959
xcrunHost = writeScriptBin "xcrunHost" ''
6060
# Use system SDK for Metal files.
6161
unset DEVELOPER_DIR
@@ -152,8 +152,11 @@ stdenv.mkDerivation (prevAttrs: {
152152
TORCH_CUDA_ARCH_LIST =
153153
if cudaPackages.cudaOlder "12.8" then
154154
"7.0;7.5;8.0;8.6;8.9;9.0"
155+
else if cudaPackages.cudaOlder "13.0" then
156+
"7.0;7.5;8.0;8.6;8.9;9.0;10.0;10.1;12.0"
155157
else
156-
"7.0;7.5;8.0;8.6;8.9;9.0;10.0;10.1;12.0";
158+
# sm_101 has been renamed to sm_110 in CUDA 13.
159+
"7.5;8.0;8.6;8.9;9.0;10.0;11.0;12.0";
157160
}
158161
// lib.optionalAttrs rocmSupport {
159162
PYTORCH_ROCM_ARCH = lib.concatStringsSep ";" torch.rocmArchs;

lib/version-utils.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{ lib }:
22

3+
let
4+
inherit (lib) versions;
5+
in
36
{
4-
flattenVersion = version: lib.replaceStrings [ "." ] [ "" ] (lib.versions.pad 2 version);
7+
flattenVersion =
8+
version: lib.replaceStrings [ "." ] [ "" ] (versions.majorMinor (versions.pad 2 version));
59
abiString = cxx11Abi: if cxx11Abi then "cxx11" else "cxx98";
610
}

0 commit comments

Comments
 (0)