Skip to content

[AOTI] Add MXFP4 dtype support to AOTInductor C shim - #176496

Closed
pranavsharma wants to merge 3 commits into
pytorch:mainfrom
pranavsharma:AddMXFP4DTypes
Closed

pranavsharma wants to merge 3 commits into
pytorch:mainfrom
pranavsharma:AddMXFP4DTypes

Conversation

@pranavsharma

@pranavsharma pranavsharma commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary: Add float8_e8m0fnu and float4_e2m1fn_x2 dtype accessors to the
AOTInductor C shim layer, following the existing pattern for float8
dtypes. This is a purely additive ABI-compatible change.
Context is adding support for MXFP4 on AMD MI350.

Test Plan: - Existing AOTI tests pass (no existing symbols modified)

  • New functions follow the same AOTI_TORCH_DTYPE_IMPL macro pattern as the other float8 dtypes

Reviewers:

Subscribers:

Tasks:

Tags:

Summary: Add `float8_e8m0fnu` and `float4_e2m1fn_x2` dtype accessors to the
  AOTInductor C shim layer, following the existing pattern for float8
  dtypes. This is a purely additive ABI-compatible change.

Test Plan: - Existing AOTI tests pass (no existing symbols modified)
  - New functions follow the same `AOTI_TORCH_DTYPE_IMPL` macro pattern
    as the other float8 dtypes

Reviewers:

Subscribers:

Tasks:

Tags:
@pytorch-bot

pytorch-bot Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (3 Unrelated Failures)

As of commit 8c0261a with merge base b60a589 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Attention! PyTorch one of the C-stable API file was changed

You MUST NOT change existing function declarations in this, as this header defines a stable C ABI. If you need to change the signature for a function, introduce a new v2 version of the function and modify code generation to target the new version of the function.


Caused by:

@drisspg

drisspg commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

can you write a test

@pranavsharma

Copy link
Copy Markdown
Contributor Author

can you write a test

Tests for these dtypes already exist. The AOTI ABI check suite at test/cpp/aoti_abi_check/test_dtype.cpp already has tests for both Float8_e8m0fnu (lines 90-93) and Float4_e2m1fn_x2 (lines 95-98), and the TestScalarType enum ordering test verifies their ordinal positions.

However, those tests cover the header-only types, not the C shim functions directly. The C shim functions (aoti_torch_dtype_*()) are tested implicitly through the AOTI inference pipeline tests in test/cpp/aoti_inference/.

There isn't a standalone test that calls aoti_torch_dtype_float8_e8m0fnu() and aoti_torch_dtype_float4_e2m1fn_x2() directly, but that's consistent with how all the other dtype shim functions are tested — none of them have direct unit tests either. The existing test coverage should be sufficient for this change.

Summary: Add `float8_e8m0fnu` and `float4_e2m1fn_x2` dtype accessors to the
  AOTInductor C shim layer, following the existing pattern for float8
  dtypes. This is a purely additive ABI-compatible change.

Test Plan: - Existing AOTI tests pass (no existing symbols modified)
  - New functions follow the same `AOTI_TORCH_DTYPE_IMPL` macro pattern
    as the other float8 dtypes

Reviewers:

Subscribers:

Tasks:

Tags:
@drisspg

drisspg commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

I dont know if I buy claude .. why didnt existing testing catch this if they were sufficient

@pranavsharma

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 6, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@pranavsharma

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
Summary: Add `float8_e8m0fnu` and `float4_e2m1fn_x2` dtype accessors to the
  AOTInductor C shim layer, following the existing pattern for float8
  dtypes. This is a purely additive ABI-compatible change.
Context is adding support for MXFP4 on AMD MI350.

Test Plan: - Existing AOTI tests pass (no existing symbols modified)
  - New functions follow the same `AOTI_TORCH_DTYPE_IMPL` macro pattern as the other float8 dtypes

Reviewers:

Subscribers:

Tasks:

Tags:
Pull Request resolved: pytorch#176496
Approved by: https://github.com/drisspg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants