Fix isbits type support for GPU device transfer#1587
Conversation
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
🧪 CI InsightsHere's what we observed from your CI run for 6cd1e8e. 🟢 All jobs passed!But CI Insights is watching 👀 |
| function array_adapt( | ||
| f::F, ::Type{aType}, ::Type{Missing}, x::AbstractArray{T} | ||
| ) where {F,aType,T} | ||
| isbitstype(T) || error( | ||
| "Cannot move array with element type `$(T)` to device. Element type must be an " * | ||
| "`isbits` type (e.g., Number, Char, or custom immutable struct with only " * | ||
| "`isbits` fields).", | ||
| ) | ||
| return f(x) | ||
| end |
There was a problem hiding this comment.
@copilot Number/AbstractChar are isbitstype, we can remove the old dispatches
There was a problem hiding this comment.
Removed the redundant dispatches for Number and AbstractChar types. They're now handled by the fallback methods since they're isbits types. Kept only the specialized methods for AbstractFloat and Complex{<:AbstractFloat} for type conversion. (commit 0ae7ae4)
Number and AbstractChar are isbits types and are now handled by the
fallback methods. Only AbstractFloat and Complex{<:AbstractFloat} keep
specialized methods for type conversion when a specific type parameter
is provided.
Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Added explicit methods for Missing and Nothing type parameters with AbstractFloat and Complex arrays to avoid method ambiguity with the general isbits fallback. This maintains full backward compatibility including type conversion for any type parameter with float arrays. Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
Clarified that specialized methods for AbstractFloat/Complex are for avoiding ambiguity and enabling type conversion, and improved fallback comment to use concrete type examples (Int32) instead of abstract types (Number) to avoid confusion. Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
lib/MLDataDevices/src/internal.jl
Outdated
| "Cannot move array with element type `$(T)` to device. Element type must be an " * | ||
| "`isbits` type (e.g., Number, Char, or custom immutable struct with only " * | ||
| "`isbits` fields).", |
Benchmark Results (Julia v1.11)Time benchmarks
Memory benchmarks
|
Replace string concatenation operator (*) with backslash line continuation (\) in error messages for better Julia style. Co-authored-by: avik-pal <30564094+avik-pal@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Plan to fix isbits types movement to GPU
array_adaptimplementation ininternal.jlisbitstypes inarray_adaptisbitstypes movementOriginal prompt
isbitstypes movement #1586💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.