[MLX] repeat_interleave without `dim` does not flatten the input and fails at runtime
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 1.3k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 678
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/executorch のほかの issue
-
module: exir
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
pytorch/executorch#25620 ·
メンテナーはふだん 1 日以内に返信
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_norm対応中かも @psiddh が 14 日前に担当しました。 オープン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 日以内に返信
-
[MLX] Any empty output fails at runtime with "write_output: arr.data<void>() is null after wait()"対応中かも @galiliya が今日担当しました。 オープンgood first issue module: mlx
pytorch/executorch#25606 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Reminder to update MLX pin to release tag対応中かも @mergennachin が今日担当しました。 オープン
pytorch/executorch#25602 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
pytorch/executorch の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Maintainer] task area:visualizer
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
RailtownAI/railtracks#1824 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
apache/datafusion#27688 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
heasarc/heasarc-tutorials#317 ·
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
mloda-ai/mloda-registry#1664 ·
メンテナーはふだん 1 日以内に返信