Skip to content

[BUG] cute.ceil_div throws internal error with int64 input #3734

Open

Description

@kainzhong

Which component has the problem?

CuTe DSL

Bug Report

Describe the bug
cute.ceil_div doesn't work with cutlass.Int64

Steps/Code to reproduce bug

from cutlass import cute, Int32, Int64

def run(name, fn, a, b):
    try:
        cute.compile(fn, a, b)
        print(f"{name:45s} OK")
    except Exception as e:
        lines = [l for l in str(e).splitlines() if l.strip()]
        print(f"{name:45s} FAIL: " + next((l for l in lines if "mismatch" in l or "INTERNAL" in l), lines[0])[:110])

@cute.jit
def only_cdiv_64(a: Int64, b: Int64):
    cute.ceil_div(a, b)                      # result unused, nothing else in the function

@cute.jit
def only_cdiv_32(a: Int64, b: Int32):
    cute.ceil_div(a, b)

@cute.jit
def cdiv_then_add_64(a: Int64, b: Int64):
    q = cute.ceil_div(a, b)
    _ = q + Int64(1)                         # plain arithmetic on the result

run("ceil_div(Int64, Int64) only, unused", only_cdiv_64, Int64(100), Int64(7))
run("ceil_div(Int64, Int32) only, unused", only_cdiv_32, Int64(100), Int32(7))
run("ceil_div(Int64, Int64) + arithmetic", cdiv_then_add_64, Int64(100), Int64(7))

Gives:

ceil_div(Int64, Int64) only, unused           FAIL: error[INTERNAL]: The compiler could not build valid IR for this code.
ceil_div(Int64, Int32) only, unused           OK
ceil_div(Int64, Int64) + arithmetic           FAIL: error[INTERNAL]: The compiler could not build valid IR for this code.

Expected behavior
Either support int64 or give a better error message (I'm not sure if it's intended for cdiv to not support int64)

Environment details (please complete the following information):
nvidia-cutlass-dsl==4.8.0

Additional context
Add any other context about the problem here.

Activity

  1. yunweili3 commented on Oct 13, 2026

    @yunweili3

    Reproduced on 4.8.0 (and 4.5.3, so not a regression). Root cause is in how _pack_tile builds the tile type: _cute_ir.pack_tile only reads a leaf's bit-width from an int_tuple-typed value (?{i64}), and a plain Int64 argument reaches it as a bare i64 value, which it types as a 32-bit leaf. The type becomes [?:1] while the cute.make_tile operand is i64, hence the verifier mismatch. The input side of ceil_div goes through pack_int_tuple, which handles i64 — that is why ceil_div(Int64, Int32) works.

    The same failure hits every function that packs a tiler with a dynamic Int64 leaf (zipped_divide, tiled_divide, logical_divide, ceil_div((a, 64), (b, 4))).

    Fix (Python side, wrap 64-bit leaves as a depth-0 int_tuple before pack_tile, same as IntValue.get_typed_value): PR #3736. With it the three cases compile and ceil_div(2**40, 2**33 + 1) gives 128 on a B200.

    One related thing I noticed while bisecting: reading an Int64 layout shape back truncates — cute.make_layout((a, 2)).shape[0] with a = 2**33 + 5 is an Int32 and evaluates to 5 on device, while cute.size(L) is correct. That comes from unpack_x_tuple and is independent of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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