Skip to content

fix(mlx): forward boundary-partitioned getitem instead of indexing a Slot - #21441

Merged
metascroy merged 2 commits into
pytorch:mainfrom
msluszniak:@ms/mlx-getitem-boundary-fix
Jul 30, 2026
Merged

fix(mlx): forward boundary-partitioned getitem instead of indexing a Slot#21441
metascroy merged 2 commits into
pytorch:mainfrom
msluszniak:@ms/mlx-getitem-boundary-fix

Conversation

@msluszniak

@msluszniak msluszniak commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

The MLX partitioner can place an operator.getitem inside a partition while leaving its multi-output parent (e.g. aten.native_layer_norm) outside it. In that case _getitem_handler receives the already-selected element as a single boundary-input Slot rather than the source tuple, so a[idx] raises 'Slot' object is not subscriptable and aborts the export.

This fix forwards the Slot directly when the resolved arg isn't a tuple/list — the partitioner has already fed the selected element as the partition input.

Impact

Unblocks transformer / layer-norm-heavy models (e.g. RF-DETR) through the MLX delegate. Localized, one-file change to the op handler; no schema/serialization change.

Test plan

  • Verified that DETR-style exports (dozens of native_layer_norm ops) lower and run correctly on device through the MLX delegate with this change.
  • Non-boundary getitem (source is a tuple/list of slots) is unchanged: a[idx] still selects the element.

cc @metascroy

…Slot

The MLX partitioner can place a getitem in a partition while leaving its
multi-output parent (e.g. aten.native_layer_norm, common in DETR) outside it. In
that case _getitem_handler receives the already-selected element as a single
boundary-input Slot, not the source tuple, so a[idx] raised
"Slot object is not subscriptable" and aborted the export. Forward the Slot
directly when it isn't a tuple/list. Unblocks transformer/layer-norm models
(RF-DETR) through the MLX delegate.
@pytorch-bot

pytorch-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 2dfbd10 with merge base d632341 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@meta-cla

meta-cla Bot commented Jul 28, 2026

Copy link
Copy Markdown

Hi @msluszniak!

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!

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 28, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: msluszniak / name: Mateusz Sluszniak (f768be6)

@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 Jul 28, 2026
@meta-cla

meta-cla Bot commented Jul 28, 2026

Copy link
Copy Markdown

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

@nil-is-all
nil-is-all requested a review from metascroy July 29, 2026 16:03
@nil-is-all nil-is-all added module: mlx Issues related to MLX Backend: Metal-accelerated inference on Apple Silicon ciflow/mlx release notes: mlx Changes to the MLX Backend: Metal-accelerated inference on Apple Silicon labels Jul 29, 2026
@nil-is-all

Copy link
Copy Markdown
Contributor

Thanks for the PR, @msluszniak. Waiting for CI to run; meanwhile could you sort out EasyCLA?

@msluszniak

Copy link
Copy Markdown
Contributor Author

@nil-is-all CLA signed ;)

@metascroy

Copy link
Copy Markdown
Contributor

@claude review this code

@claude

claude Bot commented Jul 29, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@msluszniak msluszniak closed this Jul 30, 2026
@msluszniak
msluszniak deleted the @ms/mlx-getitem-boundary-fix branch July 30, 2026 09:39
@msluszniak
msluszniak restored the @ms/mlx-getitem-boundary-fix branch July 30, 2026 09:40
@msluszniak msluszniak reopened this Jul 30, 2026
@msluszniak

Copy link
Copy Markdown
Contributor Author

Claude review fails because my branch has @ at the beginning, but there is enforcement rule that prohibits this sign. I cannot rename branch for cross-fork PR without closing it completely.

@metascroy

Copy link
Copy Markdown
Contributor

@claude review this code

@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@pytorch-bot

pytorch-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@metascroy
metascroy merged commit 43cb2b2 into pytorch:main Jul 30, 2026
241 of 242 checks passed
@metascroy

Copy link
Copy Markdown
Contributor

Thanks for the fix @msluszniak!

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: mlx Changes to the MLX Backend: Metal-accelerated inference on Apple Silicon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants