Commit Graph
1 Commits
Author SHA1 Message Date
ChennesandLeiWang1999 a443dde926 [BugFix] Reject contracting shared-buffer layouts in T.annotate_layout (#2719)
* [BugFix] Reject contracting shared-buffer layouts in T.annotate_layout

T.annotate_layout could accept a contracting many-to-one forward map on a
shared buffer. makeBufferWithLayout then misread the smaller output extent as
a replication factor, rewrote the buffer to a higher rank, and eventually
failed with an unrelated BufferStore dimensionality ICHECK.

Add a pigeonhole check for static layout shapes before the replication branch.
When the layout output extent is smaller than its input extent, raise a
user-facing ValueError that identifies the buffer and reports both extents.
Keep identity, permutation, and output-growing layouts unchanged.

This check intentionally targets contracting maps; general injectivity
analysis for maps with larger output bounding boxes is outside this change.

Fixes #2632

* [Layout] Enforce injective shared-buffer annotations

Add a LayoutNode injectivity check with an exact fallback for static domains, and reuse it for FragmentNode thread and replication coordinates. Validate shared-buffer annotations after layout reshaping so sparse many-to-one maps are rejected with a useful collision diagnostic while padded injective maps remain valid.

---------

Co-authored-by: LeiWang1999 <leiwang1999@outlook.com>
2026-07-23 11:21:48 +08:00