Skip to content

Commit deb722d

Browse files
authored
Interface upadte: contraction complexity (#67)
* use `contraction_complexity` and deprecate `timespacereadwrite_complexity` * clean up pluto notebook building * bump version * update * fix-cuda onehot
1 parent 39fea47 commit deb722d

18 files changed

+78
-288
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GenericTensorNetworks"
22
uuid = "3521c873-ad32-4bb4-b63d-f4f178f42b49"
33
authors = ["GiggleLiu <cacate0129@gmail.com> and contributors"]
4-
version = "1.3.4"
4+
version = "1.3.5"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ GenericTensorNetworks = "3521c873-ad32-4bb4-b63d-f4f178f42b49"
55
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
66
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
77
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
8-
PlutoStaticHTML = "359b1769-a58e-495b-9770-312e911026ad"
98
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"

docs/make.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ using GenericTensorNetworks
33
using GenericTensorNetworks: TropicalNumbers, Polynomials, Mods, OMEinsum, OMEinsum.OMEinsumContractionOrders, LuxorGraphPlot
44
using Documenter
55
using DocThemeIndigo
6-
using PlutoStaticHTML
76
using Literate
87

98
for each in readdir(pkgdir(GenericTensorNetworks, "examples"))
@@ -14,22 +13,6 @@ for each in readdir(pkgdir(GenericTensorNetworks, "examples"))
1413
Literate.markdown(input_file, output_dir; name=each[1:end-3], execute=false)
1514
end
1615

17-
let
18-
"""Run all Pluto notebooks (".jl" files) in `notebook_dir` and write outputs to HTML files."""
19-
notebook_dir = joinpath(pkgdir(GenericTensorNetworks), "notebooks")
20-
target_dir = joinpath(pkgdir(GenericTensorNetworks), "docs", "src", "notebooks")
21-
cp(notebook_dir, target_dir; force=true)
22-
@info "Building tutorials"
23-
# Evaluate notebooks in the same process to avoid having to recompile from scratch each time.
24-
# This is similar to how Documenter and Franklin evaluate code.
25-
# Note that things like method overrides and other global changes may leak between notebooks!
26-
use_distributed = true
27-
output_format = documenter_output
28-
bopts = BuildOptions(target_dir; use_distributed, output_format)
29-
build_notebooks(bopts)
30-
return nothing
31-
end
32-
3316
indigo = DocThemeIndigo.install(GenericTensorNetworks)
3417
DocMeta.setdocmeta!(GenericTensorNetworks, :DocTestSetup, :(using GenericTensorNetworks); recursive=true)
3518

docs/src/performancetips.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ It can remove all vertex tensors (vectors) before entering the contraction order
2828

2929
The returned object `problem` contains a field `code` that specifies the tensor network with optimized contraction order.
3030
For an independent set problem, the optimal contraction time/space complexity is ``\sim 2^{{\rm tw}(G)}``, where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G``.
31-
One can check the time, space and read-write complexity with the [`timespacereadwrite_complexity`](@ref) function.
31+
One can check the time, space and read-write complexity with the [`contraction_complexity`](@ref) function.
3232

3333
```julia
34-
julia> timespacereadwrite_complexity(problem)
35-
(21.90683335864693, 17.0, 20.03588509836998)
34+
julia> contraction_complexity(problem)
35+
Time complexity (number of element-wise multiplications) = 2^20.568850503058382
36+
Space complexity (number of elements in the largest intermediate tensor) = 2^16.0
37+
Read-write complexity (number of element-wise read and write) = 2^18.70474460304404
3638
```
3739

3840
The return values are `log2` values of the number of multiplications, the number elements in the largest tensor during contraction and the number of read-write operations to tensor elements.
@@ -81,13 +83,17 @@ julia> graph = random_regular_graph(120, 3)
8183

8284
julia> problem = IndependentSet(graph; optimizer=TreeSA(βs=0.01:0.1:25.0, ntrials=10, niters=10));
8385

84-
julia> timespacereadwrite_complexity(problem)
85-
(20.856518235241687, 16.0, 18.88208476145812)
86+
julia> contraction_complexity(problem)
87+
Time complexity (number of element-wise multiplications) = 2^20.53277253647484
88+
Space complexity (number of elements in the largest intermediate tensor) = 2^16.0
89+
Read-write complexity (number of element-wise read and write) = 2^19.34699193791874
8690

8791
julia> problem = IndependentSet(graph; optimizer=TreeSA(βs=0.01:0.1:25.0, ntrials=10, niters=10, nslices=5));
8892

89-
julia> timespacereadwrite_complexity(problem)
90-
(21.134967710592804, 11.0, 19.84529401927876)
93+
julia> contraction_complexity(problem)
94+
Time complexity (number of element-wise multiplications) = 2^21.117277836449578
95+
Space complexity (number of elements in the largest intermediate tensor) = 2^11.0
96+
Read-write complexity (number of element-wise read and write) = 2^19.854965754099602
9197
```
9298

9399
In the second `IndependentSet` constructor, we slice over 5 degrees of freedom, which can reduce the space complexity by at most 5.

docs/src/ref.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ MergeGreedy
139139
show_graph
140140
show_gallery
141141
show_einsum
142-
spring_layout!
143142
144143
diagonal_coupled_graph
145144
square_lattice_graph

examples/DominatingSet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ problem = DominatingSet(graph; optimizer=TreeSA());
4242
# otherwise, if ``v`` is in ``D``, it has a contribution ``x_v^{w_v}`` to the final result.
4343
# One can check the contraction time space complexity of a [`DominatingSet`](@ref) instance by typing:
4444

45-
timespacereadwrite_complexity(problem)
45+
contraction_complexity(problem)
4646

4747
# ## Solving properties
4848

examples/IndependentSet.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ problem = IndependentSet(graph; optimizer=TreeSA());
5151
# where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G`` (or `graph` in the code).
5252
# We can check the time, space and read-write complexities by typing
5353

54-
timespacereadwrite_complexity(problem)
54+
contraction_complexity(problem)
5555

56-
# The three return values are `log2` values of the the number of element-wise multiplication operations, the number elements in the largest tensor during contraction and the number of tensor element read-write operations.
5756
# For more information about how to improve the contraction order, please check the [Performance Tips](@ref).
5857

5958
# ## Solution space properties

examples/MaximalIS.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ problem = MaximalIS(graph; optimizer=TreeSA());
4141
# Its contraction time space complexity of a [`MaximalIS`](@ref) instance is no longer determined by the tree-width of the original graph ``G``.
4242
# It is often harder to contract this tensor network than to contract the one for regular independent set problem.
4343

44-
timespacereadwrite_complexity(problem)
45-
46-
# Results are `log2` values.
44+
contraction_complexity(problem)
4745

4846
# ## Solving properties
4947

examples/SetCovering.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ problem = SetCovering(sets);
4242
# This tensor means if none of the sets containing element ``a`` are included, then this configuration is forbidden,
4343
# One can check the contraction time space complexity of a [`SetCovering`](@ref) instance by typing:
4444

45-
timespacereadwrite_complexity(problem)
45+
contraction_complexity(problem)
4646

4747
# ## Solving properties
4848

examples/SetPacking.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ problem = SetPacking(sets);
4343
# This tensor means if in a configuration, two sets contain the element ``a``, then this configuration is forbidden,
4444
# One can check the contraction time space complexity of a [`SetPacking`](@ref) instance by typing:
4545

46-
timespacereadwrite_complexity(problem)
46+
contraction_complexity(problem)
4747

4848
# ## Solving properties
4949

0 commit comments

Comments
 (0)