[MLX] sort/argsort(descending=True) silently returns ascending order
メンテナーはふだん 1 日以内に返信
@2648782102 がすでに取り組んでいます。
2026年11月20日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Start with _sort_handler and _argsort_handler in backends/mlx/ops.py, then check the MLX SortTest and ArgsortTest cases. Run the reported op test harness with descending=True and compare values and indices with PyTorch. Done means descending results are correct, or those calls remain undelegated, with tests covering both operations.
索引モデルが issue の本文から書いたものです。
説明
The MLX delegate accepts torch.sort(..., descending=True) and torch.argsort(..., descending=True) but ignores descending. Both ops are fully delegated and return ascending results.
For x = [4, -2, 7, 1]:
sort values |
sort indices |
argsort |
|
|---|---|---|---|
| PyTorch / expected | [7, 4, 1, -2] |
[2, 0, 3, 1] |
[2, 0, 3, 1] |
| MLX delegate / actual | [-2, 1, 4, 7] |
[1, 3, 0, 2] |
[1, 3, 0, 2] |
_sort_handler and _argsort_handler both accept up to three args but only read x and dim. SortTest and ArgsortTest have no descending=True configs, so CI doesn't catch it. This is the same kind of bug as #25332 (topk ignoring largest). Either descending needs to affect the lowering, or descending=True should stay undelegated.
Repro with the MLX op test harness. It needs op_test_runner: cmake --preset mlx-release -DEXECUTORCH_BUILD_TESTS=ON && cmake --build cmake-out --target op_test_runner.
import torch
from executorch.backends.mlx.test.test_utils import OpTestCase
class Sort(torch.nn.Module):
def forward(self, x):
values, indices = torch.sort(x, descending=True)
return values, indices
class Argsort(torch.nn.Module):
def forward(self, x):
return torch.argsort(x, descending=True)
class Case(OpTestCase):
def __init__(self, name, model):
self.name, self.model = name, model
def create_model(self):
return self.model
def create_inputs(self):
return (torch.tensor([4.0, -2.0, 7.0, 1.0]),)
for name, model in [("sort_descending", Sort()), ("argsort_descending", Argsort())]:
print(name, "PASS" if Case(name, model).run_test() else "FAIL")
Both cases print MLX delegation verified and then fail the output comparison.
Environment: main at ba0d826cc8, MLX pin 1f8e74e3, Release build, Apple M2 Ultra, macOS 27.2, Python 3.13, PyTorch 2.14.0.
Found while reviewing #25358, and verified with help from Claude Code.
cc @metascroy
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 1.3k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 644
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug module: quantization module: xnnpack
難易度 4/5 3〜5日 初心者へのやさしさ 43/100
pytorch/executorch#25854 ·
メンテナーはふだん 1 日以内に返信
pytorch/executorch の issue をすべて見る
似ている issue
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelオープン
難易度 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 日以内に返信