Skip to content

[BUG] Discrepancy between CuTe C++ and pycute #3177

@jduprat

Description

@jduprat

Which component has the problem?

CUTLASS C++

Bug Report

Describe the bug
There is a discrepancy in behavior between pycute and Cute C++: composition_impl() at layout.hpp:1076-1077 uses a weak stride divisibility condition that accepts compositions pycute rejects:

// layout.hpp:1076-1077
CUTE_STATIC_ASSERT_V( ((rest_stride % curr_shape) == Int<0>{}) or (rest_stride < curr_shape), "Stride Divisibility Condition");

The weak condition violates the documented C(i) = A(B(i)) contract for standalone composition.

Steps/Code to reproduce bug

A=(4,6,8):(2,3,5), B=6:3), c = A o B

CuTe C++:

#include <cute/layout.hpp>
using namespace cute;
// Compiles, produces (_2,_3):(_6,_3), but C(2)=3 != A(B(2))=7
auto C = composition( 
     make_layout(make_shape(_4{},_6{},_8{}), make_stride(_2{},_3{},_5{})),  
     make_layout(_6{}, _3{}));

pycute:

import pycute
# Raises AssertionError — rejects the composition
pycute.composition( pycute.Layout((4, 6, 8), (2, 3, 5)), pycute.Layout(6, 3))

Expected behavior
pycute is correct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions