Skip to content

ps_sweep: a sample has n shaders when the proportional shares round down - #5881

Open
Jadiac5 wants to merge 1 commit into
ItsNotRexed:mainfrom
Jadiac5:fix/ps-sweep-sample-size
Open

Jadiac5 wants to merge 1 commit into
ItsNotRexed:mainfrom
Jadiac5:fix/ps-sweep-sample-size

Conversation

@Jadiac5

@Jadiac5 Jadiac5 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #5781 (#5781 (comment)); no item ID, a new finding.

What changed and why

pick_sample gives each stratum round(n * size / total) shaders and only corrects a sum above n. When the shares round down (two strata of 50 with n=25 make 12 + 12) or a stratum is taken whole, the sample came out below the n that the docstring and docs/shader_validation.md promise. The shaders still missing now go, one at a time, to the strata furthest below their proportional share.

The documented 480-shader sample (seed 20261122) is unchanged, because there the sum already equals n: on my own work folder the old and new functions return identical lists for n = 480, 200 and 1000.

Tests (Windows 11, Python 3.12, CPU only, no game files)

  • python -I tests/test_ps_sweep.py: 13 OK. The new test_rounding_down_still_gives_n fails on main (24 != 25).
  • python -m compileall -q make_game.py tools tests: clean.

Not done

AI-assisted (Claude Code).

@Kev-Ball

Copy link
Copy Markdown

The rounding case occurs on a retail index. With 12,101 translated pixel shaders from my Xbox 1.0.2.1 copy (15 strata), ps_sweep.py sample --n 10600 --seed 20261122 wrote 10,597 entries on the parent and 10,600 at a5a1ff5f. All 10,600 selections were distinct. At the documented --n 480, the two CLI-generated sample.json files were byte-identical.

Across the feasible request range (146–12,101 for this index), the initial proportional allocation fell short at 355 sizes: by one at 318 sizes, by two at 36, and by three only at 10,600. I exercised the sampler for each shortfall magnitude, the stratum floor, and the population cap. It hit the expected count and preserved each stratum’s minimum in those cases. CPU-only on CachyOS, AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested a5a1ff5 merged with main 561b65a on Linux (WSL2) / Python 3.12.16 (-I): pass

tests/test_ps_sweep.py: 13 run, 13 passed, 0 failed. Negative control: with tools/ps_sweep.py restored from upstream/main the new test_rounding_down_still_gives_n fails (24 != 25), 12 other tests pass; restored the fix and it passes again. Diff read: the top-up loop is bounded by min(n, total) and only picks strata with room, so it terminates.

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