You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Correctness issue when indexing "big" oneArrays #509
I am using Julia 1.11.6 and oneAPI 2.0.3. Not really sure what could be the cause, but when I use x = randn(Float32, 512, 3) it starts working again, so it seems to be related to the size of the array.
Using Julia v1.11.7 and oneAPI v2.2.0 I can still can reproduce this on my Linux system (Ubuntu 24.04). I attach the manifest of the environment in case that is useful:
The bug was in our KernelAbstractions back-end: @index(Global, Linear) returned the hardware global id, which is wrong when work-groups don't evenly divide a multidimensional range (513 rows → padded 512-item groups), so getindex_kernel skipped elements and wrote out of bounds. It's fixed on main.
We hit this on Aurora (PVC, oneAPI.jl 2.9.2, Julia 1.12.7) in a few more forms, in case it helps anyone searching:
x[:, 2, :, :] on a 4-D oneArray of size (64, 4, 500, B) is wrong for every B ≥ 2, with 768 × (B − 1) device-side Out-of-bounds array access messages. Dropping axis 1 fails the same way; dropping axis 3 or 4 is fine.
rmul!(x, s) on a (64, 1000, 16)ComplexF32 array page-faults and bans the context (@inbounds over a padded ndrange = size(A)), so ifft(x, 2) aborts via AbstractFFTs' ScaledPlan. (256, 1000, 16) is fine because the chosen work-group (256, 4, 1) divides 1000.
permutedims on 4-D arrays is affected the same way.
All of it is the @index(Global, Linear) = get_global_id() issue described above: a CPU re-run of the back-end's launch arithmetic (threads_to_workgroupsize + partition + expand) reproduces every out-of-bounds count exactly.
Is a 2.9.3 with just this fix possible? Our stack (Lux / MLDataDevices / NNlib) still pins GPUArrays 11 and KernelAbstractions 0.9, so we can't move to main until those ecosystems release KernelAbstractions 0.10 support, and in the meantime 2.9.2 silently returns wrong results for common indexing. The change against the v2.9.2 tag is small, mirroring CUDA.jl's back-end:
@device_override@inlinefunction KA.__index_Global_Linear(ctx)
return_global_linear(ctx, KA.__iterspace(ctx))
end@inline_global_linear(ctx, ::KA.NDRange{1}) =get_global_id()
@inlinefunction_global_linear(ctx, iterspace::KA.NDRange)
I =@inbounds KA.expand(iterspace, get_group_id(), get_local_id())
return@inboundsLinearIndices(KA.__ndrange(ctx))[I]
end
With that patch on top of v2.9.2, all of the cases above are exact on Aurora (PVC, NEO 25.18 LTS), including a direct check that @index(Global, Linear) matches LinearIndices for padded 3-D ranges with automatic and explicit work-group sizes. Happy to open a PR with it plus regression tests (padded N-d ranges with automatic and explicit work-group sizes, and the getindex / permutedims / rmul! cases) against a release-2.9 branch if you'd take one. If a release is not an option, is there a recommended way to pin a fixed oneAPI.jl for KernelAbstractions 0.9 users in the meantime?
Thanks @wilkieolin, that analysis is exactly right. Since the fix on main is entangled with the KernelInterface migration (#653, which also moved to KernelAbstractions 0.10 / GPUArrays 12), I cut a release-2.9 branch from v2.9.2 and opened #738 with your patch (as in CUDA.jl, mapping through the iteration space) and regression tests for the cases you listed. Once CI is green I'll merge it and register v2.9.3.
Activity
[-]Correctness issue when indexing "big" `oneArray`[/-][+]Correctness issue when indexing "big" `oneArray`s[/+]michel2323 commentedon Sep 17, 2025
Tried to reproduce, but it seems to have resolved itself in latest release. Can you confirm @cncastillo?
cncastillo commentedon Sep 17, 2025
Using Julia v1.11.7 and oneAPI v2.2.0 I can still can reproduce this on my Linux system (Ubuntu 24.04). I attach the manifest of the environment in case that is useful:
Manifest.toml.txt
EDIT: you might need to increase the size of the array (changing
513to something larger)michel2323 commentedon Oct 28, 2025
oneAPI v2.2.0 is really old. Can you try with v2.4.0?
cncastillo commentedon Oct 28, 2025
Used Julia 1.12.1 and oneAPI v2.4.0 and can still reproduce the error.
maleadt commentedon Oct 19, 2026
The bug was in our KernelAbstractions back-end: @index(Global, Linear) returned the hardware global id, which is wrong when work-groups don't evenly divide a multidimensional range (513 rows → padded 512-item groups), so getindex_kernel skipped elements and wrote out of bounds. It's fixed on main.
wilkieolin commentedon Oct 23, 2026
We hit this on Aurora (PVC, oneAPI.jl 2.9.2, Julia 1.12.7) in a few more forms, in case it helps anyone searching:
x[:, 2, :, :]on a 4-DoneArrayof size(64, 4, 500, B)is wrong for everyB ≥ 2, with768 × (B − 1)device-sideOut-of-bounds array accessmessages. Dropping axis 1 fails the same way; dropping axis 3 or 4 is fine.rmul!(x, s)on a(64, 1000, 16)ComplexF32array page-faults and bans the context (@inboundsover a paddedndrange = size(A)), soifft(x, 2)aborts via AbstractFFTs'ScaledPlan.(256, 1000, 16)is fine because the chosen work-group(256, 4, 1)divides 1000.permutedimson 4-D arrays is affected the same way.All of it is the
@index(Global, Linear) = get_global_id()issue described above: a CPU re-run of the back-end's launch arithmetic (threads_to_workgroupsize+partition+expand) reproduces every out-of-bounds count exactly.Is a 2.9.3 with just this fix possible? Our stack (Lux / MLDataDevices / NNlib) still pins GPUArrays 11 and KernelAbstractions 0.9, so we can't move to
mainuntil those ecosystems release KernelAbstractions 0.10 support, and in the meantime 2.9.2 silently returns wrong results for common indexing. The change against the v2.9.2 tag is small, mirroring CUDA.jl's back-end:With that patch on top of v2.9.2, all of the cases above are exact on Aurora (PVC, NEO 25.18 LTS), including a direct check that
@index(Global, Linear)matchesLinearIndicesfor padded 3-D ranges with automatic and explicit work-group sizes. Happy to open a PR with it plus regression tests (padded N-d ranges with automatic and explicit work-group sizes, and thegetindex/permutedims/rmul!cases) against arelease-2.9branch if you'd take one. If a release is not an option, is there a recommended way to pin a fixed oneAPI.jl for KernelAbstractions 0.9 users in the meantime?michel2323 commentedon Oct 23, 2026
Thanks @wilkieolin, that analysis is exactly right. Since the fix on
mainis entangled with the KernelInterface migration (#653, which also moved to KernelAbstractions 0.10 / GPUArrays 12), I cut arelease-2.9branch from v2.9.2 and opened #738 with your patch (as in CUDA.jl, mapping through the iteration space) and regression tests for the cases you listed. Once CI is green I'll merge it and register v2.9.3.In the meantime you can pin the branch:
Fix `@index(Global, Linear)` for padded ndranges
Fix `@index(Global, Linear)` for padded ndranges