Elastic full reduction method based on complementary binary tree

By constructing a full reduction method for complementary binary tree pairs and dynamically adjusting the communication topology, the problem of communication efficiency degradation caused by dynamic changes in nodes is solved, achieving efficient full reduction communication and fault tolerance, and optimizing resource utilization.

CN121835952APending Publication Date: 2026-04-10SOUTHWEST JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHWEST JIAOTONG UNIV
Filing Date
2025-12-24
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing full reduction algorithms lead to frequent communication topology reconstruction in distributed training environments with dynamically changing nodes, resulting in high initialization overhead and decreased communication efficiency. In particular, when nodes fail, existing fault-tolerance schemes can cause communication topology degradation, affecting training efficiency.

Method used

A flexible full reduction method based on complementary binary trees is adopted. By constructing two pairs of complementary binary trees, the communication topology is dynamically adjusted to cope with the addition and departure of nodes, maintaining the elasticity and efficiency of the communication link. The complementary binary tree design provides fault-tolerant and efficient full reduction communication.

Benefits of technology

In the case of dynamic node changes, the number of communication link reconfigurations is reduced, the efficiency of the communication topology and bandwidth utilization are maintained, the decline in communication efficiency is avoided, and fault tolerance and full utilization of resources are achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121835952A_ABST
    Figure CN121835952A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of distributed machine learning, and discloses a complementary binary tree-based elastic full reduction method, which comprises the following steps: S1, constructing two complementary binary tree pairs < T1, T2 and more; s2, performing full reduction communication on each node based on the binary tree T1 and the binary tree T2, and updating training parameters by using a reduced gradient; wherein the process of maintaining the communication topology in S2 comprises the following steps: S21, when a node i leaves, determining a leaf tree TA and a non-leaf tree TB, deleting the node i in the leaf tree TA, and adjusting the connection relationship of the non-leaf tree TB according to the degree of the node i in the non-leaf tree TB; and S22, when a node i is added, judging whether a double-leaf node j exists in the current complementary binary tree pair or not, creating the node i in the binary tree T1 and the binary tree T2 according to a judgment result, and establishing a connection relationship. According to the method, the communication topology is adjusted to realize fault tolerance while the communication link is multiplexed as much as possible, cluster computing resources are fully utilized, and the situation that the communication efficiency is reduced due to the change of all reduction members is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of distributed machine learning, and in particular to a resilient all-reduce method based on complementary binary trees. BACKGROUND

[0002] With the explosive growth of machine learning models and data sets, single machine computing power has encountered a bottleneck, and distributed training has become mainstream. Among them, all-reduce is a key collective communication operation to achieve multi-node parameter synchronization. Existing deep learning frameworks usually call high-performance communication libraries such as NCCL and Open MPI to achieve efficient communication in a static cluster based on ring or tree topology.

[0003] Real distributed training environments often have dynamicity, such as random failures of training nodes, and the scale of the job may be expanded or shrunk as needed. However, the existing all-reduce algorithm defaults to a design that requires complete reconstruction of the required communicator when the participating nodes change. This can lead to a large number of logical connections between nodes being rebuilt, causing high initialization overhead and routing shock, and thus slowing down the time it takes for the all-reduce operation to resume execution. For scenarios where the progress of training computation depends on the results of the all-reduce operation, this delay increases the idle waiting time of computing resources, leading to waste of resources and decline in training efficiency. For scenarios such as node failure, logical repair solutions such as FTCO (Fault-Tolerant Collective Operations) avoid large-scale reconstruction by directly mounting the child nodes of the failed node to its parent node, although the overhead is low, but it will cause the communication topology to gradually degenerate (for example, from a balanced tree to a star topology), seriously undermining the original communication efficiency advantage, making the root node a communication bottleneck.

[0004] Therefore, in an environment where nodes may dynamically leave or join, how to design a resilient all-reduce method to reduce the reconstruction of logical links and maintain a communication topology that can efficiently utilize bandwidth is a challenge that needs to be addressed. SUMMARY

[0005] To solve the problems in the prior art, the present application proposes a resilient all-reduce method based on complementary binary trees, and the technical solution is as follows: The resilient all-reduce method based on complementary binary trees comprises the following steps: S1. Construct two complementary binary trees pair <T1, T2>; S2. Each node performs all-reduce communication based on binary tree T1 and binary tree T2, and uses the reduced gradient to update the training parameters; Among them, the process of maintaining the communication topology in S2 includes: S21. When a node i leaves, determine the leaf tree T A and the non-leaf tree T B , delete node i in the leaf tree T A , and adjust the connection relationship of the non-leaf tree T B according to the degree of node i in the non-leaf tree T B . S22. When a node i joins, determine whether there is a double leaf node j in the current complementary binary tree pair, and create node i in the binary tree T1 and the binary tree T2 and establish the connection relationship according to the determination result.

[0006] The complementary binary tree (CBTP) based elastic all-reduce method of the application can dynamically modify the communication topology to perform elastic and efficient all-reduce communication. Specifically, the application is based on a double binary tree design, and two complementary binary trees are started to fully utilize the node bandwidth and provide fault tolerance, that is, a node is a non-leaf node in one of the trees, and is a leaf node in the other tree, or is a leaf node in both trees. Therefore, when a node fails, it usually only destroys one tree as a non-leaf node, and in the other tree as a leaf node, the failure does not affect the communication between other nodes, and the remaining active nodes can quickly adjust and restart the all-reduce operation based on the existing topology. In addition, the application can optimize the height of the communication topology by constructing a new communication topology and adjusting the scheme of node joining and leaving, so that the original double binary tree characteristics can be maintained after the node members change.

[0007] It can be seen that the complementary binary tree based elastic all-reduce method of the application adjusts the communication topology while maximizing the reuse of communication links to achieve fault tolerance, fully utilizes the cluster computing resources, avoids the decline in communication efficiency caused by all-reduce member changes, and maintains the effective bandwidth of the communication topology to achieve efficient communication while reducing the change of communication links.

[0008] The application will be further described below in conjunction with the accompanying drawings and specific embodiments. Additional aspects and advantages of the application will be partially given in the following description, partially become apparent from the following description, or be understood through the practice of the application. BRIEF DESCRIPTION OF DRAWINGS

[0009] The accompanying drawings, which form a part of the present application, are used to help understand the present application and are incorporated in and constitute a part of the specification. The contents of the accompanying drawings and the related descriptions in the present application can be used to explain the present application, but do not constitute improper limitations on the present application. In the drawings: Figure 1 The network model diagram of the application.

[0010] Figure 2 Fig. 1 is a schematic diagram of a complementary binary tree pair <T1, T2> generated for n = 6 and n = 7.

[0011] Figure 3 Fig. 4 is a diagram of the tree height of different schemes as the nodes continuously leave for a cluster node number of 128.

[0012] Figure 4 Fig. 5 is a diagram of the tree height of different schemes as the nodes continuously leave for a cluster node number of 256.

[0013] Figure 5 Fig. 6 is a diagram of the bandwidth ratio of CBTP-HO to FTCO as the nodes continuously leave for a cluster node number of 128.

[0014] Figure 6 Fig. 7 is a diagram of the bandwidth ratio of CBTP-HO to FTCO as the nodes continuously leave for a cluster node number of 256. DETAILED DESCRIPTION

[0015] The present application will be described in detail below with reference to the drawings. Those skilled in the art will be able to implement the present application based on these descriptions. Before the present application is described in detail below with reference to the drawings, it is particularly important to note that: The technical solutions and technical features provided in each part of the present application, including the following descriptions, can be combined with each other without conflict.

[0016] In addition, the embodiments of the present application involved in the following description are generally only a part of the embodiments of the present application, not all the embodiments. Therefore, all other embodiments obtained by those skilled in the art based on the embodiments in the present application without creative labor should belong to the scope of protection of the present application.

[0017] Regarding the terms and units in the present application. The terms "include", "have" and any variations thereof in the specification and claims of the present application and related parts are intended to cover non-exclusive inclusion.

[0018] The working scenario of the embodiments of the present application is set as: each participating server can establish a bidirectional connection with any other 4 servers. Such a network environment can be supported in various modern data centers, such as a computer room based on a non-blocking network architecture, and a facility using reconfigurable optical circuit switching (OCS) technology. Specifically, as shown in Fig. 8, a server cluster is formed by 16 servers, and each server can establish a bidirectional connection with any other 4 servers. Figure 1As shown, a non-blocking data center network can typically be abstracted as a single switch through which servers can easily establish bidirectional symmetrical inter-server connections; while an OCS-based architecture (such as OSA) allows each server to dynamically establish direct connections with a preset number of other servers.

[0019] Each node performs a full reduction of the gradients generated during model training using CBTP. All nodes then use the reduced gradients to update their training parameters before proceeding to the next iteration of training, until the model converges. CBTP will make corresponding adjustments if any node joins / leaves or fails during the process.

[0020] An embodiment of the elastic full reduction method based on complementary binary trees of the present invention includes the following steps: S1.CBTP initialization: Construct two complementary binary trees <T1,T2>.

[0021] The construction of binary tree T1 and binary tree T2 consists of three steps: (i) constructing a shared tree structure using an algorithm; (ii) traversing the tree in left-root-right order (i.e., inorder traversal) and mapping the i-th node to the server numbered i-1 to obtain binary tree T1; (iii) generating binary tree T2 based on binary tree T1 through mirroring or offset operations.

[0022] The construction process of binary tree T1 (Algorithm 1) is as follows: Input: Number of nodes n; Output: A binary tree T1 that satisfies the complementary structure; The specific steps are as follows: S10. Assume there are n active servers, numbered 0, 1, ..., n-1; calculate the height parameter h of the binary tree = ⌈log2(n+1)⌉; S11. Determine if the conditions for a complete binary tree are met: If n=2 h If -1, then construct a complete binary tree of height h-1 as binary tree T1; otherwise, execute S12. S12. Perform recursive construction: Construct a binary tree T1 containing only a single node; Construct a complete binary tree of height h−2 as the left subtree of the current binary tree T1; Determine if there are still remaining nodes to allocate: If n−2 h−1 If the number of nodes is 0, then return the constructed binary tree T1; otherwise, recursively execute the above construction process based on the number of remaining nodes to generate a binary tree, and use it as the right subtree of the current binary tree T1.

[0023] After the binary tree T1 is generated, the binary tree T2 is obtained by adjusting the mapping relationship between the nodes and the servers. According to the parity of n, the positions of the servers in the binary tree T2 are determined in the following manner: If n is even (i.e. n%2=0), a mirror operation is adopted: the i-th node in the in-order traversal of the binary tree T2 corresponds to the server with the number n-i-1; If n is odd (i.e. n%2=1), an offset operation is adopted: the i-th node in the in-order traversal of the binary tree T2 corresponds to the server with the number i+1%n.

[0024] Figure 2 Figures showing the complementary binary tree pair <T1, T2> generated for n=6 (a) and n=7 (b). As shown in Figure 2 the above construction design ensures that if a server is a non-leaf node in the binary tree T1 or the binary tree T2, it must be a leaf node in the other binary tree (e.g. node 0 in Figure 2 a); some servers can be leaf nodes in both trees (e.g. node 0 in Figure 2 b).

[0025] The training process is as follows: each node performs full-reduction communication based on the binary tree T1 and the binary tree T2, and updates the training parameters using the reduced gradient.

[0026] According to rigorous proof, there are only three cases for the structure of the complementary binary tree pair <T1, T2>: C1: the number of nodes n is even; C2: the number of nodes n is odd and f1(T1)=f1(T2)=0; C3: the number of nodes n is odd and (f1(T1),f1(T2))∈{(0,2),(2,0)}.

[0027] where f1(x) is the number of nodes with degree 1 in the tree x.

[0028] When initialized using Algorithm 1, the initial complementary binary tree pair <T1, T2> only presents two states of C1 and C2. To reduce the algorithm complexity, the present application ensures that the complementary binary tree pair <T1, T2> always exists in the form of C1 or C2 to support the joining and leaving of nodes. The specific design is as follows: After a node leaves, if the remaining complementary binary tree pair <T1, T2> belongs to C3 (i.e. there are two nodes with degree 1 in the binary tree T1 or the binary tree T2), one of the nodes is converted to C2 by hanging the child nodes of the other node in one step; when a node joins, the updated complementary binary tree pair <T1, T2> is ensured to still be in the form of C1 or C2.

[0029] The following explains in detail how CBTP handles the leaving and joining of nodes based on the above principles. S21. Node i leaves

[0030] When node i leaves, the following two algorithms are used to determine the leaf tree T A and the non-leaf tree T B . Node i is deleted from the leaf tree T A , and the connection relationship of the non-leaf tree T B is adjusted according to the degree of node i in the non-leaf tree T B .

[0031] Algorithm 2 The process of determining the leaf tree T A and the non-leaf tree T B and deleting node i from the leaf tree T A includes: SA1. Determine the degree of node i in the binary tree T1: if the degree of node i in the binary tree T1 is 0, then T1 = T A , T2 = T B ; otherwise, T2 = T A , T1 = T B ; SA2. Delete node i from the leaf tree T A ; SA3. Determine whether there are two nodes j and k with a degree of 1 in the leaf tree T A (i.e., enter C3 state): if there are, execute SA4; if not, execute SA5; SA4. Convert the child nodes of node j into the child nodes of node k (eliminate C3 state and return to C2); SA5. Return (T A , T B ) and end the function.

[0032] The process of adjusting the connection relationship of the non-leaf tree T B according to the degree of node i in the non-leaf tree T B is as follows: Input: the current complementary binary tree pair <T1, T2>; node i that is about to leave; Output: the adjusted complementary binary tree pair <T1, T2>; Specifically, the steps include: SB1. If the degree of node i in the non-leaf tree T B is 1, then directly connect the only child node of node i in the non-leaf tree T B to the parent node of node i (since the degree of node i is 1, there is only one child node), and delete node i; otherwise, execute SB2; SB2. If node i has degree 2 in the non-leaf tree T B , determine whether the current pair of complementary binary trees contains a double leaf node (a server that is a leaf node in both trees): If there is a double leaf node, reconnect the left and right children of node i to the double leaf node and the parent of node i, respectively (corresponding to case C2); If there is no double leaf node, reconnect the left and right children of node i to the node of degree 1 in the non-leaf tree T B and the parent of node i, respectively (corresponding to case C1); SB3. After completing the connection adjustment, delete node i and return the adjusted pair of complementary binary trees <T1, T2> and the algorithm ends.

[0033] When nodes continuously leave, multiple adjustments of Algorithm 2 can cause the tree height to increase significantly, reducing the efficiency of all-reduce. The processing of a degree-2 node i after it leaves the non-leaf tree T B is the main cause of the increase in tree height: if there is a degree-1 node j of height 1 or a double leaf node j of height 0, and the leaving degree-2 node i has a height of h, then the height of the child nodes of node i is h−1. When one of the child nodes is connected to node j, the overall height of the tree will increase by h−2 and h−1, respectively.

[0034] The tree height can be optimized using the replacement idea, i.e., replacing the leaving node i with other nodes to avoid the change in tree height caused by child node adjustment, at the cost of increasing the number of connection rebuilds by a small amount.

[0035] Algorithm 3 The process of determining the leaf tree T A and the non-leaf tree T B and deleting node i in the leaf tree T A includes: SC1. Determine the degree of node i in the binary tree T1: if the degree of node i in the binary tree T1 is 0, then T1=T A , T2=T B ; otherwise, T2=T A , T1=T B ; SC2. Delete node i in the leaf tree T A ; SC3. Determine whether there are two nodes j and k of degree 1 in the leaf tree T A : if there are, execute SC4; if there are not, execute SC5; SC4. Determine whether nodes j and k are at the same level: If not, convert the child nodes of the node at the higher level to the child nodes of the other node; If the same level, the child node of the node with higher height in j and k is connected to the parent node of the node with higher height, and then the node with lower height is connected to the node with higher height as its child node; SC5. Return (T A , T B ), the function ends.

[0036] According to the degree of node i in the non-leaf tree T B , the connection relationship of the non-leaf tree T B is adjusted as follows: Input: the current complementary binary tree pair <T1, T2>; that is, the node i to be left; Output: the adjusted complementary binary tree pair <T1, T2>; Specifically, it includes the following steps: SD1. If the degree of node i in the non-leaf tree T B is 1, the only child node of node i in the non-leaf tree T B is directly connected to the parent node of node i, and node i is deleted; otherwise, SD2 is executed; SD2. If the degree of node i in the non-leaf tree T B is 2, it is judged whether the current complementary binary tree pair contains a double leaf node: If there is a double leaf node j, node i is replaced by the double leaf node j, that is, the position of node i in the non-leaf tree T B is replaced by node j (inherited parent-child connection relationship of i); If there is no double leaf node, a node j with a degree of 1 is selected from the non-leaf tree T B , node i is replaced by the node j, and the original child nodes of node j are reconnected as the child nodes of the parent node of node j (corresponding to case C1); SD3. After the replacement is completed, node i is deleted; the adjusted complementary binary tree pair <T1, T2> is returned, and the algorithm ends.

[0037] When node i is added, the following two algorithms are used to judge whether the current complementary binary tree pair <T1, T2> contains a double leaf node j, and node i is created in binary tree T1 and binary tree T2 according to the judgment result and the connection relationship is established.

[0038] Algorithm 4 The process of creating node i in binary tree T1 and binary tree T2 and establishing the connection relationship is as follows: Input: the current complementary binary tree pair <T1, T2>; that is, the node i to be added; Output: the adjusted complementary binary tree pair <T1, T2>; Specifically, it includes the following steps: SE1. Determine whether the current complementary binary tree pair has a double-leaf node j: if yes, execute SE2; otherwise, execute SE3; SE2. There is a double-leaf node j: create a node i in binary tree T1 and a node i in binary tree T2; set node j in binary tree T1 as a child node of node i; set node j in binary tree T2 as a parent node of node i and set node i as a child node of node j; then return the adjusted complementary binary tree pair <T1, T2> and the algorithm ends; SE3. There is no double-leaf node j: create a node i in binary tree T1 and a node i in binary tree T2; set node i in binary tree T1 as a child node of a node with a degree of 1 in binary tree T1; set node i in binary tree T2 as a child node of a node with a degree of 1 in binary tree T2; then return the adjusted complementary binary tree pair <T1, T2> and the algorithm ends.

[0039] When the complementary binary tree pair <T1, T2> has a double-leaf node j and it is located at the maximum depth of at least one tree, the use of algorithm 4 to insert a new node i will increase the tree height by 1. Similarly, for the addition of node i, the tree height is controlled by optimizing the insertion position.

[0040] Algorithm 5 The process of creating a node i in binary tree T1 and binary tree T2 and establishing a connection relationship is as follows: Input: the current complementary binary tree pair <T1, T2>; the node i to be added; Output: the adjusted complementary binary tree pair <T1, T2>; Specifically comprising the following steps: SF1. Determine whether the current complementary binary tree pair has a double-leaf node j: if yes, execute SF2; otherwise, execute SF3; SF2. Execute position exchange: obtain a leaf node k1 with the maximum height (i.e. the shallowest and uppermost leaf) in binary tree T1 and exchange the positions of node j and node k1; obtain a leaf node k2 with the maximum height in binary tree T2 and exchange the positions of node j and node k2; then execute SF3; SF3. Call algorithm 4 and return the adjusted complementary binary tree pair <T1, T2> and the algorithm ends.

[0041] The beneficial effects of the present application are illustrated by experimental data as follows.

[0042] 1. Tree height comparison Under failure-free condition, the height of the tree generated by CBTP (i.e. Algorithm 1+2+4), CBTP-HO (CBTP with optimized tree height, i.e. Algorithm 1+3+5), FTCO and NCCL (NVIDIA Collective Communications Library) are compared. The initial tree height of all schemes are consistent, close to the theoretical lower bound (⌈log2(n+1)⌉-1, the height of a complete binary tree).

[0043] In the node join scenario, both FTCO and NCCL adapt to the joining of nodes by reconstruction, while the optimized CBTP-HO always maintains the optimal tree height, i.e. the tree height of the reconstructed binary tree of FTCO or NCCL.

[0044] In the failure scenario, the dynamic node departure is simulated and the change of tree height after the failure is tracked to evaluate the resilience. As shown in Figures 3-4 The optimized CBTP-HO controls the growth of tree height to zero, while the baseline CBTP almost doubles the tree height due to the unbalanced subtree insertion. In addition, the average height deviation of CBTP-HO is no more than 2, demonstrating its close-to-optimal height optimization capability. Figures 3-4 It is also shown that the tree height of FTCO is lower than that of CBTP-HO, even lower than the theoretical lower bound (i.e. the height of a complete binary tree), because FTCO relaxes the binary tree constraint by allowing the existence of k-ary k>2 subtree. Therefore, FTCO can achieve a relatively low tree height. However, as will be shown in the next section, this approach inevitably leads to a reduction in effective bandwidth.

[0045] 2. Effective bandwidth CBTP fully utilizes the available bandwidth by aggregating data in parallel through double trees. In theory, the effective bandwidth (Beff) of CBTP is twice that of FTCO. As previously analyzed, FTCO relaxes the binary tree constraint (allows k-ary subtree, k>2) for handling node departure. In tree structure, the outgoing bandwidth of each node is usually limited by the total bandwidth capacity of the node: assuming the total bandwidth capacity of all nodes is B (i.e. the maximum amount of data that a node can transmit per unit time), in a binary tree, each internal node has at most 2 child nodes, and the outgoing bandwidth needs to be allocated to 2 connections, with an available bandwidth of B / 2 for each child edge; in a k-ary tree k>2, the available bandwidth for each child edge is B / k. Since k>2, it is obvious that B / k < B / 2, i.e. the larger the branching factor, the smaller the bandwidth obtained by each child edge. In data transmission, the effective bandwidth is usually determined by the smallest bandwidth link on the path, so k-ary subtree directly leads to a decrease in overall effective bandwidth.

[0046] As shown in Figures 5-6As shown, the bandwidth ratio gradually increases with the increase of the number of remaining nodes, and starts to decrease when the number of cluster nodes is less than 1 / 10 of the initial value. When the number of leaving nodes reaches 1 / 5 of the total number of nodes, the bandwidth ratio reaches 5.

[0047] The above describes the relevant content of the present application. A person of ordinary skill in the art can implement the present application based on the above description. Based on the above content of the present application, all other embodiments obtained by a person of ordinary skill in the art without creative labor shall fall within the protection scope of the present application.

Claims

1. A flexible total reduction method based on complementary binary trees, characterized in that, Includes the following steps: S1. Construct two complementary binary trees <T1,T2>; S2. Each node performs full reduction communication based on binary tree T1 and binary tree T2, and uses the reduced gradient to update the training parameters; The process of maintaining the communication topology in S2 includes: S21. When node i leaves, determine the leaf tree T. A Afrofoliate T B In the leaf tree T A Delete node i, and determine the position of node i in the non-leaf tree T. B Degree adjustment of non-leaf trees T B The connection relationship; S22. When node i is added, determine whether there is a two-leaf node j in the current complementary binary tree pair. Based on the determination result, create node i in binary tree T1 and binary tree T2 and establish a connection relationship.

2. The method according to claim 1, characterized in that: In S1, the construction process of binary tree T1 specifically includes the following steps: S10. Assume there are n active servers, numbered 0, 1, ..., n-1; calculate the height parameter h of the binary tree = ⌈log2(n+1)⌉, that is, the value of log2(n+1) is rounded up. S11. Determine if the condition for a complete binary tree is met: If n = 2 h If -1, then construct a complete binary tree of height h-1 as binary tree T1; otherwise, execute S12. S12. Perform recursive construction: Construct a binary tree T1 containing only a single node; Construct a complete binary tree of height h−2 as the left subtree of the current binary tree T1; Determine if there are still remaining nodes to allocate: If n−2 h−1 If the number of nodes is 0, then return the constructed binary tree T1; otherwise, recursively execute the above construction process based on the number of remaining nodes to generate a binary tree, and use it as the right subtree of the current binary tree T1.

3. The method according to claim 2, characterized in that: Binary tree T2 is generated from binary tree T1 through mirroring or offset operations, with the following specific rules: If n is even, then the i-th node in the inorder traversal of binary tree T2 corresponds to the server numbered ni-1; If n is odd, then the i-th node in the inorder traversal of binary tree T2 corresponds to the server numbered (i+1)%n.

4. The method according to claim 1, characterized in that, In S21, based on node i in the non-leaf tree T B Degree adjustment of non-leaf trees T B The connection relationships specifically include: If node i is in non-leaf tree T B If the degree of node i in the non-leaf tree T is 1, then node i will be placed in the non-leaf tree T. B The only child node in the list is directly connected to the parent node of node i, and node i is deleted; If node i is in non-leaf tree T B If the degree of a binary tree is 2, then determine whether the current complementary binary tree pair contains a two-leaf node, that is, a node that is a leaf node in both trees: If a two-leaf node exists, reconnect the left and right child nodes of node i to the two-leaf node and the parent node of node i, respectively. If no two-leaf nodes exist, reconnect the left and right child nodes of node i to the non-leaf tree T respectively. B The node with degree 1 and the parent node of node i; Delete node i after completing the connection adjustment.

5. The method according to claim 4, characterized in that, Determine leaf tree T A Afrofoliate T B And in leaf tree T A The process of deleting node i includes: Determine the degree of node i in binary tree T1: If the degree of node i in binary tree T1 is 0, then binary tree T1 is determined to be a leaf tree T. A Binary tree T2 is a non-leaf tree T B Otherwise, determine that binary tree T2 is a leaf tree T. A Binary tree T1 is a non-leaf tree T B ; In the leaf tree T A Delete node i; Determine the leaf tree T A Does there exist two nodes j and k with a degree of 1? If so, then convert the child nodes of node j into child nodes of node k.

6. The method according to claim 1, characterized in that, In S21, based on node i in the non-leaf tree T B Degree adjustment of non-leaf trees T B The connection relationships are optimized for tree height using the following method: If node i is in non-leaf tree T B If the degree of node i in the non-leaf tree T is 1, then node i will be placed in the non-leaf tree T. B The only child node in the list is directly connected to the parent node of node i, and node i is deleted; If node i is in non-leaf tree T B If the degree of the binary tree is 2, then determine whether the current complementary binary tree pair contains a two-leaf node: If a two-leaf node j exists, replace node i with the two-leaf node j, that is, replace node i in the non-leaf tree T. B Replace the position in the middle with node j; If no two-leaf nodes exist, from the non-leaf tree T B Select a node j with a degree of 1, replace node i with node j, and reconnect the original child nodes of node j to become the child nodes of the parent node of node j. After the replacement is complete, delete node i.

7. The method according to claim 6, characterized in that, Determine leaf tree T A Afrofoliate T B And in leaf tree T A The process of deleting node i includes: Determine the degree of node i in binary tree T1: If the degree of node i in binary tree T1 is 0, then binary tree T1 is determined to be a leaf tree T. A Binary tree T2 is a non-leaf tree T B Otherwise, determine that binary tree T2 is a leaf tree T. A Binary tree T1 is a non-leaf tree T B ; In the leaf tree T A Delete node i; Determine the leaf tree T A Does there exist two nodes j and k with a degree of 1? If so, determine whether nodes j and k are at the same level. If they are not at the same level, then the child nodes of the higher-level node will be converted to the child nodes of the other node. If they are at the same level, connect the child node of the node with the higher height between j and k to its parent node, and then connect it to the node with the lower height as its child node.

8. The method according to claim 1, characterized in that, S22 specifically includes: Determine if the current complementary binary tree pair contains a two-leaf node j; If a two-leaf node j exists, then create node i in binary tree T1 and node i in binary tree T2; set node j in binary tree T1 as a child node of node i; set node j in binary tree T2 as the parent node of node i, and set node i as a child node of node j. If no two-leaf nodes exist, create node i in binary tree T1 and create node i in binary tree T2; set node i in binary tree T1 as a child node of the node with degree 1 in binary tree T1; set node i in binary tree T2 as a child node of the node with degree 1 in binary tree T2.

9. The method according to claim 1, characterized in that, S22 uses the following method to optimize tree height: Determine if the current complementary binary tree pair contains a two-leaf node j; If a two-leaf node j exists, then perform a position swap: in binary tree T1, find the leaf node k1 with the largest height, and swap the positions of node j and node k1; in binary tree T2, find the leaf node k2 with the largest height, and swap the positions of node j and node k2. After the position swap is completed, or if no two-leaf nodes exist, perform the following join steps: Create node i in binary tree T1, and create node i in binary tree T2; If a two-leaf node exists at the maximum height after the swap or a two-leaf node exists in the original state, then set the two-leaf node in binary tree T1 as the child node of node i, and set the two-leaf node in binary tree T2 as the parent node of node i. Otherwise, set node i in binary tree T1 as a child node of the node with degree 1 in binary tree T1, and set node i in binary tree T2 as a child node of the node with degree 1 in binary tree T2.