Skip to content

Conversation

@kshyatt
Copy link
Member

@kshyatt kshyatt commented Dec 8, 2025

This splits off basic support for CUDA tensor maps from #320, and doesn't cover Diagonals or factorizations at all. I made some modifications to things in src to make them a little more generic also. Some things aren't working yet:

  • converting from an AdjointTensorMap of a CuTensorMap to a CuTensorMap of a different scalar type
  • converting to a CuArray
  • the hasfusiontensor(I) tests
  • diag/diagm
  • index flipping

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic main) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/tensors/tensor.jl b/src/tensors/tensor.jl
index e60d4d9..6946796 100644
--- a/src/tensors/tensor.jl
+++ b/src/tensors/tensor.jl
@@ -316,15 +316,15 @@ end
 
 for randf in (:rand, :randn, :randexp, :randisometry)
     _docstr = """
-        $randf([rng=default_rng()], [TorA=Float64], codomain::ProductSpace{S,N₁},
-                 domain::ProductSpace{S,N₂}) where {S,N₁,N₂,T} -> t
-        $randf([rng=default_rng()], [TorA=Float64], codomain ← domain) -> t
+            $randf([rng=default_rng()], [TorA=Float64], codomain::ProductSpace{S,N₁},
+                     domain::ProductSpace{S,N₂}) where {S,N₁,N₂,T} -> t
+            $randf([rng=default_rng()], [TorA=Float64], codomain ← domain) -> t
         
     Generate a tensor `t` with entries generated by `$randf`.
-    The type `TorA` can be used to control the element type and
-    data type generated. For example, if `TorA` is a `CuVector{ComplexF32}`
-    or `ROCVector{Float64}`, then the final output `TensorMap` will have
-    that as its storage type.
+        The type `TorA` can be used to control the element type and
+        data type generated. For example, if `TorA` is a `CuVector{ComplexF32}`
+        or `ROCVector{Float64}`, then the final output `TensorMap` will have
+        that as its storage type.
 
     See also [`Random.$(randf)!`](@ref).
     """

@kshyatt kshyatt force-pushed the ksh/cuda_small branch 2 times, most recently from 01278bc to b8254e2 Compare December 8, 2025 20:47
@lkdvos
Copy link
Member

lkdvos commented Dec 9, 2025

I kind of failed to realize that fusiontensor(a, b, c) always returns arrays so these convert(Array, t) based methods are a bit more painful than expected. It might be reasonable to consider testing the GPU methods by comparing to the CPU implementations rather than comparing to the Array implementations?

@kshyatt
Copy link
Member Author

kshyatt commented Dec 9, 2025

I think I have them mostly working now, actually... let me push in a moment

Jutho referenced this pull request Dec 9, 2025
* initial basic design SectorVector

* some additional functionality

* relax `foreachblock` signature

* replace `SectorDict` with `SectorVector` for eig/svdvals

* export `svd_vals`

* clean up SectorVector design

* small fix

* add finitedifferences support

* update changelog

* some simplifications and extensions

* some further fixes

* some more fixes

* update dates

---------

Co-authored-by: Jutho Haegeman <jutho.haegeman@ugent.be>
@kshyatt kshyatt force-pushed the ksh/cuda_small branch 5 times, most recently from 7f2ba7d to bc33c50 Compare December 12, 2025 15:08
@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 71.15385% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ext/TensorKitCUDAExt/cutensormap.jl 62.50% 27 Missing ⚠️
src/tensors/tensor.jl 86.36% 3 Missing ⚠️
Files with missing lines Coverage Δ
ext/TensorKitCUDAExt/TensorKitCUDAExt.jl 100.00% <100.00%> (ø)
src/tensors/linalg.jl 82.33% <100.00%> (-0.37%) ⬇️
src/tensors/tensor.jl 85.31% <86.36%> (+0.01%) ⬆️
ext/TensorKitCUDAExt/cutensormap.jl 62.50% <62.50%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kshyatt kshyatt force-pushed the ksh/cuda_small branch 2 times, most recently from a4d32fc to 677f4af Compare December 17, 2025 10:43
@Jutho
Copy link
Member

Jutho commented Dec 17, 2025

Haven't looked at the tests in detail yet, but certainly looks very good already.

@kshyatt
Copy link
Member Author

kshyatt commented Dec 17, 2025

Re the tests, they are mostly copied from the CPU tensors tests. I have added a few to test CUDA specific code paths and to test conversion to/from CPU based TensorMap. Some tests do not work yet (the basic linear algebra ones, sylvester) because some of the functionality isn't yet supported on CUDA.

@kshyatt kshyatt force-pushed the ksh/cuda_small branch 2 times, most recently from bcbe1eb to 2c6af42 Compare December 18, 2025 10:51
@kshyatt
Copy link
Member Author

kshyatt commented Dec 18, 2025

OK I think I've responded to everything 🧐

@kshyatt
Copy link
Member Author

kshyatt commented Dec 19, 2025

I can't get the format issue to appear locally...

@kshyatt
Copy link
Member Author

kshyatt commented Dec 22, 2025

OK, is there anything else this needs besides #333 and somehow fixing the format check?

lkdvos
lkdvos previously approved these changes Dec 23, 2025
Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for my remaining question about the convert, and the comment about the tagged MatrixAlgebraKit version, I'm happy to merge this.

As always, thanks for the enormous amount of work (and patience), much appreciated!

Comment on lines 319 to 327
$randf([rng=default_rng()], [TorA=Float64], codomain::ProductSpace{S,N₁},
domain::ProductSpace{S,N₂}) where {S,N₁,N₂,T} -> t
$randf([rng=default_rng()], [T=Float64], codomain ← domain) -> t
$randf([rng=default_rng()], [TorA=Float64], codomain ← domain) -> t
Generate a tensor `t` with entries generated by `$randf`.
The type `TorA` can be used to control the element type and
data type generated. For example, if `TorA` is a `CuVector{ComplexF32}`
or `ROCVector{Float64}`, then the final output `TensorMap` will have
that as its storage type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like there might be some slight indenting issues?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was me fighting with the formatter

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.

4 participants