Skip to content

Commit 8340c9e

Browse files
committed
Update base for Update on "move rope related logic together"
Right now, rope related code scatters around a few different places in `llama_transformer`. It makes it hard to make changes to rope related things. This PR moves all rope related logic into its own module. Differential Revision: [D65173598](https://our.internmc.facebook.com/intern/diff/D65173598/) [ghstack-poisoned]
2 parents 2c32bf3 + cd565b5 commit 8340c9e

File tree

181 files changed

+6873
-1164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+6873
-1164
lines changed

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bd5482c7c3e1197e10c46ff739027f917d9c1fcc
1+
c8a648d4dffb9f0133ff4a2ea0e660b42105d3ad

.ci/docker/common/install_clang.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ install_ubuntu() {
1313
apt-get install -y --no-install-recommends clang-"$CLANG_VERSION"
1414
apt-get install -y --no-install-recommends llvm-"$CLANG_VERSION"
1515
# Also require LLD linker from llvm and libomp to build PyTorch from source
16-
apt-get install -y lld "libomp-${CLANG_VERSION}-dev"
16+
apt-get install -y lld "libomp-${CLANG_VERSION}-dev" "libc++-${CLANG_VERSION}-dev"
1717

1818
# Use update-alternatives to make this version the default
1919
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-"$CLANG_VERSION" 50

.ci/docker/requirements-ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mpmath==1.3.0
2-
numpy==1.22.0; python_version == '3.10'
2+
numpy==1.21.3; python_version == '3.10'
33
numpy==1.23.2; python_version == '3.11'
44
numpy; python_version >= '3.12'
55
PyYAML==6.0.1

.ci/scripts/setup-linux.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ else
1919
fi
2020

2121
# As Linux job is running inside a Docker container, all of its dependencies
22-
# have already been installed
23-
install_executorch
22+
# have already been installed, so we use PyTorch build from source here instead
23+
# of nightly. This allows CI to test against latest commits from PyTorch
24+
install_executorch "use-pt-pinned-commit"
2425
build_executorch_runner "${BUILD_TOOL}"

.ci/scripts/setup-qnn-deps.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ install_qnn() {
3131
}
3232

3333
setup_libc++() {
34+
clang_version=$1
3435
sudo apt-get update
35-
pkgs_to_check=('libc++-dev')
36+
pkgs_to_check=("libc++-${clang_version}-dev")
3637
j=0
3738
while [ $j -lt ${#pkgs_to_check[*]} ]; do
3839
install_status=$(verify_pkg_installed ${pkgs_to_check[$j]})
@@ -47,5 +48,6 @@ setup_libc++() {
4748
done
4849
}
4950

50-
setup_libc++
51+
# This needs to match with the clang version from the Docker image
52+
setup_libc++ 12
5153
install_qnn

.ci/scripts/utils.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ install_executorch() {
2020
which pip
2121
# Install executorch, this assumes that Executorch is checked out in the
2222
# current directory.
23-
# TODO(T199538337): clean up install scripts to use install_requirements.sh
24-
./install_requirements.sh --pybind xnnpack
23+
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
24+
./install_requirements.sh --pybind xnnpack --use-pt-pinned-commit
25+
else
26+
./install_requirements.sh --pybind xnnpack
27+
fi
2528
# Just print out the list of packages for debugging
2629
pip list
2730
}

.github/pull_request_template.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Summary
2+
[PLEASE REMOVE] See [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests) for ExecuTorch PR guidelines.
3+
4+
[PLEASE REMOVE] If this PR closes an issue, please add a `Fixes #<issue-id>` line.
5+
6+
[PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: <area>" label. For a list of available release notes labels, check out [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests).
7+
8+
### Test plan
9+
[PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable.

.github/workflows/_android.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ jobs:
6666
# avoid permission issue
6767
sudo chown -R "${USER}" /opt/android
6868
69+
- name: Download Artifacts
70+
shell: bash
71+
run: |
72+
set -eux
73+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
74+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
75+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
76+
unzip model.zip
77+
mv *.pte model.pte
78+
6979
- name: Gradle cache
7080
uses: gradle/actions/setup-gradle@v3
7181

.github/workflows/_unittest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
3838
.ci/scripts/setup-linux.sh cmake
3939
40+
# Install llama3_2_vision dependencies.
41+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
42+
4043
# Run pytest with coverage
4144
pytest -n auto --cov=./ --cov-report=xml
4245
# Run gtest
@@ -67,6 +70,10 @@ jobs:
6770
${CONDA_RUN} --no-capture-output \
6871
.ci/scripts/setup-macos.sh cmake
6972
73+
# Install llama3_2_vision dependencies.
74+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
75+
./examples/models/llama3_2_vision/install_requirements.sh
76+
7077
# Run pytest with coverage
7178
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
7279
# Run gtest

.github/workflows/pull.yml

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
name: test-setup-linux-gcc
3636
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
3737
strategy:
38-
matrix:
39-
include:
40-
- build-tool: cmake
4138
fail-fast: false
4239
with:
4340
runner: linux.2xlarge
@@ -50,7 +47,7 @@ jobs:
5047
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
5148
conda activate "${CONDA_ENV}"
5249
53-
BUILD_TOOL=${{ matrix.build-tool }}
50+
BUILD_TOOL="cmake"
5451
5552
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
5653
# Build and test ExecuTorch with the add model on portable backend.
@@ -89,20 +86,11 @@ jobs:
8986
strategy:
9087
matrix:
9188
dtype: [fp32]
92-
build-tool: [buck2, cmake]
9389
mode: [portable, xnnpack+custom, xnnpack+custom+qe]
9490
include:
9591
- dtype: bf16
96-
build-tool: cmake
97-
mode: portable
98-
- dtype: bf16
99-
build-tool: buck2
10092
mode: portable
10193
- dtype: bf16
102-
build-tool: cmake
103-
mode: custom
104-
- dtype: bf16
105-
build-tool: buck2
10694
mode: custom
10795
fail-fast: false
10896
with:
@@ -111,29 +99,30 @@ jobs:
11199
submodules: 'true'
112100
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
113101
timeout: 900
102+
upload-artifact: android-models
103+
upload-artifact-to-s3: true
114104
script: |
115105
# The generic Linux job chooses to use base env, not the one setup by the image
116106
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
117107
conda activate "${CONDA_ENV}"
118108
119109
DTYPE=${{ matrix.dtype }}
120-
BUILD_TOOL=${{ matrix.build-tool }}
110+
BUILD_TOOL="cmake"
121111
MODE=${{ matrix.mode }}
112+
ARTIFACTS_DIR_NAME="artifacts-to-be-uploaded/${DTYPE}-${MODE}"
113+
ARTIFACTS_DIR_NAME="${ARTIFACTS_DIR_NAME/+/-}"
122114
123115
# Setup executorch
124-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
116+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
125117
# Install requirements for export_llama
126118
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
127119
# Test llama2
128-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
120+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}" "${ARTIFACTS_DIR_NAME}"
129121
130122
test-llama-runner-linux-android:
131123
name: test-llama-runner-linux-android
132124
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
133125
strategy:
134-
matrix:
135-
include:
136-
- build-tool: cmake
137126
fail-fast: false
138127
with:
139128
runner: linux.2xlarge
@@ -146,18 +135,14 @@ jobs:
146135
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
147136
conda activate "${CONDA_ENV}"
148137
149-
BUILD_TOOL=${{ matrix.build-tool }}
138+
BUILD_TOOL="cmake"
150139
PYTHON_EXECUTABLE=python \
151140
bash .ci/scripts/build_llama_android.sh "${BUILD_TOOL}"
152141
153142
test-custom-ops-linux:
154143
name: test-custom-ops-linux
155144
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
156145
strategy:
157-
matrix:
158-
include:
159-
- build-tool: buck2
160-
- build-tool: cmake
161146
fail-fast: false
162147
with:
163148
runner: linux.2xlarge
@@ -170,7 +155,7 @@ jobs:
170155
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
171156
conda activate "${CONDA_ENV}"
172157
173-
BUILD_TOOL=${{ matrix.build-tool }}
158+
BUILD_TOOL="cmake"
174159
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
175160
# Test custom ops
176161
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
@@ -179,10 +164,6 @@ jobs:
179164
name: test-selective-build-linux
180165
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
181166
strategy:
182-
matrix:
183-
include:
184-
- build-tool: buck2
185-
- build-tool: cmake
186167
fail-fast: false
187168
with:
188169
runner: linux.2xlarge
@@ -195,7 +176,7 @@ jobs:
195176
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
196177
conda activate "${CONDA_ENV}"
197178
198-
BUILD_TOOL=${{ matrix.build-tool }}
179+
BUILD_TOOL="cmake"
199180
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
200181
# Test selective build
201182
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
@@ -235,9 +216,6 @@ jobs:
235216
name: test-quantized-aot-lib-linux
236217
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
237218
strategy:
238-
matrix:
239-
include:
240-
- build-tool: cmake
241219
fail-fast: false
242220
with:
243221
runner: linux.2xlarge
@@ -250,17 +228,14 @@ jobs:
250228
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
251229
conda activate "${CONDA_ENV}"
252230
253-
BUILD_TOOL=${{ matrix.build-tool }}
231+
BUILD_TOOL="cmake"
254232
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
255233
PYTHON_EXECUTABLE=python bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" mv2
256234
257235
test-pybind-build-linux:
258236
name: test-pybind-build-linux
259237
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
260238
strategy:
261-
matrix:
262-
include:
263-
- build-tool: cmake
264239
fail-fast: false
265240
with:
266241
runner: linux.2xlarge
@@ -274,7 +249,7 @@ jobs:
274249
conda activate "${CONDA_ENV}"
275250
276251
# build module for executorch.extension.pybindings.portable_lib
277-
BUILD_TOOL=${{ matrix.build-tool }}
252+
BUILD_TOOL="cmake"
278253
PYTHON_EXECUTABLE=python \
279254
EXECUTORCH_BUILD_XNNPACK=ON \
280255
EXECUTORCH_BUILD_PYBIND=ON \
@@ -349,6 +324,7 @@ jobs:
349324
350325
android:
351326
uses: ./.github/workflows/_android.yml
327+
needs: test-llama-runner-linux
352328

353329
unittest:
354330
uses: ./.github/workflows/_unittest.yml
@@ -357,10 +333,6 @@ jobs:
357333

358334
unittest-arm:
359335
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
360-
strategy:
361-
matrix:
362-
include:
363-
- build-tool: buck2
364336
with:
365337
runner: linux.2xlarge
366338
docker-image: executorch-ubuntu-22.04-arm-sdk
@@ -374,7 +346,7 @@ jobs:
374346
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
375347
conda activate "${CONDA_ENV}"
376348
377-
BUILD_TOOL=${{ matrix.build-tool }}
349+
BUILD_TOOL="cmake"
378350
379351
# Setup MacOS dependencies as there is no Docker support on MacOS atm
380352
PYTHON_EXECUTABLE=python \
@@ -396,7 +368,6 @@ jobs:
396368
strategy:
397369
matrix:
398370
dtype: [fp32]
399-
build-tool: [cmake]
400371
mode: [qnn]
401372
fail-fast: false
402373
with:
@@ -411,14 +382,14 @@ jobs:
411382
conda activate "${CONDA_ENV}"
412383
413384
DTYPE=${{ matrix.dtype }}
414-
BUILD_TOOL=${{ matrix.build-tool }}
385+
BUILD_TOOL="cmake"
415386
MODE=${{ matrix.mode }}
416387
417388
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
418389
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
419390
420391
# Setup executorch
421-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
392+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
422393
# Install requirements for export_llama
423394
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
424395
# Test llama2

.github/workflows/trunk.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
docker-image: executorch-ubuntu-22.04-arm-sdk
138138
submodules: 'true'
139139
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
140+
timeout: 90
140141
script: |
141142
# The generic Linux job chooses to use base env, not the one setup by the image
142143
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -162,6 +163,7 @@ jobs:
162163
docker-image: executorch-ubuntu-22.04-arm-sdk
163164
submodules: 'true'
164165
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
166+
timeout: 90
165167
script: |
166168
# The generic Linux job chooses to use base env, not the one setup by the image
167169
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")

CONTRIBUTING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,27 @@ for basics.
242242
- Give the PR a clear and thorough description. Don't just describe what the PR
243243
does: the diff will do that. Explain *why* you are making this change, in a
244244
way that will make sense to someone years from now.
245-
- Add the line `Test Plan:` (with that spelling, capitalization, and trailing
246-
colon character), followed by lines containing repeatable instructions for
245+
- Explain how you have tested your changes by including repeatable instructions for
247246
testing the PR.
248247
- If you added tests, this can be as simple as the command you used to run the
249248
tests.
250249
- If you tested the PR manually, include the steps and the outputs. Help a
251250
future editor understand how to test the code that you're modifying
252251
today.
252+
- If your PR contains or is representative of a feature/bug fix that should be
253+
called out in the release notes, please add a label for "Release notes: \<area\>",
254+
where \<area\> describes which part of ExecuTorch the change pertains to, e.g.
255+
"Release notes: runtime". Here are all of the categories:
256+
- `Release notes: runtime`: changes related to the core runtime which loads the program methods, initializes delegates, and runs the lowered graph.
257+
- `Release notes: exir`: changes to any internal representations, such as any edge-related dialects. Also any changes to passes that may modify the exir, such as memory planning.
258+
- `Release notes: quantization`: changes to quantization.
259+
- `Release notes: ops & kernels`: changes to the opset and any new / changed kernel implementations.
260+
- `Release notes: api`: changes to public facing apis (any interfaces, pybinded runtime methods, etc.).
261+
- `Release notes: backends`: changes to any of the backend delegates.
262+
- `Release notes: build`: changes related to the build system, including major dependency upgrades, notable build flags, optimizations, etc.
263+
- `Release notes: devtools`: changes to any of ExecuTorch's developer tools, for example the debugger & profiler.
264+
- `Release notes: examples`: changes to any code under `examples/`.
265+
- `Release notes: misc`: anything notable that doesn't belong in the above categories.
253266
- See https://github.com/pytorch/executorch/pull/3612 for an example PR that
254267
follows this advice.
255268
1. Before asking for a review, ensure that all [CI (continuous integration)

backends/apple/coreml/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ To quantize a Program in a Core ML favored way, the client may utilize **CoreMLQ
6565
import torch
6666
import executorch.exir
6767

68-
from torch._export import capture_pre_autograd_graph
68+
from torch.export import export_for_training
6969
from torch.ao.quantization.quantize_pt2e import (
7070
convert_pt2e,
7171
prepare_pt2e,
@@ -93,7 +93,7 @@ class Model(torch.nn.Module):
9393
source_model = Model()
9494
example_inputs = (torch.randn((1, 3, 256, 256)), )
9595

96-
pre_autograd_aten_dialect = capture_pre_autograd_graph(model, example_inputs)
96+
pre_autograd_aten_dialect = export_for_training(model, example_inputs).module()
9797

9898
quantization_config = LinearQuantizerConfig.from_dict(
9999
{

0 commit comments

Comments
 (0)