Skip to content

More graceful way of using CuTensorMap #354

Open

Description

@kshyatt
const CUDAExt = Base.get_extension(TensorKit, :TensorKitCUDAExt)
@assert !isnothing(CUDAExt)
const CuTensorMap = getglobal(CUDAExt, :CuTensorMap)

This is awful!!!

What if instead, we defined CuTensorMap in src/TensorKit.jl but made it MethodError unless the extension is loaded (which would then provide the actual constructors).

Activity

  1. lkdvos commented on Jan 20, 2026

    @lkdvos
    Member

    I completely agree, but there is actually no way to define a type alias like that in the main package. Do you know in what context you want to use this? Maybe we can provide alternative interfaces to circumvent needing CuTensorMap directly?

  2. kshyatt commented on Jan 20, 2026

    @kshyatt
    MemberAuthor

    The struct definition we may not be able to put in the main package, I agree, but we could add the wrapper constructors like CuTensorMap(::TensorMap) etc.

  3. lkdvos commented on Jan 20, 2026

    @lkdvos
    Member

    Isn't that what adapt(CuArray, t::TensorMap) is supposed to do? We can also add CUDA.cu(::TensorMap) as well

  4. kshyatt commented on Jan 20, 2026

    @kshyatt
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions