[BUG][CuTeDSL] block_dim() range [1, 1024) excludes 1024, which causes wrong-code folding
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start by tracing how CuTe DSL supplies range information for cute.arch.block_dim() and cute.arch.grid_dim() to LLVM; the issue does not name the implementation file or a test. Reproduce with the provided kernel using a runtime Int32(1024) block size and compare behavior with the range-information pass disabled. Done when the range includes 1024 and the equality check evaluates true.
Written by the indexing model from the issue text.
Description
Which component has the problem?
CuTe DSL
Bug Report
Describe the bug
The compiler specifies the wrong half-open range for the block_dim(): [1, 1024) which excludes 1024 in the register annotations passed to LLVM. Same issue with grid_dim() as well.
This causes the compiler to fold conditionals based on incorrect range by assuming that block_dim cannot be 1024. The block size must be a runtime Int32 to reproduce. With a compile-time block size, CuTe emits .reqntid 1024, and on 4.8.0 the comparison is then folded correctly, which hides the bug.
Steps/Code to reproduce bug
import cutlass
import cutlass.cute as cute
import torch
from cutlass.cute.runtime import from_dlpack
@cute.kernel
def kernel(out: cute.Tensor):
tidx, _, _ = cute.arch.thread_idx()
bdim, _, _ = cute.arch.block_dim()
if tidx == 0:
out[0] = bdim
out[1] = cutlass.Int32(1) if bdim == cutlass.Int32(1024) else cutlass.Int32(0)
@cute.jit
def launch(out: cute.Tensor, block: cutlass.Int32):
kernel(out).launch(grid=(1, 1, 1), block=(block, 1, 1))
out = torch.full((2,), -1, dtype=torch.int32, device="cuda")
t_out = from_dlpack(out)
cute.compile(launch, t_out, cutlass.Int32(1024))(t_out, cutlass.Int32(1024))
torch.cuda.synchronize()
raw, eq_max = out.tolist()
assert (raw, eq_max) == (1024, 1) # bdim should be 1024, and bdim == 1024 should be True
In the above code, the compiler assumes that bdim is in the range [1,1024) (i.e. 1024 excluded) and incorrectly deduces that bdim == cutlass.Int32(1024) is always False.
The code works by disabling use-insert-range-information-pass with:
CUTE_DSL_COMPILER_OPT=use-insert-range-information-pass=false
Expected behavior
cutedsl provides the correct range to LLVM and the condition is not folded.
Environment details (please complete the following information):
- GPUs: NVIDIA B200 (driver 580.126.20) and NVIDIA H200 (driver 580.126.09), CUDA 13.0, Ubuntu 24.04.4
- Python 3.12.3, torch 2.14.1+cu130
- nvidia-cutlass-dsl 4.8.0 (with libs-cu13) and 4.7.1 (with libs-cu12)
Additional context
n/a
- Dominant language
- C++
- Stars
- 10.7k
- Forks
- 2.2k
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/cutlass
-
[Bug][CuTeDSL][Fuzz] `utils.gemm.sm100.epilogue` releases the accumulator before `tcgen05.ld` completes: no `tcgen05.wait::ld` before the arrive that lets the next MMA overwrite TMEMPossibly taken @0z5a claimed this 3 days ago. Openbug CuTe DSL
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 4 days
-
? - Needs Triage question
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NVIDIA/cutlass#3796 · 1 comment · 1 reaction ·
Maintainers usually reply within 4 days
-
[DOC] IKET quick start omits the GEMM GPU requirement and references a missing examplePossibly taken @0z5a claimed this 14 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
NVIDIA/cutlass#3761 · 1 comment ·
Maintainers usually reply within 4 days
-
[BUG] CuTe DSL from_dlpack rejects float8_e4m3fn tensors (dtype_map lists Float8E5M2 only)Possibly taken @Ammar-Alnagar claimed this 23 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cutlass#3716 · 1 comment ·
Maintainers usually reply within 4 days
-
EllGemm ColumnMajor-output workspace sizing uses the unswapped problem shape and undersizes split-K semaphoresPossibly taken @XFDG claimed this 52 days ago. OpenCUTLASS C++
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NVIDIA/cutlass#3539 · 2 comments ·
Maintainers usually reply within 4 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
meshcore-dev/MeshCore#3760 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
deepseek-ai/DeepGEMM-Ascend#29 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
EchoTools/nevr-runtime#2042 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
emscripten-core/emscripten#28160 · 1 comment ·
Maintainers usually reply within 1 day
-
Download size and speed show scientific notation between 1000 and 1023 unitsPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 Under an hour Newbie friendliness 88/100
kiwix/kiwix-desktop#1570 ·
Maintainers usually reply within 1 day