zip2_by does not handle Underscore tiler entries: kept modes are silently split or fail to compile
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.5k
- Forks
- 2.1k
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 7
Description
Description
zip2_by (include/cute/algorithm/tuple_algorithms.hpp ~lines 1031-1056), which underpins zipped_divide / tiled_divide / zipped_product / tiled_product, has no handling for Underscore tiler entries. Two failure modes result when an _ appears in a tuple tiler and the corresponding kept profile mode is not rank-1:
-
Kept mode of rank >= 2: silently wrong grouping. The rank-2 mode is misread as a divide pair: its first submode is placed in the BLOCK group and its second in the REST group, instead of the whole mode being kept undivided.
-
Kept scalar mode: compile error (
zip2_by"Mismatched ranks" / incompletetuple_size<C<...>>).
Repro for case 1:
#include "cute/layout.hpp"
#include <iostream>
int main() {
using namespace cute;
auto L = make_layout(make_shape(_12{}, make_shape(_4{}, _8{})),
make_stride(_7{}, make_stride(_1{}, C<30>{})));
auto d = zipped_divide(L, make_tuple(_2{}, Underscore{}));
print(d);
}
Actual output:
((_2,_4),(_6,_8)):((_7,_1),(_14,_30))
The kept profile mode (4,8) was split across the two groups (_4 into the block group, _8 into the rest group). The documented meaning of _ ("keep this mode out of the division") would keep (4,8) together on the rest side. Size happens to be preserved, so nothing downstream notices - this produces layouts that are valid-looking but semantically wrong.
For contrast, the Python port treats a None tiler entry as a no-op correctly and computes ((2,1),(6,(4,8))):((7,0),(14,(1,30))) for the same input.
Suggested fix
Teach zip2_by (and its product-side counterpart) to pass Underscore entries through as "keep whole": place the entire kept mode in the REST group with an identity block entry, mirroring what the logical-divide level already does for _.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in include/cute/algorithm/tuple_algorithms.hpp around zip2_by (approximately lines 1031-1056), then trace the zipped_divide, tiled_divide, zipped_product, and tiled_product entry points. Run the provided C++ repro and compare its output with the documented Python-port behavior. Done means Underscore entries keep the entire corresponding mode together on the REST side for both division and product paths, including scalar and rank-2 cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- hpc
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100