Skip to content

Arm backend: Add MXFP4/MXFP6 linear support#20370

Open
martinlsm wants to merge 3 commits into
pytorch:mainfrom
martinlsm:linear-mxfp4-mxfp6
Open

Arm backend: Add MXFP4/MXFP6 linear support#20370
martinlsm wants to merge 3 commits into
pytorch:mainfrom
martinlsm:linear-mxfp4-mxfp6

Conversation

@martinlsm

@martinlsm martinlsm commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Add support for running torch.nn.Linear modules in MXFP4E2M1,
MXFP6E3M2 and MXFP6E2M3. Update the MXFPOpConfig to support
the data types.

Since torch lacks FP6 datatypes, the string-based definitions in
torchao are used as a workaround.

The custom TOSA op receives a new argument called
str weight_payload_dtype which tells which dtype is used for the
weights. The weight tensor itself does not contain this info since the
FP4 and FP6 formats are storted into uint8 tensors.

The CAST_TO_BLOCK_SCALED required to transform activations from/to MXFP
is also updated to support the new datatype. Its custom TOSA op gets a
str output_dtype similar to the weight_payload_dtype for the MXFP
linear op.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

@martinlsm martinlsm requested a review from digantdesai as a code owner June 18, 2026 07:20
@pytorch-bot

pytorch-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 7 New Failures, 3 Cancelled Jobs, 7 Unrelated Failures, 29 Unclassified Failures

As of commit 65128df with merge base 0da9ca3 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was 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.

@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 18, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jun 18, 2026
@martinlsm

Copy link
Copy Markdown
Collaborator Author

@pytorchbot label ciflow/trunk

@martinlsm

Copy link
Copy Markdown
Collaborator Author

@pytorchbot label "partner: arm"

@pytorch-bot pytorch-bot Bot added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Jun 18, 2026
@martinlsm

Copy link
Copy Markdown
Collaborator Author

@pytorchbot label "release notes: arm"

@pytorch-bot pytorch-bot Bot added the release notes: arm Changes to the ARM backend delegate label Jun 18, 2026
@martinlsm martinlsm requested a review from zingo June 18, 2026 07:21

@zingo zingo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK to merge if tests pass and Mypy error is fixed
nss test fails in unrelated

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: I29ca5ed16db5fe15331402e5139aead1040ce1b6
Add support for running torch.nn.Linear modules in MXFP6E3M2 and
MXFP6E2M3. Update the `MXFPOpConfig` to support the data types.

Since `torch` lacks FP6 datatypes, the string-based definitions in
`torchao` are used as a workaround.

The custom TOSA op receives a new argument called
`str weight_payload_dtype` which tells which dtype is used for the
weights. The weight tensor itself does not contain this info since the
FP4 and FP6 formats are storted into uint8 tensors.

The CAST_TO_BLOCK_SCALED required to transform activations from/to MXFP
is also updated to support the new datatype. Its custom TOSA op gets a
`str output_dtype` similar to the `weight_payload_dtype` for the MXFP
linear op.

Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: Iea06b859429c458b1921ee3e736a65f597b37239
Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com>
Change-Id: Ic972b1b93224bb03bca03599268c3a2e09f5ec4f
@martinlsm martinlsm force-pushed the linear-mxfp4-mxfp6 branch from 9463dee to 65128df Compare June 18, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants