From f768be6744559797fb3c4b23e299ab593bc6ac96 Mon Sep 17 00:00:00 2001 From: Mateusz Sluszniak <56299341+msluszniak@users.noreply.github.com> Date: Tue, 28 Jul 2026 22:09:49 +0200 Subject: [PATCH] fix(mlx): forward boundary-partitioned getitem instead of indexing a 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. --- backends/mlx/ops.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backends/mlx/ops.py b/backends/mlx/ops.py index 002cda892f3..4053688b121 100644 --- a/backends/mlx/ops.py +++ b/backends/mlx/ops.py @@ -2272,9 +2272,13 @@ def _getitem_handler(P: MLXProgramBuilder, n: Node) -> Slot: require_kwargs(P.kwargs(n), set(), "operator.getitem") a, idx = args out = P.make_or_get_slot(n) + # When the multi-output parent is left outside the partition, the partitioner + # feeds this getitem the already-selected element as a single boundary-input + # Slot (not the source tuple). In that case forward it directly. + src = a[idx] if isinstance(a, (tuple, list)) else a P.emit( IdCopyNode( - x=P.slot_to_tid(a[idx]), + x=P.slot_to_tid(src), out=P.slot_to_tid(out), ) )