Skip to content

Commit 6639b8f

Browse files
Ninja91facebook-github-bot
authored andcommitted
Add a16w8 reduce_sum FVP coverage for Ethos-U85 (#19319)
Summary: Adds an a16w8 (int16 IO + int8 weights) sweep for `aten.sum.dim_IntList` reducing the last dim with `keepdim=True`. The new tests `test_sum_dim_intlist_a16w8_{u55,u85}_INT` run on the standard Corstone-300 / Corstone-320 FVP harness. The U85 case surfaces a known numerics issue in the Vela `regor` lowering at int16 IO precision (silent zero output), tracked upstream at https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/issues/23. The Ethos-U55 path uses a different accumulator and is correct on the same OFM rescale. This diff is **additive only**: the `Sum` / `SumDefault` test classes and existing test functions are not modified, except for `skips=` annotations on the four pre-existing `dim_None` parametrize ids that are not bundled-program-serializable and surface only because this diff is the first to register `ops/test_sum.py` in the buck test target list. Test design: - Standard `pipeline.run()` with the same a16w8 kwargs other arm a16w8 tests use (e.g. `test_native_layer_norm_16a8w_u85_INT` in `test_layer_norm.py`): `a16w8_quantization=True, symmetric_io_quantization=True, qtol=128, epsilon=2**-16`. - Numerical comparison is the standard `atol`/`rtol` check from `pipeline.run()` — no SQNR helpers. - The U85 cases are wrapped with `xfails=a16w8_sum_u85_xfails, strict=False`. `strict=False` keeps the test target green both on stock Vela 5.0 (cases XFAIL) and once the upstream Vela fix is in tree (cases XPASS allowed). - `XfailIfNoCorstone320` is intentionally omitted on the new a16w8 U85 test — stacking it with the per-id `xfails=` argument makes the per-id marks not fire (verified empirically in this buck test target). A code comment in the file documents this constraint. Differential Revision: D103667823
1 parent 1debeb6 commit 6639b8f

2 files changed

Lines changed: 82 additions & 2 deletions

File tree

backends/arm/test/ops/test_sum.py

Lines changed: 81 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,27 @@ 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+
# Pre-existing failure that only surfaced after this diff registered
102+
# ops/test_sum.py in targets.bzl (Meta CI never ran these tests before):
103+
# bundled_program (used by the FVP _INT_1_0 tests) cannot serialize None
104+
# as a model input -- the input flatten/sanity check in
105+
# executorch.devtools.bundled_program.config rejects NoneType. dim=None is
106+
# already covered by the SumDefault class below. Marked skip rather than
107+
# xfail because the per-id xfails= argument does not compose with the
108+
# XfailIfNoCorstone* decorator (verified empirically); common.parametrize
109+
# explicitly supports skips= for "fail markers don't work in buck CI".
110+
_DIM_NONE_SKIP_REASON = (
111+
"bundled_program cannot serialize None as a model input "
112+
"(pre-existing failure -- only surfaced after ops/test_sum.py was "
113+
"registered in targets.bzl)"
114+
)
115+
_dim_none_skips = {
116+
"dim_None": _DIM_NONE_SKIP_REASON,
117+
"dim_None_4d_tensor": _DIM_NONE_SKIP_REASON,
118+
}
119+
120+
121+
@common.parametrize("test_data", Sum.test_parameters, skips=_dim_none_skips)
100122
@common.XfailIfNoCorstone300
101123
def test_sum_u55_INT_1_0(test_data: Tuple):
102124
pipeline = EthosU55PipelineINT[input_t1](
@@ -108,7 +130,7 @@ def test_sum_u55_INT_1_0(test_data: Tuple):
108130
pipeline.run()
109131

110132

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

0 commit comments

Comments
 (0)