[MLX] sort/argsort(descending=True) silently returns ascending order
Los mantenedores suelen responder en 1 día
@2648782102 ya está trabajando en esto.
Desde el 20/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend, machine-learning
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 5.2k
- Forks
- 1.3k
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 644
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytorch/executorch
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decompositionPosiblemente ocupada @Eureka-Zhang la tomó hace 7 días. Abiertomodule: exir
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
pytorch/executorch#25620 ·
Los mantenedores suelen responder en 1 día
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_normPosiblemente ocupada @psiddh la tomó hace 21 días. Abiertobug module: qnn partner: qualcomm
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
pytorch/executorch#24434 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
enhancement triaged
Dificultad 2/5 Medio día Aptitud para principiantes 68/100
pytorch/executorch#21640 ·
Los mantenedores suelen responder en 1 día
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scalePosiblemente ocupada @AxelNoun la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
pytorch/executorch#25873 ·
Los mantenedores suelen responder en 1 día
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 MaxPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug module: quantization module: xnnpack
Dificultad 4/5 3-5 días Aptitud para principiantes 43/100
pytorch/executorch#25854 ·
Los mantenedores suelen responder en 1 día
Todos los issues de pytorch/executorch
Issues similares
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
trezor/trezor-user-env#421 ·
-
Support new version of pythonAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 91/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
tangentcode/tangentswarm#167 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día