NVIDIA / NVIDIA/cutlass

[QST] [CuTeDSL] `cast_tensor` corner case when no stride = 1

Open
#3,026 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

? - Needs Triage inactive-30d inactive-90d question
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

What is your question?

When none of a tensor's stride includes 1, cute.recast_tensor becomes no-op.

@cute.jit
def func():
    tensor = cute.make_rmem_tensor((1, 2), cute.Float64)
    print(tensor.shape, "->", cute.recast_tensor(tensor, dtype=cute.Float16).shape)  # --> works

    tensor = cute.make_rmem_tensor((1, 1), cute.Float64)
    print(tensor.shape, "->", cute.recast_tensor(tensor, dtype=cute.Float16).shape)  # --> no-op

    layout = cute.make_layout(
        shape=(((2, 2, 2), 1), 1, 2),
        stride=(((0, 16, 0), 0), 0, 0),
    )
    tensor = cute.make_rmem_tensor(layout, cute.Float64)
    print(tensor.shape, "->", cute.recast_tensor(tensor, dtype=cute.Float16).shape)  # --> no-op

    layout = cute.make_layout(
        shape=(((2, 2, 2), 1), 1, 2),
        stride=(((0, 1, 0), 0), 0, 0),
    )
    tensor = cute.make_rmem_tensor(layout, cute.Float64)
    print(tensor.shape, "->", cute.recast_tensor(tensor, dtype=cute.Float16).shape)  # --> works

func()

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 by running the provided cute.jit reproducer and inspect the cute.recast_tensor entry point, comparing the cases with and without a stride of 1. Done means the no-stride-1 cases have the intended recast shape and a regression check covers these examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.