Identifier distribution method of equipment, electronic equipment and storage medium

By calculating the matching matrix and determining the optimal matching result in the NPU cluster, the problems of resource waste and performance loss caused by equipment failure are solved, the accurate allocation of identification information and the best matching of topology are achieved, and the robustness and dynamic flexibility of the cluster are improved.

CN121859968APending Publication Date: 2026-04-14HANG ZHOU GUO KE WEI DIAN ZI YOU XIAN GONG SI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In a multi-neural network processor (NPU) cluster, device failure can lead to the failure of matching the entire subtree, resulting in wasted resources and performance loss. How to efficiently assign the correct identifiers to the available NPUs in the cluster has become an urgent problem to be solved.

Method used

By obtaining the ideal topology tree and the target actual topology tree, the matching matrix is ​​calculated, the optimal matching result is determined using the Hungarian algorithm, and the identification information of the ideal topology tree is assigned to the devices of the corresponding nodes in the target actual topology tree to ensure the best match between the identification assignment and the physical topology.

Benefits of technology

Even in the event of equipment malfunction, it can ensure the accurate allocation of identification information, improve the robustness and dynamic flexibility of the equipment cluster, and avoid resource waste and performance loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121859968A_ABST
    Figure CN121859968A_ABST
Patent Text Reader

Abstract

The invention provides a device identifier allocation method, an electronic device and a storage medium, and the device identifier allocation method comprises the steps: obtaining an ideal topology tree and a target actual topology tree; wherein each node of the ideal topology tree comprises identification information; comparing the ideal topology tree with the target actual topology tree to obtain a comparison result; calculating a matching weight in the ideal topology tree and the target actual topology tree according to the comparison result to obtain a matching matrix; and according to the matching matrix, determining an optimal matching result, and according to the optimal matching result, allocating identification information of a corresponding node in the ideal topology tree to equipment of a corresponding node in the target actual topology tree. Through the technical scheme provided by the invention, various scenes such as equipment addition, offline and faults can be dealt with, and even if the sub-tree in the target actual topology tree is incomplete, the remaining nodes in the sub-tree can be successfully allocated with the identification information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a device identification allocation method, electronic device, and storage medium. Background Technology

[0002] Due to limitations in bus bandwidth and communication efficiency, the number of sub-NPUs that can be attached to a single NPU device in a multi-neural network processing unit (NPU) cluster is finite. Large-scale NPU clusters often use a tree-like cascaded topology where a single NPU leads to N sub-NPUs, and each sub-NPU leads to N more NPUs. On the other hand, large-scale model training and inference often require NPUs to support complex cascaded communication and inter-card communication. This necessitates assigning a fixed device identifier to each NPU in the cluster as a unique identifier for host access and NPU inter-card communication. Considering the possibility of device failure in the cluster, the failure of a single device will cause the matching of the entire subtree containing that device to fail. All devices in the subtree will become unusable due to the lack of ID values, resulting in significant resource waste and performance degradation for the NPU cluster. How to efficiently assign the correct identifiers to the available NPUs in the cluster in the event of device failure has become an urgent problem to be solved. Summary of the Invention

[0003] This invention provides a device identification allocation method, an electronic device, and a storage medium to address the deficiencies in the prior art.

[0004] This invention provides a device identifier allocation method, applied in the field of NPU, comprising: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information; The ideal topology tree and the target actual topology tree are compared to obtain the comparison result; Based on the comparison results, the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix; Based on the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

[0005] According to a device identifier allocation method provided by the present invention, obtaining the ideal topology tree and the target actual topology tree includes: The ideal topology tree is constructed according to the configuration file; wherein, the configuration file includes the identification information; Based on the topology of the devices already online, construct the target actual topology tree.

[0006] According to a device identifier allocation method provided by the present invention, the step of comparing the ideal topology tree and the target actual topology tree to obtain a comparison result includes: The number of subtrees under the root node of the ideal topology tree is compared with the number of subtrees under the root node of the target actual topology tree to obtain the comparison result.

[0007] According to a device identifier allocation method provided by the present invention, after obtaining the comparison result, the method further includes: If the number of subtrees under the root node of the ideal topology tree is less than the number of subtrees under the root node of the target actual topology tree, then the subtrees under the root node of the target actual topology tree are pruned. If the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree, then the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix.

[0008] According to a device identifier allocation method provided by the present invention, the step of calculating the matching weights in the ideal topology tree and the target actual topology tree to obtain a matching matrix includes: The matching weights of the ideal topological tree subtree and the corresponding subtree of the target actual topological tree are calculated layer by layer using a recursive method. The matching matrix is ​​constructed based on the matching weights.

[0009] According to a device identifier allocation method provided by the present invention, the step of determining the optimal matching result based on the matching matrix includes: The maximum matching weight of the matching matrix is ​​calculated using the Hungarian algorithm; The ideal topology tree node corresponding to the maximum matching weight and the corresponding node of the target actual topology tree are taken as the optimal matching result.

[0010] According to a device identifier allocation method provided by the present invention, the step of allocating the identifier information of a corresponding node in the ideal topology tree to a corresponding node in the target actual topology tree includes: The identification information of the corresponding node in the ideal topology tree is recursively distributed layer by layer to the device of the corresponding node in the target actual topology tree.

[0011] According to a device identifier allocation method provided by the present invention, the method further includes: A new actual topology tree is obtained based on the status information of the device, and the new actual topology tree is used as the target actual topology tree.

[0012] The present invention also provides a device identification allocation apparatus for an NPU, comprising: The acquisition module is configured to acquire an ideal topology tree and a target actual topology tree; wherein each node of the ideal topology tree includes identification information; The comparison module is configured to compare the ideal topology tree with the target actual topology tree to obtain a comparison result; The calculation module is configured to calculate the matching weights in the ideal topology tree and the target actual topology tree based on the comparison results, and obtain a matching matrix; The allocation module is configured to determine the optimal matching result based on the matching matrix, and allocate the identification information of the corresponding node in the ideal topology tree to the device of the corresponding node in the target actual topology tree based on the optimal matching result.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement an identification allocation method for any of the devices described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the identification allocation method for any of the devices described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the identification allocation method for any of the devices described above.

[0016] The device identifier allocation method, electronic device, and storage medium provided by this invention compare an ideal topology tree with a target actual topology tree to obtain a comparison result. Based on the comparison result, matching weights in the ideal and target actual topology trees are calculated to obtain a matching matrix. The optimal matching result is determined according to the matching matrix, and the identifier information of the corresponding node in the ideal topology tree is allocated to the corresponding node in the target actual topology tree based on the optimal matching result. The matching weights are determined based on the comparison result between the ideal and target actual topology trees. The comparison result reveals the similarity of the deep structure of the topology, ensuring that similar subtrees in the ideal and target actual topology trees are matched together, thus guaranteeing the best fit between identifier allocation and physical topology. The technical solution provided by this invention can address various scenarios such as device addition, disconnection, and failure. Even if the target actual topology tree is incomplete, as long as its structure can be found in the ideal topology tree, identifier information can be successfully allocated, solving the problem of abnormal nodes in the target actual topology tree causing other nodes in the same subtree to fail to come online. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the device identifier allocation method provided by the present invention.

[0019] Figure 2 This is a schematic diagram of an ideal topology tree in an embodiment provided by the present invention.

[0020] Figure 3 This is a schematic diagram of the target actual topology tree in the embodiments provided by the present invention.

[0021] Figure 4 This is a schematic diagram of the identification allocation device for the equipment provided by the present invention.

[0022] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0024] Figure 1 This is a flowchart illustrating a device identifier allocation method according to an exemplary embodiment. Figure 1 As shown in an exemplary embodiment, the device identification allocation method is applied in the field of NPU and includes steps 110 to 140, which are described in detail below.

[0025] Step 110: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information.

[0026] This invention provides a method for automatic identifier allocation and management in a cluster network containing large-scale neural network processors. For example... Figure 2As shown, this cluster network is controlled by a master computer (PC), which connects to NPU1, NPU2, and NPU3. NPU1 then connects to NPU4, and so on. This complete structure diagram, which includes all the planned devices and their identification information, can be regarded as an ideal topology tree.

[0027] An ideal topology tree is a logical tree structure pre-constructed according to the system design blueprint, representing a complete and fault-free cluster state. In this embodiment of the invention, the ideal topology tree can be generated by parsing a configuration file. This configuration file can be an XML, JSON, or YAML file, which defines in detail the parent-child relationships, hierarchical structure, and unique identifiers pre-assigned to each neural network processor in the design. Specifically, the configuration file includes the name of each neural network processor, its unique identifier, its parent-child relationship with other nodes, and its hierarchical information. This identifier is bound to the position of the neural network processor in the ideal topology. It should be noted that this identifier can be a static identifier. For example, the identifier of an NPU directly mounted under the host computer can be configured as 0x01; while the identifier of the first child NPU mounted under this NPU can be configured as 0x0101. When the host computer starts the initialization program, it first reads this configuration file and constructs this complete ideal topology tree with identifier information in memory.

[0028] The target actual topology tree can represent the actual online and connection status of devices in the current cluster network. In this embodiment, the target actual topology tree is dynamically constructed by the master computer scanning the cluster network.

[0029] Specifically, during the initialization phase, the host computer sends discovery signaling to its bus or network ports. Each powered-on and functional neural network processor, upon receiving the signaling or starting up automatically, reports its existence to its parent node (or directly to the host). The host collects this reported information and, based on the physical connectivity of the devices (e.g., from which port the report was received), constructs a tree structure in memory containing only currently online neural network processors. The nodes of the constructed target topology tree do not contain any identifier information; they merely reflect the physical topological relationships between the neural network processors.

[0030] Step 120: Compare the ideal topology tree with the target actual topology tree to obtain the comparison result.

[0031] In this embodiment of the invention, the ideal topology tree and the target actual topology tree are structurally compared step by step to obtain the comparison result. The comparison result characterizes the similarity or difference between the ideal topology tree and the target actual topology tree. Subsequently, based on the comparison result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

[0032] It should be noted that the device in this embodiment refers to the neural network processor in the actual topology tree. Of course, this technical solution can also be applied to other application scenarios that require building a topology tree, such as CPUs and graphics processing accelerators. The corresponding devices are CPUs, graphics processing accelerators, etc.

[0033] Step 130: Calculate the matching weights in the ideal topology tree and the target actual topology tree based on the comparison results to obtain the matching matrix.

[0034] In this embodiment of the invention, the matching weight is a numerical value used to characterize the degree of matching between a certain substructure in the ideal topology tree and a certain substructure in the target actual topology tree. The higher the weight, the more similar the two are structurally. For example, the matching weight can be calculated by counting the number of nodes with the same shape in the two substructures. The matching weights calculated pairwise between each substructure of the ideal topology tree and each substructure of the target actual topology tree can be arranged into a two-dimensional table, which is the matching matrix.

[0035] Step 140: Determine the optimal matching result based on the matching matrix, and allocate the identification information of the corresponding node in the ideal topology tree to the device of the corresponding node in the target actual topology tree based on the optimal matching result.

[0036] In this embodiment of the invention, the optimal matching result is an optimal pairing scheme found using a preset optimization algorithm based on the matching matrix. This pairing scheme maximizes the sum of the overall matching weights between the ideal topology tree and the target actual topology tree. This pairing scheme represents which node (or subtree) in the ideal topology tree each node (or subtree) in the target actual topology tree should correspond to. After determining this optimal correspondence, the identification information of the nodes in the ideal topology tree can be accurately assigned to the node devices in the target actual topology tree corresponding to them in the optimal matching result.

[0037] In this embodiment of the invention, an ideal topology tree is compared with a target actual topology tree to obtain a comparison result. Based on the comparison result, matching weights in the ideal and target actual topology trees are calculated to obtain a matching matrix. According to the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree. The matching weights are determined based on the comparison result between the ideal and target actual topology trees. The comparison result reveals the deep structural similarity of the topology, ensuring that similar subtrees in the ideal and target actual topology trees are matched together, thereby guaranteeing the best fit between the identification assignment and the physical topology. Through the technical solution provided by this invention, even if a single device is damaged or a single node is abnormal, it will not affect the allocation of identification information for other online devices, ensuring that the identification information allocation of the device cluster always accurately corresponds to the topology structure, improving the robustness and dynamic flexibility of the allocation method.

[0038] In an exemplary embodiment of the present invention, obtaining the ideal topology tree and the target actual topology tree includes: The ideal topology tree is constructed according to the configuration file; wherein, the configuration file includes the identification information; Based on the topology of the devices already online, construct the target actual topology tree.

[0039] In this embodiment of the invention, an ideal topology tree is constructed based on a configuration file. This configuration file is a persistently stored data file, and its format can be, but is not limited to, XML, JSON, YAML, or a custom text format. The configuration file predefines the complete topology of the entire NPU cluster in a structured manner. For example, the configuration file defines the parent node information of each NPU node (except the root node), as well as the child node information included by that parent node, and predefines unique identification information for each node. By parsing this configuration file, a complete ideal topology tree with all identification information can be constructed in memory.

[0040] Simultaneously, based on the topology of the online devices, a target actual topology tree is constructed. This can be done by sending probe commands to the bus or network, polling device status, etc., to scan for NPU devices that are physically powered on and have established communication connections. By collecting the online and connection information of each online device (e.g., each device reports the physical address or port number of its parent device), the current actual device connection relationships can be reconstructed from bottom to top or top to bottom, thereby constructing a target actual topology tree that does not contain identification information but only reflects the online status and physical connection status of the devices.

[0041] This embodiment obtains two types of topology trees from static configuration files and dynamic device scans respectively, providing a reliable and clear data source for subsequent comparison and matching.

[0042] In an exemplary embodiment of the present invention, comparing the ideal topology tree and the target actual topology tree to obtain a comparison result includes: The number of subtrees under the root node of the ideal topology tree is compared with the number of subtrees under the root node of the target actual topology tree to obtain the comparison result.

[0043] In this embodiment of the invention, the first round of comparison operations focuses on the root nodes of the ideal topology tree and the target actual topology tree. The number of subtrees under the root node of the ideal topology tree is compared with the number of subtrees under the root node of the target actual topology tree to obtain the comparison result. It should be noted that, in addition to comparing the number of subtrees under the root node of the ideal topology tree with the number of subtrees under the root node of the target actual topology tree, the comparison operation between the ideal topology tree and the target actual topology tree can also be carried out by traversal sequence comparison methods, such as performing preorder, inorder, postorder or level-order traversal on the two trees to obtain the node identifier sequence. Then, string comparison algorithms (such as longest common subsequence LCS, difference comparison) are used to analyze the sequence differences, and the identifier information is assigned according to the analysis results.

