Skip to content

[TorchToTosa] Lower MXFP8 aten._scaled_mm to TOSA#4560

Open
catcor01 wants to merge 3 commits intollvm:mainfrom
catcor01:cc/scaled-mm-mxfp8-tosa
Open

[TorchToTosa] Lower MXFP8 aten._scaled_mm to TOSA#4560
catcor01 wants to merge 3 commits intollvm:mainfrom
catcor01:cc/scaled-mm-mxfp8-tosa

Conversation

@catcor01
Copy link
Copy Markdown
Contributor

@catcor01 catcor01 commented May 6, 2026

Adds TorchToTosa legalization for block-scaled FP8 aten._scaled_mm with float8_e8m0fnu scale tensors.

Stacked on #4558 and #4559. Until those land and this branch is rebased, the GitHub diff will include the earlier stack commits as well. The review focus for this PR is the third commit: MXFP8/block-scaled TorchToTosa lowering.

@catcor01 catcor01 force-pushed the cc/scaled-mm-mxfp8-tosa branch 4 times, most recently from 7bd9fed to 4ae4df1 Compare May 6, 2026 08:14
catcor01 added 3 commits May 6, 2026 10:15
Add Torch op definitions, abstract interpretation support, and FX
importer handling for aten._scaled_mm, including float8_e8m0fnu
blocked-scale tensors.

Keep this change independent of TOSA legalization.

Include frontend export/import coverage for per-tensor and
blocked-scale FP8 shapes, plus out_dtype=None dtype inference.

Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: I102732ad725f89477b7f8fb2339d4fe920fa647b
Add TorchToTosa legalization for static FP8 aten._scaled_mm with
real-valued scale tensors.

Lower FP8 inputs to TOSA FP8 matmul, then apply the combined scale
product to the f32 accumulator before optional bias and final output
cast.

Support scalar/[1] per-tensor scales and simple 1-D lhs/rhs channel
scales, with lit and Python coverage for e4m3, e5m2, mixed FP8
inputs, bias, and rejection cases.

Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: Ie14b7f1a662820951ffb174285c9b5b15a9467b0
Add TorchToTosa legalization for block-scaled FP8 aten._scaled_mm
with float8_e8m0fnu scale tensors.

Lower canonical rank-3 blocked tensors directly to
tosa.matmul_t_block_scaled with BLOCK_SIZE_32, and recover the
exported reshape/view -> aten._scaled_mm -> reshape/view pattern for
flat blocked tensors.

Support rectangular and ragged blocked shapes plus the exported
transpose/contiguous/reshape RHS form, with lit and Python coverage.

Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: I31f1605b30e54e3ea32b551c8584a1b3e92bdb3e
@catcor01 catcor01 force-pushed the cc/scaled-mm-mxfp8-tosa branch from 4ae4df1 to f94be46 Compare May 6, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant