[MLX] sort/argsort(descending=True) silently returns ascending order
Maintainer thường phản hồi trong vòng 1 ngày
@2648782102 đang làm issue này rồi.
Từ ngày 20/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend, machine-learning
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 5.2k
- Fork
- 1.3k
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 644
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
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decompositionCó thể đã có người làm @Eureka-Zhang đã nhận 7 ngày trước. Đang mở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 21 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
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scaleCó thể đã có người làm @AxelNoun đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
pytorch/executorch#25873 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 MaxCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug module: quantization module: xnnpack
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
pytorch/executorch#25854 ·
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ự
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
trezor/trezor-user-env#421 ·
-
Support new version of pythonĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
tangentcode/tangentswarm#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày