Character limit on Tags raises issue when creating large, high-dimensional networks.
JoeyT1994 opened this issue · 5 comments
E.g.
using ITensors
using ITensorNetworks
L = 12
g = named_grid((L, L, L))
s = siteinds("S=1/2", g)
psi = randomITensorNetwork(s; link_space = 2)
Fails (for L > 10) with the error:
Which presumably is a limit imposed by ITensors.jl
. @emstoudenmire , @mtfishman Will this need to be changed in ITensors.jl
or is there a way to override the limit in ITensorNetworks.jl
? If there is a fundamental reason for the limit, we will probably need to catch the error and then force an integer site labelling (1, 2, ... L*L*L
)
The reason for the limit is to try to make sure all operations with tags (construction, comparison, etc.) are as fast as possible (of course, 16 is arbitrary, but we need to choose a cutoff somewhere since we are using fixed-size strings so they are cache allocated). What do the tags look like for those higher dimensional lattices? Maybe we can just come up with an alternative that doesn't go all the way to using integer labels.
I see, it is the edge/link tags that are the issue, which can get quite long:
julia> length("10×10×10↔10×10×10")
17
We already increased the tag length to 16 in ITensor/ITensors.jl#882. We could try going to 32 with the same kind of change and see if there are any performance implications (we would go up by a factor of 2 since the tags are actually represented internally as large integers using the package https://github.com/rfourquet/BitIntegers.jl, and we would change from UInt256
that were introduced in ITensor/ITensors.jl#882 to UInt512
which is also available in that package). I would guess that 32
would be hard to reach if we changed to that.
Another alternative is to split those long edge tags into two tags, i.e. "v1=10×10×10,v2=10×10×10
, which would represent the incident vertices of the edge.
@JoeyT1994 I guess this is still an issue? I think in the end the simplest solution for this case is just to split the edge tag into two tags, so change:
https://github.com/mtfishman/ITensorNetworks.jl/blob/611db6ce7e773bf3d6c6cabbc8482da0688f2dee/src/indextags.jl#L14-L16
from:
function edge_tag(e)
return "$(vertex_tag(src(e)))↔$(vertex_tag(dst(e)))"
end
to:
function edge_tag(e)
return ts"$(vertex_tag(src(e))),$(vertex_tag(dst(e)))"
end
so link indices would have (multiple) tags "10×10×10,10×10×10"
instead of "10×10×10↔10×10×10"
. Also we should change the name of that function to edge_tags
since it will output multiple tags, to be more accurate.
Yeah this is still an issue. Okay great, that sounds like a good fix. I will make a PR for that change.