[0044] Specifically, first, the root nodes of the ideal topology tree and the target actual topology tree are located respectively (i.e., ... Figure 2 (The image shows a PC node representing the host). Then, the number of first-level child nodes connected to this root node is counted. Each child node and all its descendant nodes together form a subtree. By comparing the number of subtrees under these two root nodes, a preliminary comparison result can be quickly obtained. For example, if the root node of the ideal topology tree has 3 child nodes (3 subtrees), while the root node of the target actual topology tree only has 2 child nodes (2 subtrees), then the comparison result is that the number of subtrees under the root node of the ideal topology tree is greater than the number of subtrees under the root node of the target actual topology tree. Therefore, the steps of calculating the matching weights and matching matrices in the ideal and target actual topologies can be performed. This comparison is simple, efficient, and allows for a quick judgment of the similarity of the top-level structures of the ideal and target actual topologies, providing a rapid decision-making basis for subsequent more complex matching or pruning operations.

[0045] In an exemplary embodiment of the present invention, after obtaining the comparison result, the method further includes: If the number of subtrees under the root node of the ideal topology tree is less than the number of subtrees under the root node of the target actual topology tree, then the subtrees under the root node of the target actual topology tree are pruned. If the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree, then the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix.

[0046] In this embodiment of the invention, after obtaining the comparison result, if the comparison result indicates that the number of subtrees under the root node of the ideal topology tree is less than the number of subtrees under the root node of the target actual topology tree, then the subtrees under the root node of the target actual topology tree are pruned. That is, if the number of subtrees under the root node of the target actual topology tree formed by the actual online device is more than the number of subtrees under the root node of the ideal topology tree, this is logically impossible to achieve a perfect match. Therefore, in this case, it is determined that the current target actual topology tree does not match the ideal topology tree, and a pruning operation is performed, that is, subsequent calculations of the target actual topology tree and all its lower-level nodes are abandoned to avoid invalid matching.

[0047] Conversely, if the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree, then the matching weights in the ideal and target actual topology trees are calculated to obtain the matching matrix. When the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree, it means that the subtrees in the ideal topology tree are sufficient and can potentially accommodate all the subtrees in the target actual topology tree. Therefore, the matching process can continue, proceeding to the next stage of calculating the matching weights.

[0048] In an exemplary embodiment of the present invention, calculating the matching weights in the ideal topology tree and the target actual topology tree to obtain a matching matrix includes: The matching weights of the ideal topological tree subtree and the corresponding subtree of the target actual topological tree are calculated layer by layer using a recursive method. The matching matrix is ​​constructed based on the matching weights.

[0049] In this embodiment of the invention, the matching weights of the subtrees of the ideal topology tree and the corresponding subtrees of the target actual topology tree are calculated recursively layer by layer. The matching weight represents the total number of structurally matching nodes in the two subtrees.

[0050] Specifically, in the first round, the root node of the ideal topology tree and all subtrees under the root node of the actual topology tree are respectively regarded as two vertex sets VC and VT of the bipartite graph G. To determine the matching weight between a subtree Ci in the vertex set VC corresponding to the ideal topology tree and a subtree Tj in the vertex set VT corresponding to the target actual topology tree, subtree Ci and subtree Tj are regarded as two new, independent trees, and the sets of subtrees under their root nodes are defined as vertex sets VC' and VT', respectively. That is, the grandchildren of the subtrees under the root nodes of the ideal topology tree and the target actual topology tree form the new vertex sets VC' and VT'. The above process of comparison, pruning, or calculating matching weights is repeated for the subtrees in vertex sets VC' and VT', thereby obtaining the total number of nodes that the two subtrees Ci and Tj can match using the optimal matching method. This total number of nodes is defined as the matching weight between Ci and Tj. The recursion terminates when a tree becomes a leaf node (without subtrees).

[0051] After calculating the matching weights of all subtree pairs between vertex sets VC and VT, a matching matrix is ​​constructed based on the obtained matching weights, resulting in a matrix of size |VC|x|VT|. The value of matrix element M(i,j) is the matching weight between the i-th subtree of the ideal topology tree and the j-th subtree of the target actual topology tree, calculated using the above recursive method.

[0052] In this embodiment of the invention, with Figure 2 and Figure 3 Taking the topology tree structure shown as an example, as Figure 2 and Figure 3 As shown, Figure 2 As an ideal topological tree, Figure 3 As a practical topological tree, Figure 3 NPU6 was not displayed in the target actual topology tree due to an anomaly.

[0053] During recursive matching, the three subtrees under the root node of the ideal topology tree are combined into a vertex set VC={C1,C2,C3}, and the three subtrees under the root node of the target actual topology tree are combined into a vertex set VT={T1,T2,T3}. A subtree T1 is selected from the target actual topology tree, and a subtree C1 is selected from the ideal topology tree. Recursive matching is then performed between the two selected subtrees. In the two selected subtrees, the corresponding root nodes can be confirmed as matching. However, to confirm the number of nodes that can be matched between the two selected subtrees, we need to form a new vertex set using the subtrees under the root nodes of the two subtrees, i.e., VC'={C4} and VT'={T4}. At this time, the root nodes of subtrees C4 and T4 still have child nodes, and the recursion termination condition has not been met. Then, we treat subtrees C4 and T4 as new trees and construct a new vertex set, i.e., VC''={C5, C6} and VT''={T5, T6}. The subtrees in vertex sets VC'' and VT'' are all leaf nodes, and the recursion termination condition has been met. We calculate the matching weight of VC'' and VT''. If subtree C5 matches subtree T5, then the matching weight of subtree C5 and subtree T5 is 1. If subtree C6 matches subtree T6, then the matching weight of subtree C6 and subtree T6 is 1. Furthermore, the maximum number of matching nodes at the level of subtrees C4 and T4 is 1 (root node) + 1 (C5-T5) + 1 (C6-T6) = 3. Therefore, the matching weight of subtrees C4 and T4 is 3. Further, the maximum number of matching nodes at the level of subtrees C1 and T1 is 1 + the maximum number of matching nodes at the previous level is 3 = 4. Therefore, the matching weight of subtrees C1 and T1 is 4.

[0054] Then, a subtree is selected from vertex sets VC and VT respectively for recursive calculation, such as C2 and T2, and so on, completing the recursion between subtrees in vertex sets VC and VT until the matching of the entire topology tree is completed. At each level, a matching matrix is ​​constructed between the two matched vertex sets based on the determined maximum number of matching nodes. For example, vertex sets VC and VT can form a 3×3 matching matrix.

[0055] By recursively calculating the weights, the characteristics of the tree structure at each level can be fully considered, ensuring that the calculation of the matching weights can accurately reflect the true structural similarity of the two subtrees, thus laying a solid foundation for obtaining the global optimal matching solution.

[0056] In an exemplary embodiment of the present invention, determining the optimal matching result based on the matching matrix includes: The maximum matching weight of the matching matrix is ​​calculated using the Hungarian algorithm; The ideal topology tree node corresponding to the maximum matching weight and the corresponding node of the target actual topology tree are taken as the optimal matching result.

[0057] In this embodiment of the invention, the Hungarian algorithm is used to calculate the maximum matching weight of the matching matrix. The Hungarian algorithm is a classic algorithm for solving the maximum matching problem in bipartite graphs in graph theory. This embodiment uses the Hungarian algorithm to quickly determine the maximum matching weight of the matching matrix, reducing time complexity and enabling rapid allocation of identification information for large-scale device clusters.

[0058] In this embodiment, the vertex set VC of the ideal topological tree and the vertex set of the target actual topological tree constitute the two sides of the bipartite graph, and the weights of the edges connecting them are the previously calculated matching weights. Based on the matching matrix, the Hungarian algorithm can efficiently find a one-to-one matching scheme that maximizes the sum of the weights of the selected matching pairs. This maximum sum of weights is the maximum matching weight.

[0059] Then, the ideal topology tree node corresponding to the maximum matching weight and the corresponding node in the target actual topology tree are taken as the optimal matching result. The output of the Hungarian algorithm is not only the maximum weight itself, but more importantly, the specific matching pair that generated this maximum weight. For example, the output result might be that subtree C1 in the ideal topology graph matches subtree T1 in the target actual topology tree, and subtree C3 in the ideal topology tree matches subtree T2 in the target actual topology tree. This set of matching pairs is the optimal matching result.

[0060] The Hungarian algorithm provides a mature, efficient, and globally optimal mathematical tool for finding the best match. It ensures that among many possible matching combinations, the algorithm selects the device that matches the largest number of devices in the actual target topology tree with the nodes in the ideal topology tree, thus achieving a precise match between the identification information and the topology.

[0061] In an exemplary embodiment of the present invention, the device for allocating the identification information of the corresponding node in the ideal topology tree to the corresponding node in the target actual topology tree includes: The identification information of the corresponding node in the ideal topology tree is recursively distributed layer by layer to the device of the corresponding node in the target actual topology tree.

[0062] In this embodiment of the invention, after obtaining the optimal matching result, the identification information of the corresponding node in the ideal topology tree is recursively distributed layer by layer to the device corresponding to the node in the target actual topology tree.

[0063] Specifically, first, the identifier information of the root node of the ideal topology tree is assigned to the root node of the target actual topology tree. Based on the optimal matching result, all successfully matched subtree pairs at the next level below the root node are found, such as subtree C1 in the ideal topology graph matching subtree T1 in the target actual topology tree. For each matched subtree pair, the identifier information of the root node of subtree C1 is first assigned to the root node device of subtree T1. Then, the identifier information is reassigned to the next level child nodes of subtrees C1 and T1 based on their internal matching results. This recursive process proceeds from top to bottom, layer by layer, until all nodes matched in the optimal matching result have been assigned the corresponding identifier information.

[0064] The recursive logic used for identifier allocation is consistent with the recursive logic used for calculating matching weights, ensuring that the identifier allocation process strictly follows the determined optimal matching result. This achieves a tight and orderly binding between static identifier information and dynamic topology, ensuring the consistency and traceability of identifier information during device online / offline processes.

[0065] In one exemplary embodiment of the present invention, the method further includes: A new actual topology tree is obtained based on the status information of the device, and the new actual topology tree is used as the target actual topology tree.

[0066] In this embodiment of the invention, a new actual topology tree is obtained based on the device status information, and this new actual topology tree is used as the target actual topology tree. Device status information refers to information that reflects changes in the NPU cluster topology. This includes information about new devices coming online; that is, when a new NPU device powers on and successfully connects to its parent node, an online signal is received, or the new device is detected during periodic scanning. Device status information also includes information about devices going offline; for example, when a running NPU device loses connection due to a fault, power outage, or connection interruption, the loss of its heartbeat or disconnection is detected.

[0067] Once the device status information is obtained, the currently maintained actual topology structure is updated to obtain a new actual topology tree. Then, this updated actual topology tree is used as the new target actual topology tree, triggering subsequent identifier allocation or management processes. The status information includes new NPU devices coming online, and existing NPU devices going offline or malfunctioning.

[0068] When a new NPU device comes online, there's no need for a global re-matching of the entire NPU cluster. Specifically, the parent node connected to the newly added NPU device is located and designated as the root node within a local scope. Then, the aforementioned matching and identifier allocation process is performed only on the subtree structure under that parent node. This allows for the rapid and accurate allocation of identifier information to the new NPU device without affecting the normal operation of other parts of the NPU cluster. Through this localized processing, the addition of a new NPU device does not affect other stable and fixed identifier parts of the cluster network, significantly reducing the computational overhead of dynamic maintenance and enabling rapid and efficient response to topology changes.

[0069] In response to device downtime, upon detection of a device failure, the node and all its child nodes are removed from the current topology tree, resulting in a new, smaller topology tree. Simultaneously, the previously assigned identification information for these downtime devices is recorded and stored. When the device re-enters the network for any reason (such as a system restart or recovery after a brief power outage), it can directly read the previously saved identification information from its local storage and include this information in its reported data. Upon receiving this report with clear identification information, the host no longer needs to perform a complex recursive matching process. Instead, it can directly confirm the device's identity and position in the ideal topology tree based on the identification information, thus achieving rapid device identification and communication recovery, further improving the efficiency and robustness of the entire cluster network management.

[0070] The device identification allocation apparatus provided by the present invention will be described below. The device identification allocation apparatus described below can be referred to in correspondence with the device identification allocation method described above. It should be noted that the apparatus provided in the following embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module and unit performs its operation has been described in detail in the method embodiments, and will not be repeated here.

[0071] In one exemplary embodiment of the present invention, please refer to Figure 4 , Figure 4 This is an exemplary embodiment of a device identification allocation apparatus applied in the field of NPU, which includes the following modules.

[0072] The acquisition module 410 is configured to acquire an ideal topology tree and a target actual topology tree; wherein each node of the ideal topology tree includes identification information; The comparison module 420 is configured to compare the ideal topology tree with the target actual topology tree to obtain a comparison result; The calculation module 430 is configured to calculate the matching weights in the ideal topology tree and the target actual topology tree based on the comparison result, and obtain a matching matrix; The allocation module 440 is configured to determine the optimal matching result based on the matching matrix, and allocate the identification information of the corresponding node in the ideal topology tree to the device of the corresponding node in the target actual topology tree based on the optimal matching result.

[0073] In an exemplary embodiment of the present invention, the acquisition module 410 includes: The first submodule is configured to build the ideal topology tree according to a configuration file; wherein the configuration file includes the identification information. The second submodule is configured to build the target actual topology tree based on the topology of the online devices.

[0074] In an exemplary embodiment of the present invention, the comparison module 420 includes: The comparison submodule is configured to compare the number of subtrees under the root node of the ideal topology tree with the number of subtrees under the root node of the target actual topology tree to obtain the comparison result.

[0075] In an exemplary embodiment of the present invention, the device identification allocation apparatus further includes: The pruning submodule is configured to prune the subtrees under the root node of the target actual topology tree if the number of subtrees under the root node of the ideal topology tree is less than the number of subtrees under the root node of the target actual topology tree. The first calculation submodule is configured to calculate the matching weights in the ideal topology tree and the target actual topology tree to obtain the matching matrix if the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree.

[0076] In an exemplary embodiment of the present invention, the computing module 430 includes: The second calculation submodule is configured to calculate the matching weights of the ideal topology tree subtree and the corresponding subtree of the target actual topology tree layer by layer in a recursive manner; A submodule is configured to construct the matching matrix based on the matching weights.

[0077] In an exemplary embodiment of the present invention, the allocation module 440 includes: The third calculation submodule is configured to use the Hungarian algorithm to calculate the maximum matching weight of the matching matrix; As a submodule, it is configured to take the ideal topology tree node corresponding to the maximum matching weight and the corresponding node of the target actual topology tree as the optimal matching result.

[0078] In an exemplary embodiment of the present invention, the allocation module 440 includes: The allocation submodule is configured to recursively allocate the identification information of the corresponding nodes in the ideal topology tree to the corresponding nodes in the target actual topology tree.

[0079] In an exemplary embodiment of the present invention, the device identification allocation apparatus further includes: As a module, it is configured to obtain a new actual topology tree based on the status information of the device, and use the new actual topology tree as the target actual topology tree.

[0080] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a device identifier allocation method, which is applied in the NPU field and includes: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information; The ideal topology tree and the target actual topology tree are compared to obtain the comparison result; Based on the comparison results, the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix; Based on the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

[0081] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0082] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program, the computer program being able to be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer being able to execute the device identification allocation method provided by the above methods, the method being applied in the field of NPU, including: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information; The ideal topology tree and the target actual topology tree are compared to obtain the comparison result; Based on the comparison results, the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix; Based on the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

[0083] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the device identifier allocation method provided by the methods described above. This method is applied in the field of NPUs and includes: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information; The ideal topology tree and the target actual topology tree are compared to obtain the comparison result; Based on the comparison results, the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix; Based on the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

[0084] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any inventive effort.

[0085] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for assigning device identifiers, characterized in that, Applications in the NPU field include: Obtain the ideal topology tree and the target actual topology tree; wherein each node of the ideal topology tree includes identification information; The ideal topology tree and the target actual topology tree are compared to obtain the comparison result; Based on the comparison results, the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix; Based on the matching matrix, the optimal matching result is determined, and based on the optimal matching result, the identification information of the corresponding node in the ideal topology tree is assigned to the device of the corresponding node in the target actual topology tree.

2. The device identification allocation method according to claim 1, characterized in that, The process of obtaining the ideal topology tree and the target actual topology tree includes: The ideal topology tree is constructed according to the configuration file; wherein, the configuration file includes the identification information; Based on the topology of the devices already online, construct the target actual topology tree.

3. The device identification allocation method according to claim 1, characterized in that, The step of comparing the ideal topology tree and the target actual topology tree to obtain a comparison result includes: The number of subtrees under the root node of the ideal topology tree is compared with the number of subtrees under the root node of the target actual topology tree to obtain the comparison result.

