Skip to content

Don't crash on the first codegen error encountered#248

Draft
maleadt wants to merge 1 commit into
mainfrom
tb/deferred-codegen-errors
Draft

Don't crash on the first codegen error encountered#248
maleadt wants to merge 1 commit into
mainfrom
tb/deferred-codegen-errors

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Jun 3, 2026

Taking the example from #237:

using CUDACore; import cuTile as ct

function fill_normal!(A::ct.TileArray{Float32, 1}, n::Int)
    bid = ct.bid(1)
    tile = randn(Float32, (n,))
    ct.store(A; index=bid, tile=tile)
    return
end

@cuda backend=ct blocks=64 fill_normal!(CuArray{Float32}(undef, 65536), 1024)
julia> @cuda backend=ct blocks=64 fill_normal!(CuArray{Float32}(undef, 65536), 1024)
ERROR: CodegenErrors: kernel compilation produced 14 errors:
Reason: Struct construction not supported in Tile IR: Val
Stacktrace:
 [1] (::Type{Val{_A}} where _A)()
   @ Base essentials.jl:1038 [inlined]
 [2] Val(x::Tuple)
   @ Base essentials.jl:1040 [inlined]
 [3] _reshape_to_rank(tile::cuTile.FloatTile{Shape, Float32} where Shape, ::Val{1})
   @ cuTile ~/Julia/pkg/cuTile/src/language/operations.jl:333 [inlined]
 [4] store(arr::cuTile.TileArray{Float32, 1, cuTile.ArraySpec{…}()}, index::Tuple{Int32}, tile::cuTile.FloatTile{Shape, Float32} where Shape; order::Nothing, latency::Nothing, allow_tma::Nothing)
   @ cuTile ~/Julia/pkg/cuTile/src/language/operations.jl:457 [inlined]
 [5] store(arr::cuTile.TileArray{Float32, 1, cuTile.ArraySpec{…}()}, index::Int32, tile::cuTile.FloatTile{Shape, Float32} where Shape; kwargs::@Kwargs{order::Nothing, latency::Nothing, allow_tma::Nothing})
   @ cuTile ~/Julia/pkg/cuTile/src/language/operations.jl:464 [inlined]
 [6] store(arr::cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}; index::Int32, tile::cuTile.FloatTile{Shape, Float32} where Shape, order::Nothing, latency::Nothing, allow_tma::Nothing)
   @ cuTile ~/Julia/pkg/cuTile/src/language/operations.jl:489 [inlined]
 [7] fill_normal!(A::cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}, n::Int64)
   @ Main REPL[2]:4 [inlined]

Reason: fill() shape must be a compile-time constant
Stacktrace:
 [1] _full(value::UInt32, ::Type{UInt32}, shape::Tuple{Int64})
   @ cuTile ~/Julia/pkg/cuTile/src/language/operations.jl:722 [inlined]
 [2] fill(v::UInt32, dims::Tuple{Int64})
   @ cuTile ~/Julia/pkg/cuTile/src/language/overlays.jl:172 [inlined]
 [3] fill(v::UInt32, dims::Int64)
   @ Base array.jl:540 [inlined]
 [4] randn_f32class_tile(stream::Int64, ::Type{Float32}, dims::Tuple{Int64})
   @ cuTile ~/Julia/pkg/cuTile/src/language/random.jl:437 [inlined]
 [5] randn_tile(stream::Int64, ::Type{Float32}, dims::Tuple{Int64})
   @ cuTile ~/Julia/pkg/cuTile/src/language/random.jl:486 [inlined]
 [6] randn(::Type{Float32}, dims::Tuple{Int64})
   @ cuTile ~/Julia/pkg/cuTile/src/language/random.jl:576 [inlined]
 [7] fill_normal!(A::cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}, n::Int64)
   @ Main REPL[2]:3 [inlined]

... and many more

Lots of noise, but at least the actual error (non-constant input to randn) is in there.

@maleadt maleadt changed the title Initial sketch of deferred error reporting. Don't crash on the first codegen error encountered Jun 3, 2026
@maleadt
Copy link
Copy Markdown
Member Author

maleadt commented Jun 3, 2026

Errors probably can be ordered better; the randn one happens on line 3 while the Any is in a line below.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant