Wrong results from kernels accumulating 2- and 4-byte aggregates on the Aurora LTS stack with Julia 1.13 (IGC 2.11.43)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with the reproducer in the issue and the sparse ComplexF16 tests at test/testsuite/sparse.jl:363 and :372; compare behavior across the listed IGC versions and run the reproducer with multiple group and item shapes. The issue identifies IGC as the likely source and lists possible fixes, but no option is tested as a project change. Done means a confirmed fix or workaround makes the failing Julia 1.13 LTS cases correct without breaking relevant tests.
由索引模型根据 Issue 内容生成。
描述
On Aurora's LTS stack with Julia 1.13, a kernel that accumulates a 2- or 4-byte aggregate in a loop silently returns wrong results. This isn't specific to ComplexF16: integer types such as Complex{Int16} and Complex{Int8} fail as well. The first work item of each group is right, and most others are wrong.
This is what keeps test:lts:1.13 red on main. GPUArrays 12.2.0 (JuliaGPU/GPUArrays.jl#796) rewrote the sparse reduction kernels to start from the first stored value, which exposes the bug in the sparse ComplexF16 sum(dx; dims) tests (test/testsuite/sparse.jl:363 and :372). The GPUArrays change only exposes it: a plain @oneapi kernel with the same loop also fails with GPUArrays 12.1.1.
Reproducer
using oneAPI
function accumulate_slices!(out, vals)
i = get_global_id()
a = 3i - 2
v = @inbounds vals[a]
for k in (a + 1):(a + 2)
v += @inbounds vals[k]
end
@inbounds out[i] = v
return
end
function check(T; groups, items)
n = groups * items
vals = rand(T, 3n)
out = oneArray{T}(undef, n)
@oneapi groups = groups items = items accumulate_slices!(out, oneArray(vals))
oneAPI.synchronize()
got = Array(out)
want = [sum(@view vals[(3i - 2):3i]) for i in 1:n]
return count(i -> !isapprox(got[i], want[i]; atol = 0.01), 1:n)
end
for T in (ComplexF16, Complex{Int16}, Complex{Int8}, ComplexF32)
println(rpad(T, 16),
"1 group of 32 items: ", check(T; groups = 1, items = 32), "/32 wrong, ",
"32 groups of 1 item: ", check(T; groups = 32, items = 1), "/32 wrong")
end
Wrong work items out of 32, with 1 group of 32 items:
| Element type | Julia 1.13, IGC 2.11.43 | Julia 1.13, IGC 2.34.4 | Julia 1.10, IGC 2.11.43 |
|---|---|---|---|
ComplexF16 |
31 | 0 | 0 |
Complex{Int16} |
31 | 0 | 0 |
Complex{Int8} |
31 | 0 | 0 |
ComplexF32 |
0 | 0 | 0 |
With 32 groups of 1 item, all of these are correct, so a test with items = 1 won't catch the bug.
Tested on a Data Center GPU Max 1550 with ONEAPI_LTS=1 and ZE_FLAT_DEVICE_HIERARCHY=FLAT, on NEO 1.6.33578.77 and GPUArrays 12.2.0. For the IGC 2.34.4 runs, only libigc was swapped, and the process's mapped libraries confirmed it was loaded. Only the LTS stack has been tested, not the rolling one.
Which types and kernels are affected
Results are from Julia 1.13 on IGC 2.11.43, using a + loop with shapes 1×32, 4×16 and 32×1.
| Aggregate size | Types tested | Result |
|---|---|---|
| 2 bytes | Complex{Int8}, a struct of two Int8 |
wrong |
| 4 bytes | ComplexF16, NTuple{2,Float16}, Complex{Int16}, Complex{UInt16}, and structs of two Float16, two Int16, two UInt16, Float16 + Int16, and four Int8 |
wrong |
| 6 bytes | three Float16 (struct and tuple) |
correct |
| 8 bytes | four Float16 (struct and tuple), four Int16, ComplexF32, Complex{Int32}, and structs of two Float32, two Int32, and Float16 + Float32 |
correct |
| 16 bytes | ComplexF64, and structs of four Float32 and two Float64 |
correct |
The shape of the kernel matters as well:
ComplexF16is also wrong with a*loop.- A loop that only replaces the accumulator (
if w.a > v.a; v = w; end) is correct for every type above.
These array operations were correct on Julia 1.13 and IGC 2.11.43, for the element types in brackets:
- Dense
sum(scalar anddims), andreduce(+, A)(ComplexF16,Float16,Int16,Complex{Int16}). extrema(scalar anddims), which holds a pair as its accumulator (Float16,Int16,Int8).- Sparse CSR and CSC
sum(dims)forFloat16andComplexF32.
The sparse ComplexF16 sum(dims) was the only array operation I tested that gave wrong results. Other operations weren't tested, and any user kernel that accumulates this way can hit it, including KernelAbstractions kernels.
Likely cause
This looks like an IGC bug. On Julia 1.13, the aggregate stays in private memory: the optimized IR for the failing kernels keeps an alloca ([2 x half], i32 or i16), while Julia 1.10 scalarizes it, and nothing is left for IGC to get wrong. Some kernels with a surviving alloca still work ([4 x half], [2 x float]), so the alloca alone doesn't explain it.
-ze-opt-disablegives correct results.- A pure SYCL reproducer with a pair of
halfvalues in private memory, built withicpx -fsycl -O2, fails the same way on IGC 2.11.43 and is correct on 2.34.4. So Julia isn't required to trigger it. - In that SYCL reproducer's vISA, the failing kernel has a self-move,
mov (M1, 32) V(0,0)<2> V(0,0)<1;1,0>, which matches the mixed-up lanes. This is inferred from the vISA and the wrong values, not from an instruction trace. IGC_EnableLdStCombine=0removes that move and gives correct results in the SYCL reproducer. It hasn't been tested from Julia, and the link to that pass is only a correlation.
I don't know which IGC change between 2.11.43 and 2.34.4 fixed this. It hasn't been reported to Intel yet.
Options
- Get a fixed IGC into the production and LTS stacks. This is the real fix. The full test suite hasn't been run on 2.34.4, only these reproducers and the sparse tests' operations.
- Add an IR cleanup in oneAPI.jl or GPUCompiler that removes the alloca on the LTS stack. This would protect users until IGC is updated, but it's untested.
- For CI only, set
IGC_EnableLdStCombine=0or skip the affected sparse tests on LTS with Julia 1.13. Either one turnsmaingreen, but users would still get wrong results.
- 主要语言
- Julia
- 星标
- 218
- 派生
- 36
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 59
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaGPU/oneAPI.jl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 43/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
JuliaGPU/oneAPI.jl#750 · 1 条评论 ·
维护者通常 1 天内回复
-
performance
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
-
libraries upstream
难度 4/5 1-2 天 新手友好度 22/100
JuliaGPU/oneAPI.jl#703 · 2 条评论 ·
维护者通常 1 天内回复
查看 JuliaGPU/oneAPI.jl 的全部 Issue
相似的 Issue
-
lux
难度 2/5 1-3 小时 新手友好度 76/100
JuliaGraphs/GraphNeuralNetworks.jl#732 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
erfinv(::Float16) and erfcinv(::Float16) are wrong for abs(x) <= 0.75 (erfinv(Float16(0)) == 0.2201)未关闭
难度 2/5 1-3 小时 新手友好度 82/100
JuliaMath/SpecialFunctions.jl#571 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 67/100