Negative-stride views crash kernels

未关闭
#321 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
julia
领域
compilers, hpc

调研方向

Start with TileArray(arr) conversion and src/compiler/analysis/assume.jl, especially the op_predicates chain applying nonneg_range() to strides. Trace how a reversed view reaches codegen and compare the stated rejection and ArraySpec approaches. Done means negative-stride views no longer cause an illegal GPU memory access and instead are safely rejected or handled without an invalid non-negative-stride assumption.

由索引模型根据 Issue 内容生成。

描述

A view with a negative stride converts to a TileArray without complaint, but kernels using it read out of bounds:

using CUDA, cuTile; import cuTile as ct
function copy_tiles(dst, src)
    i = ct.bid(1)
    ct.store(dst, i, ct.load(src, i, (256,)))
    return
end
n = 4096
x = CuArray(Float32.(1:n)); y = CUDA.zeros(Float32, n)
@cuda backend=cuTile blocks=n÷256 copy_tiles(y, view(x, n:-1:1))
# CUDA error: an illegal memory access was encountered (code 700, ERROR_ILLEGAL_ADDRESS)

TileArray(arr) takes strides(arr) as is, so the reversed view becomes a TileArray with stride -1. Codegen asserts every size and stride is non-negative (op_predicates in src/compiler/analysis/assume.jl chains nonneg_range() for :stride), so tileiras may rely on an assumption that doesn't hold. cuTile Python makes the same assumption (stride_lower_bound_incl=0 for every JIT array argument), but PyTorch doesn't produce negative strides; view(x, n:-1:1) or reverse views do.

Options: reject negative strides when converting (an ArgumentError rather than a GPU fault), or record in the ArraySpec that strides may be negative and drop the assumption for such arrays, as Python's ArrayConstraint.stride_lower_bound_incl allows.

Reproduced on main (5c8e90b5), RTX 5080, Julia 1.13.

主要语言
Julia
星标
90
派生
13
平均合并
4 天 8 小时
30 天内合并 PR
19

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaGPU/cuTile.jl 的其他 Issue

查看 JuliaGPU/cuTile.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。