Skip to content

Add MLX op handler for aten.trunc#18985

Closed
Jah-yee wants to merge 1 commit intopytorch:mainfrom
Jah-yee:roomwithoutroof/add-mlx-trunc
Closed

Add MLX op handler for aten.trunc#18985
Jah-yee wants to merge 1 commit intopytorch:mainfrom
Jah-yee:roomwithoutroof/add-mlx-trunc

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Good day

This PR adds support for aten.trunc in the MLX delegate backend, addressing issue #18923.

Summary

Add a decomposed handler for aten.trunc that uses existing MLX nodes (floor, ceil, where) to implement truncation toward zero on Metal GPU.

Changes

  • Add _trunc_handler in backends/mlx/ops.py using the decomposition: trunc(x) = where(x >= 0, floor(x), ceil(x))
  • Add test coverage for trunc operation

Testing

python -m executorch.backends.mlx.test.run_all_tests -k trunc

References

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

cc @metascroy

Add a decomposed handler for aten.trunc that uses existing MLX nodes
(floor, ceil, where, greater_equal) to implement truncation toward zero
on Metal GPU.

Fixes: pytorch#18923
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 18, 2026

🔗 Helpful Links

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

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

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 Apr 18, 2026
@github-actions
Copy link
Copy Markdown

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.

@Jah-yee
Copy link
Copy Markdown
Author

Jah-yee commented Apr 18, 2026

Closing as duplicate - trunc handler already covered in PR #18982.

@Jah-yee Jah-yee closed this Apr 18, 2026
@nil-is-all nil-is-all added the module: mlx Issues related to MLX Backend: Metal-accelerated inference on Apple Silicon label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: mlx Issues related to MLX Backend: Metal-accelerated inference on Apple Silicon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Good First Issue: Add MLX Op Handler for aten.trunc

2 participants