Skip to content

Fix empty PyTorch uniform device selection#4528

Merged
FlorianPfaff merged 4 commits into
mainfrom
agent/fix-pytorch-empty-uniform-device-selection
Jul 22, 2026
Merged

Fix empty PyTorch uniform device selection#4528
FlorianPfaff merged 4 commits into
mainfrom
agent/fix-pytorch-empty-uniform-device-selection

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

What changed

  • prefer an existing non-CPU tensor device when constructing the empty-result fallback for PyTorch uniform
  • retain the first tensor device when all bounds are on CPU
  • add a regression covering CPU low and meta-device high bounds

Root cause

The empty descending-interval compatibility path selected low.device whenever low was a tensor. With a CPU low tensor and a non-CPU high tensor, it therefore attempted to coerce the non-CPU endpoint onto CPU. This was inconsistent with the backend's binary-device selection contract and could fail for non-materializable devices such as meta.

Impact

Zero-sized PyTorch uniform draws now preserve an existing accelerator or meta device regardless of endpoint order.

Validation

  • branch is 2 commits ahead of main and 0 behind
  • diff is limited to the empty-uniform compatibility helper and focused regression coverage
  • full local tests were unavailable because this environment has no GitHub network checkout or gh binary; GitHub Actions should validate the branch

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 20.2s
✅ JSON prettier 7 0 0 0 1.47s
✅ JSON v8r 7 0 0 3.85s
✅ MARKDOWN markdownlint 68 0 0 0 2.02s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.84s
✅ PYTHON black 1585 220 0 0 88.38s
✅ PYTHON isort 1585 400 0 0 2.64s
✅ REPOSITORY betterleaks yes no no 2.13s
✅ REPOSITORY checkov yes no no 50.9s
✅ REPOSITORY gitleaks yes no no 14.33s
✅ REPOSITORY git_diff yes no no 0.36s
✅ REPOSITORY secretlint yes no no 61.58s
✅ REPOSITORY syft yes no no 5.79s
✅ REPOSITORY trivy-sbom yes no no 6.67s
✅ REPOSITORY trufflehog yes no no 29.81s
✅ YAML prettier 11 0 0 0 0.71s
✅ YAML v8r 11 0 0 11.82s
✅ YAML yamllint 11 0 0 0.52s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review July 20, 2026 21:18
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) July 20, 2026 21:18
auto-merge was automatically disabled July 21, 2026 20:05

Pull request was closed

@FlorianPfaff
FlorianPfaff force-pushed the agent/fix-pytorch-empty-uniform-device-selection branch from 966c5c7 to 4a03325 Compare July 21, 2026 20:05
@FlorianPfaff FlorianPfaff reopened this Jul 21, 2026
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) July 21, 2026 20:07
@FlorianPfaff
FlorianPfaff merged commit 52a6283 into main Jul 22, 2026
25 checks passed
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