Skip to content
Merged
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
30 changes: 29 additions & 1 deletion .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ install_pytorch_and_domains() {
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}
# Download key must match the upload key below (basename of dist/*.whl,
# which always carries setup.py's resolved +gitHASH). Branch-ref pins
# like `release/2.11` would otherwise produce `+gitrelease` here and
# never hit the cache.
local torch_short_hash=$(git rev-parse --short=7 HEAD)
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"

Expand All @@ -127,6 +131,30 @@ install_pytorch_and_domains() {
USE_DISTRIBUTED=1 python setup.py bdist_wheel
pip install "$(echo dist/*.whl)"

# Invariant: the basename setup.py just produced must match the cache
# URL we'd reconstruct on the next run. If they diverge (someone edits
# torch_wheel_name above, or PyTorch renames its wheels), the cache
# will silently miss and every macOS run will fall back to a ~30-min
# source build. Fail loudly so the regression is caught immediately.
shopt -s nullglob
local built_wheels=(dist/*.whl)
shopt -u nullglob
if [[ ${#built_wheels[@]} -ne 1 ]]; then
echo "ERROR: expected exactly 1 wheel in dist/, found ${#built_wheels[@]}" >&2
exit 1
fi
local built_wheel_name
built_wheel_name=$(basename "${built_wheels[0]}")
local expected_wheel_name="${torch_wheel_name//\%2B/+}"
if [[ "${built_wheel_name}" != "${expected_wheel_name}" ]]; then
echo "ERROR: built torch wheel name does not match cache URL key:" >&2
echo " built: ${built_wheel_name}" >&2
echo " expected: ${expected_wheel_name}" >&2
echo "Fix torch_wheel_name construction in install_pytorch_and_domains" >&2
echo "in .ci/scripts/utils.sh" >&2
exit 1
fi

# Only AWS runners have access to S3
if command -v aws && [[ -z "${GITHUB_RUNNER:-}" ]]; then
for wheel_path in dist/*.whl; do
Expand Down
Loading