Skip to content

[BUG] [CuTeDSL] cute.coalesce doesn't do anything on dynamic shapes #3469

Description

@lw

Which component has the problem?

CuTe DSL

Bug Report

Describe the bug
A mode with a dynamic shape doesn't get coalesced into previous modes, even though the stride is static and the previous modes are fully static too (and that's all that's needed to check whether the modes can be coalesced).

Steps/Code to reproduce bug

import torch
import cutlass.cute as cute
from cutlass.cute.runtime import from_dlpack


@cute.jit
def repro(tensor: cute.Tensor):
    layout = cute.make_layout(
        (16, tensor.shape[1] // 128),
        stride=(8, 128),
    )
    expected = cute.make_layout(
        (16 * (tensor.shape[1] // 128),),
        stride=(8,),
    )

    print("input:    ", layout)
    print("coalesced:", cute.coalesce(layout))
    print("expected: ", expected)


tensor = from_dlpack(torch.empty((4096, 8192), device="cuda"))
tensor = tensor.mark_compact_shape_dynamic(mode=1)
repro(tensor)

Output:

input:     (16,?):(8,128)
coalesced: (16,?):(8,128)
expected:  (?{div=16}):(8)

Environment details (please complete the following information):
Version 4.7.0 of CuTeDSL

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