Skip to content

Commit aff01f5

Browse files
author
Github Executorch
committed
Update on "Integrate torchgen exception boundary with ExecuTorch"
As of #7746, we build with exceptions by default, so we just need to use them. Differential Revision: [D67904052](https://our.internmc.facebook.com/intern/diff/D67904052/) [ghstack-poisoned]
2 parents 00f6b85 + 46f7faf commit aff01f5

File tree

136 files changed

+3736
-1618
lines changed

Some content is hidden

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

136 files changed

+3736
-1618
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-
cb4af2b4752220c3ca3de6e7e95b3a6fdc31f794
1+
0a94bb432ed75cc2d950d81b2921363218a7e459

.ci/scripts/test_eval_llama_mmlu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ run_and_verify() {
4343
--tasks mmlu \
4444
-f 5 \
4545
--max_seq_length 2048 \
46+
--max_context_length 2048 \
4647
--limit 5 > result.txt
4748

4849
# Verify result.txt

.ci/scripts/test_eval_llama_wikitext.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ run_and_verify() {
4141
-kv \
4242
-d fp32 \
4343
--max_seq_length 2048 \
44+
--max_context_length 2048 \
4445
--limit 5 > result.txt
4546

4647
# Verify result.txt

.github/workflows/apple.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
id: set_version
3838
shell: bash
3939
run: |
40-
VERSION="0.4.0.$(TZ='PST8PDT' date +%Y%m%d)"
40+
VERSION="0.5.0.$(TZ='PST8PDT' date +%Y%m%d)"
4141
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
4242
4343
build-demo-ios:

.github/workflows/doc-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ jobs:
8484
needs: build
8585
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
8686
permissions:
87+
id-token: write
8788
contents: write
88-
contents: read
8989
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
9090
with:
9191
repository: pytorch/executorch

.github/workflows/pull.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ jobs:
221221
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
222222
223223
# install pybind
224-
bash install_executorch.sh --pybind xnnpack
224+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
225225
226226
# install Llava requirements
227227
bash examples/models/llama/install_requirements.sh
@@ -484,7 +484,7 @@ jobs:
484484
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
485485
486486
# install pybind
487-
bash install_executorch.sh --pybind xnnpack
487+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
488488
489489
# install phi-3-mini requirements
490490
bash examples/models/phi-3-mini/install_requirements.sh
@@ -514,7 +514,7 @@ jobs:
514514
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
515515
516516
# install pybind
517-
bash install_executorch.sh --pybind xnnpack
517+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
518518
519519
# install llama requirements
520520
bash examples/models/llama/install_requirements.sh
@@ -544,7 +544,7 @@ jobs:
544544
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
545545
546546
# install pybind
547-
bash install_executorch.sh --pybind xnnpack
547+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
548548
549549
# install llama requirements
550550
bash examples/models/llama/install_requirements.sh
@@ -574,7 +574,7 @@ jobs:
574574
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
575575
576576
# install pybind
577-
bash install_executorch.sh --pybind xnnpack
577+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
578578
579579
# install llama requirements
580580
bash examples/models/llama/install_requirements.sh

.github/workflows/trunk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
conda activate "${CONDA_ENV}"
151151
152152
source .ci/scripts/utils.sh
153-
install_executorch
153+
install_executorch "use-pt-pinned-commit"
154154
155155
.ci/scripts/setup-arm-baremetal-tools.sh
156156
@@ -180,7 +180,7 @@ jobs:
180180
conda activate "${CONDA_ENV}"
181181
182182
source .ci/scripts/utils.sh
183-
install_executorch
183+
install_executorch "use-pt-pinned-commit"
184184
185185
.ci/scripts/setup-arm-baremetal-tools.sh
186186

.lintrunner.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
merge_base_with = "origin/main"
1+
merge_base_with = "main"
22

33
[[linter]]
44
code = 'FLAKE8'

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,38 @@ Meta has a [bounty program](https://www.facebook.com/whitehat/) for the safe
4444
disclosure of security bugs. In those cases, please go through the process
4545
outlined on that page and do not file a public issue.
4646

47+
### Issue Labels
48+
49+
#### Module/Partner Labels
50+
51+
[Labels beginning with `module:`](https://github.com/pytorch/executorch/labels?q=%22module%3A+%22)
52+
indicate the area that the issue relates to. The ExecuTorch oncall will
53+
typically add this label.
54+
55+
[Labels beginning with `partner:`](https://github.com/pytorch/executorch/labels?q=%22partner%3A+%22)
56+
indicate the ExecuTorch partner who owns the issue. The ExecuTorch oncall will
57+
typically add this label.
58+
59+
#### Lifecycle Labels
60+
61+
The ExecuTorch oncall will triage new issues. If the issue requires more
62+
information from the issue's author, oncall will add the `need-user-input` label
63+
and wait for the author to respond.
64+
65+
Once the issue contains enough information, the oncall will:
66+
- Ensure that the title is descriptive
67+
- Add one of the labels:
68+
- `bug`: The issue describes an unexpected problem
69+
- `feature`: The issue describes a request for new functionality
70+
- `rfc`: The issue describes a proposed change to functionality
71+
- Add one `module:` label or one `partner:` label, as described above
72+
- Add the `triaged` label
73+
74+
After this point, the oncall has finished the triage process, and the
75+
module owner or partner is responsible for resolving the issue. (See
76+
https://github.com/pytorch/executorch/issues/7679 for the mapping of labels to
77+
owners.)
78+
4779
### Claiming Issues
4880
We'd love your help closing out [open
4981
issues](https://github.com/pytorch/executorch/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen)

README-wheel.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ standard on-device iOS and Android mobile deployments. One of the main goals for
44
ExecuTorch is to enable wider customization and deployment capabilities of the
55
PyTorch programs.
66

7-
The `executorch` pip package is in alpha.
8-
* Supported python versions: 3.10, 3.11
7+
The `executorch` pip package is in beta.
8+
* Supported python versions: 3.10, 3.11, 3.12
99
* Compatible systems: Linux x86_64, macOS aarch64
1010

11-
The prebuilt `executorch.extension.pybindings.portable_lib` module included in
12-
this package provides a way to run ExecuTorch `.pte` files, with some
13-
restrictions:
11+
The prebuilt `executorch.runtime` module included in this package provides a way
12+
to run ExecuTorch `.pte` files, with some restrictions:
1413
* Only [core ATen
1514
operators](https://pytorch.org/executorch/stable/ir-ops-set-definition.html)
1615
are linked into the prebuilt module
1716
* Only the [XNNPACK backend
1817
delegate](https://pytorch.org/executorch/main/native-delegates-executorch-xnnpack-delegate.html)
19-
is linked into the prebuilt module
20-
* [macOS only] [Core ML](https://pytorch.org/executorch/main/build-run-coreml.html) and [MPS](https://pytorch.org/executorch/main/build-run-mps.html) backend delegates are linked into the prebuilt module.
18+
is linked into the prebuilt module.
19+
* \[macOS only] [Core ML](https://pytorch.org/executorch/main/build-run-coreml.html)
20+
and [MPS](https://pytorch.org/executorch/main/build-run-mps.html) backend
21+
delegates are also linked into the prebuilt module.
2122

2223
Please visit the [ExecuTorch website](https://pytorch.org/executorch/) for
2324
tutorials and documentation. Here are some starting points:

README.md

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
1-
# ExecuTorch
2-
3-
**ExecuTorch** is an end-to-end solution for enabling on-device inference
4-
capabilities across mobile and edge devices including wearables, embedded
5-
devices and microcontrollers. It is part of the PyTorch Edge ecosystem and
6-
enables efficient deployment of PyTorch models to edge devices.
1+
<div align="center">
2+
<img src="./docs/source/_static/img/et-logo.png" alt="Logo" width="200">
3+
<h1 align="center">ExecuTorch: A powerful on-device AI Framework</h1>
4+
</div>
5+
6+
7+
<div align="center">
8+
<a href="https://github.com/pytorch/executorch/graphs/contributors"><img src="https://img.shields.io/github/contributors/pytorch/executorch?style=for-the-badge&color=blue" alt="Contributors"></a>
9+
<a href="https://github.com/pytorch/executorch/stargazers"><img src="https://img.shields.io/github/stars/pytorch/executorch?style=for-the-badge&color=blue" alt="Stargazers"></a>
10+
<a href="https://discord.gg/MeacgB7A"><img src="https://img.shields.io/badge/Discord-Join%20Us-purple?logo=discord&logoColor=white&style=for-the-badge" alt="Join our Discord community"></a>
11+
<a href="https://pytorch.org/executorch/stable/index.html"><img src="https://img.shields.io/badge/Documentation-000?logo=googledocs&logoColor=FFE165&style=for-the-badge" alt="Check out the documentation"></a>
12+
<hr>
13+
</div>
14+
15+
**ExecuTorch** is an end-to-end solution for on-device inference and training. It powers much of Meta's on-device AI functionality including: Facebook, Oculus, Meta Glasses, Instagram, WhatsApp and more.
16+
17+
It covers a wide gamut of models including: LLMs (Large Language Models), CV (Computer Vision), ASR (Automatic Speech Recognition), TTS (Text to Speech).
18+
19+
Platform Support:
20+
- Operating Systems:
21+
- iOS
22+
- Mac
23+
- Android
24+
- Linux
25+
- Microcontrollers
26+
27+
- Hardware Acceleration:
28+
- Apple
29+
- ARM
30+
- Cadence
31+
- MediaTek
32+
- Vulkan
33+
- XNNPACK
734

835
Key value propositions of ExecuTorch are:
936

@@ -17,35 +44,21 @@ Key value propositions of ExecuTorch are:
1744
experience due to a lightweight runtime and utilizing full hardware
1845
capabilities such as CPUs, NPUs, and DSPs.
1946

20-
For a comprehensive technical overview of ExecuTorch and step-by-step tutorials,
21-
please visit our documentation website [for the latest release](https://pytorch.org/executorch/stable/index.html) (or the [main branch](https://pytorch.org/executorch/main/index.html)).
22-
23-
Check out the [Getting Started](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) page for a quick spin.
24-
25-
Check out the examples of [Llama](./examples/models/llama/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
47+
## Getting Started
48+
To get started you can:
2649

50+
- Visit the [Step by Step Tutorial](https://pytorch.org/executorch/main/index.html) on getting things running locally and deploy a model to a device
51+
- Use this [Colab Notebook](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) to start playing around right away
52+
- Jump straight into LLMs use cases by following specific instructions for [Llama](./examples/models/llama/README.md) and [Llava](./examples/models/llava/README.md)
2753

28-
**[UPDATE - 10/24]** We have added support for running [Llama 3.2 Quantized 1B/3B](./examples/models/llama/README.md) models via ExecuTorch.
29-
30-
## Feedback
54+
## Feedback and Engagement
3155

3256
We welcome any feedback, suggestions, and bug reports from the community to help
33-
us improve our technology. Please use the [PyTorch
34-
Forums](https://discuss.pytorch.org/c/executorch) for discussion and feedback
35-
about ExecuTorch using the **ExecuTorch** category, and our [GitHub
36-
repository](https://github.com/pytorch/executorch/issues) for bug reporting.
37-
38-
We recommend using the latest release tag from the
39-
[Releases](https://github.com/pytorch/executorch/releases) page when developing.
57+
us improve our technology. Check out the [Discussion Board](https://github.com/pytorch/executorch/discussions) or chat real time with us on [Discord](https://discord.gg/MeacgB7A)
4058

4159
## Contributing
4260

43-
See [CONTRIBUTING.md](CONTRIBUTING.md) for details about issues, PRs, code
44-
style, CI jobs, and other development topics.
45-
46-
To connect with us and other community members, we invite you to join PyTorch Slack community by filling out this [form](https://docs.google.com/forms/d/e/1FAIpQLSeADnUNW36fjKjYzyHDOzEB_abKQE9b6gqqW9NXse6O0MWh0A/viewform). Once you've joined, you can:
47-
* Head to the `#executorch-general` channel for general questions, discussion, and community support.
48-
* Join the `#executorch-contributors` channel if you're interested in contributing directly to project development.
61+
We welcome contributions. To get started review the [guidelines](CONTRIBUTING.md) and chat with us on [Discord](https://discord.gg/MeacgB7A)
4962

5063

5164
## Directory Structure

backends/arm/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ The you can run the tests with
122122
pytest -c /dev/null -v -n auto backends/arm/test --arm_run_corstoneFVP
123123
```
124124

125+
## Passes
126+
127+
With the default passes in the Arm Ethos-U backend, assuming the model lowers fully to the
128+
Ethos-U, the exported program is composed of a Quantize node, Ethos-U custom delegate
129+
and a Dequantize node. In some circumstances, you may want to feed quantized input to the Neural
130+
Network straight away, e.g. if you have a camera sensor outputting (u)int8 data and keep all the
131+
arithmetic of the application in the int8 domain. For these cases, you can apply the
132+
`exir/passes/quantize_io_pass.py`. See the unit test in `executorch/backends/arm/
133+
test/passes/test_ioquantization_pass.py`for an example how to feed quantized inputs and
134+
obtain quantized outputs.
135+
136+
125137
### Code coverage
126138

127139
To get code coverage:

backends/arm/_passes/annotate_channels_last_dim_order_pass.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def insert_input_transpose(node, input_node, graph_module):
129129
permute_node.meta["tosa_dim_order"] = tuple(
130130
range(len(input_node.meta["val"].size()))
131131
)
132+
permute_node.meta["val"] = input_node.meta["val"]
132133

133134
@staticmethod
134135
def insert_output_transpose(node, graph_module):
@@ -141,6 +142,9 @@ def insert_output_transpose(node, graph_module):
141142
permute_node.meta["tosa_dim_order"] = (
142143
AnnotateChannelsLastDimOrder.NHWC_order
143144
)
145+
permute_node.meta["val"] = node.meta["val"].permute(
146+
AnnotateChannelsLastDimOrder.NHWC_order
147+
)
144148
node.meta["tosa_dim_order"] = (0, 1, 2, 3)
145149
users = [user for user in node.users if user != permute_node]
146150
for user in users:

backends/arm/_passes/annotate_decomposed_matmul.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
import itertools
88

9+
from typing import List
10+
911
import torch
1012
from executorch.backends.arm._passes.arm_pass_utils import create_node
11-
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op
13+
14+
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op, QuantArgs
1215
from executorch.exir.dialects._ops import ops as exir_ops
1316
from executorch.exir.pass_base import ExportPass, PassResult
1417
from torch.fx import GraphModule
@@ -24,6 +27,22 @@ class AnnotateDecomposedMatmulPass(ExportPass):
2427
matmul-op (can be mm or bmm).
2528
"""
2629

30+
def _match_partition_to_node(
31+
self, node: torch.fx.Node, partitioned_inputs: List[torch.fx.Node]
32+
) -> torch.fx.Node:
33+
"""
34+
The partition.input_nodes order is not guaranteed. Compare these
35+
with the matmul node inputs coming in and return the nodes
36+
in the correct order.
37+
"""
38+
if not node or node in partitioned_inputs or node.op == "placeholder":
39+
return node
40+
else:
41+
return self._match_partition_to_node(
42+
node.all_input_nodes[0], partitioned_inputs
43+
)
44+
raise RuntimeError(f"Cannot find an input node which matches, {node}.")
45+
2746
def call(self, graph_module: GraphModule) -> PassResult:
2847
matmul_partitions = get_source_partitions(
2948
graph_module.graph,
@@ -45,28 +64,36 @@ def call(self, graph_module: GraphModule) -> PassResult:
4564
matmul_node = [
4665
node for node in partition.nodes if node.target in matmul_targets
4766
][0]
67+
4868
if quantized_input:
4969
matmul_args = matmul_node.all_input_nodes
50-
for i in range(len(matmul_args)):
51-
input_node = partition.input_nodes[i]
52-
matmul_input_node = matmul_args[i]
70+
for node in matmul_args:
71+
input_node = self._match_partition_to_node(
72+
node, partition.input_nodes
73+
)
74+
5375
# Remove partition input dq-node
5476
input_node.replace_all_uses_with(input_node.all_input_nodes[0])
5577
graph_module.graph.erase_node(input_node)
56-
input_node_qargs = input_node.args[1:]
78+
input_node_qargs = QuantArgs.from_operator(
79+
input_node.target, input_node.args
80+
)
81+
5782
with graph_module.graph.inserting_before(matmul_node):
5883
# Create new dq-node before matmul
5984
dq_node = create_node(
6085
graph=graph_module.graph,
6186
op_target=dq_op,
6287
)
63-
dq_node.args = (matmul_input_node, *input_node_qargs)
64-
matmul_node.replace_input_with(matmul_input_node, dq_node)
88+
dq_node.args = (node, *input_node_qargs)
89+
matmul_node.replace_input_with(node, dq_node)
6590

6691
partition_output = list(partition.output_nodes[0].users)[0]
6792
quantized_output = partition_output.target == q_op
6893
if quantized_output:
69-
output_node_qargs = partition_output.args[1:]
94+
output_node_qargs = QuantArgs.from_operator(
95+
partition_output.target, partition_output.args
96+
)
7097
with graph_module.graph.inserting_after(matmul_node):
7198
# Create q-node after matmul
7299
q_node = create_node(

0 commit comments

Comments
 (0)