Skip to content

fix(config): reject a non-positive tile instead of silently miscomputing#120

Open
boskodev790 wants to merge 1 commit into
zeokin:mainfrom
boskodev790:fix/config-reject-nonpositive-tile
Open

fix(config): reject a non-positive tile instead of silently miscomputing#120
boskodev790 wants to merge 1 commit into
zeokin:mainfrom
boskodev790:fix/config-reject-nonpositive-tile

Conversation

@boskodev790

Copy link
Copy Markdown

Lane: fix/bug — CPU-safe validation only, no GPU scorecard, does not enter the GPU queue.

Summary

Config.__post_init__ validates dtype, vram_fraction and storage, but not tile. gemm.multiply selects the tile edge with cfg.tile or auto_tile(...), so a non-positive tile passes through with a silently wrong result rather than an error:

  • tile=0 is falsy, so it quietly falls back to auto — the users explicit request is ignored.
  • a negative tile is truthy and flows into _tiles(n, T), whose range(0, n, T) is empty. The tiled (i, j, k) loop then writes no blocks, C is returned untouched (all zeros), and the run still reports a normal GFLOP/s. A wrong answer presented as a successful computation is worse than a crash.
>>> from matmul.config import Config
>>> Config(tile=-5).tile      # accepted today
-5
>>> from matmul.gemm import _tiles
>>> _tiles(1000, -5)          # covers nothing
[]

Change

matmul/config.py — in __post_init__, reject tile that is not None and < 1, mirroring the existing validation. None remains the way to request auto-tiling.

Tests (CPU-only, no GPU)

tests/test_config_tile_validation.py: negative and zero tiles raise ValueError; None and a positive tile are accepted; plus a guard documenting that the rejected values are exactly the ones that make the tiled cover empty.

Verification

uv sync --extra test
uv run python -m strategy.smoke                                     # PASS
uv run --extra test python -m pytest tests/ strategy/tests/ eval/tests/ -q   # 99 passed, 23 skipped
uv run --extra test ruff check matmul/config.py tests/test_config_tile_validation.py   # clean

Touches only matmul/ and tests/ — no protected paths (eval/, docs/, .github/, dashboard/).

Config validated dtype, vram_fraction and storage but not tile. gemm.multiply
picks the tile edge with `cfg.tile or auto_tile(...)`, so a non-positive tile
slips through with a silently wrong outcome: 0 is falsy and quietly falls back to
auto (ignoring the user's explicit request), and a negative tile is truthy and
flows into _tiles(n, T), whose range(0, n, T) is empty -- the tiled loop writes no
blocks, C is returned untouched (all zeros), and the run still reports a normal
GFLOP/s. Validate in __post_init__ that tile is None (auto) or a positive int,
mirroring the existing checks. CPU-safe test coverage added; no GPU path touched.
@github-actions github-actions Bot added area:matmul Exact engine and tile schedules (matmul/) area:tests Correctness gates and test suites (tests/) status:needs-review Awaiting maintainer review type:bug Something is incorrect or broken status:ready-non-gpu Fix/docs PR cleared non-GPU triage; maintainer review only labels Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:matmul Exact engine and tile schedules (matmul/) 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.

1 participant