Skip to content

Fix PyTorch symmetric Leopardi collar dtype - #5381

Merged
FlorianPfaff merged 1 commit into
mainfrom
fix/pytorch-leopardi-collar-dtype
Aug 21, 2026
Merged

Fix PyTorch symmetric Leopardi collar dtype#5381
FlorianPfaff merged 1 commit into
mainfrom
fix/pytorch-leopardi-collar-dtype

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

Fix the PyTorch regression in symmetric Leopardi small-grid partitioning.

The existing regression

tests/test_leopardi_symmetric_small_grid.py::test_symmetric_four_point_partition_uses_two_collars

fails in the current Python 3.13 PyTorch CI matrix: get_equal_area_caps(2, 4, symmetric=True) returns region counts [3, 1, 1, 1] instead of the intended [1, 1, 1, 1].

Root cause

PR #5202 fixed small symmetric partitions by making the half-collar count an explicitly integer backend array:

array((1, round(ratio_half)), dtype=int32)

The later compatibility wrapper in src/pyrecest/sampling/leopardi_sampler/__init__.py reimplemented that logic but omitted dtype=int32. On PyTorch the tuple mixes the Python integer lower bound with a floating backend result from round(ratio_half), so the construction is promoted away from the discrete collar-count contract.

Fix

Restore the explicit backend int32 dtype in the compatibility wrapper, matching the canonical implementation already present in leopardi_sampler.py and the fix originally merged in #5202.

No partition formulas or public API are changed.

Evidence

  • Reproduced from the existing PyTorch 3.13 test-results artifact of workflow run 32406079884 on a current-main-based branch.
  • The focused regression already exists in the repository, so no duplicate test is added.
  • Branch is based directly on main at b7d3edc9ac05600de5345dc20fd6f3db33154d86.
  • Final diff: one production file, 4 additions / 1 deletion.
  • No open Leopardi PR existed at the time of this fix.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 7.98s
✅ JSON prettier 7 0 0 0 0.64s
✅ JSON v8r 7 0 0 5.13s
✅ MARKDOWN markdownlint 68 0 0 0 2.06s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.44s
✅ PYTHON black 1989 15 0 0 65.87s
✅ PYTHON isort 1989 28 0 0 2.95s
✅ REPOSITORY betterleaks yes no no 1.22s
✅ REPOSITORY checkov yes no no 35.59s
✅ REPOSITORY git_diff yes no no 0.14s
✅ REPOSITORY secretlint yes no no 105.67s
✅ REPOSITORY syft yes no no 2.75s
✅ REPOSITORY trivy-sbom yes no no 3.19s
✅ YAML prettier 11 0 0 0 0.64s
✅ YAML v8r 11 0 0 17.19s
✅ YAML yamllint 11 0 0 1.1s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

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@10.0.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_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

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

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 21, 2026 06:37
@FlorianPfaff
FlorianPfaff merged commit 9e15b07 into main Aug 21, 2026
14 of 24 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