[MLX] Any empty output fails at runtime with "write_output: arr.data<void>() is null after wait()"
Maintainer antworten meist innerhalb von 1 Tag
@galiliya arbeitet bereits daran.
Seit 23.11.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
An MLX-delegated program fails at runtime whenever one of its outputs has zero elements. PyTorch eager returns the empty tensor, and export puts the whole graph on MLX, so the failure only shows up when the program runs:
RuntimeError: Failed to execute method forward, error: 0x1: MLX execute failed: write_output: arr.data<void>() is null after wait(); CALL_DELEGATE execute failed at instruction 0: 0x1
It isn't tied to one op. All of these fail, while x + 1 on a non-empty input runs fine:
| Model | Input shape | Expected output shapes |
|---|---|---|
torch.topk(x, 0) |
(3, 5) |
(3, 0), (3, 0) |
x[:, 2:2] * 2 |
(3, 5) |
(3, 0) |
x + 1 |
(0, 5) |
(0, 5) |
(x + 1, x[:, 2:2] * 2) |
(3, 5) |
(3, 5), (3, 0) |
write_output resizes the output and checks that the byte counts match (both are 0). It then throws because arr.data<void>() is null, which is what MLX gives for an empty array. Since there's nothing to copy, returning early before the null check fixes all four cases in my local build:
if (out_nbytes == 0) {
return;
}
FACTO found this while I was reviewing #25358. All 11 of its generated topk.default cases with k=0 fail this way, across int8, uint8, int64, float16, bfloat16 and float32 and for both values of largest. The MLX op tests have no empty-output configs, so CI doesn't catch it. #25331 is a separate empty-tensor bug (an empty mm crashes inside MLX) that this change doesn't address.
Repro, with an MLX-enabled Python runtime:
import torch
from executorch.backends.mlx.partitioner import MLXPartitioner
from executorch.exir import to_edge_transform_and_lower
from executorch.extension.pybindings.portable_lib import (
_load_for_executorch_from_buffer,
)
class Model(torch.nn.Module):
def forward(self, x):
values, indices = torch.topk(x, 0)
return values, indices
inputs = (torch.randn(3, 5),)
print(Model()(*inputs)) # two empty (3, 0) tensors
ep = torch.export.export(Model(), inputs)
edge = to_edge_transform_and_lower(ep, partitioner=[MLXPartitioner()])
runtime = _load_for_executorch_from_buffer(edge.to_executorch().buffer)
print(runtime.forward(inputs)) # RuntimeError
Environment: reproduced at #25358's head cbfc7ed1a6 with MLX pin 14dc9c67 (write_output is unchanged on main at 729de6f2c9), Release build, Apple M2 Ultra, macOS 27.2, Python 3.13, PyTorch 2.14.0.
Verified with help from Claude Code.
cc @metascroy
- Vorherrschende Sprache
- Python
- Sterne
- 5.2k
- Forks
- 1.3k
- Ø Merge
- 1 T. 14 Std.
- Gemergte PRs (30 T.)
- 678
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pytorch/executorch
-
module: exir
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
pytorch/executorch#25620 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_normEvtl. vergeben @psiddh hat das vor 14 Tagen übernommen. Offenbug module: qnn partner: qualcomm
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
pytorch/executorch#24434 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement triaged
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 68/100
pytorch/executorch#21640 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Reminder to update MLX pin to release tagEvtl. vergeben @mergennachin hat das heute übernommen. Offen
pytorch/executorch#25602 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
[MLX] repeat_interleave without `dim` does not flatten the input and fails at runtimeEvtl. vergeben @vineetha00 hat das vor 1 Tag übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 55/100
pytorch/executorch#25523 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in pytorch/executorch
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
OpenFreeEnergy/openfe#2371 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
NCATSTranslator/Babel#1269 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 80/100
Maintainer antworten meist innerhalb von 1 Tag
-
404 on sample dataOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100