4. The device identification allocation method according to claim 3, characterized in that, After obtaining the comparison result, the process further includes: If the number of subtrees under the root node of the ideal topology tree is less than the number of subtrees under the root node of the target actual topology tree, then the subtrees under the root node of the target actual topology tree are pruned. If the number of subtrees under the root node of the ideal topology tree is greater than or equal to the number of subtrees under the root node of the target actual topology tree, then the matching weights in the ideal topology tree and the target actual topology tree are calculated to obtain the matching matrix.

5. The device identification allocation method according to claim 1, characterized in that, The calculation of the matching weights in the ideal topology tree and the target actual topology tree to obtain the matching matrix includes: The matching weights of the ideal topological tree subtree and the corresponding subtree of the target actual topological tree are calculated layer by layer using a recursive method. The matching matrix is ​​constructed based on the matching weights.

6. The device identification allocation method according to claim 1, characterized in that, The step of determining the optimal matching result based on the matching matrix includes: The maximum matching weight of the matching matrix is ​​calculated using the Hungarian algorithm; The ideal topology tree node corresponding to the maximum matching weight and the corresponding node of the target actual topology tree are taken as the optimal matching result.

7. The device identification allocation method according to claim 1, characterized in that, The device for assigning the identification information of the corresponding node in the ideal topology tree to the corresponding node in the target actual topology tree includes: The identification information of the corresponding node in the ideal topology tree is recursively distributed layer by layer to the device of the corresponding node in the target actual topology tree.

8. The device identification allocation method according to any one of claims 1 to 7, characterized in that, The method further includes: A new actual topology tree is obtained based on the status information of the device, and the new actual topology tree is used as the target actual topology tree.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the device identification allocation method as described in any one of claims 1 to 8.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the device identification allocation method as described in any one of claims 1 to 8.