Skip to content

Revert "Arm backend: Lower MXFP Linear to TOSA"#20047

Merged
zingo merged 2 commits into
mainfrom
revert-19969-lower-linear
Jun 5, 2026
Merged

Revert "Arm backend: Lower MXFP Linear to TOSA"#20047
zingo merged 2 commits into
mainfrom
revert-19969-lower-linear

Conversation

@zingo
Copy link
Copy Markdown
Collaborator

@zingo zingo commented Jun 4, 2026

@zingo zingo requested a review from digantdesai as a code owner June 4, 2026 21:35
Copilot AI review requested due to automatic review settings June 4, 2026 21:35
@pytorch-bot pytorch-bot Bot added the ci-no-td label Jun 4, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Jun 4, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20047

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 1 Cancelled Job

As of commit aa82cd0 with merge base 4c9c444 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOB - The following job was cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jun 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts the Arm backend change that lowered MXFP Linear into explicit TOSA block-scaled operators, restoring the previous behavior by removing the MXFP-specific dialect ops, visitors, rewrite pass, and associated tests.

Changes:

  • Remove TOSA dialect ops and Arm operator visitors for CAST_TO_BLOCK_SCALED / MATMUL_T_BLOCK_SCALED, plus the MXFP linear rewrite pass.
  • Tighten FP8 extension validation to require the dedicated fp8* extensions (rather than allowing mxfp as a substitute).
  • Simplify/relocate MXFP linear tests to only validate eager CPU/reference behavior.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
backends/arm/tosa/mapping.py Removes MXFP-as-fallback extension validation for FP8 dtypes.
backends/arm/tosa/dialect/ops/matmul_t_block_scaled.py Deletes fake op definition for block-scaled matmul.
backends/arm/tosa/dialect/ops/cast_to_block_scaled.py Deletes fake op definition for block-scaled cast.
backends/arm/tosa/dialect/init.py Stops importing the removed dialect ops.
backends/arm/test/targets.bzl Updates/removes test targets related to the reverted MXFP lowering pipeline.
backends/arm/test/passes/test_rewrite_mxfp_linear_pass.py Deletes tests for the removed rewrite pass.
backends/arm/test/ops/test_mxfp_linear.py Simplifies MXFP linear tests to eager CPU reference checks.
backends/arm/test/ops/mxfp/common.py Deletes MXFP pipeline helper utilities.
backends/arm/test/ops/mxfp/init.py Deletes empty package marker for removed MXFP test helpers.
backends/arm/test/misc/tosa_dialect/test_tosa_dialect_mxfp_linear.py Deletes tests for removed TOSA dialect MXFP ops.
backends/arm/test/misc/tosa_dialect/test_tosa_dialect_cast_to_block_scaled.py Deletes tests for removed TOSA dialect MXFP ops.
backends/arm/process_node.py Removes float8_e8m0fnu handling from tensor serialization path.
backends/arm/operators/op_tosa_matmul_t_block_scaled.py Deletes TOSA serializer visitor for block-scaled matmul.
backends/arm/operators/op_tosa_cast_to_block_scaled.py Deletes TOSA serializer visitor for block-scaled cast.
backends/arm/operators/init.py Stops importing the removed operator visitors.
backends/arm/operator_support/tosa_supported_operators.py Removes MXFP custom-op support list and loosens dtype gating changes tied to MXFP.
backends/arm/_passes/rewrite_mxfp_linear.py Deletes the MXFP linear rewrite pass implementation.
backends/arm/_passes/arm_pass_manager.py Removes the rewrite pass from the Arm pass pipeline.
backends/arm/_passes/init.py Stops exporting the removed rewrite pass.
Comments suppressed due to low confidence (2)

backends/arm/test/ops/test_mxfp_linear.py:185

  • test_data is a callable (values in test_data_fp are lambda: (...)) produced by common.parametrize, but the helper annotates it as torch.Tensor. This is misleading for readers and type checkers.
    backends/arm/test/ops/test_mxfp_linear.py:214
  • test_data here is a callable provided by common.parametrize (dict values are lambdas), not a torch.Tensor. The current annotation is incorrect/misleading.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 31 to 48
def _tensor_to_numpy(tensor: torch.Tensor) -> np.ndarray:
tensor = tensor.detach().cpu().contiguous()
if tensor.dtype in (
torch.bfloat16,
torch.float8_e4m3fn,
torch.float8_e5m2,
torch.float8_e8m0fnu,
):
if tensor.dtype in (torch.bfloat16, torch.float8_e4m3fn, torch.float8_e5m2):
try:
import ml_dtypes # type: ignore[import-not-found]
except ImportError as e:
raise RuntimeError(
f"ml_dtypes is required to serialize {tensor.dtype} tensors for TOSA. "
"Have you run setup.sh?"
) from e

ml_dtype_map = {
torch.bfloat16: (torch.uint16, ml_dtypes.bfloat16),
torch.float8_e4m3fn: (torch.uint8, ml_dtypes.float8_e4m3fn),
torch.float8_e5m2: (torch.uint8, ml_dtypes.float8_e5m2),
torch.float8_e8m0fnu: (torch.uint8, ml_dtypes.float8_e8m0fnu),
}
storage_dtype, ml_dtype = ml_dtype_map[tensor.dtype]
return tensor.view(storage_dtype).numpy().view(ml_dtype)
@zingo zingo added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Jun 5, 2026
@zingo zingo merged commit 7f19a2e into main Jun 5, 2026
487 of 498 checks passed
@zingo zingo deleted the revert-19969-lower-linear branch June 5, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants