Skip to content

Commit 146b92c

Browse files
authored
Merge branch 'main' into fix-manifest
2 parents fd14116 + 991c37f commit 146b92c

77 files changed

Lines changed: 2762 additions & 255 deletions

File tree

Some content is hidden

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

.ci/scripts/setup-macos.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ setup_macos_env_variables
116116
# buck2 atm
117117
install_buck
118118
brew install libomp
119-
install_pip_dependencies
120119

121120
# TODO(huydhn): Unlike our self-hosted runner, GitHub runner doesn't have access
122121
# to our infra, so compiler caching needs to be setup differently using GitHub
@@ -125,10 +124,17 @@ if [[ -z "${GITHUB_RUNNER:-}" ]]; then
125124
install_sccache
126125
fi
127126

127+
# Install pinned torch before requirements-ci.txt so torchsr's transitive
128+
# torch dep is satisfied by the existing install and pip does not pull a
129+
# separate copy from PyPI. sccache is initialized above so source-build
130+
# cache misses still hit the cache.
128131
print_cmake_info
129132
install_pytorch_and_domains
130-
# We build PyTorch from source here instead of using nightly. This allows CI to test against
131-
# the pinned commit from PyTorch
133+
134+
install_pip_dependencies
135+
136+
# install_executorch's --use-pt-pinned-commit skips re-installing torch since
137+
# install_pytorch_and_domains already installed the pinned build above.
132138
if [[ "$EDITABLE" == "true" ]]; then
133139
install_executorch --use-pt-pinned-commit --editable
134140
else

.ci/scripts/test_lora.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ Okay, so I need to calculate 15% of 80."
159159
EXPECTED_QUANT_LORA_PREFIX="
160160
<|im_start|>user Calculate 15% of 80?<|im_end|><|im_start|>assistant
161161
To calculate 15% of 80, we can multiply 80 by 15/100.
162-
So, 15% of 80 is equal to (80 * 15) / 100 = 1200 / 100 = 12.
162+
80 * 15/100 = 12.
163+
So, 15% of 80 is 12.
163164
#### 12
164165
The answer is: 12<|im_end|>"
165166
EXPECTED_QUANT_LORA_ALTERNATE_PREFIX="

.ci/scripts/utils.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ install_pytorch_and_domains() {
127127
if [[ "${torch_wheel_not_found}" == "1" ]]; then
128128
echo "No cached wheel found, continue with building PyTorch at ${TORCH_VERSION}"
129129

130+
# Install PyTorch's own build-time deps so the source build does not
131+
# silently inherit them from whatever else happens to be in the env
132+
# (e.g. executorch's requirements-ci.txt).
133+
pip install -r requirements-build.txt
130134
git submodule update --init --recursive
131135
USE_DISTRIBUTED=1 python setup.py bdist_wheel
132136
pip install "$(echo dist/*.whl)"

backends/aoti/slim/cuda/test/targets.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
1+
load("@fbcode_macros//build_defs:gpu_cpp_unittest.bzl", "gpu_cpp_unittest")
22
load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils")
33

44
def cuda_slim_cpp_unittest(name):
5-
cpp_unittest(
5+
gpu_cpp_unittest(
66
name = "test_" + name,
77
srcs = [
88
"test_" + name + ".cpp",
@@ -16,6 +16,7 @@ def cuda_slim_cpp_unittest(name):
1616
external_deps = [
1717
("cuda", None, "cuda-lazy"),
1818
],
19+
hip_compatible = False,
1920
keep_gpu_sections = True,
2021
remote_execution = re_test_utils.remote_execution(
2122
platform = "gpu-remote-execution",

backends/arm/_passes/decompose_permute_for_u55_pass.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from executorch.backends.arm._passes.arm_pass import ArmPass
1515
from executorch.backends.arm._passes.rewrite_slice import RewriteSlicePass
1616
from executorch.backends.arm.arm_vela import vela_compile
17-
from executorch.backends.arm.ethosu.compile_spec import EthosUCompileSpec
1817
from executorch.backends.arm.tosa.mapping import map_dtype
1918
from executorch.backends.arm.tosa.specification import get_context_spec
2019
from executorch.exir.dialects._ops import ops as exir_ops
@@ -112,6 +111,9 @@ def _violates_exact_constraint(
112111
permutation and dtype to check wheter it is supported.
113112
"""
114113

114+
# Lazy import to avoid circular dependency
115+
from executorch.backends.arm.ethosu.compile_spec import EthosUCompileSpec
116+
115117
if dtype not in (torch.int8, torch.bool, torch.int16):
116118
return True
117119

backends/arm/public_api_manifests/api_manifest_running.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ signature = "EthosUCompileSpec(target: str, system_config: str | None = None, me
2222

2323
[python.EthosUCompileSpec.DebugMode]
2424
kind = "enum"
25-
signature = "EthosUCompileSpec.DebugMode(value, names=None, *, module=None, qualname=None, type=None, start=1)"
25+
signature = "EthosUCompileSpec.DebugMode(*values)"
2626

2727
[python.EthosUCompileSpec.__eq__]
2828
kind = "function"
@@ -106,7 +106,7 @@ signature = "VgfCompileSpec(tosa_spec: executorch.backends.arm.tosa.specificatio
106106

107107
[python.VgfCompileSpec.DebugMode]
108108
kind = "enum"
109-
signature = "VgfCompileSpec.DebugMode(value, names=None, *, module=None, qualname=None, type=None, start=1)"
109+
signature = "VgfCompileSpec.DebugMode(*values)"
110110

111111
[python.VgfCompileSpec.__eq__]
112112
kind = "function"

backends/arm/scripts/generate_public_api_manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def _api_kind(obj: object) -> str:
6060

6161

6262
def _api_signature(path: str, obj: object) -> str:
63+
if inspect.isclass(obj) and issubclass(obj, enum.Enum):
64+
# EnumMeta.__call__ renders differently across Python versions.
65+
return f"{path}(*values)"
6366
try:
6467
return f"{path}{inspect.signature(cast(Any, obj))}"
6568
except (TypeError, ValueError):

backends/arm/test/ops/test_sum.py

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from typing import Callable, Tuple
77

8+
import pytest
9+
810
import torch
911
from executorch.backends.arm.test import common
1012

@@ -96,7 +98,16 @@ def test_sum_dim_intlist_tosa_INT(test_data: input_t1):
9698
pipeline.run()
9799

98100

99-
@common.parametrize("test_data", Sum.test_parameters)
101+
# dim=None cases skipped: executorch.devtools.bundled_program.config rejects
102+
# None as a model input (cannot be serialized into the bundled program).
103+
_DIM_NONE_SKIP_REASON = "bundled_program cannot serialize None as a model input"
104+
_dim_none_skips = {
105+
"dim_None": _DIM_NONE_SKIP_REASON,
106+
"dim_None_4d_tensor": _DIM_NONE_SKIP_REASON,
107+
}
108+
109+
110+
@common.parametrize("test_data", Sum.test_parameters, skips=_dim_none_skips)
100111
@common.XfailIfNoCorstone300
101112
def test_sum_u55_INT_1_0(test_data: Tuple):
102113
pipeline = EthosU55PipelineINT[input_t1](
@@ -108,7 +119,7 @@ def test_sum_u55_INT_1_0(test_data: Tuple):
108119
pipeline.run()
109120

110121

111-
@common.parametrize("test_data", Sum.test_parameters)
122+
@common.parametrize("test_data", Sum.test_parameters, skips=_dim_none_skips)
112123
@common.XfailIfNoCorstone320
113124
def test_sum_u85_INT_1_0(test_data: Tuple):
114125
pipeline = EthosU85PipelineINT[input_t1](
@@ -220,3 +231,60 @@ def test_sum_tosa_FP(test_data: Callable[[], input_t2]):
220231
def test_sum_tosa_INT(test_data: Callable[[], input_t2]):
221232
pipeline = TosaPipelineINT[input_t1](SumDefault(), test_data(), SumDefault.aten_op)
222233
pipeline.run()
234+
235+
236+
# a16w8 (int16 IO + int8 weights) coverage for sum.dim_IntList. Surfaces the
237+
# Ethos-U85 int16 ReduceSum silent-zero issue tracked upstream at
238+
# https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/issues/23.
239+
240+
241+
class SumLastDim(torch.nn.Module):
242+
"""Reduce the last dim with keepdim=True."""
243+
244+
def forward(self, x: torch.Tensor) -> torch.Tensor:
245+
return x.sum(dim=-1, keepdim=True)
246+
247+
248+
a16w8_sum_test_parameters = {
249+
"rank1_16": lambda: (torch.rand(16),),
250+
"rank3_8x1x16": lambda: (torch.rand(8, 1, 16),),
251+
"rank3_4x4x16": lambda: (torch.rand(4, 4, 16),),
252+
}
253+
254+
255+
@common.parametrize("test_data", a16w8_sum_test_parameters)
256+
@common.XfailIfNoCorstone300
257+
def test_sum_dim_intlist_a16w8_u55_INT(test_data: Callable[[], input_t1]):
258+
pipeline = EthosU55PipelineINT[input_t1](
259+
SumLastDim(),
260+
test_data(),
261+
aten_op,
262+
exir_ops=[],
263+
a16w8_quantization=True,
264+
symmetric_io_quantization=True,
265+
qtol=128,
266+
epsilon=2**-16,
267+
)
268+
pipeline.run()
269+
270+
271+
# All cases hit upstream Vela issue #23 (linked above). strict=False so the
272+
# test target stays green both on stock Vela 5.0 (cases XFAIL) and once the
273+
# Vela fix is in tree (cases XPASS).
274+
@common.parametrize("test_data", a16w8_sum_test_parameters)
275+
@common.XfailIfNoCorstone320
276+
@pytest.mark.xfail(
277+
reason="Ethos-U85 int16 ReduceSum returns zero (vela#23)", strict=False
278+
)
279+
def test_sum_dim_intlist_a16w8_u85_INT(test_data: Callable[[], input_t1]):
280+
pipeline = EthosU85PipelineINT[input_t1](
281+
SumLastDim(),
282+
test_data(),
283+
aten_op,
284+
exir_ops=[],
285+
a16w8_quantization=True,
286+
symmetric_io_quantization=True,
287+
qtol=128,
288+
epsilon=2**-16,
289+
)
290+
pipeline.run()

backends/arm/test/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def define_arm_tests():
3030
"ops/test_slice.py",
3131
"ops/test_sigmoid.py",
3232
"ops/test_sub.py",
33+
"ops/test_sum.py",
3334
"ops/test_tanh.py",
3435
"ops/test_view.py",
3536
"ops/test_cos.py",

backends/arm/tosa/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ def are_fake_tensors_broadcastable(
6464
def broadcast_tensors(tosa_fb, nodes: list[Node]) -> list[Any]:
6565
"""Broadcast the FX nodes to a shared shape inside the TOSA graph.
6666
67-
This mirrors ``reshape_for_broadcast`` but also emits the tile operators
68-
needed to materialize the broadcast and supports any number of inputs.
67+
This emits the reshape and tile operators needed to materialize the
68+
broadcast and supports any number of inputs.
6969
7070
Args:
7171
tosa_fb (Any): TOSA graph builder that receives the broadcast
7272
operators.
7373
nodes (list[Node]): FX nodes whose tensor metadata should be
7474
broadcast.
75-
tosa_spec (TosaSpecification): Active TOSA specification used to
76-
decode tensor metadata.
7775
7876
Returns:
7977
list[Any]: Broadcast versions of the inputs. Each element is either

0 commit comments

Comments
 (0)