Skip to content

fix(tests): generate integer inputs portably#607

Merged
voltjia merged 1 commit into
masterfrom
fix/portable-integer-test-inputs
May 15, 2026
Merged

fix(tests): generate integer inputs portably#607
voltjia merged 1 commit into
masterfrom
fix/portable-integer-test-inputs

Conversation

@voltjia
Copy link
Copy Markdown
Collaborator

@voltjia voltjia commented May 14, 2026

Summary

  • Make randint_strided fall back to torch.randint(...).copy_() when device-specific random_ is unavailable.
  • Preserve the existing fast path for devices that support random_ directly.

Motivation

Some PyTorch accelerator forks do not implement random_ for every integer dtype. The test utility should still be able to generate integer inputs portably across supported platforms.

Closes # N/A

Type of Change

  • N/A feat — new feature / new operator / new platform
  • fix — bug fix
  • N/A perf — performance improvement
  • N/A refactor — code restructuring without behavior change
  • N/A test — adding or fixing tests only
  • N/A docs — documentation only
  • N/A build / ci — build system or CI configuration
  • N/A chore — tooling, formatting, or other non-code changes
  • N/A 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)
  • N/A PyTorch C++ bindings (WITH_TORCH)
  • N/A Build system / CMake / CI
  • N/A Python bindings / user-facing API

Test Results on Supported Platforms

Direct profile, PYTEST_WORKERS=1.

Platform Built pytest Result Notes / Hardware
NVIDIA Yes 4151 passed, 1375 skipped in 294.91s Full pytest tests/. Matches #604/#605/#608 pass/skip counts.
Iluvatar Yes 3651 passed, 375 skipped in 261.93s Full pytest tests/. Matches #604/#605/#608 pass/skip counts.
MetaX Yes 5795 passed, 1447 skipped in 361.78s Full pytest tests/. Matches #604/#605/#608 pass/skip counts.
Cambricon Yes 3073 passed, 3857 skipped in 892.41s Full pytest tests/. Fixes the previous 12 tests/test_add.py integer-input failures seen in #604/#605/#608.
Moore Yes 300 failed, 5459 passed, 1483 skipped in 541.04s Full pytest tests/. Same known pre-existing tests/test_gemm.py MUSA failures as #604/#605/#608.
Ascend Yes 3828 passed, 138 skipped in 455.21s; container exit code 137 after pytest Full pytest tests/. No pytest failures in this run; same post-test exit-code behavior as #605/#608 and no regression versus #604.

Compared with the last merged baseline PRs #604, #608, and #605, this PR has no regression in build status or collected coverage. Cambricon improves by removing the 12 known integer-input failures from tests/test_add.py; the remaining known Moore failure class is unchanged.

Full validation summaries
ruff:
1 file already formatted
All checks passed!

nvidia build=0 test=0
4151 passed, 1375 skipped in 294.91s

iluvatar build=0 test=0
3651 passed, 375 skipped in 261.93s

metax build=0 test=0
5795 passed, 1447 skipped in 361.78s

cambricon build=0 test=0
3073 passed, 3857 skipped in 892.41s

moore build=0 test=1
300 failed, 5459 passed, 1483 skipped in 541.04s

ascend build=0 test=137
3828 passed, 138 skipped in 455.21s

Benchmark / Performance Impact

N/A. The fallback only runs when the direct device random_ path is unavailable.

Notes for Reviewers

The fallback copies values generated as int64 into the requested dtype/device, which keeps the helper usable on accelerator forks with incomplete integer RNG coverage.


Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits.
  • Branch name follows <type>/xxx-yyyy-zzzz.
  • Each commit message follows Conventional Commits.
  • Small PR is a single squashable commit.
  • No stray merge commits from master.
  • No fixup! / squash! / wip commits remain.

Scope and Design

  • Changes are minimal.
  • No dead code, debug prints, or unrelated TODOs were added.
  • No unrelated formatting churn.
  • N/A Public API changes.

General Code Hygiene

  • Code is self-explanatory.
  • Modified file ends with a newline.
  • No trailing whitespace, tab/space mixing, or stray BOMs.
  • N/A Comments/error messages with identifiers.
  • N/A New comments.
  • N/A New error messages.

C++ Specific

N/A. No C++ files changed.

Python Specific

  • Code follows the surrounding Python style.
  • ruff check tests/utils.py passed.
  • ruff format --check tests/utils.py passed.
  • N/A New comments.
  • Framework-specific exception handling conventions are preserved.
  • No blank line rule violations were introduced.
  • Return spacing follows surrounding style.
  • N/A Docstrings.
  • N/A Type hints.

Testing

  • Full platform testing was run across NVIDIA, Iluvatar, MetaX, Cambricon, Moore, and Ascend.
  • N/A No new tests were added.
  • N/A No test parameterization changes.
  • N/A No new flaky tests.
  • Regression coverage: Cambricon integer-input failures in tests/test_add.py are covered by full-platform validation and now pass.

Build, CI, and Tooling

  • Fresh package build passed on all supported platforms.
  • N/A compile_commands.json.
  • N/A Backend auto-detection.
  • N/A CUDA-like mutual exclusion.
  • N/A CI workflows are expected to validate formatting.
  • N/A Runtime dependencies.

Documentation

  • N/A User-facing documentation changes.
  • N/A New public utilities.
  • N/A Breaking changes.

Security and Safety

  • No secrets or personal data are committed.
  • N/A Third-party code.
  • N/A Unsafe pointer arithmetic.

@voltjia voltjia force-pushed the fix/portable-integer-test-inputs branch from 267851a to 48e2d50 Compare May 15, 2026 03:25
@voltjia voltjia marked this pull request as ready for review May 15, 2026 04:06
@voltjia voltjia requested a review from a team May 15, 2026 04:06
@voltjia voltjia force-pushed the fix/portable-integer-test-inputs branch from 48e2d50 to 9cec903 Compare May 15, 2026 05:41
@voltjia voltjia requested review from Ziminli and bitzyz May 15, 2026 07:09
@voltjia
Copy link
Copy Markdown
Collaborator Author

voltjia commented May 15, 2026

@bitzyz 初审,@Ziminli 终审。

@voltjia voltjia merged commit 3ba68c4 into master May 15, 2026
4 checks passed
@voltjia voltjia deleted the fix/portable-integer-test-inputs branch May 15, 2026 07:45
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.

3 participants