Skip to content

Commit 020ca13

Browse files
committed
torch: Rebase patches on 2.14.0
1 parent 98f8bc0 commit 020ca13

3 files changed

Lines changed: 49 additions & 904 deletions

File tree

.github/workflows/build-torch.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ jobs:
6969
run: |
7070
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0001-CI-Add-manywheel-Dockerfile-for-riscv64.patch
7171
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0002-CI-Add-cpu-riscv64-support-to-manywheel-scripts.patch
72-
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0003-CI-Add-native-build-image-for-linux-riscv64.patch
7372
7473
- name: Login to GitHub Container Registry
7574
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
@@ -153,7 +152,6 @@ jobs:
153152
run: |
154153
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0001-CI-Add-manywheel-Dockerfile-for-riscv64.patch
155154
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0002-CI-Add-cpu-riscv64-support-to-manywheel-scripts.patch
156-
git apply ../python-wheels/patches/torch/${{ env.TORCH_VERSION }}+cpu/0003-CI-Add-native-build-image-for-linux-riscv64.patch
157155
158156
- name: Populate binary env
159157
working-directory: pytorch

patches/torch/2.14.0+cpu/0002-CI-Add-cpu-riscv64-support-to-manywheel-scripts.patch

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ From: RISE Project CI <ci@riseproject.dev>
33
Date: Thu, 10 Jul 2026 00:00:00 +0000
44
Subject: [PATCH 2/2] [CI] Add cpu-riscv64 support to manywheel scripts
55

6-
Add riscv64 support to the manywheel build scripts:
6+
Add riscv64 support to the manywheel scripts:
77
- build.sh: add cpu-riscv64 to GPU_ARCH_TYPE case
88
- build_env_setup.py: add manylinux_2_39_riscv64 PLATFORM_TAG and cpu-riscv64 env setup
99
- build_wheel.py: add riscv64 BLAS configuration (OpenBLAS, no MKLDNN)
@@ -14,30 +14,31 @@ Upstream-Status: Submitted [https://github.com/pytorch/pytorch/pull/191657]
1414
Signed-off-by: RISE Project CI <ci@riseproject.dev>
1515
---
1616
diff --git a/.ci/manywheel/build.sh b/.ci/manywheel/build.sh
17+
index 2f4abd2..8a0b0db 100755
1718
--- a/.ci/manywheel/build.sh
1819
+++ b/.ci/manywheel/build.sh
19-
@@ -6,7 +6,7 @@
20+
@@ -6,7 +6,7 @@ SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
2021
PYTORCH_ROOT="${PYTORCH_ROOT:-$(cd "${SCRIPTPATH}/../.." && pwd)}"
21-
22+
2223
case "${GPU_ARCH_TYPE:-BLANK}" in
2324
- cuda|cuda-aarch64|cpu|cpu-aarch64|cpu-cxx11-abi|xpu|rocm)
2425
+ cuda|cuda-aarch64|cpu|cpu-aarch64|cpu-riscv64|cpu-cxx11-abi|xpu|rocm)
2526
# New pipeline: pyproject-driven build via `python -m build`
2627
# then patchelf-based wheel repair.
2728
source "${SCRIPTPATH}/set_desired_python.sh"
28-
2929
diff --git a/.ci/manywheel/build_env_setup.py b/.ci/manywheel/build_env_setup.py
30+
index 776fde3..f8edfd2 100755
3031
--- a/.ci/manywheel/build_env_setup.py
3132
+++ b/.ci/manywheel/build_env_setup.py
32-
@@ -186,6 +186,7 @@
33+
@@ -227,6 +227,7 @@ def discover_rocm_home() -> str:
3334
PLATFORM_TAGS: dict[str, str] = {
3435
"x86_64": "manylinux_2_28_x86_64",
3536
"aarch64": "manylinux_2_28_aarch64",
3637
+ "riscv64": "manylinux_2_39_riscv64",
3738
}
38-
39-
40-
@@ -453,7 +454,13 @@
39+
40+
41+
@@ -494,7 +495,13 @@ def main() -> None:
4142
setup_cuda(cuda_version)
4243
env_out.update(cuda_build_env(cuda_version, arch))
4344
print(f"CUDA {cuda_version} environment configured")
@@ -52,14 +53,14 @@ diff --git a/.ci/manywheel/build_env_setup.py b/.ci/manywheel/build_env_setup.py
5253
cleanup_cuda_for_cpu_build()
5354
env_out.update(CPU_BUILD_ENV)
5455
print("CPU environment configured")
55-
5656
diff --git a/.ci/manywheel/build_wheel.py b/.ci/manywheel/build_wheel.py
57+
index 4b33397..b39298e 100755
5758
--- a/.ci/manywheel/build_wheel.py
5859
+++ b/.ci/manywheel/build_wheel.py
59-
@@ -36,26 +36,34 @@
60+
@@ -36,26 +36,34 @@ def configure_blas_env() -> None:
6061
os.environ["CMAKE_LIBRARY_PATH"] = "/opt/intel/lib:/lib"
6162
return
62-
63+
6364
- if arch != "aarch64":
6465
- return
6566
+ elif arch == "aarch64":
@@ -82,15 +83,16 @@ diff --git a/.ci/manywheel/build_wheel.py b/.ci/manywheel/build_wheel.py
8283
+ print("Using OpenBLAS and ACL for MKLDNN on CPU aarch64")
8384
+ os.environ["BLAS"] = "OpenBLAS"
8485
+ os.environ["OpenBLAS_HOME"] = "/opt/OpenBLAS"
85-
86+
+
87+
+ elif arch == "riscv64":
88+
+ os.environ["USE_MKLDNN"] = "0"
89+
8690
- if not Path("/acl").is_dir():
8791
- sys.exit("ERROR: ARM Compute Library not found at /acl")
8892
- os.environ["USE_MKLDNN"] = "1"
8993
- os.environ["USE_MKLDNN_ACL"] = "1"
9094
- os.environ["ACL_ROOT_DIR"] = "/acl"
91-
+ elif arch == "riscv64":
92-
+ os.environ["USE_MKLDNN"] = "0"
93-
95+
-
9496
- if gpu_arch_type == "cuda-aarch64":
9597
- nvpl = Path("/usr/local/lib/libnvpl_blas_lp64_gomp.so.0")
9698
- if not nvpl.is_file():
@@ -105,28 +107,28 @@ diff --git a/.ci/manywheel/build_wheel.py b/.ci/manywheel/build_wheel.py
105107
+ print("Using OpenBLAS for MKLDNN on CPU riscv64")
106108
os.environ["BLAS"] = "OpenBLAS"
107109
os.environ["OpenBLAS_HOME"] = "/opt/OpenBLAS"
108-
109110

110111
diff --git a/.ci/manywheel/repair_wheel.py b/.ci/manywheel/repair_wheel.py
112+
index 5cc1122..a66444e 100755
111113
--- a/.ci/manywheel/repair_wheel.py
112114
+++ b/.ci/manywheel/repair_wheel.py
113-
@@ -24,6 +24,8 @@
114-
from dataclasses import dataclass
115-
from pathlib import Path
116-
115+
@@ -29,6 +29,8 @@ from pathlib import Path
116+
117+
from auditwheel.wheeltools import add_platforms, InWheelCtx
118+
117119
+from build_env_setup import PLATFORM_TAGS
118120
+
119-
121+
120122
PATCHELF = "/usr/local/bin/patchelf"
121-
122-
@@ -85,19 +87,22 @@
123+
124+
@@ -116,19 +118,22 @@ def rocm_rpaths() -> str:
123125
)
124-
125-
126+
127+
126128
-def aarch64_extra_deps(use_cuda: bool) -> list[Path]:
127129
+def arch_extra_deps(arch: str, use_cuda: bool) -> list[Path]:
128130
"""Libraries to bundle into torch/lib/ on aarch64.
129-
131+
130132
- CPU builds link against OpenBLAS + libgfortran; CUDA builds link against
131133
- NVPL. Both pick up ARM Compute Library (ACL) for oneDNN acceleration.
132134
+ CPU builds link against OpenBLAS + libgfortran
@@ -151,63 +153,61 @@ diff --git a/.ci/manywheel/repair_wheel.py b/.ci/manywheel/repair_wheel.py
151153
if use_cuda:
152154
candidates += [
153155
Path(f"/usr/local/lib/{name}")
154-
@@ -110,7 +115,8 @@
156+
@@ -141,7 +146,8 @@ def aarch64_extra_deps(use_cuda: bool) -> list[Path]:
155157
]
156158
else:
157159
candidates.append(Path("/opt/OpenBLAS/lib/libopenblas.so.0"))
158160
- deps = [p for p in candidates if p.is_file()]
159161
+
160162
+ deps: list[Path] = [p for p in candidates if p.is_file()]
161163
return deps
162-
163-
164-
@@ -295,7 +301,7 @@
165-
wheel: Path,
164+
165+
166+
@@ -352,7 +358,7 @@ def repair_wheel(
166167
output_dir: Path,
168+
platform_tag: str,
167169
libgomp_path: Path,
168170
- aarch64_deps: list[Path],
169171
+ arch_deps: list[Path],
170172
bundled_libs: list[BundledLib],
171173
aux_files: list[AuxFile],
172174
c_so_rpath: str,
173-
@@ -320,7 +326,7 @@
175+
@@ -379,7 +385,7 @@ def repair_wheel(
174176
)
175-
177+
176178
# Bundle aarch64 BLAS/LAPACK/ACL dependencies (no-op on x86)
177179
- for dep in aarch64_deps:
178180
+ for dep in arch_deps:
179181
shutil.copy(dep, torch_lib / dep.name)
180-
182+
181183
# TODO: Remove when switching to ROCm wheels
182-
@@ -399,7 +405,7 @@
184+
@@ -487,21 +493,23 @@ def main() -> None:
183185
lib_so_rpath = "$ORIGIN"
184186
force_rpath = False
185-
187+
186188
- aarch64_deps = aarch64_extra_deps(use_cuda) if arch == "aarch64" else []
187189
+ arch_deps = arch_extra_deps(arch, use_cuda)
188-
190+
189191
args.output_dir.mkdir(parents=True, exist_ok=True)
190192
wheels = sorted(args.input_dir.glob("*.whl"))
191-
@@ -411,7 +417,7 @@
193+
if not wheels:
194+
sys.exit(f"No wheels found in {args.input_dir}")
195+
196+
- platform_tag = f"manylinux_2_28_{arch}"
197+
+ if arch not in PLATFORM_TAGS:
198+
+ sys.exit(f"Unknown arch {arch}")
199+
+ platform_tag = PLATFORM_TAGS[arch]
200+
for whl in wheels:
201+
repair_wheel(
192202
whl,
193203
args.output_dir,
204+
platform_tag,
194205
libgomp_path,
195206
- aarch64_deps,
196207
+ arch_deps,
197208
bundled_libs,
198209
aux_files,
199210
c_so_rpath,
200-
@@ -419,7 +425,9 @@
201-
force_rpath,
202-
)
203-
204-
- retag_wheels(args.output_dir, f"manylinux_2_28_{arch}")
205-
+ if arch not in PLATFORM_TAGS:
206-
+ sys.exit(f"Unknown arch {arch}")
207-
+ retag_wheels(args.output_dir, PLATFORM_TAGS[arch])
208-
repaired = list(args.output_dir.glob("*.whl"))
209-
print(f"Repaired {len(repaired)} wheel(s) in {args.output_dir}")
210-
211211

212212
--
213213
2.39.0

0 commit comments

Comments
 (0)