Enzyme/AMDGPU function without sub-tapes
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 344
- Forks
- 79
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 27
Description
@wsmoses @michel2323
While trying to look into the compilation times of Enzyme, I was on my laptop where I can only use AMDGPU.
Besides running into https://github.com/EnzymeAD/Enzyme.jl/issues/2478 and I also encountered
ERROR: LoadError: AssertionError: ROCArray only supports bits types
Stacktrace:
[1] ROCArray{nothing, 1, AMDGPU.Runtime.Mem.HIPBuffer}(::UndefInitializer, dims::Tuple{Int64})
@ AMDGPU ~/.julia/packages/AMDGPU/IDGfT/src/array.jl:7
[2] (ROCArray{nothing, 1})(::UndefInitializer, dims::Tuple{Int64})
@ AMDGPU ~/.julia/packages/AMDGPU/IDGfT/src/array.jl:70
[3] (ROCArray{nothing})(::UndefInitializer, dims::UInt32)
@ AMDGPU ~/.julia/packages/AMDGPU/IDGfT/src/array.jl:88
[4] #augmented_primal#25
@ ~/.julia/packages/AMDGPU/IDGfT/ext/AMDGPUEnzymeCoreExt/AMDGPUEnzymeCoreExt.jl:203
[5] augmented_primal
@ ~/.julia/packages/AMDGPU/IDGfT/ext/AMDGPUEnzymeCoreExt/AMDGPUEnzymeCoreExt.jl:181 [inlined]
MWE:
using AMDGPU
using Enzyme
function square_kernel!(x)
i = workitemIdx().x
x[i] *= x[i]
sync_workgroup()
return nothing
end
# basic squaring on GPU
function square!(x)
@roc gridsize = length(x) groupsize = length(x) square_kernel!(x)
return nothing
end
A = AMDGPU.ones(64)
dA = AMDGPU.ones(64)
@time square!(A)
A .= (1:1:64)
dA .= 1
@time Enzyme.autodiff(Reverse, square!, Duplicated(A, dA))
@show dA
@assert all(dA .≈ (2:2:128))
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MWE and the augmented_primal stack frames at AMDGPUEnzymeCoreExt.jl:181 and :203. Reproduce the ROCArray assertion on AMDGPU, then trace how Enzyme.autodiff reaches augmented_primal. Done means the MWE completes without the assertion and the final dA values satisfy the shown assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100