Skip to content
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

[NDTensors] [BUG] DiagBlockSparse * DiagBlockSparse contraction broken #1079

Open
mtfishman opened this issue Feb 28, 2023 · 1 comment
Open
Labels
bug Something isn't working NDTensors Requires changes to the NDTensors.jl library.

Comments

@mtfishman
Copy link
Member

Description of bug

julia> s = [QN(0) => 1, QN(1) => 1];

julia> i, j, k = Index.((s, s, s));

julia> t1 = δ(i, dag(j));

julia> t2 = δ(j, dag(k));

julia> t1 * t2
ERROR: UndefVarError: IndsR not defined
Stacktrace:
  [1] contraction_output_type(TensorT1::Type{NDTensors.DiagBlockSparseTensor{Float64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.DiagBlockSparse{Float64, Float64, 2}}}, TensorT2::Type{NDTensors.DiagBlockSparseTensor{Float64, 2, Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}}, NDTensors.DiagBlockSparse{Float64, Float64, 2}}}, indsR::Tuple{Index{Vector{Pair{QN, Int64}}}, Index{Vector{Pair{QN, Int64}}}})
    @ NDTensors ~/.julia/dev/ITensors/NDTensors/src/blocksparse/diagblocksparse.jl:278
[...]

This is with NDTensors v0.1.49 and is a regression caused by #1051, which means that this operation wasn't be tested properly (and should be tested in NDTensors). @kmp5VT I can look into this one.

@mtfishman mtfishman added bug Something isn't working NDTensors Requires changes to the NDTensors.jl library. labels Feb 28, 2023
@mtfishman mtfishman assigned mtfishman and unassigned mtfishman Feb 28, 2023
@mtfishman
Copy link
Member Author

This is a bit more involved then I expected, and ultimately would be made much easier by making BlockSparse and DiagBlockSparse more generic by sharing more code. I think we should be able to combine them into a single parametrized type, parametrized by the storage type of the blocks. So I'll leave this one open, for now people can use:

julia> @show denseblocks(t1) * denseblocks(t2);
denseblocks(t1) * denseblocks(t2) = ITensor ord=2
Dim 1: (dim=2|id=584) <Out>
 1: QN(0) => 1
 2: QN(1) => 1
Dim 2: (dim=2|id=9) <In>
 1: QN(0) => 1
 2: QN(1) => 1
NDTensors.BlockSparse{Float64, Vector{Float64}, 2}
 2×2
Block(1, 1)
 [1:1, 1:1]
 1.0

Block(2, 2)
 [2:2, 2:2]
 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working NDTensors Requires changes to the NDTensors.jl library.
Projects
None yet
Development

No branches or pull requests

1 participant