NVIDIA / NVIDIA/cutlass

zipped/tiled divide with a dynamic tiler skips divisibility checks on static layouts and returns a non-size-preserving layout

Open
#3,513 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CUTLASS C++
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

Description

When a zipped/tiled divide receives a dynamic tiler against a fully static layout, the divisibility requirement is checked nowhere, and the result is a silently non-size-preserving layout.

#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, 128);   // 128 does not divide size(L) == 384
    print(d);
    print(" size="); print(size(d));   // 288
}

Actual output:

((12,4,2),(1,1,3)):((_7,_1,_30),(896,11,90))
 size=288

size(d) == 288 != size(L) == 384, strides run past the layout's cosize (896), and no diagnostic of any kind fires. Each individual configuration is handled correctly on its own:

  • fully static tiler: compile-time static_assert fires ("Shape Divisibility Condition"),
  • fully dynamic operands: the runtime assert catches it,
  • mixed static layout / dynamic tiler: the static path's runtime check is compiled out (the shapes are static, so the dynamic assert sees nothing to test) and the static check cannot see the dynamic tiler, so every guard is skipped.

The Python port asserts on the same input, which highlights the gap when cross-checking.

Suggested fix

In the mixed case, emit a runtime divisibility check (or a CUTE_GCC_UNREACHABLE-style guarded assert) comparing the dynamic tiler size against the known static layout size before performing the division, so misuses fail loudly instead of producing layouts whose size differs from the input.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cute/layout.hpp at zipped_divide and reproduce the supplied mixed static-layout/dynamic-tiler example. Trace the divisibility guards for static and dynamic shapes, then ensure the mixed case reports invalid divisibility before division and preserves the input size; compare behavior with the fully static and fully dynamic cases and the Python port.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.