`atomic_store_add` of a slice extracted from a tile adds nothing when the slice is under 256 bytes

オープン
#337 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
julia

調査の方向性

Start by reproducing the issue with the Julia kernel and size table in the report, comparing extract followed by atomic_store_add against the masked-sum workaround. The report says the emitted Tile IR looks correct and points to tileiras as a possible source, but gives no repository file or test entry point. Done means identifying the cause and ensuring atomic additions of extracted slices work across the reported sizes and element types.

索引モデルが issue の本文から書いたものです。

説明

On cuTile 1.0.0 (tileiras 13.3.36, and 13.4.92 with cuTile main), atomic_store_add of a slice that extract takes from a loaded tile leaves the destination unchanged when the slice is small. A plain store of the same slice is right, and so is atomic_store_add of the whole tile. On a GB10 (sm_121), cuTile 1.0.0 and tileiras 13.3.36:

Slice (Float32) store atomic_store_add
8 × 1 (32 B) right CUDA_ERROR_MISALIGNED_ADDRESS
16 × 1 (64 B) right wrong: nothing added
32 × 1 (128 B) right wrong: nothing added
64 × 1 (256 B) right right

BFloat16 behaves the same by bytes: 8 and 16 rows fault, 32 and 64 rows add nothing, and 128 rows are right. With cuTile main and tileiras 13.4.92, compute-sanitizer reports the fault as "Misaligned shared or local address" inside atomic_store_add. The Tile IR that cuTile.jl emits looks right (extract %tile[1, 0] : tile<2x16xf32> -> tile<1x16xf32>, then atomic_red_view_tko ... addf), so this seems to be in tileiras.

using CUDACore, cuTile
const ct = cuTile

function k(out, g, ::Val{R}, ::Val{Atomic}) where {R, Atomic}
    x = ct.load(g, (Int32(1), Int32(1)), (R, 2))
    slice = ct.extract(x, (1, 2), (R, 1))
    Atomic ? ct.atomic_store_add(out, (Int32(1), Int32(2)), slice) : ct.store(out, (Int32(1), Int32(2)), slice)
    return
end

for R in (16, 64)
    g = CuArray(rand(Float32, R, 2))
    for atomic in (false, true)
        out = CUDACore.zeros(Float32, R, 2)
        ct.launch(k, 1, out, g, Val(R), Val(atomic))
        println(atomic ? "atomic_store_add" : "store", " of column 2, R = $R: ",
            Array(out)[:, 2] == Array(g)[:, 2] ? "right" : "wrong")
    end
end
store of column 2, R = 16: right
atomic_store_add of column 2, R = 16: wrong
store of column 2, R = 64: right
atomic_store_add of column 2, R = 64: right

A workaround that is right at every size we tried (1 to 128 rows, Float32 and BFloat16): build the slice as a masked sum, sum(ifelse.(lane .== 2, x, 0f0); dims = 2), rather than extract.

A related observation on cuTile main, possibly by design: atomic_store_add at a tile index before the first (index 0) raises CUDA_ERROR_ILLEGAL_INSTRUCTION, while one past the last is clipped silently.

This should probably be reported upstream instead but I wanted to record it quickly before I forgot about it.

2026/11/05: Still happens on tileiras 13.5

Assisted by: Opus 5.5

主要言語
Julia
スター
90
フォーク
13
平均マージ
4日 8時間
マージ済み PR(30日)
19

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaGPU/cuTile.jl のほかの issue

JuliaGPU/cuTile.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。