Skip to content

fix(strategy): validate n before Backend construction in runner#268

Merged
zeokin merged 1 commit into
zeokin:mainfrom
RealDiligent:fix/strategy-runner-validate-n
Jul 16, 2026
Merged

fix(strategy): validate n before Backend construction in runner#268
zeokin merged 1 commit into
zeokin:mainfrom
RealDiligent:fix/strategy-runner-validate-n

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

  • strategy.runner.run / compare constructed Backend before validating n, unlike matmul.runner which already rejects non-Integral / non-positive n early.
  • Add a shared _require_positive_n guard (reject bool, non-Integral, < 1) before device setup in both entry points.
  • Extend tests/test_public_api_boundaries.py with a _NoBackend stub so invalid n is proven to fail before backend construction.

Test plan

  • uv run --extra test python -m pytest tests/test_public_api_boundaries.py -v
  • uv run python -m strategy.smoke

@github-actions github-actions Bot added area:strategy Smart strategies / transforms (strategy/) area:tests Correctness gates and test suites (tests/) status:needs-review Awaiting maintainer review type:bug Something is incorrect or broken labels Jul 16, 2026
Mirror matmul.runner's Integral/positive-n guard in strategy.runner.run
and compare so invalid n fails with a clear ValueError before device
setup, instead of reaching Backend or allocate.
@github-actions github-actions Bot added the status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only label Jul 16, 2026
@zeokin
zeokin merged commit fda8b82 into zeokin:main Jul 16, 2026
6 checks passed
zeokin added a commit that referenced this pull request Jul 16, 2026
zeokin added a commit that referenced this pull request Jul 16, 2026
Re-applies the changes from #235, #253, #255, #266, #267, and #268, which
were reverted in error on 2026-07-16. #232 was already restored in 4c44b45.

CPU-safe suite green (411 passed, 24 skipped).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:strategy Smart strategies / transforms (strategy/) area:tests Correctness gates and test suites (tests/) status:needs-review Awaiting maintainer review status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only type:bug Something is incorrect or broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants