ITensor / NDTensors.jl

A Julia package for n-dimensional sparse tensors.
Apache License 2.0
27 stars 7 forks source link

Small threading bug #63

Closed mtfishman closed 3 years ago

mtfishman commented 3 years ago

This fixes a bug in the multithreaded block sparse code when a block sparse contraction doesn't result in any viable blocks, for example, something like:

using ITensors

i = Index([QN(0) => 1, QN(1) => 1])
A = emptyITensor(i', dag(i))
B = emptyITensor(i', dag(i))
A[i' => 1, i => 1] = 11.0
B[i' => 2, i => 2] = 22.0

using_threaded_blocksparse = ITensors.disable_threaded_blocksparse()
C1 = A' * B
ITensors.enable_threaded_blocksparse()
C2 = A' * B
if using_threaded_blocksparse
  ITensors.enable_threaded_blocksparse()
else
  ITensors.disable_threaded_blocksparse()
end

This showed up in a very particular DMRG calculation (2D Hubbard model conserving spin and particle number, with the Hamiltonian modified by splitblocks and using multithreading over blocks). It only showed up in the multithreading code since the serial code automatically handled this special case.