[MLX] repeat_interleave without `dim` does not flatten the input and fails at runtime
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Start with _repeat_interleave_handler in backends/mlx/ops.py, where a missing dim is read as 0 instead of the None default that flattens the input first. Read the existing repeat_interleave tests, which always pass dim, and add a case without it using the 2x3 input from the report. Done when the MLX-delegated output matches PyTorch's flattened shape [12] with values [0,0,1,1,...,5,5]. The reporter says they already have a fix and plan to open a PR, so check with them before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
torch.repeat_interleave(x, repeats) with no dim repeats the elements of the flattened input and returns a 1-D tensor. The MLX delegate treats a missing dim as dim=0, so for inputs with more than one dimension it repeats along axis 0 without flattening. The program exports and is delegated to MLX, then fails when it runs because the output rank does not match.
For x = torch.arange(6.0).reshape(2, 3) and torch.repeat_interleave(x, 2):
| Result | |
|---|---|
| PyTorch / expected | [0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 5., 5.], shape [12] |
| MLX delegate / actual | runtime error |
Failed to execute method forward, error: 0x1: Attempted to change the tensor rank which is immutable: old=1, new=2; MLX execute failed: write_output: failed to resize output tensor; CALL_DELEGATE execute failed at instruction 0: 0x1
Reproduced on ExecuTorch 8c3f75dfb1d70ad12161ab3c42b06b7e7a65e8ce.
Environment: Apple Silicon MacBook Air, macOS 15.1, Xcode 16.2, Python 3.12, built with install_executorch.py.
With an MLX-enabled ExecuTorch 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):
return torch.repeat_interleave(x, 2)
inputs = (torch.arange(6.0).reshape(2, 3),)
model = Model().eval()
print(model(*inputs)) # tensor([0., 0., 1., 1., 2., 2., 3., 3., 4., 4., 5., 5.])
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
_repeat_interleave_handler in backends/mlx/ops.py uses dim = args[2] if len(args) > 2 else 0, but the default for aten.repeat_interleave.self_int is dim=None, which means flatten first. The existing repeat_interleave tests always pass dim.
Found by reading the op handlers for arguments whose defaults are not honored, after #25332 and #25363. I have a fix with tests and will open a PR.
Investigated and written with assistance from Anthropic Claude.
cc @metascroy
- Ngôn ngữ chính
- Python
- Star
- 5.2k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 678
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytorch/executorch
-
module: exir
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
pytorch/executorch#25620 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_normCó thể đã có người làm @psiddh đã nhận 14 ngày trước. Đang mởbug module: qnn partner: qualcomm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
pytorch/executorch#24434 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement triaged
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 68/100
pytorch/executorch#21640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[MLX] Any empty output fails at runtime with "write_output: arr.data<void>() is null after wait()"Có thể đã có người làm @galiliya đã nhận hôm nay. Đang mởgood first issue module: mlx
pytorch/executorch#25606 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Reminder to update MLX pin to release tagCó thể đã có người làm @mergennachin đã nhận hôm nay. Đang mở
pytorch/executorch#25602 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytorch/executorch
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Maintainer] task area:visualizer
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
RailtownAI/railtracks#1824 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
apache/datafusion#27688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
mloda-ai/mloda-registry#1664 ·
Maintainer thường phản hồi trong vòng 1 ngày