Skip to content

Fix derived CuTracedArray construction in ReactantCUDAExt - #3205

Draft
ptiede with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-derived-array-not-found
Draft

ptiede with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-derived-array-not-found

Conversation

Copilot AI commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

ReactantCUDAExt still referenced CUDA-internal derived-array helpers that do not exist for CuTracedArray. As a result, reshaping traced CUDA arrays in compiled kernels could fail on an undefined _derived_array path.

  • Derived CuTracedArray reconstruction

    • add a raw-pointer constructor for CuTracedArray
    • add a local _derived_array helper that rebuilds traced CUDA arrays from the existing pointer plus the new shape encoded in the type parameters
  • Remove stale CUDA leftovers from reshape/reinterpret

    • route Base.reshape through the local derived-array helper
    • update Base.reinterpret to use the same reconstruction path instead of accessing CUDA CuDeviceArray fields that CuTracedArray does not have
  • Regression coverage

    • add a CUDA integration test that reshapes a traced array inside an @cuda kernel and checks a value that depends on Julia’s column-major reshape semantics
function reshape_kernel!(out, x)
    xr = reshape(x, 2, 2)
    @inbounds out[1] = xr[1, 2]
    return nothing
end

Copilot AI and others added 2 commits August 20, 2026 17:54
Co-authored-by: ptiede <5565461+ptiede@users.noreply.github.com>
Co-authored-by: ptiede <5565461+ptiede@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix derived array not found in CUDAExt Fix derived CuTracedArray construction in ReactantCUDAExt Aug 20, 2026
Copilot AI requested a review from ptiede August 20, 2026 17:55
@ptiede

ptiede commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@copilot can we not just use the _derived_array from CUDA.jl directly?

Co-authored-by: ptiede <5565461+ptiede@users.noreply.github.com>

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot can we not just use the _derived_array from CUDA.jl directly?

Yes — I switched this to use CUDA._derived_array when that helper exists, with a guarded import so the extension still loads if the symbol is absent. Addressed in adc7e6b.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Derived array not found in CUDAExt

2 participants