Skip to content

fix(pycute): logical_product with an int tiler computed logical_divide - #3479

Open
arcusbuilds wants to merge 2 commits into
NVIDIA:mainfrom
arcusbuilds:pycute-logical-product-int-tiler
Open

fix(pycute): logical_product with an int tiler computed logical_divide#3479
arcusbuilds wants to merge 2 commits into
NVIDIA:mainfrom
arcusbuilds:pycute-logical-product-int-tiler

Conversation

@arcusbuilds

Copy link
Copy Markdown

Fixes #3478.

logical_product(layout, <int>) called logical_divide, so it returned a divide result. Recursing with Layout(tiler) reaches the correct branch, which is what the C++ reference does at include/cute/layout.hpp:1670.

Before:

product Layout(4): ((2, 5), 4):((5, 1), 10)
product int 4    : ((2, 2), 3):((5, 1), 2)

After:

product Layout(4): ((2, 5), 4):((5, 1), 10)
product int 4    : ((2, 5), 4):((5, 1), 10)

The tuple-tiler, zipped_product and tiled_product paths bottom out in the same branch and are fixed with it. After the change the integer path delegates to the Layout path, so the two forms cannot diverge again.

Adds test/python/pycute/test_product.py. There was no test for logical_product before. It ports the post-conditions from test/unit/cute/core/logical_product.cpp over the same cases, and pins the integer and tuple forms against their Layout equivalents. run_all_tests.py discovers it automatically; the suite goes from 10 to 14 tests.

The nine Layout-tiler cases in test_logical_product pass both before and after the fix, since a Layout tiler skips the integer branch. They are the control: the other three tests failing while that one stays green shows the failure is the integer path and not the test file.

The second commit applies the same one-word fix to operators/cutlass/operators/fusion/pycute/layout.py, a copy of the same module. It is kept separate. Say the word and I will drop it if that tree is regenerated from an internal source.

logical_product(layout, <int>) dispatched to logical_divide, returning a
divide result under a product name. logical_product(layout, Layout(<int>))
was unaffected, so the two forms disagreed. The tuple-tiler, zipped_product
and tiled_product paths all bottom out in the same branch and were broken
with it.

Recurse with Layout(tiler) instead, matching the C++ reference at
include/cute/layout.hpp:1671.

Adds test/python/pycute/test_product.py, the first coverage for
logical_product, porting the post-conditions from
test/unit/cute/core/logical_product.cpp and pinning the int and
tuple tiler forms against their Layout equivalents.

Signed-off-by: arcusbuilds <srijankeshri007@gmail.com>
…endored pycute

operators/cutlass/operators/fusion/pycute/layout.py is a copy of
python/pycute/layout.py and carries the identical defect. Kept as a
separate commit so it can be dropped if this tree is a frozen
vendored drop.

Signed-off-by: arcusbuilds <srijankeshri007@gmail.com>
@ccecka

ccecka commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

The outdated NVIDIA/cutlass version of pycute needs to be removed and pointed to the complete and supported PyCuTe here
https://github.com/NVlabs/CuTe

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.

[BUG] pycute: logical_product with an integer tiler computes logical_divide

2 participants