TensorBFS / OMEinsumContractionOrders.jl

Tensor network contraction order optimizers for OMEinsum
MIT License
25 stars 3 forks source link

Slicing #20

Closed GiggleLiu closed 2 years ago

GiggleLiu commented 2 years ago

Example

julia> using OMEinsumContractionOrders, OMEinsum

julia> code = ein"ij,jk,kl,lm->im"
ij, jk, kl, lm -> im

julia> optcode0 = optimize_code(code, uniformsize(code, 2), TreeSA(nslices=0))
SlicedEinsum{Char, NestedEinsum{OMEinsum.DynamicEinCode{Char}}}(Slicing{Char}(Char[]), ij, jm -> im
├─ jk, km -> jm
│  ├─ kl, lm -> km
│  │  ├─ lm
│  │  └─ kl
│  └─ jk
└─ ij
)

julia> timespace_complexity(optcode0, uniformsize(optcode0, 2))
(4.584962500721156, 2.0)

julia> optcode = optimize_code(code, uniformsize(code, 2), TreeSA(nslices=2))
SlicedEinsum{Char, NestedEinsum{OMEinsum.DynamicEinCode{Char}}}(Slicing{Char}(['l', 'i']), lm, li -> im
├─ jl, ij -> li
│  ├─ ij
│  └─ kl, jk -> jl
│     ├─ jk
│     └─ kl
└─ lm
)

julia> timespace_complexity(optcode, uniformsize(optcode, 2))
(5.0, 1.0)

@ChenZhao44, @brenjohn @kshyatt This feature can help you reduce the space complexity of your tensor networks.

codecov[bot] commented 2 years ago

Codecov Report

Merging #20 (601ed1d) into master (3edc0f8) will increase coverage by 0.22%. The diff coverage is 96.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #20      +/-   ##
==========================================
+ Coverage   95.14%   95.37%   +0.22%     
==========================================
  Files           6        7       +1     
  Lines         556      670     +114     
==========================================
+ Hits          529      639     +110     
- Misses         27       31       +4     
Impacted Files Coverage Δ
src/OMEinsumContractionOrders.jl 100.00% <ø> (ø)
src/interfaces.jl 100.00% <ø> (ø)
src/simplify.jl 94.82% <ø> (+0.09%) :arrow_up:
src/treesa.jl 93.46% <90.24%> (-1.03%) :arrow_down:
src/slicing.jl 98.82% <98.82%> (ø)
src/kahypar.jl 94.32% <100.00%> (+0.75%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3edc0f8...601ed1d. Read the comment docs.

GiggleLiu commented 2 years ago

Now I switched to the iterator interface. Since this PR changes the return type of TreeSA() optimizer (From NestedEinsum to SlicedEinsum), might break some packages depending on it. I will tag a new minor version.