Skip to content

[ML] Upgrade to PyTorch 2.7.1 #2863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/pipelines/build_linux.json.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"cpu": "6",
"ephemeralStorage": "20G",
"memory": "64G",
"image": os.getenv("DOCKER_IMAGE", "docker.elastic.co/ml-dev/ml-linux-build:33")
"image": os.getenv("DOCKER_IMAGE", "docker.elastic.co/ml-dev/ml-linux-build:34")
},
"aarch64": {
"provider": "aws",
Expand Down Expand Up @@ -100,7 +100,7 @@ def main(args):
"cpu": "6",
"ephemeralStorage": "20G",
"memory": "64G",
"image": "docker.elastic.co/ml-dev/ml-linux-aarch64-cross-build:16"
"image": "docker.elastic.co/ml-dev/ml-linux-aarch64-cross-build:17"
},
"commands": [
".buildkite/scripts/steps/build_and_test.sh"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipelines/build_macos.json.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
agents = {
"aarch64": {
"provider": "orka",
"image": "ml-macos-13-arm-004.orkasi"
"image": "ml-macos-13-arm-005.orkasi"
}
}
envs = {
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipelines/build_windows.json.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main(args):
"provider": "gcp",
"machineType": "c2-standard-16",
"minCpuPlatform": "Intel Cascade Lake",
"image": "family/ml-cpp-4-windows-2022",
"image": "family/ml-cpp-5-windows-2022",
},
"commands": [
f'if ( "{args.action}" -eq "debug" ) {{\$Env:ML_DEBUG="1"}}',
Expand Down
6 changes: 3 additions & 3 deletions .ci/orka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Files

- `install.sh` The script that does the software installs on the image
- `orka-macos-12-arm.pkr.hcl` The packer definition for a MacOS 12 ARM builder image
- `orka-macos-13-arm.pkr.hcl` The packer definition for a MacOS 13 ARM builder image


## Set Up Packer
Expand All @@ -26,7 +26,7 @@ Make sure you are connected to the Orka VM.

Packer requires access to secrets in vault, where VAULT_ADDR=https://vault-ci-prod.elastic.dev and VAULT_TOKEN must be set appropriately in the environment.

Run the following to create the image (MacOS 12 ARM in this example):
Run the following to create the image (MacOS 13 ARM in this example):

```
packer build orka-macos-13-arm.pkr.hcl
Expand Down Expand Up @@ -63,7 +63,7 @@ The ML packer scripts do the following:
* Install JDK `11.0.25`
* Install CMake `3.30.5`
* Install Boost `1.86.0` from source
* Install PyTorch `2.5.1` from source
* Install PyTorch `2.7.1` from source

## Caveats

Expand Down
2 changes: 1 addition & 1 deletion .ci/orka/orka-macos-13-arm.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ locals {

source "macstadium-orka" "image" {
source_image = "generic-13-ventura-arm-002.orkasi"
image_name = "ml-macos-13-arm-004.orkasi"
image_name = "ml-macos-13-arm-005.orkasi"
orka_endpoint = local.orka_endpoint
orka_user = local.orka_user
orka_password = local.orka_password
Expand Down
4 changes: 2 additions & 2 deletions .ci/orka/third_party_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sudo rm -rf boost_1_86_0
sudo pip3 install numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses

# Build and install PyTorch
git clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git && \
git clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git && \
cd pytorch && \
git submodule sync && \
git submodule update --init --recursive && \
Expand All @@ -59,7 +59,7 @@ export DNNL_TARGET_ARCH=AARCH64
export USE_MKLDNN=ON
export USE_QNNPACK=OFF
export USE_PYTORCH_QNNPACK=OFF
export PYTORCH_BUILD_VERSION=2.5.1
export PYTORCH_BUILD_VERSION=2.7.1
export PYTORCH_BUILD_NUMBER=1
python3 setup.py install

Expand Down
2 changes: 1 addition & 1 deletion 3rd_party/licenses/pytorch-INFO.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name,version,revision,url,license,copyright,sourceURL
PyTorch,2.5.1,a8d6afb511a69687bbb2b7e88a3cf67917e1697e,https://pytorch.org,BSD-3-Clause,,
PyTorch,2.7.1,e2d141dbde55c2a4370fac5165b0561b6af4798b,https://pytorch.org,BSD-3-Clause,,
6 changes: 3 additions & 3 deletions build-setup/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Then copy the shared libraries to the system directory:
(cd /opt/intel/oneapi/mkl/2024.0 && tar cf - lib) | (cd /usr/local/gcc133 && sudo tar xvf -)
```

### PyTorch 2.5.1
### PyTorch 2.7.1

(This step requires a reasonable amount of memory. It failed on a machine with 8GB of RAM. It succeeded on a 16GB machine. You can specify the number of parallel jobs using environment variable MAX_JOBS. Lower number of jobs will reduce memory usage.)

Expand All @@ -352,7 +352,7 @@ sudo /usr/local/gcc133/bin/python3.12 -m pip install numpy pyyaml setuptools cff
Then obtain the PyTorch code:

```
git clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git
git clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git
cd pytorch
git submodule sync
git submodule update --init --recursive
Expand Down Expand Up @@ -386,7 +386,7 @@ export USE_MKLDNN=ON
export USE_QNNPACK=OFF
export USE_PYTORCH_QNNPACK=OFF
[ $(uname -m) = x86_64 ] && export USE_XNNPACK=OFF
export PYTORCH_BUILD_VERSION=2.5.1
export PYTORCH_BUILD_VERSION=2.7.1
export PYTORCH_BUILD_NUMBER=1
/usr/local/gcc133/bin/python3.12 setup.py install
```
Expand Down
10 changes: 5 additions & 5 deletions build-setup/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ Download the graphical installer for Python 3.10.10 from <https://www.python.org

Install using all the default options. When the installer completes a Finder window pops up. Double click the `Install Certificates.command` file in this folder to install the SSL certificates Python needs.

### PyTorch 2.5.1
### PyTorch 2.7.1

PyTorch requires that certain Python modules are installed. To install them:

```
sudo /Library/Frameworks/Python.framework/Versions/3.10/bin/pip3.10 install numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses
sudo /Library/Frameworks/Python.framework/Versions/3.12/bin/pip3.12 install numpy ninja pyyaml setuptools cffi typing_extensions future six requests dataclasses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo Python 3.12

```

Then obtain the PyTorch code:

```
git clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git
git clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git
cd pytorch
git submodule sync
git submodule update --init --recursive
Expand Down Expand Up @@ -188,9 +188,9 @@ export DNNL_TARGET_ARCH=AARCH64
export USE_MKLDNN=ON
export USE_QNNPACK=OFF
export USE_PYTORCH_QNNPACK=OFF
export PYTORCH_BUILD_VERSION=2.5.1
export PYTORCH_BUILD_VERSION=2.7.1
export PYTORCH_BUILD_NUMBER=1
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 setup.py install
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 setup.py install
```

Once built copy headers and libraries to system directories:
Expand Down
6 changes: 3 additions & 3 deletions build-setup/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ On the "Advanced Options" screen, check "Install for all users" and "Add Python

For the time being, do not take advantage of the option on the final installer screen to reconfigure the machine to allow paths longer than 260 characters. We still support Windows versions that do not have this option.

### PyTorch 2.5.1
### PyTorch 2.7.1

(This step requires a lot of memory. It failed on a machine with 12GB of RAM. It just about fitted on a 20GB machine. 32GB RAM is recommended.)

Expand All @@ -216,7 +216,7 @@ Next, in a Git bash shell run:

```
cd /c/tools
git clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git
git clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git
cd pytorch
git submodule sync
git submodule update --init --recursive
Expand Down Expand Up @@ -272,7 +272,7 @@ set USE_QNNPACK=OFF
set USE_PYTORCH_QNNPACK=OFF
set USE_XNNPACK=OFF
set MSVC_Z7_OVERRIDE=OFF
set PYTORCH_BUILD_VERSION=2.5.1
set PYTORCH_BUILD_VERSION=2.7.1
set PYTORCH_BUILD_NUMBER=1
python setup.py install
```
Expand Down
6 changes: 3 additions & 3 deletions dev-tools/build_windows_third_party_deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Write-Host "--- Done Installing libxml2 2.9.14"
Write-Host "--- Installing boost 1.86.0"
cd c:\tools
$Archive="boost_1_86_0.tar.bz2"
$ZipSource="https://archives.boost.io/main/release/1.86.0/source/$Archive"
$ZipSource="https://archives.boost.io/release/1.86.0/source/$Archive"
$ZipDestination="\tools\$Archive"
(New-Object Net.WebClient).DownloadFile($ZipSource, $ZipDestination)
C:\Progra~1\git\bin\bash.exe -c "tar jxvf boost_1_86_0.tar.bz2"
Expand Down Expand Up @@ -117,7 +117,7 @@ mv "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\$f\
# Build and install PyTorch (this may take a while)
Write-Host "--- Installing PyTorch locally"
cd c:\tools
git clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git
git clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git
cd pytorch
git submodule sync
git submodule update --init --recursive
Expand All @@ -131,7 +131,7 @@ set USE_QNNPACK=OFF
set USE_PYTORCH_QNNPACK=OFF
set USE_XNNPACK=OFF
set MSVC_Z7_OVERRIDE=OFF
set PYTORCH_BUILD_VERSION=2.5.1
set PYTORCH_BUILD_VERSION=2.7.1
set PYTORCH_BUILD_NUMBER=1
python setup.py install
Write-Host "--- Done Installing PyTorch locally"
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/build_linux_aarch64_cross_build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
HOST=docker.elastic.co
ACCOUNT=ml-dev
REPOSITORY=ml-linux-aarch64-cross-build
VERSION=14
VERSION=17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to 15 and 16?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the version numbers in the Docker files had been bumped for the last couple of versions, but not in the build scripts, so they were lagging behind. Initially I just bumped the version in this build script and ended up clobbering an existing Docker image.


set -e

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/build_linux_aarch64_native_build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sleep 5
HOST=docker.elastic.co
ACCOUNT=ml-dev
REPOSITORY=ml-linux-aarch64-native-build
VERSION=14
VERSION=17

set -e

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/build_linux_build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sleep 5
HOST=docker.elastic.co
ACCOUNT=ml-dev
REPOSITORY=ml-linux-build
VERSION=31
VERSION=34

set -e

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_aarch64_cross_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-cross-build:16
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-cross-build:17

MAINTAINER David Roberts <dave.roberts@elastic.co>

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_aarch64_cross_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN dnf -y update && \
RUN \
mkdir -p /usr/local/sysroot-aarch64-linux-gnu/usr && \
cd /usr/local/sysroot-aarch64-linux-gnu/usr && \
wget --quiet -O - https://s3-eu-west-2.amazonaws.com/ml-cpp-artifacts/dependencies/usr-aarch64-linux-gnu-16.tar.bz2 | tar jxf - && \
wget --quiet -O - https://s3-eu-west-2.amazonaws.com/ml-cpp-artifacts/dependencies/usr-aarch64-linux-gnu-17.tar.bz2 | tar jxf - && \
cd .. && \
ln -s usr/lib lib && \
ln -s usr/lib64 lib64
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_aarch64_native_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-native-build:16
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-native-build:17

MAINTAINER David Roberts <dave.roberts@elastic.co>

Expand Down
4 changes: 2 additions & 2 deletions dev-tools/docker/linux_aarch64_native_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ RUN \
# If the PyTorch branch is changed also update PYTORCH_BUILD_VERSION
RUN \
cd ${build_dir} && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git && \
cd pytorch && \
git submodule sync && \
git submodule update --init --recursive && \
Expand All @@ -183,7 +183,7 @@ RUN \
export USE_MKLDNN=ON && \
export USE_QNNPACK=OFF && \
export USE_PYTORCH_QNNPACK=OFF && \
export PYTORCH_BUILD_VERSION=2.5.1 && \
export PYTORCH_BUILD_VERSION=2.7.1 && \
export PYTORCH_BUILD_NUMBER=1 && \
export MAX_JOBS=10 && \
/usr/local/bin/python3.12 setup.py install && \
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_aarch64_native_tester/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-native-build:16
FROM docker.elastic.co/ml-dev/ml-linux-aarch64-native-build:17

MAINTAINER David Roberts <dave.roberts@elastic.co>

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-build:33
FROM docker.elastic.co/ml-dev/ml-linux-build:34

LABEL maintainer="Valeriy Khakhutskyy <valeriy.khakhutskyy@elastic.co>"

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_dependency_builder_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-build:33 AS builder
FROM docker.elastic.co/ml-dev/ml-linux-build:34 AS builder

# This is basically automating the setup instructions in build-setup/linux.md

Expand Down
4 changes: 2 additions & 2 deletions dev-tools/docker/linux_image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.
# If the PyTorch branch is changed also update PYTORCH_BUILD_VERSION
RUN \
cd ${build_dir} && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git && \
cd pytorch && \
git submodule sync && \
git submodule update --init --recursive && \
Expand All @@ -198,7 +198,7 @@ RUN \
export USE_QNNPACK=OFF && \
export USE_PYTORCH_QNNPACK=OFF && \
export USE_XNNPACK=OFF && \
export PYTORCH_BUILD_VERSION=2.5.1 && \
export PYTORCH_BUILD_VERSION=2.7.1 && \
export PYTORCH_BUILD_NUMBER=1 && \
export MAX_JOBS=10 && \
/usr/local/bin/python3.12 setup.py install && \
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker/linux_tester/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

# Increment the version here when a new tools/3rd party components image is built
FROM docker.elastic.co/ml-dev/ml-linux-build:33
FROM docker.elastic.co/ml-dev/ml-linux-build:34

LABEL maintainer="Valeriy Khakhutskyy <valeriy.khakhutskyy@elastic.co>"

Expand Down
4 changes: 2 additions & 2 deletions dev-tools/docker/ubuntu_devbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ ENV PATH=/usr/local/gcc133/bin:/usr/bin:/bin:/usr/sbin:/sbin
# If the PyTorch branch is changed also update PYTORCH_BUILD_VERSION
RUN \
cd ${build_dir} && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.5.1 https://github.com/pytorch/pytorch.git && \
git -c advice.detachedHead=false clone --depth=1 --branch=v2.7.1 https://github.com/pytorch/pytorch.git && \
cd pytorch && \
git submodule sync && \
git submodule update --init --recursive && \
Expand All @@ -179,7 +179,7 @@ RUN \
export USE_QNNPACK=OFF && \
export USE_PYTORCH_QNNPACK=OFF && \
export USE_XNNPACK=OFF && \
export PYTORCH_BUILD_VERSION=2.5.1 && \
export PYTORCH_BUILD_VERSION=2.7.1 && \
export PYTORCH_BUILD_NUMBER=1 && \
export MAX_JOBS=10 && \
/usr/local/bin/python3.12 setup.py install
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ do
TEMP_TAG=`git rev-parse --short=14 HEAD`-$PLATFORM-$$

prefetch_docker_base_image "$DOCKERFILE"
docker build --no-cache --force-rm -t $TEMP_TAG --build-arg VERSION_QUALIFIER="$VERSION_QUALIFIER" --build-arg SNAPSHOT=$SNAPSHOT --build-arg ML_DEBUG=$ML_DEBUG -f "$DOCKERFILE" .
docker build --no-cache --force-rm -t $TEMP_TAG --progress=plain --build-arg VERSION_QUALIFIER="$VERSION_QUALIFIER" --build-arg SNAPSHOT=$SNAPSHOT --build-arg ML_DEBUG=$ML_DEBUG -f "$DOCKERFILE" .
# Using tar to copy the build artifacts out of the container seems more reliable
# than docker cp, and also means the files end up with the correct uid/gid
docker run --rm --workdir=/ml-cpp $TEMP_TAG bash -c "tar cf - build/distributions && sleep 30" | tar xvf -
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/docker_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ do
TEMP_TAG=`git rev-parse --short=14 HEAD`-$PLATFORM-$$

prefetch_docker_base_image "$DOCKERFILE"
docker build --no-cache --force-rm -t $TEMP_TAG --build-arg VERSION_QUALIFIER="$VERSION_QUALIFIER" --build-arg SNAPSHOT=$SNAPSHOT --build-arg BOOST_TEST_OUTPUT_FORMAT_FLAGS=$BOOST_TEST_OUTPUT_FORMAT_FLAGS --build-arg ML_DEBUG=$ML_DEBUG -f "$DOCKERFILE" .
docker build --no-cache --force-rm -t $TEMP_TAG --progress=plain --build-arg VERSION_QUALIFIER="$VERSION_QUALIFIER" --build-arg SNAPSHOT=$SNAPSHOT --build-arg BOOST_TEST_OUTPUT_FORMAT_FLAGS=$BOOST_TEST_OUTPUT_FORMAT_FLAGS --build-arg ML_DEBUG=$ML_DEBUG -f "$DOCKERFILE" .
# Using tar to copy the build and test artifacts out of the container seems
# more reliable than docker cp, and also means the files end up with the
# correct uid/gid
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
//=== Bug Fixes

//=== Regressions
== {es} version 9.2.0

=== Enhancements

* Update the PyTorch library to version 2.7.1. (See {ml-pull}2863[#2863].)

== {es} version 9.1.0

Expand Down