Make `unsafe_free!` work with nested tuples
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Julia
- Stars
- 1.4k
- Forks
- 281
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 30
Description
DL packages like Lux use nested named tuples to store parameter and state vectors. It would be good to allow CUDA.unsafe_free! to work on something like the MWE below.
julia> nt = (; a = CUDA.ones(4))
(a = Float32[1.0, 1.0, 1.0, 1.0],)
julia> nt = (; a = CUDA.ones(4), nt)
(a = Float32[1.0, 1.0, 1.0, 1.0], nt = (a = Float32[1.0, 1.0, 1.0, 1.0],))
julia> CUDA.unsafe_free!(nt)
ERROR: MethodError: no method matching unsafe_free!(::NamedTuple{(:a, :nt), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, NamedTuple{(:a,), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}}})
Closest candidates are:
unsafe_free!(::CuArray)
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 from the existing unsafe_free!(::CuArray) method shown in the issue and reproduce the nested NamedTuple MWE in a Julia CUDA.jl environment. Trace how unsafe_free! handles supported values, then verify that the example and deeper nested named tuples are freed without the reported MethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- hpc
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100