Skip to content

feat: align argsort with PyTorch parameter order#809

Merged
voltjia merged 1 commit into
masterfrom
feat/align-argsort-python-api
Jul 24, 2026
Merged

feat: align argsort with PyTorch parameter order#809
voltjia merged 1 commit into
masterfrom
feat/align-argsort-python-api

Conversation

@voltjia

@voltjia voltjia commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add the PyTorch-compatible argsort(input, dim, descending, stable, out) interface and trailing-default overloads.
  • Keep the previous input, stable, dim, descending, out interface as an explicitly deprecated overload and cover both paths in the existing operator test module.

Motivation

The current public parameter order follows neither the PyTorch Python API nor its positional semantics. This change makes the primary InfiniOps interface match torch.argsort, while preserving a migration path for existing callers.

No standalone issue is associated with this alignment follow-up.

Type of Change

  • feat - new feature / new operator / new platform
  • fix - bug fix
  • perf - performance improvement (no behavioral change)
  • refactor - code restructuring without behavior change
  • test - adding or fixing tests only
  • docs - documentation only
  • build / ci - build system or CI configuration
  • chore - tooling, formatting, or other non-code changes
  • Breaking change

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Host: ssh nvidia
Image: accelerator-dev/nvidia:latest
PyTorch: 2.10.0a0+b4e4ee8

cmake ... -DWITH_CPU=ON -DWITH_NVIDIA=ON -DWITH_TORCH=ON \
  -DINFINI_OPS_OPS=argsort -DINFINI_OPS_TORCH_OPS=argsort
cmake --build build-nvidia --target ops -j 16
Build passed.

python -m pytest tests/test_argsort.py --devices cpu cuda -q
5 passed

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
CPU Yes targeted build passed Targeted public and deprecated overload cases passed
NVIDIA Yes targeted build passed Targeted public and deprecated overload cases passed
Iluvatar No N/A - not affected N/A - not affected
MetaX No N/A - not affected N/A - not affected
Cambricon No N/A - not affected N/A - not affected
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected
Additional validation
python -m pytest tests/test_generate_wrappers.py tests/test_generate_torch_ops.py -q
25 passed

clang-format 21.1.8 --dry-run --Werror: passed
Ruff check and format check: passed

Benchmark / Performance Impact

N/A. This changes API routing only; the underlying ATen implementation is unchanged.

Notes for Reviewers

API alignment

Interface Signature Alignment basis
InfiniOps primary interface argsort(input, dim=-1, descending=False, stable=False, out) PyTorch parameters in Python order; explicit out remains last per CONTRIBUTING.md.
PyTorch public API torch.argsort(input, dim=-1, descending=False, stable=False, *, out=None) Pinned PyTorch source
  • Prefix overloads provide each trailing Python default without adding a separate policy/configuration file.
  • The previous argsort(input, stable, dim, descending, out) constructor and call operator remain available with [[deprecated]] migration diagnostics.

@voltjia
voltjia changed the base branch from master to fix/pin-ruff-version July 24, 2026 07:53
@voltjia
voltjia force-pushed the feat/align-argsort-python-api branch from 5e16a66 to 6e250e4 Compare July 24, 2026 08:02
Base automatically changed from fix/pin-ruff-version to master July 24, 2026 08:13
@voltjia
voltjia force-pushed the feat/align-argsort-python-api branch from 6e250e4 to 1585c2c Compare July 24, 2026 08:27
@voltjia
voltjia marked this pull request as ready for review July 24, 2026 08:38
@voltjia
voltjia requested a review from a team July 24, 2026 08:38
@voltjia voltjia changed the title feat: align argsort with PyTorch parameter order feat: align argsort with PyTorch parameter order Jul 24, 2026
@voltjia
voltjia merged commit 66b86f5 into master Jul 24, 2026
16 of 20 checks passed
@voltjia
voltjia deleted the feat/align-argsort-python-api branch July 24, 2026 08:39
@voltjia voltjia mentioned this pull request Jul 24, 2026
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant