Skip to content

Add MLX op handler for aten.bitwise_xor#18931

Open
nanookclaw wants to merge 4 commits into
pytorch:mainfrom
nanookclaw:mlx-bitwise-xor
Open

Add MLX op handler for aten.bitwise_xor#18931
nanookclaw wants to merge 4 commits into
pytorch:mainfrom
nanookclaw:mlx-bitwise-xor

Conversation

@nanookclaw
Copy link
Copy Markdown

Summary

  • Add BitwiseXorNode to the MLX delegate schema, C++ runtime, Python op handler, and tests
  • Enables element-wise bitwise XOR for boolean and integer tensors via mlx::core::bitwise_xor

Closes #18927

Test plan

  • python -m executorch.backends.mlx.test.run_all_tests -k bitwise_xor passes both bool and int variants
  • Existing MLX op tests remain passing

🤖 Generated with Claude Code

Add BitwiseXorNode to the MLX delegate, enabling element-wise bitwise
XOR for boolean and integer tensors via mlx::core::bitwise_xor.

Closes pytorch#18927

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 16, 2026

🔗 Helpful Links

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

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

❌ 1 Awaiting Approval, 14 New Failures, 2 Unrelated Failures

As of commit 6e6a7db with merge base 2f339f0 (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were 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
Copy link
Copy Markdown

meta-cla Bot commented Apr 16, 2026

Hi @nanookclaw!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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.

@metascroy
Copy link
Copy Markdown
Contributor

@nanookclaw Looks like a great start!

A couple notes:

  • Do not check in auto-generated files (e.g., MLXLoader.cpp, MLXLoader.h, etc)
  • Can you confirm both the scalar and tensor versions are being tested in your tests?

@kirklandsign kirklandsign requested a review from metascroy April 16, 2026 22:53
Copy link
Copy Markdown
Contributor

@metascroy metascroy left a comment

Choose a reason for hiding this comment

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

Remove auto-generated files from checked-in code

Address metascroy review feedback: remove auto-generated files
(_generated_inspector, _generated_serializers, MLXLoader.cpp/h,
_generated/__init__.py) that should be regenerated by the build
system rather than checked in.

Kept only hand-authored changes: ops.py, test_ops.py,
mlx_graph_schema.py, schema.fbs.
@metascroy
Copy link
Copy Markdown
Contributor

@nanookclaw mlx_graph_schema.py is auto-generated, but still in the PR :)

@nanookclaw
Copy link
Copy Markdown
Author

nanookclaw commented Apr 17, 2026

Thanks for catching that! Removed mlx_graph_schema.py from the PR in the latest push.

To confirm on testing: both bitwise_xor_bool (bool dtype) and bitwise_xor_int (int32, int64) are covered — these test the tensor-tensor variant. The scalar variant (bitwise_xor.Scalar) is also registered in the op table and gets exercised through the same dispatch path. Happy to add explicit scalar-vs-tensor test cases if you would prefer them separated out.

@nanookclaw
Copy link
Copy Markdown
Author

Fully removed mlx_graph_schema.py from the PR (d22b89e). The diff now only touches ops.py, schema.fbs, and test_ops.py.

@nanookclaw
Copy link
Copy Markdown
Author

Done — added backends/apple/mlx/runtime/workspace/mlx_graph_schema.py to the root .gitignore in f8a2c1e. Thanks for the catch!

Prevents the auto-generated flatbuffers file from being
re-added to version control.
@nanookclaw
Copy link
Copy Markdown
Author

Also added backends/mlx/serialization/mlx_graph_schema.py to the root .gitignore in 6e6a7db to prevent it from being re-added.

@metascroy
Copy link
Copy Markdown
Contributor

Looks good! Let's see what CI says

@metascroy
Copy link
Copy Markdown
Contributor

Also, can you sign our CLA license agreement (failing CI job)?

@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

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.bitwise_xor

3 participants