Skip to content

[Reshard] Add property tests for the tiled COO read planner - #2

Merged
zxpdemonio merged 1 commit into
zxpdemonio:cruz/coo-sparse-weight-transferfrom
rishabhsinha17:reshard/tiled-coo-properties
Oct 26, 2026
Merged

zxpdemonio merged 1 commit into
zxpdemonio:cruz/coo-sparse-weight-transferfrom
rishabhsinha17:reshard/tiled-coo-properties

Conversation

@rishabhsinha17

Copy link
Copy Markdown

Description

Property suite for the tiled COO planner in kvcache-ai#3751, offered as commits onto that PR per the discussion in kvcache-ai#3747. The reshard tests already use Hypothesis in tests/test_reshard_geometry.py, so this adds one file next to test_tiled_coo.py and no new dependency.

Every test states one README contract as an invariant over random layouts, target boxes and packed payloads and checks it against an oracle that only knows global tile boxes. Covered contracts are canonical immutable layouts that round trip through to_dict, tile runs selecting only the tiles that meet each source/target overlap with a full-width row range planned as one run, directory windows that contain each endpoint once and bridge at most 64 unused entries, per-run payload slices equal to their source slices with maximal coalescing, boundary filtering restoring the coordinate oracle and being a no-op whenever the selected tiles all lie inside the target, one target reading the same entries alone or in any batch order, a partition of a record reading each entry once after filtering, and bind_offsets rejecting wrong lengths, negative, non-integer and non-monotone directories.

Suggested Merge Priority

  • P2

Module

  • Reshard (mooncake-reshard)

Type of Change

  • Other (tests only)

How Has This Been Tested?

Test commands:

PYTHONPATH=python:mooncake-reshard/python python -m pytest -q \
  mooncake-reshard/tests/model_weight_planner \
  mooncake-reshard/tests/weight_manifest
bash scripts/check_reshard_types.sh

Test results:

  • Unit tests pass (381 passed at 5ef9976 plus this commit, 10 of them new; the same properties at 20x examples, 27,000 in total, all passed)
  • Strict pyright unchanged at zero errors (the tests are not in the include list)
  • ruff, ruff-format and codespell pass on the new file

Checklist

  • I have performed a self-review of my own code
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have added tests to prove my changes are effective

AI Assistance Disclosure

  • AI tools were used (specify below)

Claude Code wrote the strategies, the oracle and the test bodies from the README contracts, and every count above comes from a run on this branch.

State the README contracts of TiledCOOLayout and plan_tiled_coo_read as
Hypothesis invariants over random layouts, target boxes and packed
payloads, checked against an oracle that only knows global tile boxes.

Signed-off-by: Rishabh Sinha <rsinha17@terpmail.umd.edu>
@zxpdemonio
zxpdemonio merged commit 28ebaa0 into zxpdemonio:cruz/coo-sparse-weight-transfer Oct 26, 2026
1 check passed
@zxpdemonio

Copy link
Copy Markdown
Owner

Thank you, @rishabhsinha17. I independently reviewed and merged this contribution into the branch behind upstream kvcache-ai/Mooncake#3751, preserving your original commit (3c273ebf) and authorship.

Independent verification on the exact contributed commit:

  • the new property suite plus the existing tiled COO tests: 33 passed;
  • the full mooncake-reshard Python suite: 980 passed, 3 skipped, 1 environment-specific native Store test deselected;
  • Ruff check and format check for the added file: passed.

The deselected test is unrelated to this contribution: the verification host has an older installed native mooncake.store that does not expose begin_weight_snapshot. The upstream PR has moved to merge commit 28ebaa09, and its CI is now running.

Your property tests are a useful addition, especially the independent geometry oracle, placement/order invariance, directory/payload range checks, and empty-intersection coverage. On the coverage point raised in your upstream review: a TiledCOOLayout is intentionally writer-local, so the planner returns intersections contributed by that source; a partial intersection or an empty plan means partial/no local work. Completeness across all writers belongs to the manifest/integration layer that has visibility into the full source set. We will make that contract explicit in the upstream documentation.

Thanks again for the careful review and contribution. Further testing and discussion around the reshard path are very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants