ITensor / ITensorNetworks.jl

A package with general tools for working with higher-dimensional tensor networks based on ITensor.
MIT License
56 stars 12 forks source link

Better functionality for partitioned tensor networks/graphs #87

Closed mtfishman closed 5 months ago

mtfishman commented 1 year ago

For example, something we want to do is be able to flatten a doubly-partitioned tensor network into a singly-partitioned tensor network:

julia> tn = randomITensorNetwork(named_grid((4, 4)); link_space=2);

julia> tnp = partition(tn; npartitions=2);

julia> tnpp = partition(tnp; npartitions=2);

julia> tnp2 = DataGraph(underlying_graph(tnpp), map(tnp -> reduce(⊗, vertex_data(tnp)), vertex_data(tnpp)));

julia> tnp2[1] == tnp[1]
true

julia> tnp2[2] == tnp[2]
true

It would be nice to define a function that flattens a partitioned ITensorNetwork:

ITensorNetwork(partitioned_tn::DataFraph{<:Any,ITensorNetwork}) = reduce(⊗, vertex_data(partitioned_tn))

and then make sure map_vertex_data works for this case (which currently errors if the vertex data type changes), so we can do:

map_vertex_data(ITensorNetwork, tnpp) 

Other ideas would be to define a PartitionedITensorNetwork so we can dispatch on that type:

const PartitionedITensorNetwork{V} = DataGraph{V,<:ITensorNetwork}

and distinguish between singly-partitioned vs. more nested partitionings. Having a function that flattens nested partitioned network into a single ITensorNetwork would be helpful as well.

A related function we have for dealing with nested partitioned tensor networks is nested_graph_leaf_vertices, which works like this:

vertex_groups = nested_graph_leaf_vertices(tnpp)

for finding groups of vertices but maybe the API should be rethought since it's a confusing name.

mtfishman commented 1 year ago

Another idea would be to add a way to call partition and specify that you want to make sure that certain vertices are grouped together. An interface could be:

julia> tn = randomITensorNetwork(named_grid((4, 4)); link_space=2);

julia> tnp = partition(tn; npartitions=2, group_vertices=[[(1, 1), (2, 1)], [(3, 4), (4, 4)]]);

to make sure that vertices (1, 1), (2, 1) are grouped together and [(3, 4), (4, 4)] are grouped together. This could be implemented by first partitioning the graph according to the grouping (treating unspecified vertices as groups of 1), partitioning that partitioned graph, and then regrouping based on the functionality in the first post of this issue.

mtfishman commented 5 months ago

Closed by #126.