Skip to content

[Backend Tester] Clean up a few test issues #13258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 118 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
f120e70
Update
GregoryComer Jul 18, 2025
0fb85e6
Update
GregoryComer Jul 18, 2025
4d8d844
Update
GregoryComer Jul 19, 2025
dc12b40
Update
GregoryComer Jul 21, 2025
ead0616
Update
GregoryComer Jul 22, 2025
0f13676
Update
GregoryComer Jul 22, 2025
b0b01f2
Update
GregoryComer Jul 22, 2025
8b9c9ef
Update
GregoryComer Jul 22, 2025
06bf03a
Update
GregoryComer Jul 22, 2025
2f8f49b
Update
GregoryComer Jul 22, 2025
8ca7766
Update
GregoryComer Jul 22, 2025
bffb95f
Update
GregoryComer Jul 22, 2025
d21492b
Update
GregoryComer Jul 22, 2025
e2c4ea5
Update
GregoryComer Jul 22, 2025
8230848
Update
GregoryComer Jul 22, 2025
2a1f564
Update
GregoryComer Jul 22, 2025
b35e7b1
Update
GregoryComer Jul 22, 2025
5c4c6ce
Update
GregoryComer Jul 22, 2025
9397803
Update
GregoryComer Jul 22, 2025
9dfeb5a
Update
GregoryComer Jul 22, 2025
ff5c4a5
Update
GregoryComer Jul 22, 2025
42a5de5
Update
GregoryComer Jul 22, 2025
402d8f5
Update
GregoryComer Jul 22, 2025
34d3ab3
Update
GregoryComer Jul 22, 2025
1105e04
Update
GregoryComer Jul 22, 2025
482bd21
Update
GregoryComer Jul 22, 2025
ea548b7
Update
GregoryComer Jul 23, 2025
4108f54
Update
GregoryComer Jul 23, 2025
7ef236b
Update
GregoryComer Jul 23, 2025
4a58c9d
Update
GregoryComer Jul 23, 2025
3b866b4
Update
GregoryComer Jul 23, 2025
5ba25cb
Update
GregoryComer Jul 23, 2025
19760fc
Update
GregoryComer Jul 23, 2025
81dfb07
Update
GregoryComer Jul 23, 2025
4d50265
Update
GregoryComer Jul 23, 2025
5f66043
Update
GregoryComer Jul 23, 2025
24e919d
Update
GregoryComer Jul 23, 2025
523cc20
Update
GregoryComer Jul 23, 2025
74c95fe
Update
GregoryComer Jul 23, 2025
5d437b1
Update
GregoryComer Jul 23, 2025
89757ce
Update
GregoryComer Jul 23, 2025
423f79a
Update
GregoryComer Jul 23, 2025
69f7f9c
Update
GregoryComer Jul 23, 2025
c0f6224
Update
GregoryComer Jul 23, 2025
e2ea2a3
Update
GregoryComer Jul 23, 2025
7a2fab5
Update
GregoryComer Jul 23, 2025
033c231
Update
GregoryComer Jul 23, 2025
a9ed762
Update
GregoryComer Jul 23, 2025
64b174a
Update
GregoryComer Jul 23, 2025
3976629
Update
GregoryComer Jul 23, 2025
27cd171
Update
GregoryComer Jul 23, 2025
7bdd3e5
Update
GregoryComer Jul 23, 2025
b1254cd
Update
GregoryComer Jul 23, 2025
f2e2289
Update
GregoryComer Jul 23, 2025
cdd15c1
Update
GregoryComer Jul 23, 2025
e2df06e
Update
GregoryComer Jul 23, 2025
4461bd8
Update
GregoryComer Jul 23, 2025
7e97fd0
Update
GregoryComer Jul 23, 2025
bcb697c
Update
GregoryComer Jul 23, 2025
11a5a02
Update
GregoryComer Jul 24, 2025
244b146
Update
GregoryComer Jul 24, 2025
de21ac2
Update
GregoryComer Jul 24, 2025
fd26fc7
Update
GregoryComer Jul 24, 2025
4ae840d
Update
GregoryComer Jul 24, 2025
710ea49
Update
GregoryComer Jul 24, 2025
32f54b0
Update
GregoryComer Jul 24, 2025
a27d18c
Update
GregoryComer Jul 24, 2025
2eb59fc
Update
GregoryComer Jul 24, 2025
5cc4941
Update
GregoryComer Jul 24, 2025
ef7af5c
Update
GregoryComer Jul 24, 2025
18e89c1
Update
GregoryComer Jul 24, 2025
4719c90
Update
GregoryComer Jul 25, 2025
dd09555
Update
GregoryComer Aug 8, 2025
f1db3a0
Update
GregoryComer Aug 8, 2025
e0700b2
Update
GregoryComer Aug 8, 2025
f260b50
Update
GregoryComer Aug 8, 2025
d62ee60
Update
GregoryComer Aug 8, 2025
b2ab3a5
Update
GregoryComer Aug 8, 2025
c23c3e9
Update
GregoryComer Aug 8, 2025
c99c41a
Update
GregoryComer Aug 9, 2025
bf57d6c
Update
GregoryComer Aug 9, 2025
f261355
Update
GregoryComer Aug 11, 2025
c3a24f9
Update
GregoryComer Aug 11, 2025
1697cbc
Update
GregoryComer Aug 11, 2025
b94b45e
Update
GregoryComer Aug 11, 2025
5740f0a
Update
GregoryComer Aug 11, 2025
ed6840d
Update
GregoryComer Aug 11, 2025
f2a7e1f
Update
GregoryComer Aug 11, 2025
0e162ab
Update
GregoryComer Aug 11, 2025
c6bd56b
Update
GregoryComer Aug 11, 2025
144a8ae
Update
GregoryComer Aug 12, 2025
bd79ef2
Update
GregoryComer Aug 12, 2025
8932c29
Update
GregoryComer Aug 12, 2025
ea2549c
Update
GregoryComer Aug 12, 2025
ffaa1c3
Update
GregoryComer Aug 12, 2025
f4b0dc2
Update
GregoryComer Aug 12, 2025
5e92884
Update
GregoryComer Aug 12, 2025
7e1a002
Update
GregoryComer Aug 12, 2025
a628d29
Update
GregoryComer Aug 12, 2025
3615d89
Update
GregoryComer Aug 12, 2025
e994bc1
Update
GregoryComer Aug 12, 2025
0aba8e1
Update
GregoryComer Aug 12, 2025
4329bf6
Update
GregoryComer Aug 12, 2025
1d34f49
Update
GregoryComer Aug 12, 2025
933fba2
Update
GregoryComer Aug 12, 2025
d468ae4
Update
GregoryComer Aug 12, 2025
acbd480
Update
GregoryComer Aug 12, 2025
e515bf1
Update
GregoryComer Aug 12, 2025
1897d4e
Update
GregoryComer Aug 12, 2025
f65d80f
Update
GregoryComer Aug 12, 2025
0d1f097
Update
GregoryComer Aug 12, 2025
f0c2490
Update
GregoryComer Aug 12, 2025
871312a
Update
GregoryComer Aug 12, 2025
53990fe
Update
GregoryComer Aug 12, 2025
567d055
Update
GregoryComer Aug 12, 2025
31bc137
Update
GregoryComer Aug 12, 2025
dae5d43
Update
GregoryComer Aug 12, 2025
637b8a2
Update
GregoryComer Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def __init__(
if default_partitioner_cls is not None
else []
)
self.edge_compile_conf = edge_compile_config or EdgeCompileConfig()
self.edge_compile_conf = edge_compile_config or EdgeCompileConfig(
_check_ir_validity=False
)
self.edge_dialect_program = None

def stage_type(self) -> StageType:
Expand Down
12 changes: 6 additions & 6 deletions backends/test/suite/operators/test_amax.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,39 +207,39 @@ def test_amax_edge_cases(self, flow: TestFlow) -> None:
AmaxModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AmaxModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AmaxModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([[1.0, float("nan"), 3.0], [4.0, 5.0, float("nan")]])
self._test_op(
AmaxModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AmaxModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AmaxModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

def test_amax_scalar(self, flow: TestFlow) -> None:
Expand Down
12 changes: 6 additions & 6 deletions backends/test/suite/operators/test_amin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,39 +209,39 @@ def test_amin_edge_cases(self, flow: TestFlow) -> None:
AminModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AminModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AminModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([[1.0, float("nan"), 3.0], [4.0, 5.0, float("nan")]])
self._test_op(
AminModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AminModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
AminModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

def test_amin_scalar(self, flow: TestFlow) -> None:
Expand Down
12 changes: 6 additions & 6 deletions backends/test/suite/operators/test_argmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,39 +149,39 @@ def test_argmax_edge_cases(self, flow: TestFlow) -> None:
ArgmaxModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgmaxModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgmaxModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([[1.0, float("nan"), 3.0], [4.0, 5.0, float("nan")]])
self._test_op(
ArgmaxModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgmaxModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgmaxModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([5.0])
Expand Down
12 changes: 6 additions & 6 deletions backends/test/suite/operators/test_argmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,39 +149,39 @@ def test_argmin_edge_cases(self, flow: TestFlow) -> None:
ArgminModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgminModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgminModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([[1.0, float("nan"), 3.0], [4.0, 5.0, float("nan")]])
self._test_op(
ArgminModel(),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgminModel(dim=0),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)
self._test_op(
ArgminModel(dim=1),
(x,),
flow,
use_random_test_inputs=False,
generate_random_test_inputs=False,
)

x = torch.tensor([5.0])
Expand Down
4 changes: 2 additions & 2 deletions backends/test/suite/operators/test_floor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@


class FloorModel(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return torch.floor(x)


@operator_test
Expand Down
25 changes: 10 additions & 15 deletions backends/test/suite/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,32 @@ class TestResult(IntEnum):
SUCCESS_UNDELEGATED = 1
""" The test succeeded without the backend delegating anything. """

EAGER_FAIL = 2
""" The test failed due to the model failing to run in eager mode. """
SKIPPED = 2
""" The test was skipped due to a non-backend failure. """

QUANTIZE_FAIL = 3
""" The test failed due to the quantization stage failing. """

EXPORT_FAIL = 4
""" The test failed due to the model failing to export. """

LOWER_FAIL = 5
LOWER_FAIL = 4
""" The test failed due to a failure in partitioning or lowering. """

PTE_LOAD_FAIL = 6
PTE_LOAD_FAIL = 5
""" The test failed due to the resulting PTE failing to load. """

PTE_RUN_FAIL = 7
PTE_RUN_FAIL = 6
""" The test failed due to the resulting PTE failing to run. """

OUTPUT_MISMATCH_FAIL = 8
OUTPUT_MISMATCH_FAIL = 7
""" The test failed due to a mismatch between runtime and reference outputs. """

UNKNOWN_FAIL = 9
UNKNOWN_FAIL = 8
""" The test failed in an unknown or unexpected manner. """

def is_success(self):
return self in {TestResult.SUCCESS, TestResult.SUCCESS_UNDELEGATED}

def is_non_backend_failure(self):
return self in {TestResult.EAGER_FAIL, TestResult.EAGER_FAIL}
return self in {TestResult.SKIPPED}

def is_backend_failure(self):
return not self.is_success() and not self.is_non_backend_failure()
Expand All @@ -66,12 +63,10 @@ def display_name(self):
return "Success (Delegated)"
elif self == TestResult.SUCCESS_UNDELEGATED:
return "Success (Undelegated)"
elif self == TestResult.EAGER_FAIL:
return "Fail (Eager)"
elif self == TestResult.SKIPPED:
return "Skipped"
elif self == TestResult.QUANTIZE_FAIL:
return "Fail (Quantize)"
elif self == TestResult.EXPORT_FAIL:
return "Fail (Export)"
elif self == TestResult.LOWER_FAIL:
return "Fail (Lowering)"
elif self == TestResult.PTE_LOAD_FAIL:
Expand Down
26 changes: 23 additions & 3 deletions backends/test/suite/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

import torch

# Set of unsupported ops that should cause tests to be skipped
UNSUPPORTED_PORTABLE_OPS = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are adding a Portable flow, how would these show up there? Some PTE_FAIL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question. They won't be reported as failures. I think that's mostly fine, since the main goal is to validate backends. That being said, we could only skip these tests for flows that are expected to delegate - though backend op libs might make it trickier. I'll make this change.

"aten::_embedding_bag",
"aten::median",
"aten::median.dim",
"aten::round.decimals",
}

from executorch.backends.test.harness.error_statistics import ErrorStatistics
from executorch.backends.test.harness.stages import StageType
from executorch.backends.test.suite.discovery import discover_tests, TestFilter
Expand Down Expand Up @@ -70,7 +78,7 @@ def build_result(
try:
model(*inputs)
except Exception as e:
return build_result(TestResult.EAGER_FAIL, e)
return build_result(TestResult.SKIPPED, e)

try:
tester = flow.tester_factory(model, inputs)
Expand All @@ -96,7 +104,7 @@ def build_result(
tester._get_default_stage(StageType.EXPORT, dynamic_shapes=dynamic_shapes),
)
except Exception as e:
return build_result(TestResult.EXPORT_FAIL, e)
return build_result(TestResult.SKIPPED, e)

lower_start_time = time.perf_counter()
try:
Expand Down Expand Up @@ -125,7 +133,16 @@ def build_result(
if n.op == "call_function"
)

# Only run the runtime portion if something was delegated (or the flow doesn't delegate).
# Check if any undelegated ops are in the unsupported ops set.
has_unsupported_ops = any(
op in UNSUPPORTED_PORTABLE_OPS for op in undelegated_op_counts.keys()
)

# Skip the test if there are unsupported portable ops remaining.
if has_unsupported_ops:
return build_result(TestResult.SKIPPED)

# Only run the runtime portion if something was delegated (or the flow doesn't delegate)
if is_delegated or not flow.is_delegated:
try:
tester.to_executorch().serialize()
Expand All @@ -142,12 +159,15 @@ def build_result(
tester.run_method_and_compare_outputs(
inputs=None if generate_random_test_inputs else inputs,
statistics_callback=lambda stats: error_statistics.append(stats),
atol=1e-1,
rtol=4e-2,
)
except AssertionError as e:
return build_result(TestResult.OUTPUT_MISMATCH_FAIL, e)
except Exception as e:
return build_result(TestResult.PTE_RUN_FAIL, e)
else:
# Skip the test if nothing is delegated
return build_result(TestResult.SUCCESS_UNDELEGATED)

return build_result(TestResult.SUCCESS)
Expand Down
4 changes: 2 additions & 2 deletions backends/test/suite/tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
flow="flow1",
name="test2_backend2_flow1",
params={"use_dynamic_shapes": True},
result=TestResult.EXPORT_FAIL,
result=TestResult.SKIPPED,
error=None,
tensor_error_statistics=[],
),
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_csv_report_simple(self):
self.assertEqual(records[3]["Test Case"], "test2")
self.assertEqual(records[3]["Backend"], "backend2")
self.assertEqual(records[3]["Flow"], "flow1")
self.assertEqual(records[3]["Result"], "Fail (Export)")
self.assertEqual(records[3]["Result"], "Skipped")
self.assertEqual(records[3]["Dtype"], "")
self.assertEqual(records[3]["Use_dynamic_shapes"], "True")

Expand Down
Loading