-
Notifications
You must be signed in to change notification settings - Fork 608
Use cached PyTorch wheels on MacOS jobs #9484
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
Changes from all commits
eaed605
3071d26
947c39c
9cbe26a
1576f32
fbd4949
b47eb88
bc6baf3
3b1938f
34fed00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,12 +60,46 @@ install_pytorch_and_domains() { | |
# Fetch the target commit | ||
pushd pytorch || return | ||
git checkout "${TORCH_VERSION}" | ||
git submodule update --init --recursive | ||
|
||
export USE_DISTRIBUTED=1 | ||
# Then build and install PyTorch | ||
python setup.py bdist_wheel | ||
pip install "$(echo dist/*.whl)" | ||
local system_name=$(uname) | ||
if [[ "${system_name}" == "Darwin" ]]; then | ||
local platform=$(python -c 'import sysconfig; import platform; v=platform.mac_ver()[0].split(".")[0]; platform=sysconfig.get_platform().split("-"); platform[1]=f"{v}_0"; print("_".join(platform))') | ||
fi | ||
local python_version=$(python -c 'import platform; v=platform.python_version_tuple(); print(f"{v[0]}{v[1]}")') | ||
local torch_release=$(cat version.txt) | ||
local torch_short_hash=${TORCH_VERSION:0:7} | ||
local torch_wheel_path="cached_artifacts/pytorch/executorch/pytorch_wheels/${system_name}/${python_version}" | ||
local torch_wheel_name="torch-${torch_release}%2Bgit${torch_short_hash}-cp${python_version}-cp${python_version}-${platform:-}.whl" | ||
|
||
local cached_torch_wheel="https://gha-artifacts.s3.us-east-1.amazonaws.com/${torch_wheel_path}/${torch_wheel_name}" | ||
# Cache PyTorch wheel is only needed on MacOS, Linux CI already has this as part | ||
# of the Docker image | ||
local torch_wheel_not_found=0 | ||
if [[ "${system_name}" == "Darwin" ]]; then | ||
pip install "${cached_torch_wheel}" || torch_wheel_not_found=1 | ||
else | ||
torch_wheel_not_found=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this else statement and just set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I want it to default to 0 (found the wheel) because |
||
fi | ||
|
||
# Found no such wheel, we will build it from source then | ||
if [[ "${torch_wheel_not_found}" == "1" ]]; then | ||
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}" | ||
|
||
git submodule update --init --recursive | ||
USE_DISTRIBUTED=1 python setup.py bdist_wheel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log that we're building from source |
||
pip install "$(echo dist/*.whl)" | ||
|
||
# Only AWS runners have access to S3 | ||
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then | ||
for wheel_path in dist/*.whl; do | ||
local wheel_name=$(basename "${wheel_path}") | ||
echo "Caching ${wheel_name}" | ||
aws s3 cp "${wheel_path}" "s3://gha-artifacts/${torch_wheel_path}/${wheel_name}" | ||
done | ||
fi | ||
else | ||
echo "Use cached wheel at ${cached_torch_wheel}" | ||
fi | ||
|
||
# Grab the pinned audio and vision commits from PyTorch | ||
TORCHAUDIO_VERSION=$(cat .github/ci_commit_pins/audio.txt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also cache audio, vision, and other wheels, but the gain is probably smaller because it's fast to build them. This can come in subsequent PRs. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to set default value for TORCH_WHEEL_NOT_FOUND (to handle non Darwin case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, this function is currently used only on MacOS, but I remember reading that we can now build ExecuTorch on Windows too