-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_loong64.patch
More file actions
197 lines (185 loc) · 8.75 KB
/
Copy pathpatch_loong64.patch
File metadata and controls
197 lines (185 loc) · 8.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
diff --git a/.ci/manywheel/build.sh b/.ci/manywheel/build.sh
index 2f4abd2..06aaf77 100755
--- a/.ci/manywheel/build.sh
+++ b/.ci/manywheel/build.sh
@@ -6,7 +6,7 @@ SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PYTORCH_ROOT="${PYTORCH_ROOT:-$(cd "${SCRIPTPATH}/../.." && pwd)}"
case "${GPU_ARCH_TYPE:-BLANK}" in
- cuda|cuda-aarch64|cpu|cpu-aarch64|cpu-cxx11-abi|xpu|rocm)
+ cuda|cuda-aarch64|cpu|cpu-aarch64|cpu-loongarch64|cpu-cxx11-abi|xpu|rocm)
# New pipeline: pyproject-driven build via `python -m build`
# then patchelf-based wheel repair.
source "${SCRIPTPATH}/set_desired_python.sh"
diff --git a/.ci/manywheel/build_common.sh b/.ci/manywheel/build_common.sh
index 02bb2d7..91e8274 100644
--- a/.ci/manywheel/build_common.sh
+++ b/.ci/manywheel/build_common.sh
@@ -41,6 +41,9 @@ if [[ "$OS_NAME" == *"AlmaLinux"* ]]; then
aarch64)
PLATFORM="manylinux_2_28_aarch64"
;;
+ loongarch64)
+ PLATFORM="manylinux_2_38_loongarch64"
+ ;;
*)
echo "Other architectures: $ARCH, not setting PLATFORM"
;;
@@ -115,6 +118,7 @@ if [[ -z "$PYTORCH_ROOT" ]]; then
exit 1
fi
pushd "$PYTORCH_ROOT"
+retry pip install -U pip
retry pip install -qUr requirements-build.txt
python -m spin clean
retry pip install -qr requirements.txt
@@ -376,6 +380,10 @@ for pkg in /$WHEELHOUSE_DIR/torch_no_python*.whl /$WHEELHOUSE_DIR/torch*linux*.w
wheel_file=$(echo $(basename $pkg) | sed -e 's/-cp.*$/.dist-info\/WHEEL/g')
sed -i -e s#linux_aarch64#"${PLATFORM}"# $wheel_file;
fi
+ if [[ $PLATFORM == "manylinux_2_38_loongarch64" ]]; then
+ wheel_file=$(echo $(basename $pkg) | sed -e 's/-cp.*$/.dist-info\/WHEEL/g')
+ sed -i -e s#linux_loongarch64#"${PLATFORM}"# $wheel_file;
+ fi
# regenerate the RECORD file with new hashes
record_file=$(echo $(basename $pkg) | sed -e 's/-cp.*$/.dist-info\/RECORD/g')
@@ -428,6 +436,11 @@ for pkg in /$WHEELHOUSE_DIR/torch_no_python*.whl /$WHEELHOUSE_DIR/torch*linux*.w
zip -rq $pkg_name $PREIX*
rm -f $pkg
mv $pkg_name $(dirname $pkg)/$pkg_name
+ elif [[ $PLATFORM == "manylinux_2_38_loongarch64" ]]; then
+ pkg_name=$(echo $(basename $pkg) | sed -e s#linux_loongarch64#"${PLATFORM}"#)
+ zip -rq $pkg_name $PREIX*
+ rm -f $pkg
+ mv $pkg_name $(dirname $pkg)/$pkg_name
else
# zip up the wheel back
zip -rq $(basename $pkg) $PREIX*
diff --git a/.ci/manywheel/build_env_setup.py b/.ci/manywheel/build_env_setup.py
index 776fde3..bcb869a 100755
--- a/.ci/manywheel/build_env_setup.py
+++ b/.ci/manywheel/build_env_setup.py
@@ -227,6 +227,7 @@ def discover_rocm_home() -> str:
PLATFORM_TAGS: dict[str, str] = {
"x86_64": "manylinux_2_28_x86_64",
"aarch64": "manylinux_2_28_aarch64",
+ "loongarch64": "manylinux_2_38_loongarch64",
}
@@ -251,7 +252,7 @@ def install_os_packages() -> None:
# (.ci/docker/manywheel/Dockerfile_2_28). Only zip + openssl are not,
# matching the legacy build_common.sh contract.
name = os_name()
- if any(distro in name for distro in ("AlmaLinux", "CentOS", "Red Hat")):
+ if any(distro in name for distro in ("AlmaLinux", "Anolis OS", "CentOS", "Red Hat")):
subprocess.run(
["yum", "install", "-q", "-y", "zip", "openssl"],
check=True,
@@ -494,7 +495,7 @@ def main() -> None:
setup_cuda(cuda_version)
env_out.update(cuda_build_env(cuda_version, arch))
print(f"CUDA {cuda_version} environment configured")
- elif gpu_arch_type in ("cpu", "cpu-aarch64", "cpu-s390x", "cpu-cxx11-abi"):
+ elif gpu_arch_type in ("cpu", "cpu-aarch64", "cpu-loongarch64", "cpu-s390x", "cpu-cxx11-abi"):
cleanup_cuda_for_cpu_build()
env_out.update(CPU_BUILD_ENV)
print("CPU environment configured")
diff --git a/.ci/manywheel/build_wheel.py b/.ci/manywheel/build_wheel.py
index 4b33397..510e73d 100755
--- a/.ci/manywheel/build_wheel.py
+++ b/.ci/manywheel/build_wheel.py
@@ -58,6 +58,13 @@ def configure_blas_env() -> None:
print("Using OpenBLAS and ACL for MKLDNN on CPU aarch64")
os.environ["BLAS"] = "OpenBLAS"
os.environ["OpenBLAS_HOME"] = "/opt/OpenBLAS"
+ elif gpu_arch_type in ("cpu-loongarch64", "cpu"):
+ openblas = Path("/opt/OpenBLAS/lib/libopenblas.so.0")
+ if not openblas.is_file():
+ sys.exit(f"ERROR: OpenBLAS not found at {openblas}")
+ print("Using OpenBLAS on CPU loongarch64")
+ os.environ["BLAS"] = "OpenBLAS"
+ os.environ["OpenBLAS_HOME"] = "/opt/OpenBLAS"
def main() -> None:
diff --git a/.ci/manywheel/repair_wheel.py b/.ci/manywheel/repair_wheel.py
index 5cc1122..329684e 100755
--- a/.ci/manywheel/repair_wheel.py
+++ b/.ci/manywheel/repair_wheel.py
@@ -145,6 +145,29 @@ def aarch64_extra_deps(use_cuda: bool) -> list[Path]:
return deps
+def loongarch64_extra_deps(use_cuda: bool) -> list[Path]:
+ """Libraries to bundle into torch/lib/ on loongarch64.
+
+ CPU builds link against OpenBLAS + libgfortran.
+ """
+ deps: list[Path] = []
+ candidates: list[Path] = [Path("/usr/lib64/libgfortran.so.5")]
+ if use_cuda:
+ candidates += [
+ Path(f"/usr/local/lib/{name}")
+ for name in (
+ "libnvpl_blas_lp64_gomp.so.0",
+ "libnvpl_lapack_lp64_gomp.so.0",
+ "libnvpl_blas_core.so.0",
+ "libnvpl_lapack_core.so.0",
+ )
+ ]
+ else:
+ candidates.append(Path("/opt/OpenBLAS/lib/libopenblas.so.0"))
+ deps = [p for p in candidates if p.is_file()]
+ return deps
+
+
# ROCm shared libs to bundle. Discovered under $ROCM_HOME/{lib,lib64}.
ROCM_SO_FILES: list[str] = [
"libMIOpen.so",
@@ -488,20 +511,24 @@ def main() -> None:
force_rpath = False
aarch64_deps = aarch64_extra_deps(use_cuda) if arch == "aarch64" else []
+ loongarch64_deps = loongarch64_extra_deps(use_cuda) if arch == "loongarch64" else []
+
+ arch_deps = loongarch64_deps if arch == "loongarch64" else aarch64_deps
args.output_dir.mkdir(parents=True, exist_ok=True)
wheels = sorted(args.input_dir.glob("*.whl"))
if not wheels:
sys.exit(f"No wheels found in {args.input_dir}")
- platform_tag = f"manylinux_2_28_{arch}"
+ manylinux_version = os.environ.get("AUDITWHEEL_POLICY", "manylinux_2_28")
+ platform_tag = f"{manylinux_version}_{arch}"
for whl in wheels:
repair_wheel(
whl,
args.output_dir,
platform_tag,
libgomp_path,
- aarch64_deps,
+ arch_deps,
bundled_libs,
aux_files,
c_so_rpath,
diff --git a/.ci/pytorch/build.sh b/.ci/pytorch/build.sh
index 87e8cc6..dfa2efc 100755
--- a/.ci/pytorch/build.sh
+++ b/.ci/pytorch/build.sh
@@ -242,7 +242,7 @@ fi
# Do not change workspace permissions for ROCm and s390x CI jobs
# as it can leave workspace with bad permissions for cancelled jobs
-if [[ "$BUILD_ENVIRONMENT" != *rocm* && "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *riscv64*cross* && -d /var/lib/jenkins/workspace ]]; then
+if [[ "$BUILD_ENVIRONMENT" != *rocm* && "$BUILD_ENVIRONMENT" != *loongarch64* && "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *riscv64*cross* && -d /var/lib/jenkins/workspace ]]; then
# Workaround for dind-rootless userid mapping (https://github.com/pytorch/ci-infra/issues/96)
WORKSPACE_ORIGINAL_OWNER_ID=$(stat -c '%u' "/var/lib/jenkins/workspace")
cleanup_workspace() {
@@ -266,7 +266,7 @@ if [[ "$BUILD_ENVIRONMENT" != *libtorch* ]]; then
# Release xpu build stress with WERROR=1
# set only when building other architectures
# or building non-XLA tests.
- if [[ "$BUILD_ENVIRONMENT" != *rocm* && "$BUILD_ENVIRONMENT" != *xla* && "$BUILD_ENVIRONMENT" != *riscv64* && "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *xpu* ]]; then
+ if [[ "$BUILD_ENVIRONMENT" != *rocm* && "$BUILD_ENVIRONMENT" != *xla* && "$BUILD_ENVIRONMENT" != *riscv64* && "$BUILD_ENVIRONMENT" != *loongarch64* && "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *xpu* ]]; then
# TODO: Remove me and may be just focus on numpy-2.x testing
if [[ "$PYTHON_VERSION" =~ ^3\.1[0-2]$ ]]; then
# Install numpy-2.0.2 for builds which are backward compatible with 1.X
@@ -423,6 +423,6 @@ if [[ "$BUILD_ENVIRONMENT" != *libtorch* ]]; then
PYTHONPATH=. python tools/stats/export_test_times.py
fi
# don't do this for s390x or riscv64 as they don't use sccache
-if [[ "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *riscv64*cross* ]]; then
+if [[ "$BUILD_ENVIRONMENT" != *loongarch64* && "$BUILD_ENVIRONMENT" != *s390x* && "$BUILD_ENVIRONMENT" != *riscv64*cross* ]]; then
print_sccache_stats
fi