[MLX] Empty matrix multiplication crashes the process in Contiguous::eval_gpu
维护者通常 1 天内回复
@jay23606 已经在做这个了。
开始于 2026年11月20日。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
Start by tracing the MLX backend execution path to Contiguous::eval_gpu, using the standalone op_test_runner reproduction with the empty (0, 5) and (5, 10) inputs. Compare MLX delegated execution with the portable kernel control; done means the runtime returns an empty (0, 10) tensor or safely rejects the unsupported shape instead of crashing.
由索引模型根据 Issue 内容生成。
描述
An MLX-delegated torch.mm with valid inputs of shapes (0, 5) and (5, 10) terminates the process with SIGSEGV. PyTorch eager and the ExecuTorch portable kernel both return the expected empty (0, 10) tensor. Export succeeds and assigns the operation to MLX, so the failure reaches applications at runtime.
Reproduced on ExecuTorch 3e8e3f8a0ea22bac35cd67757add7a82c82bd287 with its original MLX pin 1f8e74e3f12f31365464a6867c6579f0e9b29d85 (v0.32.2), and independently with the proposed MLX pin 14dc9c673bce9a51dca4e58f5b2ccae80736431d. This predates the pin update being investigated for #25319.
Environment: Apple M5 Max, macOS 27.2, Release build, Python 3.12, PyTorch 2.15.0. Both the MLX-enabled Python runtime and the standalone C++ op_test_runner crash. Disabling TF32 does not prevent it.
With an MLX-enabled ExecuTorch Python runtime, this is sufficient to reproduce:
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 (
_get_registered_backend_names,
_load_for_executorch_from_buffer,
)
assert "MLXBackend" in _get_registered_backend_names()
class Model(torch.nn.Module):
def forward(self, a, b):
return torch.mm(a, b)
inputs = (torch.empty(0, 5), torch.ones(5, 10))
model = Model().eval()
print(model(*inputs)) # tensor([], size=(0, 10))
ep = torch.export.export(model, inputs)
edge = to_edge_transform_and_lower(ep, partitioner=[MLXPartitioner()])
assert sum(
n.target == torch.ops.higher_order.executorch_call_delegate
for n in edge.exported_program().graph.nodes
) == 1
program = edge.to_executorch()
runtime = _load_for_executorch_from_buffer(program.buffer)
print(runtime.forward(inputs)) # SIGSEGV
As a control, replacing the lowering with to_edge(ep) executes successfully through the portable kernel.
The standalone runner stops at a null dereference in Contiguous::eval_gpu:
stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
mlx::core::Contiguous::eval_gpu(...) + 40
mlx::core::gpu::eval(...)
mlx::core::eval_impl(...)
mlx::core::async_eval(...)
executorch::backends::mlx::MLXBackend::execute(...)
executorch::runtime::Method::execute_instruction()
Expected: return the empty output. Unsupported empty shapes should at least be rejected safely before native execution. A normal model input should not terminate a hosting process.
Found during OpInfo validation; reproduced independently of that harness. Investigated and written with assistance from OpenAI Codex.
cc @metascroy
- 主要语言
- Python
- 星标
- 5.2k
- 派生
- 1.3k
- 平均合并
- 1 天 7 小时
- 30 天内合并 PR
- 644
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/executorch 的其他 Issue
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decomposition可能已有人在做 @Eureka-Zhang 于 7 天前认领。 未关闭module: exir
难度 2/5 1-3 小时 新手友好度 66/100
pytorch/executorch#25620 ·
维护者通常 1 天内回复
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_norm可能已有人在做 @psiddh 于 21 天前认领。 未关闭bug module: qnn partner: qualcomm
难度 2/5 1-3 小时 新手友好度 74/100
pytorch/executorch#24434 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement triaged
难度 2/5 半天 新手友好度 68/100
pytorch/executorch#21640 ·
维护者通常 1 天内回复
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scale可能已有人在做 @AxelNoun 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
pytorch/executorch#25873 ·
维护者通常 1 天内回复
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 Max可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug module: quantization module: xnnpack
难度 4/5 3-5 天 新手友好度 43/100
pytorch/executorch#25854 ·
维护者通常 1 天内回复
查看 pytorch/executorch 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
trezor/trezor-user-env#421 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 1/5 1-3 小时 新手友好度 91/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
tangentcode/tangentswarm#167 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复