-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial buildkite script * Dummy message * Tweak pipeline * Tweak * Tweak * Fix * Tidy up labelling * Add Adapt ext and CUDA + Adapt test-time deps * CUDA ext * Remove Adapt-specific stuff * Fix issues * More perf stuff * Basic CUDA functionality * Bump compat
- Loading branch information
1 parent
2e56d20
commit c75c08d
Showing
6 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
steps: | ||
- label: "Julia v1" | ||
plugins: | ||
- JuliaCI/julia#v1: | ||
version: "1" | ||
- JuliaCI/julia-test#v1: ~ | ||
- JuliaCI/julia-coverage#v1: | ||
codecov: true | ||
agents: | ||
queue: "juliagpu" | ||
cuda: "*" | ||
if: build.message !~ /\[skip tests\]/ | ||
timeout_in_minutes: 60 | ||
env: | ||
TEST_GROUP: "gpu" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module TapirCUDAExt | ||
|
||
using LinearAlgebra, Random, Tapir | ||
|
||
using Base: IEEEFloat | ||
using CUDA: CuArray, cu | ||
|
||
import Tapir: | ||
MinimalCtx, | ||
rrule!!, | ||
@is_primitive, | ||
tangent_type, | ||
zero_tangent, | ||
randn_tangent, | ||
increment!!, | ||
set_to_zero!!, | ||
_add_to_primal, | ||
_diff, | ||
_dot, | ||
_scale, | ||
TestUtils, | ||
CoDual, | ||
NoPullback | ||
|
||
import Tapir.TestUtils: populate_address_map!, AddressMap, __increment_should_allocate | ||
|
||
# Tell Tapir.jl how to handle CuArrays. | ||
|
||
tangent_type(::Type{P}) where {P<:CuArray{<:IEEEFloat}} = P | ||
zero_tangent(x::CuArray{<:IEEEFloat}) = zero(x) | ||
function randn_tangent(rng::AbstractRNG, x::CuArray{Float32}) | ||
return cu(randn(rng, Float32, size(x)...)) | ||
end | ||
TestUtils.has_equal_data(x::P, y::P) where {P<:CuArray{<:IEEEFloat}} = x == y | ||
increment!!(x::P, y::P) where {P<:CuArray{<:IEEEFloat}} = x .+= y | ||
__increment_should_allocate(::Type{<:CuArray{<:IEEEFloat}}) = true | ||
set_to_zero!!(x::CuArray{<:IEEEFloat}) = x .= 0 | ||
_add_to_primal(x::P, y::P) where {P<:CuArray{<:IEEEFloat}} = x + y | ||
_diff(x::P, y::P) where {P<:CuArray{<:IEEEFloat}} = x - y | ||
_dot(x::P, y::P) where {P<:CuArray{<:IEEEFloat}} = Float64(dot(x, y)) | ||
_scale(x::Float64, y::P) where {T<:IEEEFloat, P<:CuArray{T}} = T(x) * y | ||
function populate_address_map!(m::AddressMap, p::CuArray, t::CuArray) | ||
k = pointer_from_objref(p) | ||
v = pointer_from_objref(t) | ||
haskey(m, k) && (@assert m[k] == v) | ||
m[k] = v | ||
return m | ||
end | ||
|
||
# Basic rules for operating on CuArrays. | ||
|
||
@is_primitive( | ||
MinimalCtx, | ||
Tuple{Type{<:CuArray}, UndefInitializer, Vararg{Int, N}} where {N}, | ||
) | ||
function rrule!!( | ||
p::CoDual{Type{P}}, | ||
init::CoDual{UndefInitializer}, | ||
dims::CoDual{Int}... | ||
) where {P<:CuArray{<:Base.IEEEFloat}} | ||
_dims = map(primal, dims) | ||
y = CoDual(P(undef, _dims), P(undef, _dims)) | ||
return y, NoPullback(p, init, dims...) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using CUDA | ||
|
||
@testset "cuda" begin | ||
|
||
# Check we can operate on CuArrays. | ||
test_tangent( | ||
Xoshiro(123456), | ||
CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}(undef, 8, 8); | ||
interface_only=false, | ||
) | ||
|
||
# Check we can instantiate a CuArray. | ||
interp = Tapir.TapirInterpreter() | ||
TestUtils.test_derived_rule( | ||
sr(123456), CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, undef, 256; | ||
interp, perf_flag=:none, interface_only=true, is_primitive=true, | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c75c08d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
c75c08d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/107306
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: