Skip to content

test(sharding): verify shard offset arithmetic against the CuTe layout algebra - #302

Open
d-v-b wants to merge 4 commits into
mainfrom
claude/happy-stonebraker-f40d70
Open

d-v-b wants to merge 4 commits into
mainfrom
claude/happy-stonebraker-f40d70

Conversation

@d-v-b

@d-v-b d-v-b commented Aug 17, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Checks sharding byte offsets and chunk localization against the independent CuTe layout algebra. logical_divide maps shard elements into nested chunk coordinates; blocked_product maps those coordinates into the stored data section. The tests compare every encoded element and index entry with these layouts, then construct complete shard blobs from the oracle and decode them through public full/strided reads and synchronous decoding.

Fixed and generated tilings cover one to three dimensions, non-square shapes, unit chunks and grid extents, C/F memory and within-chunk order, index placement at either end, and lexicographic/colexicographic/power-of-two Morton layouts. The generated cases exposed a fixture assumption: a zero-valued singleton chunk was being omitted as fill. The oracle now uses a fill sentinel outside its labels, preserving the fully populated layout it intends to check.

PyCuTe is pinned to commit 2e12e571c3882c5be669f8d326d630853a3571aa as a test-only dependency of the optional Hatch matrix. Missing CuTe fails in that matrix and skips elsewhere. A changelog entry is included.

Validation after integrating current main:

  • 388 tests passed in the actual Python 3.12 optional Hatch environment, including 60 generated tilings per property run.
  • A simulated missing dependency failed explicitly in the optional matrix; the minimal environment skipped the oracle module as intended.
  • Replacing colexicographic traversal with lexicographic traversal caused a raw element-layout assertion to fail, confirming the oracle detects incorrect order arithmetic.
  • Ruff, formatting, and mypy passed.

Non-power-of-two Morton compaction and unordered layouts remain outside this stride-layout oracle. Other optional Python/platform matrix combinations were not rerun in this local review.

d-v-b added 2 commits August 17, 2026 08:11
…t algebra

Add tests/test_codecs/test_sharding_cute_oracle.py, which derives the
shard -> inner-chunk -> element layouts independently with PyCuTe
(logical_divide for the shard/chunk nesting, blocked_product for the
data-section layout under each subchunk_write_order) and asserts that a
shard written by zarr places every element and every index entry where
the algebra predicts -- and, conversely, that a blob assembled purely
from the algebra decodes correctly. Covers 1-3D shapes, C/F memory
order, C/F within-chunk order (TransposeCodec), lexicographic /
colexicographic / power-of-two morton write orders, and both index
locations. Chunk localization (% chunks_per_shard) is checked as the
divide remainder.

PyCuTe is a test-only oracle: it is not on PyPI, so it is pinned to a
commit as an extra-dependency of the 'optional' hatch test matrix, and
the module importorskips elsewhere. It is never imported at runtime.

Assisted-by: ClaudeCode:claude-fable-5
Assisted-by: ClaudeCode:claude-fable-5
Generate independent tilings across dimensions and storage orders. Keep zero-valued singleton chunks outside the fill value so fully populated oracle layouts remain valid, and fail when CuTe is missing from the optional Hatch matrix.

Assisted-by: Codex:GPT-6

This branch has not been deployed

No deployments
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