You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ This package implements generic tensor networks to compute *solution space prope
8
8
The *solution space properties* include
9
9
* The maximum/minimum solution sizes,
10
10
* The number of solutions at certain sizes,
11
-
* The enumeration of solutions at certian sizes.
12
-
* The direct sampling of solutions at certian sizes.
11
+
* The enumeration of solutions at certain sizes.
12
+
* The direct sampling of solutions at certain sizes.
13
13
14
14
The solvable problems include [Independent set problem](@ref), [Maximal independent set problem](@ref), [Cutting problem (Spin-glass problem)](@ref), [Vertex matching problem](@ref), [Binary paint shop problem](@ref), [Coloring problem](@ref), [Dominating set problem](@ref), [Set packing problem](@ref) and [Set covering problem](@ref).
The [`IndependentSet`](@ref) constructor maps a independent set problem to a tensor network with optimized contraction order.
16
+
The [`IndependentSet`](@ref) constructor maps an independent set problem to a tensor network with optimized contraction order.
17
17
The key word argument `optimizer` specifies the contraction order optimizer of the tensor network.
18
-
Here, we choose the local search based [`TreeSA`](@ref) algorithm,
19
-
which is one of the state of the art contraction order optimizer detailed in [arXiv: 2108.05665](https://arxiv.org/abs/2108.05665).
20
-
One can type `?TreeSA` in a Julia REPL for more information about how to configure the hyper-parameters of the `TreeSA` method.
21
-
Alternative tensor network contraction orders optimizers include
18
+
Here, we choose the local search based [`TreeSA`](@ref) algorithm, which often finds the smallest time/space complexity and supports slicing.
19
+
One can type `?TreeSA` in a Julia REPL for more information about how to configure the hyper-parameters of the [`TreeSA`](@ref) method,
20
+
while the detailed algorithm explanation is in [arXiv: 2108.05665](https://arxiv.org/abs/2108.05665).
21
+
Alternative tensor network contraction order optimizers include
22
22
*[`GreedyMethod`](@ref) (default, fastest in searching speed but worst in contraction complexity)
23
-
*[`TreeSA`](@ref) (often best in contraction complexity, supports slicing)
24
23
*[`KaHyParBipartite`](@ref)
25
24
*[`SABipartite`](@ref)
26
25
27
-
The keyword argument `simplifier`is for preprocessing sub-routine to improve the searching speed of the contraction order finding.
26
+
The keyword argument `simplifier`specifies the preprocessor to improve the searching speed of the contraction order finding.
28
27
For example, the `MergeGreedy()` here "contracts" tensors greedily whenever the contraction result has a smaller space complexity.
29
28
It can remove all vertex tensors (vectors) before entering the contraction order optimization algorithm.
30
29
31
-
The returned instance `problem` contains a field `code` that specifies the tensor network contraction order. For an independent set problem, its contraction time space complexity is ``2^{{\rm tw}(G)}``, where ``{\rm tw(G)}`` is the [tree-width](https://en.wikipedia.org/wiki/Treewidth) of ``G``.
32
-
One can check the time, space and read-write complexity with the following function.
30
+
The returned object `problem` contains a field `code` that specifies the tensor network with optimized contraction order.
31
+
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``.
32
+
One can check the time, space and read-write complexity with the [`timespacereadwrite_complexity`](@ref) function.
33
33
34
34
```julia
35
35
julia>timespacereadwrite_complexity(problem)
36
36
(21.90683335864693, 17.0, 20.03588509836998)
37
37
```
38
38
39
-
The return values are `log2` of the the number of iterations, the number elements in the largest tensor during contraction and the number of read-write operations to tensor elements.
40
-
In this example, the number of `+` and `*` operations are both ``\sim 2^{21.9}``
41
-
and the number of read-write operations are ``\sim 2^{20}``.
42
-
The largest tensor size is ``2^{17}``, one can check the element size by typing
39
+
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.
40
+
In this example, the number `*` operations is ``\sim 2^{21.9}``, the number of read-write operations are ``\sim 2^{20}``, and the largest tensor size is ``2^{17}``.
It means one only needs 298 KB memory to find the graph polynomial with the finite field approach,
66
-
but needs 71 MB memory to find the graph polynomial using the [`Polynomial`](https://juliamath.github.io/Polynomials.jl/stable/polynomials/polynomial/#Polynomial-2) type.
65
+
The finite field approach only requires 298 KB memory, while using the [`Polynomial`](https://juliamath.github.io/Polynomials.jl/stable/polynomials/polynomial/#Polynomial-2) number type requires 71 MB memory.
67
66
68
67
!!! note
69
-
* The actual run time memory can be several times larger than the size of the maximum tensor.
70
-
There is no constant bound for the factor, an empirical value for it is 3x.
71
-
* For mutable types like [`Polynomial`](https://juliamath.github.io/Polynomials.jl/stable/polynomials/polynomial/#Polynomial-2) and [`ConfigEnumerator`](@ref), the `sizeof` function does not measure the actual element size.
68
+
* The actual run time memory can be several times larger than the size of the maximum tensor, so the [`estimate_memory`](@ref) is more accurate in estimating the peak memory.
69
+
* For mutable element types like [`ConfigEnumerator`](@ref), none of memory estimation functions measure the actual memory usage correctly.
72
70
73
71
## Slicing
74
72
@@ -98,7 +96,7 @@ In this application, the slicing achieves the largest possible space complexity
98
96
i.e. the peak memory usage is reduced by a factor ``32``, while the (theoretical) computing time is increased by at a factor ``< 2``.
99
97
100
98
## GEMM for Tropical numbers
101
-
You can speed up the Tropical number matrix multiplication when computing `SizeMax()` by using the Tropical GEMM routines implemented in package [`TropicalGEMM.jl`](https://github.com/TensorBFS/TropicalGEMM.jl/).
99
+
One can speed up the Tropical number matrix multiplication when computing the solution space property [`SizeMax`](@ref)`()` by using the Tropical GEMM routines implemented in package [`TropicalGEMM`](https://github.com/TensorBFS/TropicalGEMM.jl/).
The `TropicalGEMM` pirates the `LinearAlgebra.mul!` interface, hence it takes effect upon using.
120
-
The GEMM routine can speed up the computation on CPU for one order, with multi-threading, it can be even faster.
121
-
Benchmark shows the performance of `TropicalGEMM` is close to the theoretical optimal value.
122
-
123
-
## Sum product representation for configurations
124
-
[`SumProductTree`](@ref) (an alias of [`SumProductTree`](@ref) with [`StaticElementVector`](@ref) as its data type) can save a lot memory for you to store exponential number of configurations in polynomial space.
125
-
It is a sum-product expression tree to store [`ConfigEnumerator`](@ref) in a lazy style, configurations can be extracted by depth first searching the tree with the `Base.collect` method. Although it is space efficient, it is in general not easy to extract information from it.
126
-
This tree structure supports directed sampling so that one can get some statistic properties from it with an intermediate effort.
127
-
128
-
For example, if we want to check some property of an intermediate scale graph, one can type
129
-
```julia
130
-
julia> graph =random_regular_graph(70, 3)
131
-
132
-
julia> problem =IndependentSet(graph; optimizer=TreeSA());
133
-
134
-
julia> tree =solve(problem, ConfigsAll(; tree_storage=true))[];
135
-
16633909006371
136
-
```
137
-
If one wants to store these configurations, he will need a hard disk of size 256 TB!
138
-
However, this sum-product binary tree structure supports efficient and unbiased direct sampling.
139
-
140
-
```julia
141
-
samples =generate_samples(tree, 1000);
142
-
```
143
-
144
-
With these samples, one can already compute useful properties like distribution of hamming distance (see [`hamming_distribution`](@ref)).
The `TropicalGEMM` package pirates the `LinearAlgebra.mul!` interface, hence it takes effect upon using.
118
+
The above example shows more than 10x speed up on a single thread CPU, which can be even faster if [the Julia multi-threading](https://docs.julialang.org/en/v1/manual/multi-threading/) if turned on.
119
+
The benchmark in the `TropicalGEMM` repo shows this performance is close to the theoretical optimal value.
169
120
170
121
## Multiprocessing
171
-
Submodule `GenericTensorNetworks.SimpleMutiprocessing` provides a function [`GenericTensorNetworks.SimpleMultiprocessing.multiprocess_run`](@ref) function for simple multi-processing jobs.
122
+
Submodule `GenericTensorNetworks.SimpleMutiprocessing` provides one function [`GenericTensorNetworks.SimpleMultiprocessing.multiprocess_run`](@ref) function for simple multi-processing jobs.
123
+
It is not directly related to `GenericTensorNetworks`, but is very convenient to have one.
172
124
Suppose we want to find the independence polynomial for multiple graphs with 4 processes.
173
125
We can create a file, e.g. named `run.jl` with the following content
174
126
175
127
```julia
176
128
using Distributed, GenericTensorNetworks.SimpleMultiprocessing
177
-
using Random, GenericTensorNetworks # to avoid multi-precompiling
129
+
using Random, GenericTensorNetworks # to avoid multi-precompilation
178
130
@everywhereusing Random, GenericTensorNetworks
179
131
180
132
results =multiprocess_run(collect(1:10)) do seed
@@ -207,7 +159,7 @@ $ julia -p4 run.jl
207
159
You will see a vector of polynomials printed out.
208
160
209
161
## Make use of GPUs
210
-
To upload the computing to GPU, you just add need to use CUDA, and offer a new key word argument.
162
+
To upload the computation to GPU, you just add `using CUDA` before calling the `solve` function, and set the keyword argument `usecuda` to `true`.
211
163
```julia
212
164
julia> using CUDA
213
165
[ Info: OMEinsum loaded the CUDA module successfully
[`SumProductTree`](@ref) can use polynomial memory to store exponential number of configurations.
3
+
It is a sum-product expression tree to store [`ConfigEnumerator`](@ref) in a lazy style, where configurations can be extracted by depth first searching the tree with the `Base.collect` method.
4
+
Although it is space efficient, it is in general not easy to extract information from it due to the exponential large configuration space.
5
+
Directed sampling is one of its most important operations, with which one can get some statistic properties from it with an intermediate effort. For example, if we want to check some property of an intermediate scale graph, one can type
6
+
```julia
7
+
julia> graph =random_regular_graph(70, 3)
8
+
9
+
julia> problem =IndependentSet(graph; optimizer=TreeSA());
10
+
11
+
julia> tree =solve(problem, ConfigsAll(; tree_storage=true))[];
12
+
16633909006371
13
+
```
14
+
If one wants to store these configurations, he will need a hard disk of size 256 TB!
15
+
However, this sum-product binary tree structure supports efficient and unbiased direct sampling.
16
+
17
+
```julia
18
+
samples =generate_samples(tree, 1000);
19
+
```
20
+
21
+
With these samples, one can already compute useful properties like Hamming distance (see [`hamming_distribution`](@ref)) distribution.
0 commit comments