SYCL batching causes invalid results
- Dominant language
- Julia
- Stars
- 215
- Forks
- 37
- Avg merge
- 10h 47m
- Merged PRs (30d)
- 14
Description
Hello, I am trying to run a simplified "forward" passage of a neural network with GPU.
On CUDA/CuArray I have always the same, correct results for my output, but with oneAPI/oneArray, the first time I have the correct result, but the subsequent times I have random results and random crashes (but never the first time).
Any clue ?
```julia
using Test, oneAPI, BenchmarkTools, LinearAlgebra
# Function definitions
relu(x) = max(0,x)
forward_layer(x,w,w0,f) = f.(w*x .+ w0)
function forward_network!(y,x,w1,w2,w3,w01,w02,w03,f=relu)
x1 = forward_layer(x,w1,w01,f)
x2 = forward_layer(x1,w2,w02,f)
y .= forward_layer(x2,w3,w03,identity)
return nothing
end
# CPU data
(nd0,nd1,nd2,ndy) = (200,300,300,1)
x = rand(Float32,nd0); y = Vector{Float32}(undef,ndy)
w1 = rand(Float32,nd1,nd0); w2 = rand(Float32,nd2,nd1); w3 = rand(Float32,ndy,nd2)
w01 = rand(Float32,nd1); w02 = rand(Float32,nd2); w03 = rand(Float32,ndy);
# CPU call
forward_network!(y,x,w1,w2,w3,w01,w02,w03,relu)
# GPU data
y_g = oneArray{Float32}(undef,ndy)
x_g = oneArray(x)
w1_g = oneArray(w1); w2_g = oneArray(w2); w3_g = oneArray(w3);
w01_g = oneArray(w01); w02_g = oneArray(w02); w03_g = oneArray(w03);
# GPU call
forward_network!(y_g,x_g,w1_g,w2_g,w3_g,w01_g,w02_g,w03_g,relu)
# Correctness check..
y ≈ Array(y_g) # true
# Second (and further) attempt..
y_g = oneArray{Float32}(undef,ndy)
forward_network!(y_g,x_g,w1_g,w2_g,w3_g,w01_g,w02_g,w03_g,relu)
y ≈ Array(y_g) # false !
```
Perhaps linked to https://github.com/JuliaGPU/oneAPI.jl/issues/327 ?
Ubuntu 22.04, oneAPI v1.5.0, Intel CPU i5-8350U, UHD Graphics 620
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided Julia reproduction with oneAPI and repeating forward_network! after the initial GPU call, comparing Array(y_g) with the CPU result and observing crashes. Trace the oneArray operations used by forward_layer and the repeated allocations; done means repeated calls produce stable, correct results without crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100