-
Notifications
You must be signed in to change notification settings - Fork 269
Wrapper for Blocksparse CuTensor code #3057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kmp5VT
wants to merge
20
commits into
JuliaGPU:master
Choose a base branch
from
kmp5VT:kmp5/feature/wrap_blocksparse_cutensor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c4918d5
Working on implementing the wrapper for the new blocksparse cutensor …
kmp5VT c15fea2
Revert to cutensor_jll.libcutensor as this has the blocksparse cutens…
kmp5VT 82752ad
Remove redudant convert function
kmp5VT 9678ecf
Merge branch 'JuliaGPU:master' into kmp5/feature/wrap_blocksparse_cut…
kmp5VT affc3d4
Make blocksparse code more generic (generic case). Would it be better…
kmp5VT a3a3f07
Merge branch 'master' into kmp5/feature/wrap_blocksparse_cutensor
kmp5VT 67013c8
Merge branch 'kmp5/feature/wrap_blocksparse_cutensor' of github.com:k…
kmp5VT f6f5c5f
Merge branch 'JuliaGPU:master' into kmp5/feature/wrap_blocksparse_cut…
kmp5VT 1ec69cf
Working on simplyfying and making accessors
kmp5VT 8f5ef88
Fix problem with stride
kmp5VT 9285b07
Small comment reminder
kmp5VT cda4a4e
Add a contraction test for the blocksparse system (not comprehensive …
kmp5VT 94b8152
Merge branch 'master' into kmp5/feature/wrap_blocksparse_cutensor
kmp5VT 138edaf
Closer to clang.jl construction
kmp5VT ce2eeec
Merge branch 'kmp5/feature/wrap_blocksparse_cutensor' of github.com:k…
kmp5VT 3c11bec
Merge branch 'master' into kmp5/feature/wrap_blocksparse_cutensor
kmp5VT cc4b826
Update cutensor.toml for block sparse contraction
kshyatt 3316f63
Merge branch 'master' into kmp5/feature/wrap_blocksparse_cutensor
kmp5VT c493659
Apply suggestion from @lkdvos
kmp5VT f6fb806
Merge branch 'JuliaGPU:master' into kmp5/feature/wrap_blocksparse_cut…
kmp5VT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,66 @@ | ||
| # interfacing with other packages | ||
|
|
||
| ## Base | ||
|
|
||
| # function Base.:(+)(A::CuTensor, B::CuTensor) | ||
| # α = convert(eltype(A), 1.0) | ||
| # γ = convert(eltype(B), 1.0) | ||
| # C = similar(B) | ||
| # elementwise_binary_execute!(α, A.data, A.inds, CUTENSOR_OP_IDENTITY, | ||
| # γ, B.data, B.inds, CUTENSOR_OP_IDENTITY, | ||
| # C.data, C.inds, CUTENSOR_OP_ADD) | ||
| # C | ||
| # end | ||
|
|
||
| # function Base.:(-)(A::CuTensor, B::CuTensor) | ||
| # α = convert(eltype(A), 1.0) | ||
| # γ = convert(eltype(B), -1.0) | ||
| # C = similar(B) | ||
| # elementwise_binary_execute!(α, A.data, A.inds, CUTENSOR_OP_IDENTITY, | ||
| # γ, B.data, B.inds, CUTENSOR_OP_IDENTITY, | ||
| # C.data, C.inds, CUTENSOR_OP_ADD) | ||
| # C | ||
| # end | ||
|
|
||
| ## For now call contract in ITensor and rely on UnallocatedArrays to make | ||
| ## C in a dry-run of the contraction. | ||
| # function Base.:(*)(A::CuTensorBS, B::CuTensorBs) | ||
| # tC = promote_type(eltype(A), eltype(B)) | ||
| # A_uniqs = [(idx, i) for (idx, i) in enumerate(A.inds) if !(i in B.inds)] | ||
| # B_uniqs = [(idx, i) for (idx, i) in enumerate(B.inds) if !(i in A.inds)] | ||
| # A_sizes = map(x->size(A,x[1]), A_uniqs) | ||
| # B_sizes = map(x->size(B,x[1]), B_uniqs) | ||
| # A_inds = map(x->x[2], A_uniqs) | ||
| # B_inds = map(x->x[2], B_uniqs) | ||
| # C = CuTensor(CUDA.zeros(tC, Dims(vcat(A_sizes, B_sizes))), vcat(A_inds, B_inds)) | ||
| # return mul!(C, A, B) | ||
| # end | ||
|
|
||
|
|
||
| ## LinearAlgebra | ||
|
|
||
| using LinearAlgebra | ||
|
|
||
| # function LinearAlgebra.axpy!(a, X::CuTensor, Y::CuTensor) | ||
| # elementwise_binary_execute!(a, X.data, X.inds, CUTENSOR_OP_IDENTITY, | ||
| # one(eltype(Y)), Y.data, Y.inds, CUTENSOR_OP_IDENTITY, | ||
| # Y.data, Y.inds, CUTENSOR_OP_ADD) | ||
| # return Y | ||
| # end | ||
|
|
||
| # function LinearAlgebra.axpby!(a, X::CuTensor, b, Y::CuTensor) | ||
| # elementwise_binary_execute!(a, X.data, X.inds, CUTENSOR_OP_IDENTITY, | ||
| # b, Y.data, Y.inds, CUTENSOR_OP_IDENTITY, | ||
| # Y.data, Y.inds, CUTENSOR_OP_ADD) | ||
| # return Y | ||
| # end | ||
|
|
||
| function LinearAlgebra.mul!(C::CuTensorBS, A::CuTensorBS, B::CuTensorBS, α::Number, β::Number) | ||
| contract!(α, | ||
| A, A.inds, CUTENSOR_OP_IDENTITY, | ||
| B, B.inds, CUTENSOR_OP_IDENTITY, | ||
| β, | ||
| C, C.inds, CUTENSOR_OP_IDENTITY, | ||
| CUTENSOR_OP_IDENTITY; jit=CUTENSOR_JIT_MODE_DEFAULT) | ||
| return C | ||
| end | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.