Skip to content

Commit ea48d21

Browse files
committed
docs: grammar improvements
1 parent de14c1e commit ea48d21

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

docs/src/tensornetwork.md

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Tensor networks
22

33
We now introduce the core ideas of tensor networks, highlighting their
4-
connections with the probabilistic graphical models (PGM) domain to align the terminology between them.
4+
connections with probabilistic graphical models (PGM) to align the terminology
5+
between them.
56

6-
For our purposes, a **tensor** is equivalent with the concept of a factor
7-
presented above, which we detail more formally below.
7+
For our purposes, a tensor is equivalent to the concept of a factor as defined
8+
in the PGM domain, which we detail more formally below.
89

910
## What is a tensor?
11+
1012
*Definition*: A tensor $T$ is defined as:
1113
```math
1214
T: \prod_{V \in \bm{V}} \mathcal{D}_{V} \rightarrow \texttt{number}.
@@ -39,17 +41,25 @@ of. Thus, in this context, the terms **label**, **index**, and
3941
**variable** are synonymous and hence used interchangeably.
4042

4143
## What is a tensor network?
42-
We now turn our attention to defining a **tensor network**.
43-
Tensor network a mathematical object that can be used to represent a multilinear map between tensors. It is widely used in condensed matter physics [^Orus2014][^Pfeifer2014] and quantum simulation [^Markov2008][^Pan2022]. It is also a powerful tool for solving combinatorial optimization problems [^Liu2023].
44-
It is important to note that we use a generalized version of the conventional
45-
notation, which is also knwon as the [eisnum](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html) function that widely used in high performance computing.
46-
Packages that implement the conventional notation include
44+
45+
We now turn our attention to defining a **tensor network**, a mathematical
46+
object used to represent a multilinear map between tensors. This concept is
47+
widely employed in fields like condensed matter physics
48+
[^Orus2014][^Pfeifer2014], quantum simulation [^Markov2008][^Pan2022], and
49+
even in solving combinatorial optimization problems [^Liu2023]. It's worth
50+
noting that we use a generalized version of the conventional notation, most
51+
commonly known through the
52+
[eisnum](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html)
53+
function, which is commonly used in high-performance computing. Packages that
54+
implement this conventional notation include
4755
- [numpy](https://numpy.org/doc/stable/reference/generated/numpy.einsum.html)
4856
- [OMEinsum.jl](https://github.com/under-Peter/OMEinsum.jl)
4957
- [PyTorch](https://pytorch.org/docs/stable/generated/torch.einsum.html)
5058
- [TensorFlow](https://www.tensorflow.org/api_docs/python/tf/einsum)
5159

52-
This approach allows us to represent a more extensive set of sum-product multilinear operations between tensors, meeting the requirements of the PGM field.
60+
This approach allows us to represent a broader range of sum-product
61+
multilinear operations between tensors, thus meeting the requirements of the
62+
PGM field.
5363

5464
*Definition*[^Liu2023]: A tensor network is a multilinear map represented by the triple
5565
$\mathcal{N} = (\Lambda, \mathcal{T}, \bm{\sigma}_0)$, where:
@@ -62,34 +72,35 @@ $\mathcal{N} = (\Lambda, \mathcal{T}, \bm{\sigma}_0)$, where:
6272

6373
More specifically, each tensor $T^{(k)}_{\bm{\sigma}_k} \in \mathcal{T}$ is
6474
labeled by a string $\bm{\sigma}_k \in \Lambda^{r \left(T^{(k)} \right)}$, where
65-
$r \left(T^{(k)} \right)$ is the rank of $T^{(k)}$. The multilinear map, or
66-
the `contraction`, applied to this triple is defined as
75+
$r \left(T^{(k)} \right)$ is the rank of $T^{(k)}$. The multilinear map, also
76+
known as the `contraction`, applied to this triple is defined as
6777
```math
6878
\texttt{contract}(\Lambda, \mathcal{T}, \bm{\sigma}_0) = \sum_{\bm{\sigma}_{\Lambda
6979
\setminus [\bm{\sigma}_0]}} \prod_{k=1}^{M} T^{(k)}_{\bm{\sigma}_k},
7080
```
7181
Notably, the summation extends over all instantiations of the variables that
7282
are not part of the output tensor.
7383

74-
As an example, the matrix multiplication can be specified as a tensor network
75-
contraction
84+
As an example, consider matrix multiplication, which can be specified as a
85+
tensor network contraction:
7686
```math
7787
(AB)_{ik} = \texttt{contract}\left(\{i,j,k\}, \{A_{ij}, B_{jk}\}, ik\right),
7888
```
79-
where matrices $A$ and $B$ are input tensors labeled by strings $ij, jk \in
80-
\{i, j, k\}^2$. The output tensor is labeled by string $ik$. The
81-
summation runs over indices $\Lambda \setminus [ik] = \{j\}$. The contraction
82-
corresponds to
89+
Here, matrices $A$ and $B$ are input tensors labeled by strings $ij, jk \in
90+
\{i, j, k\}^2$. The output tensor is labeled by string $ik$. Summations run
91+
over indices $\Lambda \setminus [ik] = \{j\}$. The contraction corresponds to
8392
```math
8493
\texttt{contract}\left(\{i,j,k\}, \{A_{ij}, B_{jk}\}, ik\right) = \sum_j
8594
A_{ij}B_{jk},
8695
```
87-
In programming languages, this is equivalent to einsum notation `ij, jk -> ik`.
88-
89-
Diagrammatically, a tensor network can be represented as an *open hypergraph*. In the tensor network diagram, a tensor is mapped to a vertex,
90-
and a variable is mapped to a hyperedge. If and only if tensors share the same variable, we connect
91-
them with the same hyperedge for that variable. The diagrammatic
92-
representation of matrix multiplication is as bellow.
96+
In the einsum notation commonly used in various programming languages, this is
97+
equivalent to `ij, jk -> ik`.
98+
99+
Diagrammatically, a tensor network can be represented as an *open hypergraph*.
100+
In this diagram, a tensor maps to a vertex, and a variable maps to a
101+
hyperedge. Tensors sharing the same variable are connected by the same
102+
hyperedge for that variable. The diagrammatic representation of matrix
103+
multiplication is:
93104
```@eval
94105
using TikzPictures
95106
@@ -116,19 +127,20 @@ save(SVG("the-tensor-network1"), tp)
116127
<img src="the-tensor-network1.svg" style="margin-left: auto; margin-right: auto; display:block; width=50%">
117128
```
118129

119-
Here, we use different colors to denote different hyperedges. Hyperedges for
130+
In this diagram, we use different colors to denote different hyperedges. Hyperedges for
120131
$i$ and $j$ are left open to denote variables in the output string
121-
$\bm{\sigma}_0$. The reason why we should use hyperedges rather than regular edge
122-
will be made clear by the followng star contraction example.
132+
$\bm{\sigma}_0$. The reason we use hyperedges rather than regular edges will
133+
become clear in the following star contraction example.
123134
```math
124135
\texttt{contract}(\{i,j,k,l\}, \{A_{il}, B_{jl}, C_{kl}\}, ijk) = \sum_{l}A_{il}
125136
B_{jl} C_{kl}
126137
```
127-
In programming languages, this is equivalent to einsum notation `il, jl, kl -> ijk`.
138+
The equivalent einsum notation employed by many programming languages is `il,
139+
jl, kl -> ijk`.
128140

129-
Among the variables, $l$ is shared by all three tensors, hence the diagram can
130-
not be represented as a simple graph. The hypergraph representation is as
131-
below.
141+
Since the variable $l$ is shared across all three tensors, a simple graph
142+
can't capture the diagram's complexity. The more appropriate hypergraph
143+
representation is shown below.
132144
```@eval
133145
using TikzPictures
134146
@@ -171,23 +183,27 @@ save(SVG("the-tensor-network2"), tp)
171183
<img src="the-tensor-network2.svg" style="margin-left: auto; margin-right: auto; display:block; width=50%">
172184
```
173185

174-
As a final comment, repeated indices in the same tensor is not forbidden in
175-
the definition of a tensor network, hence self-loops are also allowed in a tensor
176-
network diagram.
186+
As a final note, our definition of a tensor network allows for repeated
187+
indices within the same tensor, which translates to self-loops in their
188+
corresponding diagrams.
177189

178190
## Tensor network contraction orders
191+
179192
The performance of a tensor network contraction depends on the order in which
180193
the tensors are contracted. The order of contraction is usually specified by
181194
binary trees, where the leaves are the input tensors and the internal nodes
182195
represent the order of contraction. The root of the tree is the output tensor.
183196

184-
Plenty of algorithms have been proposed to find the optimal contraction order, which includes
197+
Numerous approaches have been proposed to determine efficient contraction
198+
orderings, which include:
185199
- Greedy algorithms
186200
- Breadth-first search and Dynamic programming [^Pfeifer2014]
187201
- Graph bipartitioning [^Gray2021]
188202
- Local search [^Kalachev2021]
189203

190-
Some of them have already been included in the [OMEinsum](https://github.com/under-Peter/OMEinsum.jl) package. Please check [Performance Tips](@ref) for more details.
204+
Some of these have been implemented in the
205+
[OMEinsum](https://github.com/under-Peter/OMEinsum.jl) package. Please check
206+
[Performance Tips](@ref) for more details.
191207

192208
## References
193209

@@ -210,4 +226,4 @@ Some of them have already been included in the [OMEinsum](https://github.com/und
210226
Pan F, Chen K, Zhang P. Solving the sampling problem of the sycamore quantum circuits[J]. Physical Review Letters, 2022, 129(9): 090502.
211227

212228
[^Liu2023]:
213-
Liu J G, Gao X, Cain M, et al. Computing solution space properties of combinatorial optimization problems via generic tensor networks[J]. SIAM Journal on Scientific Computing, 2023, 45(3): A1239-A1270.
229+
Liu J G, Gao X, Cain M, et al. Computing solution space properties of combinatorial optimization problems via generic tensor networks[J]. SIAM Journal on Scientific Computing, 2023, 45(3): A1239-A1270.

0 commit comments

Comments
 (0)