Skip to content

Add MLX integer support for aten.bitwise_and#18979

Open
yadferhad wants to merge 6 commits intopytorch:mainfrom
yadferhad:add-full-integer-support-for-aten-bitwise-and
Open

Add MLX integer support for aten.bitwise_and#18979
yadferhad wants to merge 6 commits intopytorch:mainfrom
yadferhad:add-full-integer-support-for-aten-bitwise-and

Conversation

@yadferhad
Copy link
Copy Markdown

@yadferhad yadferhad commented Apr 17, 2026

Summary

Fixes #18925

aten.bitwise_and currently goes through the bool-only LogicalAndNode path in the MLX delegate, which means integer tensors do not lower correctly. This switches aten.bitwise_and to a dedicated BitwiseAndNode while keeping aten.logical_and on the existing logical path.

This change:

  • adds BitwiseAndNode to the MLX schema
  • adds exec_bitwise_and() to the MLX interpreter runtime
  • registers aten.bitwise_and.Tensor and aten.bitwise_and.Scalar as table-driven MLX binary ops
  • keeps aten.logical_and on the existing bool-only logical path
  • adds MLX op tests for bool, integer, and scalar bitwise_and

Test plan

  • python3 -m py_compile backends/mlx/ops.py backends/mlx/test/test_ops.py
  • python3 backends/mlx/serialization/generate.py
  • PYTHONPATH=src python3 -m executorch.backends.mlx.test.run_all_tests --list | rg 'bitwise_and'
    • in a local dev env, this registers:
      • bitwise_and_bool
      • bitwise_and_int
      • bitwise_and_scalar

cc @metascroy

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 17, 2026

🔗 Helpful Links

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

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

⚠️ 12 Awaiting Approval

As of commit 434fd1c with merge base 851cffb (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 17, 2026

Hi @yadferhad!

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!

@yadferhad
Copy link
Copy Markdown
Author

@pytorchbot label "release notes: apple"

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 17, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@pytorch-bot pytorch-bot Bot added the release notes: apple Changes to the Apple backend delegate label Apr 17, 2026
@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 17, 2026
Comment thread backends/mlx/ops.py Outdated
@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
@metascroy
Copy link
Copy Markdown
Contributor

Hi @yadferhad! Thanks for the PR!

Overall it looks great, just two follow-up requests:

  1. There are some merge conflicts. Can you resolve them?
  2. Can you paste a screenshot of passing tests for bitwise_and in the PR summary?

Also note that we currently have a PR merge freeze until our CI is healthy again, but hopefully we can get this merged next week

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 6, 2026

The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:

  • ciflow/mlx

Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/mlx 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 release notes: apple Changes to the Apple backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Good First Issue: Add Full Integer Support for aten.bitwise_and

3 participants