Skip to content

Commit f42f3d6

Browse files
committed
Add --no-patches flag option to get-source.sh.
1 parent 3a1aafb commit f42f3d6

4 files changed

Lines changed: 105 additions & 24 deletions

File tree

ML-Frameworks/pytorch-aarch64/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ where `YY` is the year, and `MM` the month of the increment.
1515

1616
### Added
1717
- TorchAO installation via nightly AArch64 wheel (0.18.0.dev20260505) in Dockerfile
18+
- Adds a `--source-variant {upstream,pinned,patched}` option to `build.sh` and
19+
`get-source.sh` to select PyTorch's upstream submodule hashes, repo-pinned
20+
component hashes without patches, or the default repo-pinned patched source tree.
21+
- Adds the installation of `torchao` via nightly AArch64 wheels in Dockerfile.
1822

1923
### Changed
2024
- Updates `filelock` from 3.16.1 to 3.20.3.

ML-Frameworks/pytorch-aarch64/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ adding your patch to `utils/patch_cache` with the name
7474
- `--use-existing-sources` skips `get-source.sh` and just builds
7575
- `--fresh` overwrites sources
7676
- `--wheel-only` build just the torch wheel (no Docker image)
77+
- `--source-variant {upstream,pinned,patched}` controls which source recipe
78+
`get-source.sh` uses:
79+
- `upstream` uses PyTorch's upstream submodule hashes without extra patches
80+
- `pinned` uses repo-pinned component hashes without extra patches
81+
- `patched` uses repo-pinned component hashes and extra patches (default)
7782

7883
### Updating pinned versions
7984

@@ -173,6 +178,13 @@ Note that we get patches from PRs for two reasons:
173178
crucially whether it has been merged.
174179
- We avoid the license ambiguity of patches from one project living in another
175180

181+
> [!NOTE]
182+
>
183+
> If you wish to disable patch application, run `build.sh` or `get-source.sh`
184+
> with `--source-variant pinned`.
185+
> If you also wish to use PyTorch's upstream submodule versions for ideep,
186+
> oneDNN, and KleidiAI, use `--source-variant upstream`.
187+
176188
To keep up to date with the development branches of the components, there is a
177189
helper script called `./bump-sources.sh`.
178190
After bumping the sources, you will probably find that `./get-source.sh` will

ML-Frameworks/pytorch-aarch64/build.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,25 @@ fi
3333
rm -f .torch_build_container_id
3434

3535
if ! [[ $* == *--use-existing-sources* ]]; then
36-
./get-source.sh
36+
get_source_args=()
37+
args=("$@")
38+
for ((i = 0; i < ${#args[@]}; i++)); do
39+
case "${args[$i]}" in
40+
--source-variant)
41+
if [[ $((i + 1)) -ge ${#args[@]} ]]; then
42+
>&2 echo "error: --source-variant requires a value"
43+
exit 1
44+
fi
45+
get_source_args+=(--source-variant "${args[$((i + 1))]}")
46+
i=$((i + 1))
47+
;;
48+
--source-variant=*)
49+
get_source_args+=("${args[$i]}")
50+
;;
51+
esac
52+
done
53+
54+
./get-source.sh "${get_source_args[@]}"
3755
fi
3856

3957
# Set the output dir for the wheels

ML-Frameworks/pytorch-aarch64/get-source.sh

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,62 @@ source ./versions.sh
99

1010
set -eux -o pipefail
1111

12+
source_variant=patched
13+
14+
while [[ $# -gt 0 ]]; do
15+
case "$1" in
16+
--source-variant)
17+
if [[ $# -lt 2 ]]; then
18+
>&2 echo "error: --source-variant requires a value"
19+
exit 1
20+
fi
21+
source_variant="$2"
22+
shift 2
23+
;;
24+
--source-variant=*)
25+
source_variant="${1#*=}"
26+
shift
27+
;;
28+
*)
29+
>&2 echo "error: unknown option '$1'"
30+
exit 1
31+
;;
32+
esac
33+
done
34+
35+
case "$source_variant" in
36+
upstream|pinned|patched) ;;
37+
*)
38+
>&2 echo "error: invalid --source-variant '$source_variant'"
39+
>&2 echo "valid values: upstream, pinned, patched"
40+
exit 1
41+
;;
42+
esac
43+
1244
git-shallow-clone https://github.com/pytorch/pytorch.git $PYTORCH_HASH
1345
(
14-
# Apply patches to PyTorch build
1546
cd pytorch
1647

17-
# https://github.com/pytorch/pytorch/pull/182655 - Update ACL/OpenBLAS/manywheel build scripts and add ccache support
18-
apply-github-patch pytorch/pytorch 159406ab7f210bacadb757fabef28ac9ddacb706
48+
# Apply patches to PyTorch
49+
if [[ "$source_variant" != patched ]]; then
50+
echo "Not applying extra patches to PyTorch build for source variant '$source_variant'"
51+
else
52+
# https://github.com/pytorch/pytorch/pull/182655 - Update ACL/OpenBLAS/manywheel build scripts and add ccache support
53+
apply-github-patch pytorch/pytorch 159406ab7f210bacadb757fabef28ac9ddacb706
1954

20-
# https://github.com/pytorch/pytorch/pull/170600 - Gate deletion of clean-up steps in build_common.sh
21-
apply-github-patch pytorch/pytorch e368ec2693b8b2b8ba35d0913f1d663ba2fdc804
55+
# https://github.com/pytorch/pytorch/pull/170600 - Gate deletion of clean-up steps in build_common.sh
56+
apply-github-patch pytorch/pytorch e368ec2693b8b2b8ba35d0913f1d663ba2fdc804
2257

23-
# https://github.com/pytorch/pytorch/pull/167328 - Build cpuinfo into c10 shared library
24-
apply-github-patch pytorch/pytorch 7c053dd1582b778c81101dd452708c4ec6e58233
25-
apply-github-patch pytorch/pytorch b1782bbe0eda5957870e2f6e95b8f167e04843cb
26-
apply-github-patch pytorch/pytorch 337925aed2babb3ef7808f78536bbbc9df346a4f
58+
# https://github.com/pytorch/pytorch/pull/167328 - Build cpuinfo into c10 shared library
59+
apply-github-patch pytorch/pytorch 7c053dd1582b778c81101dd452708c4ec6e58233
60+
apply-github-patch pytorch/pytorch b1782bbe0eda5957870e2f6e95b8f167e04843cb
61+
apply-github-patch pytorch/pytorch 337925aed2babb3ef7808f78536bbbc9df346a4f
2762

28-
# https://github.com/pytorch/pytorch/pull/177867 - Add ASIMD_BF16 Vectorized class specialisation
29-
apply-github-patch pytorch/pytorch 6cbed7b8e0d5985569b4cc36931afc717930fe00
30-
apply-github-patch pytorch/pytorch 6e6878ec8869fd8f7d9314571a3e84933f149ef5
31-
apply-github-patch pytorch/pytorch e14a2184c44c96e433f468ba12e104dc6be85886
63+
# https://github.com/pytorch/pytorch/pull/177867 - Add ASIMD_BF16 Vectorized class specialisation
64+
apply-github-patch pytorch/pytorch 6cbed7b8e0d5985569b4cc36931afc717930fe00
65+
apply-github-patch pytorch/pytorch 6e6878ec8869fd8f7d9314571a3e84933f149ef5
66+
apply-github-patch pytorch/pytorch e14a2184c44c96e433f468ba12e104dc6be85886
67+
fi
3268

3369
# Remove deps that we don't need for manylinux AArch64 CPU builds before fetching.
3470
# Only used when jni.h is present (see .ci/pytorch/build.sh:116), which is not the case for manylinux
@@ -63,19 +99,30 @@ git-shallow-clone https://github.com/pytorch/pytorch.git $PYTORCH_HASH
6399
git rm 3rdparty/composable_kernel
64100
)
65101

66-
(
67-
cd third_party/ideep
68-
git fetch origin $IDEEP_HASH && git clean -f && git checkout -f FETCH_HEAD
102+
# Fetch desired version of ideep/oneDNN/KleidiAI
103+
if [[ "$source_variant" == upstream ]]; then
104+
echo "Using PyTorch's upstream submodule hashes for ideep, oneDNN, and KleidiAI for source variant '$source_variant'"
105+
else
106+
(
107+
cd third_party/ideep
108+
git fetch origin $IDEEP_HASH && git clean -f && git checkout -f FETCH_HEAD
69109

110+
(
111+
cd mkl-dnn
112+
git fetch origin $ONEDNN_HASH && git clean -f && git checkout -f FETCH_HEAD
113+
114+
if [[ "$source_variant" != patched ]]; then
115+
echo "Not applying extra patches to oneDNN build for source variant '$source_variant'"
116+
else
117+
echo "No oneDNN patches to apply"
118+
fi
119+
)
120+
)
70121
(
71-
cd mkl-dnn
72-
git fetch origin $ONEDNN_HASH && git clean -f && git checkout -f FETCH_HEAD
122+
cd third_party/kleidiai
123+
git fetch origin $KLEIDIAI_HASH && git clean -f && git checkout -f FETCH_HEAD
73124
)
74-
)
75-
(
76-
cd third_party/kleidiai
77-
git fetch origin $KLEIDIAI_HASH && git clean -f && git checkout -f FETCH_HEAD
78-
)
125+
fi
79126

80127
# rebuild third_party/LICENSES_BUNDLED.txt after modifying PyTorch submodules if we can
81128
# this will also get done in PyTorch build too

0 commit comments

Comments
 (0)