Skip to content

Commit d5ef3f1

Browse files
committed
Update
[ghstack-poisoned]
2 parents 8282b6d + c0676fe commit d5ef3f1

File tree

175 files changed

+5216
-3937
lines changed

Some content is hidden

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

175 files changed

+5216
-3937
lines changed

.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/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'

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# Copyright 2024-2025 Arm Limited and/or its affiliates.
23
# All rights reserved.
34
#
45
# This source code is licensed under the BSD-style license found in the
@@ -819,6 +820,14 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
819820
list(APPEND _executor_runner_libs quantized_ops_lib)
820821
endif()
821822

823+
if(EXECUTORCH_ENABLE_EVENT_TRACER)
824+
if(EXECUTORCH_BUILD_DEVTOOLS)
825+
list(APPEND _executor_runner_libs etdump flatccrt)
826+
else()
827+
message(SEND_ERROR "Use of 'EXECUTORCH_ENABLE_EVENT_TRACER' requires 'EXECUTORCH_BUILD_DEVTOOLS' to be enabled.")
828+
endif()
829+
endif()
830+
822831
add_executable(executor_runner ${_executor_runner__srcs})
823832
if(CMAKE_BUILD_TYPE STREQUAL "Release")
824833
if(APPLE)

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:

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def insert_input_transpose(node, input_node, graph_module):
116116
with graph_module.graph.inserting_before(node):
117117
permute_node = create_node(
118118
graph_module.graph,
119-
torch.ops.passthrough_to_tosa._transpose,
119+
torch.ops.passthrough_to_tosa._transpose.default,
120120
args=(
121121
input_node,
122122
list(AnnotateChannelsLastDimOrder.NHWC_inverse_order),
@@ -129,18 +129,22 @@ 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):
135136
with graph_module.graph.inserting_after(node):
136137
permute_node = create_node(
137138
graph_module.graph,
138-
torch.ops.passthrough_to_tosa._transpose,
139+
torch.ops.passthrough_to_tosa._transpose.default,
139140
args=(node, list(AnnotateChannelsLastDimOrder.NHWC_order)),
140141
)
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(

backends/arm/_passes/arm_pass_manager.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from executorch.backends.arm._passes.convert_squeezes_to_view import ( # type: ignore[import-not-found]
2525
ConvertSqueezesToViewPass,
2626
)
27+
from executorch.backends.arm._passes.decompose_batchnorm_pass import (
28+
DecomposeBatchNormPass,
29+
)
2730
from executorch.backends.arm._passes.decompose_div_pass import DecomposeDivPass
2831
from executorch.backends.arm._passes.decompose_layernorm_pass import (
2932
DecomposeLayerNormPass,
@@ -39,9 +42,10 @@
3942
from executorch.backends.arm._passes.decompose_var_pass import DecomposeVarPass
4043
from executorch.backends.arm._passes.fold_qdq_with_annotated_qparams_pass import (
4144
FoldAndAnnotateQParamsPass,
42-
QuantizeFullArgument,
45+
QuantizeOperatorArguments,
4346
RetraceFoldedDtypesPass,
4447
)
48+
from executorch.backends.arm._passes.fuse_batchnorm2d_pass import FuseBatchnorm2DPass
4549
from executorch.backends.arm._passes.fuse_quantized_activation_pass import ( # type: ignore[import-not-found]
4650
FuseQuantizedActivationPass,
4751
)
@@ -86,13 +90,14 @@ def _transform(self, graph_module: GraphModule):
8690
def _tosa_080_BI_pipeline(self, exported_program: ExportedProgram) -> GraphModule:
8791
self.add_pass(FuseQuantizedActivationPass())
8892
self.add_pass(RemoveGetItemPass())
93+
self.add_pass(DecomposeBatchNormPass())
8994
self.add_pass(ConvertSplitToSlicePass())
9095
self.add_pass(ConvertMmToBmmPass())
9196
self.add_pass(DecomposeLinearPass())
9297
self.add_pass(ConvertMeanDimToAveragePoolPass())
9398

9499
self.add_pass(AnnotateDecomposedMatmulPass())
95-
self.add_pass(QuantizeFullArgument())
100+
self.add_pass(QuantizeOperatorArguments())
96101
self.add_pass(FoldAndAnnotateQParamsPass()) # type: ignore[call-arg]
97102
self.add_pass(RetraceFoldedDtypesPass())
98103
self.add_pass(InsertTableOpsPass(exported_program))
@@ -120,15 +125,17 @@ def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
120125
self.add_pass(ConvertSplitToSlicePass())
121126
self.add_pass(ConvertMmToBmmPass())
122127
self.add_pass(DecomposeLinearPass())
128+
self.add_pass(DecomposeBatchNormPass())
123129
self.add_pass(DecomposeLayerNormPass())
124130
self.add_pass(DecomposeVarPass())
125131
self.add_pass(DecomposeMeanDimPass())
126132
self.add_pass(ConvertMeanDimToAveragePoolPass())
127133
self.add_pass(DecomposeDivPass())
128134
self.add_pass(DecomposeSoftmaxesPass())
135+
self.add_pass(FuseBatchnorm2DPass(exported_program))
129136

130137
self.add_pass(AnnotateDecomposedMatmulPass())
131-
self.add_pass(QuantizeFullArgument())
138+
self.add_pass(QuantizeOperatorArguments())
132139
self.add_pass(FoldAndAnnotateQParamsPass()) # type: ignore[call-arg]
133140
self.add_pass(RetraceFoldedDtypesPass())
134141
self.add_pass(InsertTableOpsPass(exported_program))

0 commit comments

Comments
 (0)