-
Notifications
You must be signed in to change notification settings - Fork 834
Arm backend: Add FP16 (pt.8) and BF16 support to operators #17370
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
base: main
Are you sure you want to change the base?
Conversation
Add FP16 support for operators: - add - amax - amin - permute - sum Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com> Change-Id: Iacdf79adf8e4ce9d16dce91f590f49eef339323d
Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com> Change-Id: I42d15ff8c62463fe628bad103ef24b7a11b8b4a3
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17370
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Awaiting Approval, 10 New Failures, 15 Unrelated FailuresAs of commit c3b4336 with merge base 9c74c32 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label ciflow/trunk |
|
@pytorchbot label "partner: arm" |
|
@pytorchbot label "release notes: arm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds FP16 (and for a subset, BF16) support coverage for the Arm backend by expanding operator dtype validation and extending the existing operator test suites.
Changes:
- Allow FP16 (and BF16 where applicable) in Arm TOSA lowering dtype validation for
add,sum,permute,amax, andamin. - Extend Arm backend operator tests to exercise FP16 (and BF16 for
amax/amin) paths across TOSA FP and (where relevant) VGF pipelines. - Refactor some test parametrization/xfail mappings to separate FP vs INT expectations.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| backends/arm/test/ops/test_to_copy.py | Splits redundant-cast xfail mappings for FP vs INT pipelines. |
| backends/arm/test/ops/test_sum.py | Adds FP16 test coverage for sum (dim_IntList and default variants). |
| backends/arm/test/ops/test_permute.py | Adds FP16 test coverage for permute and simplifies test suite dict composition. |
| backends/arm/test/ops/test_amin.py | Adds FP16/BF16 test cases and uses explicit op-name constants for pipelines. |
| backends/arm/test/ops/test_amax.py | Adds FP16/BF16 test cases and uses explicit op-name constants for pipelines. |
| backends/arm/test/ops/test_add.py | Adds FP16/BF16 test cases for add variants and consolidates FP tests. |
| backends/arm/operators/op_sum.py | Allows FP16 dtype in sum dtype validation. |
| backends/arm/operators/op_permute.py | Allows FP16 dtype in permute dtype validation. |
| backends/arm/operators/op_amin.py | Allows FP16 and BF16 dtypes in amin dtype validation. |
| backends/arm/operators/op_amax.py | Allows FP16 and BF16 dtypes in amax dtype validation. |
| backends/arm/operators/op_add.py | Allows FP16 dtype in add dtype validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| amin_exir_op = "executorch_exir_dialects_edge__ops_aten_amin_default" | ||
|
|
||
| min_aten_op = "torch.ops.aten.min" | ||
| min_exir_op = "executorch_exir_dialects_edge__ops_aten_min_default" |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amin_exir_op and min_exir_op are defined but never referenced in this file. Consider deleting them or using them in the relevant pipelines / not-delegated checks to avoid unused-variable lint issues and keep the test definitions focused.
| amin_exir_op = "executorch_exir_dialects_edge__ops_aten_amin_default" | |
| min_aten_op = "torch.ops.aten.min" | |
| min_exir_op = "executorch_exir_dialects_edge__ops_aten_min_default" | |
| min_aten_op = "torch.ops.aten.min" |
|
|
||
| test_data_fp16 = { | ||
| "4d_big_small_fp16": lambda: ( | ||
| (10e10) * torch.randn(1, 10, 20, 30, dtype=torch.float16), |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_data_fp16 scales random FP16 values by 10e10 (~1e11), which will overflow FP16 (max ~6.5e4) and likely produce inf/-inf. This makes the test less meaningful and can hide numerical issues; consider using a scale within FP16 range (or generate values already bounded) so the test exercises real finite FP16 behavior.
| (10e10) * torch.randn(1, 10, 20, 30, dtype=torch.float16), | |
| (1e4) * torch.randn(1, 10, 20, 30, dtype=torch.float16), |
| test_data_fp16: list[input_t2] = { | ||
| "4d_randn_diff_rank_fp16": lambda: ( | ||
| torch.randn(1, 1, 4, 4, dtype=torch.float16), | ||
| torch.randn(4, 1, dtype=torch.float16), | ||
| ), | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type annotation for test_data_fp16 is list[input_t2], but the assigned value is a dict keyed by test name. This mismatch can confuse readers and breaks static type checking; annotate it as a Dict[str, Callable[[], input_t2]] (or similar) to match usage.
| test_data_bf16: list[input_t2] = { | ||
| "4d_randn_diff_rank_bf16": lambda: ( | ||
| torch.randn(1, 1, 4, 4, dtype=torch.bfloat16), | ||
| torch.randn(4, 1, dtype=torch.bfloat16), | ||
| ), | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type annotation for test_data_bf16 is list[input_t2], but the assigned value is a dict keyed by test name. Update the annotation to a Dict[...] (matching how it’s used with common.parametrize and dict union) to avoid type confusion.
| amax_exir_op = "executorch_exir_dialects_edge__ops_aten_amax_default" | ||
|
|
||
| max_aten_op = "torch.ops.aten.max" | ||
| max_exir_op = "executorch_exir_dialects_edge__ops_aten_max_default" |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
amax_exir_op and max_exir_op are defined but never used in this test module. If they’re not needed, remove them; if they are, prefer using them where you currently inline the EXIR op strings to keep the file consistent and avoid unused-symbol lint failures.
| amax_exir_op = "executorch_exir_dialects_edge__ops_aten_amax_default" | |
| max_aten_op = "torch.ops.aten.max" | |
| max_exir_op = "executorch_exir_dialects_edge__ops_aten_max_default" | |
| max_aten_op = "torch.ops.aten.max" |
Add FP16 support for operators:
Add BF16 support for operators:
cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai