Skip to content

fix(cute-layout): accept one-axis blocked and raked products - #1713

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/cute-layout-one-axis-products
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix/cute-layout-one-axis-products

Conversation

@0z5a

@0z5a 0z5a commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

zipped_product (cute-layout/src/algebra/tiling.rs), which backs blocked_product, raked_product and make_layout_tv, splits the block and the repetition layout returned by logical_product into modes and expects exactly one of each per axis. With one-axis inputs the repetition complement(a) ∘ b can have several flat modes, for example complement(3:2, 12) = (2,2):(1,6), so valid inputs fail with AlgebraError("product: unexpected mode structure"):

Call main this PR
blocked_product(3:2, 4:1) error (3,2,2):(2,1,6)
raked_product(3:2, 4:1) error (2,2,3):(1,6,2)
raked_product(4:2, 4:1), make_layout_tv(4:2, 4:1) error ok

logical_product succeeds on the same inputs (logical_product(4:2, 4:1) = (4,(2,2)):(2,(1,8))); only the pairing step fails.

Changes

  • zipped_product: for a single axis, pair the whole block with the whole repetition instead of splitting them with modes(). For one-axis layouts that modes() already split into one entry each, this is the same pair, so inputs that worked before give the same result.
  • New test one_axis_products_accept_a_multi_mode_repetition: checks both results above element by element against their definition and that the twelve cells cover offsets 0..12 exactly once.

C++ CuTe's blocked_product accepts this case; its raked_product does not compile for it ("Mismatched Ranks" in detail::zip), so for the raked half this follows the definition and this crate's own logical_product.

Testing

CPU only; the crate has no dependencies, so rustc --edition 2024 --test --crate-name cute_layout src/lib.rs (rustc 1.95.0, aarch64 Linux), main at 44a85d3:

main this PR
new test fails: product: unexpected mode structure passes
cute-layout unit tests 62 passed, 1 failed 63 passed

rustfmt --check --edition 2024 (1.9.0) is clean on both changed files. A Python port of logical_product and the products, fuzzed against their definition over 3 × 20k cases (with #1712's guard applied), shows 88–121 spurious errors per 20k on main and none with this change.

  • just -f cuda-oxide/Justfile check passes (the local mirror of CI: fmt, clippy, tests, guards, docs)
  • cargo oxide run <example> passes, or cuda-oxide/scripts/smoketest.sh -o '^<example>$'
  • New example added (if applicable)

Checklist

  • All commits signed off (git commit -s)
  • All commits cryptographically signed and shown as Verified on GitHub (git commit -S)
  • SPDX headers on new source files

@0z5a
0z5a requested a review from nihalpasham as a code owner November 3, 2026 10:25
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

zipped_product splits the block and the repetition layout into modes and
expects one of each per axis. With one-axis inputs the repetition
complement(a) o b can have several flat modes (complement(3:2, 12) is
(2,2):(1,6)), so blocked_product(3:2, 4:1), raked_product(4:2, 4:1) and
make_layout_tv(4:2, 4:1) failed with "product: unexpected mode
structure", although logical_product succeeds on the same inputs. For a
single axis, pair the whole block with the whole repetition. Inputs that
already worked produce the same layouts.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@0z5a
0z5a force-pushed the fix/cute-layout-one-axis-products branch from ac12c01 to ef00b70 Compare November 5, 2026 09:57

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