fix(tests): generate integer inputs portably#607
Merged
Conversation
30 tasks
267851a to
48e2d50
Compare
48e2d50 to
9cec903
Compare
Collaborator
Author
bitzyz
approved these changes
May 15, 2026
Ziminli
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
randint_stridedfall back totorch.randint(...).copy_()when device-specificrandom_is unavailable.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
feat— new feature / new operator / new platformfix— bug fixperf— performance improvementrefactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changesPlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Test Results on Supported Platforms
Direct profile,
PYTEST_WORKERS=1.pytestResult4151 passed, 1375 skipped in 294.91spytest tests/. Matches #604/#605/#608 pass/skip counts.3651 passed, 375 skipped in 261.93spytest tests/. Matches #604/#605/#608 pass/skip counts.5795 passed, 1447 skipped in 361.78spytest tests/. Matches #604/#605/#608 pass/skip counts.3073 passed, 3857 skipped in 892.41spytest tests/. Fixes the previous 12tests/test_add.pyinteger-input failures seen in #604/#605/#608.300 failed, 5459 passed, 1483 skipped in 541.04spytest tests/. Same known pre-existingtests/test_gemm.pyMUSA failures as #604/#605/#608.3828 passed, 138 skipped in 455.21s; container exit code 137 after pytestpytest 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
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
int64into the requested dtype/device, which keeps the helper usable on accelerator forks with incomplete integer RNG coverage.Checklist
Title, Branch, and Commits
<type>/xxx-yyyy-zzzz.master.fixup!/squash!/wipcommits remain.Scope and Design
General Code Hygiene
C++ Specific
N/A. No C++ files changed.
Python Specific
ruff check tests/utils.pypassed.ruff format --check tests/utils.pypassed.Testing
tests/test_add.pyare covered by full-platform validation and now pass.Build, CI, and Tooling
compile_commands.json.Documentation
Security and Safety