Skip to content

Commit 1b68ef8

Browse files
atalmanmalfet
andauthored
Numpy 2.0.0 support PRs cherry-pick (#1770)
* [BE] Remove macos x86 build statements, remove python <3.8 (#1745) * [BE] Remove macos x86 build statements, remove python <3.8 * fix * deprecate * Update nightly wheel build numpy to 2.0 (#1747) * Update wheel build numpy to 2.0 (#1746) * Update wheel build numpy to 2.0 * aarch64 * Update build_wheel.sh * Simplify * Install llvm-openmp for M1 PyTorch builds Otherwise the binary will be super slow Also drop `nomkl` as there were never mkl on Apple silicon * Add numpy 2.0.0rc1 support to conda and wheels (#1768) * Add numpy 2.0.0rc1 support to conda and wheels * conda * conda * test * fix * Add numpy 2.0.0rc1 support to conda and wheels (#1769) --------- Co-authored-by: Nikita Shulga <[email protected]>
1 parent c217c11 commit 1b68ef8

File tree

8 files changed

+40
-164
lines changed

8 files changed

+40
-164
lines changed

aarch64_linux/aarch64_ci_setup.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ conda create -y -c conda-forge -n "${CONDA_ENV_NAME}" python=${DESIRED_PYTHON}
2626
conda activate "${CONDA_ENV_NAME}"
2727

2828
if [[ "$DESIRED_PYTHON" == "3.8" ]]; then
29-
NUMPY_VERSION="1.24.4"
29+
pip install -q numpy==1.24.4
3030
else
31-
NUMPY_VERSION="1.26.2"
31+
pip install -q --pre numpy==2.0.0rc1
3232
fi
33-
conda install -y -c conda-forge numpy==${NUMPY_VERSION} pyyaml==6.0.1 patchelf==0.17.2 pygit2==1.13.2 openblas==0.3.25=*openmp* ninja==1.11.1 scons==4.5.2
33+
conda install -y -c conda-forge pyyaml==6.0.1 patchelf==0.17.2 pygit2==1.13.2 openblas==0.3.25=*openmp* ninja==1.11.1 scons==4.5.2
3434

3535
python --version
3636
conda --version

conda/build_pytorch.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if [ -z "$ANACONDA_TOKEN" ]; then
8585
fi
8686
if [[ -z "$ANACONDA_USER" ]]; then
8787
# This is the channel that finished packages will be uploaded to
88-
ANACONDA_USER=soumith
88+
ANACONDA_USER='pytorch'
8989
fi
9090
if [[ -z "$GITHUB_ORG" ]]; then
9191
GITHUB_ORG='pytorch'
@@ -360,12 +360,14 @@ for py_ver in "${DESIRED_PYTHON[@]}"; do
360360
fi
361361

362362
echo "Calling conda-build at $(date)"
363+
# TODO: Remove atalman channel once we can wend numpy from
364+
# anaconda or pytorch or pytorch nightly channel
363365
time CMAKE_ARGS=${CMAKE_ARGS[@]} \
364366
EXTRA_CAFFE2_CMAKE_FLAGS=${EXTRA_CAFFE2_CMAKE_FLAGS[@]} \
365367
PYTORCH_GITHUB_ROOT_DIR="$pytorch_rootdir" \
366368
PYTORCH_BUILD_STRING="$build_string" \
367369
PYTORCH_MAGMA_CUDA_VERSION="$cuda_nodot" \
368-
conda build -c "$ANACONDA_USER" \
370+
conda build -c "$ANACONDA_USER" -c atalman \
369371
${NO_TEST:-} \
370372
--no-anaconda-upload \
371373
--python "$py_ver" \

conda/pytorch-nightly/meta.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ requirements:
2929
- typing_extensions
3030
- ninja
3131
- libuv # [win]
32-
- numpy=1.19 # [py <= 39]
33-
- numpy=1.21.5 # [py == 310]
34-
- numpy=1.23.5 # [py == 311]
35-
- numpy=1.26.0 # [py >= 312]
32+
- numpy=1.19 # [py == 38]
33+
- numpy=2.0.0rc1 # [py >= 39]
3634
- openssl=1.1.1l # [py >= 38 and py <= 310 and linux]
3735
- openssl=1.1.1s # [py == 311 and linux]
3836
- openssl=3.0.12 # [py >= 312 and linux]

manywheel/build_common.sh

+6-23
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,7 @@ fi
7676
# in this case
7777
if [[ -n "$DESIRED_PYTHON" && "$DESIRED_PYTHON" != cp* ]]; then
7878
python_nodot="$(echo $DESIRED_PYTHON | tr -d m.u)"
79-
case ${DESIRED_PYTHON} in
80-
3.[6-7]*)
81-
DESIRED_PYTHON="cp${python_nodot}-cp${python_nodot}m"
82-
;;
83-
# Should catch 3.8+
84-
3.*)
85-
DESIRED_PYTHON="cp${python_nodot}-cp${python_nodot}"
86-
;;
87-
esac
79+
DESIRED_PYTHON="cp${python_nodot}-cp${python_nodot}"
8880
fi
8981

9082
if [[ ${python_nodot} -ge 310 ]]; then
@@ -119,24 +111,15 @@ pushd "$PYTORCH_ROOT"
119111
python setup.py clean
120112
retry pip install -qr requirements.txt
121113
case ${DESIRED_PYTHON} in
122-
cp36-cp36m)
123-
retry pip install -q numpy==1.11
124-
;;
125-
cp3[7-8]*)
114+
cp38*)
126115
retry pip install -q numpy==1.15
127116
;;
128-
cp310*)
129-
retry pip install -q numpy==1.21.2
130-
;;
131-
cp311*)
132-
retry pip install -q numpy==1.23.1
133-
;;
134-
cp312*)
135-
retry pip install -q numpy==1.26.1
117+
cp31*)
118+
retry pip install -q --pre numpy==2.0.0rc1
136119
;;
137120
# Should catch 3.9+
138121
*)
139-
retry pip install -q numpy==1.19.4
122+
retry pip install -q --pre numpy==2.0.0rc1
140123
;;
141124
esac
142125

@@ -280,7 +263,7 @@ replace_needed_sofiles() {
280263
patchedname=$3
281264
if [[ "$origname" != "$patchedname" ]] || [[ "$DESIRED_CUDA" == *"rocm"* ]]; then
282265
set +e
283-
origname=$($PATCHELF_BIN --print-needed $sofile | grep "$origname.*")
266+
origname=$($PATCHELF_BIN --print-needed $sofile | grep "$origname.*")
284267
ERRCODE=$?
285268
set -e
286269
if [ "$ERRCODE" -eq "0" ]; then

manywheel/conda_build.sh

-89
This file was deleted.

wheel/build_wheel.sh

+18-38
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,8 @@ fi
9797
whl_tmp_dir="${MAC_PACKAGE_WORK_DIR}/dist"
9898
mkdir -p "$whl_tmp_dir"
9999

100-
if [[ -n "$CROSS_COMPILE_ARM64" || $(uname -m) == "arm64" ]]; then
101-
mac_version='macosx_11_0_arm64'
102-
libtorch_arch='arm64'
103-
else
104-
mac_version='macosx_10_9_x86_64'
105-
libtorch_arch='x86_64'
106-
fi
100+
mac_version='macosx_11_0_arm64'
101+
libtorch_arch='arm64'
107102

108103
# Create a consistent wheel package name to rename the wheel to
109104
wheel_filename_new="${TORCH_PACKAGE_NAME}-${build_version}${build_number_prefix}-cp${python_nodot}-none-${mac_version}.whl"
@@ -141,35 +136,31 @@ case $desired_python in
141136
echo "Using 3.12 deps"
142137
SETUPTOOLS_PINNED_VERSION=">=68.0.0"
143138
PYYAML_PINNED_VERSION=">=6.0.1"
144-
NUMPY_PINNED_VERSION="==1.26.0"
139+
NUMPY_PINNED_VERSION="=2.0.0rc1"
145140
;;
146141
3.11)
147142
echo "Using 3.11 deps"
148143
SETUPTOOLS_PINNED_VERSION=">=46.0.0"
149144
PYYAML_PINNED_VERSION=">=5.3"
150-
NUMPY_PINNED_VERSION="==1.23.5"
145+
NUMPY_PINNED_VERSION="=2.0.0rc1"
151146
;;
152147
3.10)
153148
echo "Using 3.10 deps"
154149
SETUPTOOLS_PINNED_VERSION=">=46.0.0"
155150
PYYAML_PINNED_VERSION=">=5.3"
156-
NUMPY_PINNED_VERSION="=1.21.2"
151+
NUMPY_PINNED_VERSION="=2.0.0rc1"
157152
;;
158153
3.9)
159154
echo "Using 3.9 deps"
160155
SETUPTOOLS_PINNED_VERSION=">=46.0.0"
161156
PYYAML_PINNED_VERSION=">=5.3"
162-
NUMPY_PINNED_VERSION="=1.19"
157+
NUMPY_PINNED_VERSION="=2.0.0rc1"
163158
;;
164159
3.8)
165160
echo "Using 3.8 deps"
166-
if [[ "$(uname -m)" == "arm64" ]]; then
167-
SETUPTOOLS_PINNED_VERSION=">=46.0.0"
168-
PYYAML_PINNED_VERSION=">=5.3"
169-
NUMPY_PINNED_VERSION="=1.19"
170-
else
171-
NUMPY_PINNED_VERSION="=1.17"
172-
fi
161+
SETUPTOOLS_PINNED_VERSION=">=46.0.0"
162+
PYYAML_PINNED_VERSION=">=5.3"
163+
NUMPY_PINNED_VERSION="=1.19"
173164
;;
174165
*)
175166
echo "Using default deps"
@@ -182,30 +173,24 @@ tmp_env_name="wheel_py$python_nodot"
182173
conda create ${EXTRA_CONDA_INSTALL_FLAGS} -yn "$tmp_env_name" python="$desired_python"
183174
source activate "$tmp_env_name"
184175

185-
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq "numpy${NUMPY_PINNED_VERSION}" nomkl "setuptools${SETUPTOOLS_PINNED_VERSION}" "pyyaml${PYYAML_PINNED_VERSION}" typing_extensions requests
186-
187-
if [[ "$(uname -m)" == "arm64" ]]; then
188-
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq cmake ninja
176+
if [[ $desired_python != "3.8" ]]; then
177+
pip install -q --pre numpy=${NUMPY_PINNED_VERSION}
189178
else
190-
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq cmake ninja mkl-include==2022.2.1 mkl-static==2022.2.1 -c intel
179+
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq "numpy${NUMPY_PINNED_VERSION}"
191180
fi
181+
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq llvm-openmp=14.0.6 cmake ninja "setuptools${SETUPTOOLS_PINNED_VERSION}" "pyyaml${PYYAML_PINNED_VERSION}" typing_extensions requests
192182
retry pip install -qr "${pytorch_rootdir}/requirements.txt" || true
193183

194184
# For USE_DISTRIBUTED=1 on macOS, need libuv and pkg-config to find libuv.
195185
export USE_DISTRIBUTED=1
196186
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq libuv pkg-config
197187

198-
if [[ -n "$CROSS_COMPILE_ARM64" || "$(uname -m)" == "arm64" ]]; then
199-
if [[ -n "$CROSS_COMPILE_ARM64" ]]; then
200-
export CMAKE_OSX_ARCHITECTURES=arm64
201-
fi
202-
export USE_MKLDNN=OFF
203-
export USE_QNNPACK=OFF
204-
export BUILD_TEST=OFF
205-
elif [[ "$(uname -m)" == "x86_64" ]]; then
206-
retry conda install ${EXTRA_CONDA_INSTALL_FLAGS} -yq llvmdev=9
207-
export USE_LLVM="${CONDA_PREFIX}"
188+
if [[ -n "$CROSS_COMPILE_ARM64" ]]; then
189+
export CMAKE_OSX_ARCHITECTURES=arm64
208190
fi
191+
export USE_MKLDNN=OFF
192+
export USE_QNNPACK=OFF
193+
export BUILD_TEST=OFF
209194

210195
pushd "$pytorch_rootdir"
211196
echo "Calling setup.py bdist_wheel at $(date)"
@@ -289,9 +274,4 @@ else
289274
zip -rq "$PYTORCH_FINAL_PACKAGE_DIR/libtorch-macos-${libtorch_arch}-$PYTORCH_BUILD_VERSION.zip" libtorch
290275
cp "$PYTORCH_FINAL_PACKAGE_DIR/libtorch-macos-${libtorch_arch}-$PYTORCH_BUILD_VERSION.zip" \
291276
"$PYTORCH_FINAL_PACKAGE_DIR/libtorch-macos-${libtorch_arch}-latest.zip"
292-
if [[ "${libtorch_arch}" == "x86_64" ]]; then
293-
# For backward compatibility make unarched latest to point to x86_64
294-
cp "$PYTORCH_FINAL_PACKAGE_DIR/libtorch-macos-${libtorch_arch}-$PYTORCH_BUILD_VERSION.zip" \
295-
"$PYTORCH_FINAL_PACKAGE_DIR/libtorch-macos-latest.zip"
296-
fi
297277
fi

windows/condaenv.bat

-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ FOR %%v IN (%DESIRED_PYTHON%) DO (
99
set PYTHON_VERSION_STR=%%v
1010
set PYTHON_VERSION_STR=!PYTHON_VERSION_STR:.=!
1111
conda remove -n py!PYTHON_VERSION_STR! --all -y || rmdir %CONDA_HOME%\envs\py!PYTHON_VERSION_STR! /s
12-
if "%%v" == "3.7" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
1312
if "%%v" == "3.8" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
1413
if "%%v" == "3.9" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy>=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
1514
if "%%v" == "3.10" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.21.3 "mkl=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
1615
if "%%v" == "3.11" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.23.4 "mkl=2020.2" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
1716
if "%%v" == "3.12" call conda create -n py!PYTHON_VERSION_STR! -y -q -c=conda-forge numpy=1.26.0 "mkl=2023.1" intel-openmp=2023.2.0 pyyaml boto3 "cmake=3.19.6" ninja typing_extensions python=%%v
18-
if "%%v" == "3" call conda create -n py!PYTHON_VERSION_STR! -y -q numpy=1.11 "mkl=2020.2" pyyaml boto3 cmake ninja typing_extensions python=%%v
1917
)
2018
endlocal
2119

windows/internal/smoke_test.bat

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ if "%DESIRED_PYTHON%" == "3.11" set "PYTHON_INSTALLER_URL=https://www.python.org
3535
if "%DESIRED_PYTHON%" == "3.10" set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe"
3636
if "%DESIRED_PYTHON%" == "3.9" set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.9.0/python-3.9.0-amd64.exe"
3737
if "%DESIRED_PYTHON%" == "3.8" set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.8.2/python-3.8.2-amd64.exe"
38-
if "%DESIRED_PYTHON%" == "3.7" set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.7.9/python-3.7.9-amd64.exe"
39-
if "%DESIRED_PYTHON%" == "3.6" set "PYTHON_INSTALLER_URL=https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe"
4038
if "%PYTHON_INSTALLER_URL%" == "" (
4139
echo Python %DESIRED_PYTHON% not supported yet
4240
)
@@ -54,7 +52,13 @@ if errorlevel 1 exit /b 1
5452

5553
set "PATH=%CD%\Python%PYTHON_VERSION%\Scripts;%CD%\Python;%PATH%"
5654

57-
pip install -q numpy protobuf
55+
56+
if "%DESIRED_PYTHON%" == "3.12" pip install -q --pre numpy==2.0.0rc1 protobuf
57+
if "%DESIRED_PYTHON%" == "3.11" pip install -q --pre numpy==2.0.0rc1 protobuf
58+
if "%DESIRED_PYTHON%" == "3.10" pip install -q --pre numpy==2.0.0rc1 protobuf
59+
if "%DESIRED_PYTHON%" == "3.9" pip install -q --pre numpy==2.0.0rc1 protobuf
60+
if "%DESIRED_PYTHON%" == "3.8" pip install -q numpy protobuf
61+
5862
if errorlevel 1 exit /b 1
5963

6064
for /F "delims=" %%i in ('where /R "%PYTORCH_FINAL_PACKAGE_DIR:/=\%" *.whl') do pip install "%%i"

0 commit comments

Comments
 (0)