SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Yuki Takezawa $^{1,2*}$ , Ryoma Sato $^{1,2*}$ , Han Bao $^{1,2}$ , Kenta Niwa $^{3}$ , Makoto Yamada $^{2}$ $^{1}$ Kyoto University,  $^{2}$ OIST,  $^{3}$ NTT Communication Science Laboratories
Decentralized learning has recently been attracting increasing attention for its applications in parallel computation and privacy preservation. Many recent studies stated that the underlying network topology with a faster consensus rate (a.k.a. spectral gap) leads to a better convergence rate and accuracy for decentralized learning. However, a topology with a fast consensus rate, e.g., the exponential graph, generally has a large maximum degree, which incurs significant communication costs. Thus, seeking topologies with both a fast consensus rate and small maximum degree is important. In this study, we propose a novel topology combining both a fast consensus rate and small maximum degree called the BASE- $(k + 1)$  GRAPH. Unlike the existing topologies, the BASE- $(k + 1)$  GRAPH enables all nodes to reach the exact consensus after a finite number of iterations for any number of nodes and maximum degree  $k$ . Thanks to this favorable property, the BASE- $(k + 1)$  GRAPH endows Decentralized SGD (DSGD) with both a faster convergence rate and more communication efficiency than the exponential graph. We conducted experiments with various topologies, demonstrating that the BASE- $(k + 1)$  GRAPH enables various decentralized learning methods to achieve higher accuracy with better communication efficiency than the existing topologies. Our code is available at https://github.com/yukiTakezawa/BaseGraph.
Distributed learning, which allows training neural networks in parallel on multiple nodes, has become an important paradigm owing to the increased utilization of privacy preservation and large-scale machine learning. In a centralized fashion, such as All-Reduce and Federated Learning [8, 9, 16, 26, 27], all or some selected nodes update their parameters by using their local dataset and then compute the average parameter of these nodes, although computing the average of many nodes is the major bottleneck in the training time [18, 19, 23]. To reduce communication costs, decentralized learning gains significant attention [11, 18, 24]. Because decentralized learning allows nodes to exchange parameters only with a few neighbors in the underlying network topology, decentralized learning is more communication efficient than All-Reduce and Federated Learning.
While decentralized learning can improve communication efficiency, it may degrade the convergence rate and accuracy due to its sparse communication characteristics [11, 48]. Specifically, the smaller the maximum degree of an underlying network topology is, the fewer the communication cost becomes [33, 39]; meanwhile, the faster the consensus rate (a.k.a. spectral gap) of a topology is, the faster the convergence rate of decentralized learning becomes [11]. Thus, developing a topology with both a fast consensus rate and small maximum degree is essential for decentralized learning. Table 1 summarizes the properties of various topologies. For instance, the ring and exponential graph are
Table 1: Comparison among different topologies with  $n$  nodes. The definition of the consensus rate and finite-time convergence is shown in Sec. 3.
Topology	Consensus Rate	Connection	Maximum Degree	#Nodes n
Ring [28]	1 - O(n-2)	Undirected	2	∀n ∈ N
Torus [28]	1 - O(n-1)	Undirected	4	∀n ∈ N
Exp. [43]	1 - O((log2(n))-1)	Directed	[log2(n)]	∀n ∈ N
1-peer Exp. [43]	O(log2(n))-finite time conv.	Directed	1	A power of 2
1-peer Hypercube [31]	O(log2(n))-finite time conv.	Undirected	1	A power of 2
Base-(k+1) Graph (ours)	O(logk+1(n))-finite time conv.	Undirected	k	∀n ∈ N
commonly used [1, 3, 12, 23]. The ring is a communication-efficient topology because its maximum degree is two but its consensus rate quickly deteriorates as the number of nodes  $n$  increases [28]. The exponential graph has a fast consensus rate, which does not deteriorate much as  $n$  increases, but it incurs significant communication costs because its maximum degree increases as  $n$  increases [43]. Thus, these topologies sacrifice either communication efficiency or consensus rate.
Recently, the 1-peer exponential graph [43] and 1-peer hypercube graph [31] were proposed as topologies that combine both a small maximum degree and fast consensus rate (see Sec. C.4 for examples). As Fig. 1 shows, in the ring and exponential graph, node parameters only reach the consensus asymptotically by repeating exchanges of parameters with neighbors. Contrarily, in the 1-peer exponential and 1-peer hypercube graphs, parameters reach the exact consensus after a finite number of iterations when  $n$  is a power of 2 (see Fig. 21 in Sec. F.2). Thanks to this property of finite-time convergence, the 1-peer exponential and 1-peer hypercube graphs enable Decentralized SGD (DSGD) [18] to converge at the same convergence rate as the exponential graph when  $n$  is a power of 2, even though the maximum degree of the 1-peer exponential and 1-peer hypercube graphs is only one [43].
However, this favorable property only holds when  $n$  is a power of 2. When  $n$  is not a power of 2, the 1-peer hypercube graph cannot be constructed, and the 1-peer exponential graph only reaches the consensus asymptotically as well as the ring and exponential graph, as Fig. 1 illustrates. Thus, the 1-peer exponential and 1-peer hypercube graphs cannot enable DSGD to converge as fast as the exponential graph when  $n$  is not a power of 2. Moreover, even if  $n$  is a power of 2, the 1-peer hypercube and 1-peer exponential graphs still cannot enable DSGD to converge faster than the exponential graph.
Figure 1: Comparison of consensus rate. See Sec. 6 for detailed experimental settings. The number in the bracket is the maximum degree.
In this study, we ask the following question: Can we construct topologies that provide DSGD with both a faster convergence rate and better communication efficiency than the exponential graph for any number of nodes? Our work provides the affirmative answer by proposing the BASE- $(k + 1)$  GRAPH, which is finite-time convergence for any number of nodes  $n$  and maximum degree  $k$  (see Fig. 1). Thanks to this favorable property, the BASE-2 GRAPH enables DSGD to converge faster than the ring and torus and as fast as the exponential graph for any  $n$ , while the BASE-2 GRAPH is more communication-efficient than the ring, torus, and exponential graph because its maximum degree is only one. Furthermore, when  $2 \leq k < \lceil \log_2(n) \rceil$ , the BASE- $(k + 1)$  GRAPH enables DSGD to converge faster with fewer communication costs than the exponential graph because the maximum degree of the BASE- $(k + 1)$  GRAPH is still less than that of the exponential graph. Experimentally, we compared the BASE- $(k + 1)$  GRAPH with various existing topologies, demonstrating that the BASE- $(k + 1)$  GRAPH enables various decentralized learning methods to more successfully reconcile accuracy and communication efficiency than the existing topologies.
Decentralized Learning. The most widely used decentralized learning methods are DSGD [18] and its adaptations [1, 2, 19]. Many researchers have improved DSGD and proposed DSGD with momentum [4, 20, 44, 45], communication compression methods [6, 10, 23, 35, 38], etc. While DSGD is a simple and efficient method, DSGD is sensitive to data heterogeneity [36]. To mitigate this issue, various methods have been proposed, which can eliminate the effect of data heterogeneity on the convergence rate, including gradient tracking [21, 29, 30, 34, 42, 47],  $D^2$  [36], etc. [17, 37, 46].
2Note that the maximum degree of the BASE-  $(k + 1)$  GRAPh is not  $k + 1$  , but at most  $k$
Effect of Topologies. Many prior studies indicated that topologies with a fast consensus rate improve the accuracy of decentralized learning [11, 13, 25, 39]. For instance, DSGD and gradient tracking converge faster as the topology has a faster consensus rate [18, 34]. Zhu et al. [48] revealed that topology with a fast consensus rate improves the generalization bound of DSGD. Especially when the data distributions are statistically heterogeneous, the topology with a fast consensus rate prevents the parameters of each node from drifting away and can improve accuracy [11, 34]. However, communication costs increase as the maximum degree increases [33, 43]. Thus, developing a topology with a fast consensus rate and small maximum degree is important for decentralized learning.
3 Preliminary and Notation
Notation. A graph  $G$  is represented by  $(V, E)$  where  $V$  is a set of nodes and  $E$  is a set of edges. If  $G$  is a graph,  $V(G)$  (resp.  $E(G)$ ) denotes the set of nodes (resp. edges) of  $G$ . For any  $a_1, \dots, a_n$ ,  $(a_1, \dots, a_n)$  denotes the ordered set. An empty (ordered) set is denoted by  $\emptyset$ . For any  $n \in \mathbb{N}$ , let  $[n] := \{1, \dots, n\}$ . For any  $n, a \in \mathbb{N}$ ,  $\mathrm{mod}(a, n)$  is the remainder of dividing  $a$  by  $n$ .  $\| \cdot \|_F$  denotes Frobenius norm, and  $\mathbf{1}_n$  denotes an  $n$ -dimensional vector with all ones.
Topology. Let  $G$  be an underlying network topology with  $n$  nodes, and  $W \in [0,1]^{n \times n}$  be a mixing matrix associated with  $G$ . That is,  $W_{ij}$  is the weight of the edge  $(i,j)$ , and  $W_{ij} > 0$  if and only if  $(i,j) \in E(G)$ . Most of the decentralized learning methods require  $W$  to be doubly stochastic (i.e.,  $W\mathbf{1}_n = \mathbf{1}_n$  and  $W^\top \mathbf{1}_n = \mathbf{1}_n$ ) [18, 20, 29, 36]. Then, the consensus rate of  $G$  is defined below.
Definition 1. Let  $\mathbf{W}$  be a mixing matrix associated with a graph  $G$  with  $n$  nodes. Let  $\mathbf{x}_i \in \mathbb{R}^d$  be a parameter that node  $i$  has. Let  $\mathbf{X} := (\mathbf{x}_1, \dots, \mathbf{x}_n) \in \mathbb{R}^{d \times n}$  and  $\bar{\mathbf{X}} := \frac{1}{n} \mathbf{X} \mathbf{1}_n \mathbf{1}_n^\top$ . The consensus rate  $\beta \in [0,1)$  is the smallest value that satisfies  $\| \mathbf{X} \mathbf{W} - \bar{\mathbf{X}} \|_F^2 \leq \beta^2 \| \mathbf{X} - \bar{\mathbf{X}} \|_F^2$  for any  $\mathbf{X}$ .
Thanks to  $\beta \in [0,1)$ ,  $\pmb{x}_i$  asymptotically converge to consensus  $\frac{1}{n}\sum_{i=1}^{n}\pmb{x}_i$  by repeating parameter exchanges with neighbors. However, this does not mean that all nodes reach the exact consensus within a finite number of iterations except when  $\beta = 0$ , that is, when  $G$  is fully connected. Then, utilizing time-varying topologies, Ying et al. [43] and Shi et al. [31] aimed to obtain sequences of graphs that can make all nodes reach the exact consensus within finite iterations and proposed the 1-peer exponential and 1-peer hypercube graphs respectively (see Sec. C.4 for illustrations).
Definition 2. Let  $(G^{(1)},\dots ,G^{(m)})$  be a sequence of graphs with the same set of nodes (i.e.,  $V(G^{(1)}) = \dots = V(G^{(m)}))$ . Let  $n$  be the number of nodes. Let  $\mathbf{W}^{(1)},\dots ,\mathbf{W}^{(m)}$  be mixing matrices associated with  $G^{(1)},\dots ,G^{(m)}$ , respectively. Suppose that  $\mathbf{W}^{(1)},\dots ,\mathbf{W}^{(m)}$  satisfy  $\mathbf{X}\mathbf{W}^{(1)}\mathbf{W}^{(2)}\cdots \mathbf{W}^{(m)} = \bar{\mathbf{X}}$  for any  $\mathbf{X}\in \mathbb{R}^{d\times n}$ , where  $\bar{\mathbf{X}} = \frac{1}{n}\mathbf{X}\mathbf{1}_n\mathbf{1}_n^\top$ . Then,  $(G^{(1)},\dots ,G^{(m)})$  is called  $m$ -finite time convergence or an  $m$ -finite time convergent sequence of graphs.
Because Definition 2 assumes that  $V(G^{(1)}) = \dots = V(G^{(m)})$  holds, we often write a sequence of graphs  $(G^{(1)},\dots ,G^{(m)})$  as  $(E(G^{(1)}),\dots ,E(G^{(m)}))$  using a slight abuse of notation. Additionally, in the following section, we often abbreviate the weights of self-loops because they are uniquely determined due to the condition that the mixing matrix is doubly stochastic.
4 Construction of Finite-time Convergent Sequence of Graphs
In this section, we propose the BASE- $(k + 1)$  GRAPH, which is finite-time convergence for any number of nodes  $n \in \mathbb{N}$  and maximum degree  $k \in [n - 1]$ . Specifically, we consider the setting where node  $i$  has a parameter  $\pmb{x}_i$  and propose a graph sequence whose maximum degree is at most  $k$  that makes all nodes reach the exact consensus  $\frac{1}{n} \sum_{i=1}^{n} \pmb{x}_i$ . To this end, we first propose the  $k$ -PEER HYPER-HYPERCUBE GRAPH, which is finite-time convergence when  $n$  does not have prime factors larger than  $k + 1$ . Using it, we propose the SIMPLE BASE- $(k + 1)$  GRAPH and BASE- $(k + 1)$  GRAPH, which are finite-time convergence for any  $n$ .
Figure 2: Illustration of the 2-PEER HYPER-HYPERCUBE GRAPH.
Algorithm 1  $k$ -PEER HYPER-HYPERCUBE GRAPH  $\mathcal{H}_k(V)$
1: Input: the set of nodes  $V \coloneqq \{v_{1},\dots ,v_{n}\}$  and number of nodes  $n$ .  
2: Decompose  $n$  as  $n = n_1\times \dots \times n_L$  with minimum  $L$  such that  $n_l\in [k + 1]$  for all  $l\in [L]$ .  
3: for  $l\in [L]$  do  
4: Initialize  $b_{i}$  to zero for all  $i\in [n]$  and  $E^{(l)}$  to  $\emptyset$ .  
5: for  $i\in [n]$  do  
6: for  $m\in [n_l]$  do  
7:  $j\gets \mathrm{mod}(i + m\times \prod_{l' = 1}^{l - 1}n_{l'} - 1,n) + 1.$   
8: if  $b_{i} < n_{l} - 1$  and  $b_{j} < n_{l} - 1$  then  
9: Add edge  $(v_{i},v_{j})$  with weight  $\frac{1}{n_l}$  to  $E^{(l)}$  and  $b_{i}\gets b_{i} + 1$ .  
10: return  $(E^{(1)},E^{(2)},\dots ,E^{(L)})$ .
4.1  $k$ -peer Hyper-hypercube Graph
Before proposing the BASE- $(k + 1)$  GRAPH, we first extend the 1-peer hypercube graph [31] to the  $k$ -peer setting and propose the  $k$ -PEER HYPER-HYPERCUBE GRAPH, which is finite-time convergence when the number of nodes  $n$  does not have prime factors larger than  $k + 1$  and is used as a component in the BASE- $(k + 1)$  GRAPH. Let  $V$  be a set of  $n$  nodes. We assume that all prime factors of  $n$  are less than or equal to  $k + 1$ . That is, there exists  $n_1, n_2, \dots, n_L \in [k + 1]$  such that  $n = n_1 \times \dots \times n_L$ . In this case, we can construct the  $L$ -finite time convergent sequence of graphs whose maximum degree is at most  $k$ . Using Fig. 2a, we explain how all nodes reach the exact consensus. Let  $G^{(1)}$  and  $G^{(2)}$  denote the graphs in Fig. 2a from left to right, respectively. After the nodes exchange parameters with neighbors in  $G^{(1)}$ , nodes 1 and 2, nodes 3 and 4, and nodes 5 and 6 have the same parameter respectively. Then, after exchanging parameters in  $G^{(2)}$ , all nodes reach the exact consensus. We present the complete algorithms for constructing the  $k$ -PEER HYPER-HYPERCUBE GRAPH in Alg. 1.
4.2 Simple Base-  $(k + 1)$  Graph
As described in Sec. 4.1, when  $n$  do not have prime factors larger than  $k + 1$ , we can easily make all nodes reach the exact consensus by the  $k$ -PEER HYPER-HYPERCUBE GRAPH. However, when  $n$  has prime factors larger than  $k + 1$ , e.g., when  $(k,n) = (1,5)$ , the  $k$ -PEER HYPER-HYPERCUBE GRAPH cannot be constructed. In this section, we extend the  $k$ -PEER HYPER-HYPERCUBE GRAPH and propose the SIMPLE BASE- $(k + 1)$  GRAPH, which is finite-time convergence for any number of nodes  $n$  and maximum degree  $k$ . Note that the maximum degree of the SIMPLE BASE- $(k + 1)$  GRAPH is not  $k + 1$ , but at most  $k$ .
We present the pseudo-code for constructing the SIMPLE BASE- $(k + 1)$  GRAPH in Alg. 2. For simplicity, here we explain only the case when the maximum degree  $k$  is one. The case with  $k \geq 2$  is explained in Sec. B. The SIMPLE BASE- $(k + 1)$  GRAPH mainly consists of the following four steps. The key idea is that splitting  $V$  into disjoint subsets to which the  $k$ -PEER HYPER-HYPERCUBE GRAPH is applicable.
Step 1. As in the base-2 number of  $n$ , we decompose  $n$  as  $n = 2^{p_1} + \dots + 2^{p_L}$  in line 1, and then split  $V$  into disjoint subsets  $V_1, \dots, V_L$  such that  $|V_l| = 2^{p_l}$  for all  $l \in [L]$  in line 3.
Step 2. For all  $l \in [L]$ , we make all nodes in  $V_{l}$  obtain the average of parameters in  $V_{l}$  using the 1-PEER HYPER-HYPERCUBE GRAPH  $\mathcal{H}_1(V_l)$  in line 11. Then, we initialize  $l'$  as one.
Step 3. Each node in  $V_{l' + 1} \cup \dots \cup V_L$  exchanges parameters with one node in  $V_{l'}$  such that the average in  $V_{l'}$  becomes equivalent to the average in  $V$ . We increase  $l'$  by one and repeat step 3 until  $l' = L$ . This procedure corresponds to line 15.
Step 4. For all  $l \in [L]$ , we make all nodes in  $V_{l}$  obtain the average in  $V_{l}$  using the 1-PEER HYPERHYPERCUBE GRAPH  $\mathcal{H}_1(V_l)$ . Because the average in  $V_{l}$  is equivalent to the average in  $V$  after step 3, all nodes can reach the exact consensus. This procedure corresponds to line 25.
Using the example presented in Fig. 3, we explain Alg. 2 in more detail. Let  $G^{(1)}, \dots, G^{(5)}$  denote the graphs in Fig. 3 from left to right, respectively. In step 1, we split  $V := \{1, \dots, 5\}$  into
3 Splitting  $V_{l}$  into  $V_{l,1},\dots ,V_{l,a_l}$  becomes crucial when  $k\geq 2$  (see Sec. B).
$V_{1} := \{1, \dots, 4\}$  and  $V_{2} := \{5\}$ . In step 2, nodes in  $V_{1}$  obtain the average in  $V_{1}$  by exchanging parameters in  $G^{(1)}$  and  $G^{(2)}$ . In step 3, the average in  $V_{1}$  becomes equivalent to the average in  $V$  by exchanging parameters in  $G^{(3)}$ . In step 4, nodes in  $V_{1}$  can get the average in  $V$  by exchanging parameters in  $G^{(4)}$  and  $G^{(5)}$ . Because node 5 also obtains the average in  $V$  after exchanging parameters in  $G^{(3)}$ , all nodes reach the exact consensus after exchanging parameters in  $G^{(5)}$ .
Note that edges added in lines 20 and 27 are not necessary if we only need to make all nodes reach the exact consensus. Nonetheless, these edges are effective in keeping the parameters of nodes close in value to each other in decentralized learning because the parameters are updated by gradient descent before the parameter exchange with neighbors. For instance, edge  $(1,2)$  in  $G^{(3)}$ , which is added in line 20, is not necessary for finite-time convergence because nodes 1 and 2 already have the same parameter after exchanging parameters in  $G^{(1)}$  and  $G^{(2)}$ . We provide more examples in Sec. C.
Figure 3: SIMPLE BASE-2 GRAPH with  $n = 5(= 2^2 + 1)$ . The value on the edge is the edge weight, and the edges are colored in the same color as the line in Alg. 2 where they were added.
Algorithm 2 SIMPLE BASE- $(k + 1)$  GRAPH  $\mathcal{A}_k^{\mathrm{simple}}(V)$
1: Input: the set of nodes  $V$  and number of nodes  $n(= a_1(k + 1)^{p_1} + a_2(k + 1)^{p_2} + \dots +a_L(k + 1)^{p_L})$  such that  $p_1 > p_2 > \dots >p_L\geq 0$  and  $a_{l}\in [k]$  for all  $l\in [L]$    
2: If all prime factors of  $n$  are less than or equal to  $k + 1$  then return  $\mathcal{H}_k(V)$    
3: Split  $V$  into disjoint subsets  $V_{1},\dots ,V_{L}$  such that  $|V_l| = a_l(k + 1)^{p_l}$  for all  $l\in [L]$  . Then, for all  $l\in [L]$  , split  $V_{l}$  into disjoint subsets  $V_{l,1},\dots ,V_{l,a_l}$  such that  $|V_{l,a}| = (k + 1)^{p_l}$  for all  $a\in [a_l]$    
4: Construct  $k$  -PEER HYPER-HYPERCUBE GRAPH  $\mathcal{H}_k(V_l)$  for all  $l\in [L]$  and  $m_{1} = |\mathcal{H}_{k}(V_{1})|$    
5: Construct  $k$  -PEER HYPER-HYPERCUBE GRAPH  $\mathcal{H}_k(V_{l,a})$  for all  $l\in [L]$  and  $a\in [a_l]$    
6: Initialize  $b_{l}$  as zero for all  $l\in [L]$  , and initialize m as zero.   
7: while  $b_{1} <   |\mathcal{H}_{k}(V_{1,1})|$  do   
8:  $m\gets m + 1$  and  $E^{(m)}\gets \emptyset$    
9: for  $l\in \{L,L - 1,\dots ,1\}$  do   
10: if  $m\leq m_1$  then   
11: Add  $E(\mathcal{H}_k(V_l)^{(m')})$  to  $E^{(m)}$  where  $m^{\prime} = \mathrm{mod}(m - 1,|\mathcal{H}_k(V_l)|) + 1.$    
12: else if  $m <   m_1 + l$  then   
13: for  $v\in V_l$  do   
14: Select isolated node  $u_{1},\dots ,u_{a_{m - m_{1}}}$  from  $V_{m - m_1,1},\dots ,V_{m - m_1,a_m - m_1}$    
15: Add edges  $(v,u_{1}),\dots ,(v,u_{a_{m - m_{1}}})$  with weight  $\frac{|V_m - m_1|}{a_m - m_1\sum_{l' = m - m_1}^{L}|V_{l'}|}$  to  $E^{(m)}$    
16: else if  $m = m_1 + l$  and  $l\neq L$  then   
17: while There are two or more isolated nodes in  $V_{l}$  do   
18:  $c\gets$  the number of isolated nodes in  $V_{l}$    
19: Select min  $\{k + 1,c\}$  isolated nodes  $V^{\prime}$  in  $V_{l}$    
20: Add edges with weights  $\frac{1}{|V'|}$  to  $E^{(m)}$  such that  $V^{\prime}$  compose the complete graph   
21: else   
22:  $b_{l}\gets b_{l} + 1$    
23: if  $p_l\neq 0$  then   
24: for  $a\in [a_l]$  do   
25: Add  $E(\mathcal{H}_k(V_{l,a})^{(m')})$  to  $E^{(m)}$  where  $m^{\prime} = \mathrm{mod}(b_{l} - 1,|\mathcal{H}_{k}(V_{l,a})|) + 1.$    
26: else   
27: Add  $E(\mathcal{H}_k(V_l)^{(m')})$  to  $E^{(m)}$  where  $m^{\prime} = \mathrm{mod}(b_{l} - 1,|\mathcal{H}_{k}(V_{l})|) + 1.$    
28: return  $(E^{(1)},E^{(2)},\dots ,E^{(m)})$
Algorithm 3 BASE-  $(k + 1)$  GRAPH  $A_{k}(V)$
1: Input: the set of nodes  $V$  and number of nodes  $n$ .
2: Decompose  $n$  as  $n = p \times q$  such that  $p$  is a multiple of  $2, 3, \dots, (k + 1)$  and  $q$  is prime to  $2, 3, \dots, (k + 1)$ .
3: Split  $V$  into disjoint subsets  $V_{1},\dots ,V_{p}$  such that  $|V_l| = q$  for all  $l$
4: Construct SIMPLE BASE-  $(k + 1)$  GRAPH  $\mathcal{A}_k^{\mathrm{simple}}(V_l)$  for all  $l\in [p]$
5: for  $m \in \{1, 2, \dots, |\mathcal{A}_k^{\text{simple}}(V_1)|\}$  do
6:  $E^{(m)}\gets \bigcup_{l\in [p]}E(\mathcal{A}_k^{\mathrm{simple}}(V_l)^{(m)})$
7: Split  $V$  into disjoint subsets  $U_{1},\dots ,U_{q}$  such that  $|U_l| = p$  and  $|U_{l}\cap V_{l^{\prime}}| = 1$  for all  $l,l^{\prime}$
8: Construct  $k$ -PEER HYPER-HYPERCUBE GRAPH  $\mathcal{H}_k(U_l)$  for all  $l \in [q]$ .
9: for  $m \in \{1, 2, \dots, |\mathcal{H}_k(U_1)|\}$  do
10:  $E^{(m + |\mathcal{A}_k^{\mathrm{simple}}(V_1)|)}\gets \bigcup_{l\in [q]}E(\mathcal{H}_k(U_l)^{(m)})$
11:  $\mathcal{E}\gets (E^{(1)},E^{(2)},\dots ,E^{(|A_k^{\mathrm{simple}}(V_1)| + |\mathcal{H}_k(U_1)|)}).$
12: If  $|\mathcal{A}_k^{\mathrm{simple}}(V)| < |\mathcal{E}|$  then return  $\mathcal{A}_k^{\mathrm{simple}}(V)$  else return  $\mathcal{E}$ .
(a) BASE-2 GRAPH with  $n = 6(= 2 \times (2 + 1))$
(b) SIMPLE BASE-2 GRAPH with  $n = 6(= 2^2 + 2)$
Figure 4: Comparison of SIMPLE BASE-2 GRAPH and BASE-2 GRAPH with  $n = 6$ . The value on the edge indicates the edge weight. The edges added in line 10 in Alg. 3 are colored black, and the edges added in line 6 are colored the same color as the line in Alg. 2 where they are added.
4.3 Base-  $(k + 1)$  Graph
The SIMPLE BASE- $(k + 1)$  GRAPH is finite-time convergence for any  $n$  and  $k$ , while the SIMPLE BASE- $(k + 1)$  GRAPH contains graphs that are not necessary for the finite-time convergence and becomes a redundant sequence of graphs in some cases, e.g.,  $(k,n) = (1,6)$  (see the example in Fig. 4b and a detailed explanation in Sec. C.2). To remove this redundancy, this section proposes the BASE- $(k + 1)$  GRAPH that can make all nodes reach the exact consensus after fewer iterations than the SIMPLE BASE- $(k + 1)$  GRAPH.
The pseudo-code for constructing the BASE- $(k + 1)$  GRAPH is shown in Alg. 3. The BASE- $(k + 1)$  GRAPH consists of the following three steps.
Step 1. We decompose  $n$  as  $p \times q$  such that  $p$  is a multiple of  $2, \dots, (k + 1)$  and  $q$  is prime to  $2, \dots, (k + 1)$ , and split  $V$  into disjoint subsets  $V_{1}, \dots, V_{p}$  such that  $|V_{l}| = q$  for all  $l \in [p]$ .
Step 2. For all  $l \in [p]$ , we make all nodes in  $V_{l}$  reach the average in  $V_{l}$  by the SIMPLE BASE-( $k + 1$ ) GRAPH  $\mathcal{A}_k^{\mathrm{simple}}(V_l)$ . Then, we take  $p$  nodes from  $V_{1}, \dots, V_{p}$  respectively and construct a set  $U_{1}$ . Similarly, we construct  $U_{2}, \dots, U_{q}$  such that  $U_{1}, \dots, U_{q}$  are disjoint sets.
Step 3. For all  $l \in [q]$ , we make all nodes in  $U_{l}$  reach the average in  $U_{l}$  by the  $k$ -PEER HYPERHYPERCUBE GRAPH  $\mathcal{H}_k(U_l)$ . Because the average in  $U_{l}$  is equivalent to the average in  $V$  after step 2, all nodes reach the exact consensus.