Communication method and related apparatus

By adjusting the storage location and communication order of data blocks in the device memory, the problem of mismatch between communication traffic and bandwidth between devices in the computing cluster was solved, and the execution efficiency of aggregated communication was improved.

WO2026242909A1PCT designated stage Publication Date: 2026-11-26HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2026/096929
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-08-28
Filing Date
2026-05-14
Publication Date
2026-11-26

AI Technical Summary

Technical Problem

The mismatch between inter-device communication traffic and link bandwidth within the computing cluster leads to low efficiency in aggregated communication execution.

Method used

By adjusting the location of the device's fragmented data in memory and rearranging the storage order of data blocks, the communication volume between devices within the same computing node is increased, the communication volume between different computing nodes is reduced, and the execution order of aggregate communication operations is optimized.

Benefits of technology

It improves the communication efficiency between devices within a computing node and reduces the communication volume between different computing nodes, thereby improving the overall execution efficiency of aggregated communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026096929_26112026_PF_FP_ABST
    Figure CN2026096929_26112026_PF_FP_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of computing. Disclosed in the embodiments of the present application are a communication method and a related apparatus. In the embodiments of the present application, positions of data blocks provided by a plurality of devices in memory are rearranged, and then an execution sequence of collective communication operations between devices of a same computing node and collective communication operations between devices of different computing nodes is adjusted, so as to reduce data blocks transmitted in a single transmission between devices of different computing nodes, and increase data blocks transmitted in a single transmission between devices of a same computing node, thereby reducing transmission traffic between devices of different computing nodes and increasing transmission traffic between devices of a same computing node, and thus improving the execution efficiency of collective communication.
Need to check novelty before this filing date? Find Prior Art

Description

Communication methods and related devices

[0001] This application claims priority to Chinese Patent Application No. 202510661149.2, filed on May 21, 2025, entitled "A Calculation Method", and to Chinese Patent Application No. 202511224908.5, filed on August 28, 2025, entitled "Communication Method and Related Apparatus", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of computing technology, and in particular to a communication method and related apparatus. Background Technology

[0003] Collective communication is a global communication operation involving all devices within a computing cluster (such as graphics processing units, GPUs). During the training and inference of large models, collective communication can be used to achieve multiple data transfers between devices.

[0004] Multiple devices within a computing cluster are typically deployed across multiple computing nodes (such as servers). When performing global communication operations, a mismatch often occurs between communication traffic and link bandwidth. For example, the link bandwidth between devices within a computing node is large while the communication traffic is small, while the link bandwidth between devices deployed on different computing nodes is small while the communication traffic is large, affecting the execution efficiency of aggregated communication. Summary of the Invention

[0005] This application provides a communication method and related apparatus that improves the efficiency of aggregated communication by reducing the amount of communication between devices in computing nodes and increasing the amount of communication within devices in computing nodes.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] Firstly, a communication method is provided for a computing cluster, the computing cluster comprising M computing nodes, each computing node comprising N devices, each device providing a data block, the data block being a fragmented data block of the device, where M and N are both integers greater than or equal to 2, the method comprising: each device storing its provided data block into its own first memory, wherein the M*N devices of the computing cluster include M first devices, the M first devices having the same local number, and the offsets corresponding to the positions of the fragmented data blocks of the M first devices in their respective first memory increasing sequentially; sequentially arranged... In the M first devices of the column, the difference in the offsets of the fragment data blocks of two adjacent first devices in their own first memory is the occupied value. The occupied value is the size of the memory occupied by the fragment data block with the smaller offset among the two fragment data blocks of the two adjacent first devices. The local number is used to indicate the arrangement order of the first devices in the computing node. Each device performs a first operation and a second operation in sequence based on the data block. The first operation is a collective communication operation performed with devices with the same local number in different computing nodes, and the second operation is a collective communication operation performed with devices in the same computing node.

[0008] In this embodiment, when each of the M*N devices provides a data block, that data block is a fragmented data block for that device. The M devices in the M computing nodes have the same local ID. These M devices with the same local ID satisfy characteristic one: the offsets of the M fragmented data blocks of the sequentially arranged M devices in their respective first memory locations increase sequentially; the difference in the offsets of the fragmented data blocks of two adjacent devices in their respective first memory locations is equal to the size of the memory occupied by the fragmented data block of one of the adjacent devices. Based on this, the M devices with the same local ID in the M computing nodes first perform a collective communication operation between devices on different computing nodes. After the collective communication operation is completed, each device obtains M data blocks. Since the M devices with the same local ID satisfy characteristic one, after the collective communication operation is performed, each device will have M consecutively stored data blocks in its first memory. Each device can transmit the M consecutively stored data blocks in a single transmission during subsequent collective communication operations. Then, each device performs a collective communication operation with other devices on the same compute node, based on M contiguous data blocks. After all N devices on the compute node have completed the collective communication operation, each device will have M*N contiguous data blocks in its first memory. In summary, when M devices with the same local ID on M compute nodes perform a collective communication operation, one data block is transmitted between devices at a time. However, when N devices on the same compute node perform a collective communication operation, M data blocks are transmitted between devices at a time. By increasing the number of data blocks transmitted at a time within the same compute node and decreasing the number of data blocks transmitted at a time between devices on different compute nodes, the communication volume between devices on the same compute node is increased, while the communication volume between devices on different compute nodes is decreased, thereby improving the efficiency of the collective communication operation.

[0009] In some implementations of the first aspect, after each device sequentially executes the first operation and the second operation, each device stores N*M data blocks in its first memory. The method further includes:

[0010] Each device stores the N*M data blocks in the first memory into its own second memory; wherein, the N*M data blocks of each device include fragmented data blocks of the N*M devices, and the offset of the fragmented data block of the device with rank i in the second memory is the sum of the memory size occupied by the fragmented data block of the device with rank 0 to the memory size occupied by the fragmented data block of the device with rank i-1, where N*M-1≥i≥0, and rank is the global number of the device. For example, the offset of the fragmented data block of the device with rank 3 in the second memory is the sum of the memory size occupied by the fragmented data block of the device with rank 0, the memory size occupied by the fragmented data block of the device with rank 1, and the memory size occupied by the fragmented data block of the device with rank 2.

[0011] Thus, each device provides a data block. After each device performs the first and second operations, each device obtains N*M data blocks. By rearranging the positions of the N*M data blocks in the memory of each device, the execution result obtained by the N*M devices performing the collective communication operation is satisfied, that is, the execution result of the N*M devices performing the collective communication operation is obtained.

[0012] In some implementations of the first aspect, if the memory size occupied by the fragmented data blocks of M*N devices is equal, the offset of the position of each fragmented data block in the first memory is j*size, where j satisfies: j=A*M+B, where A is the remainder of rank divided by M, B is the quotient of rank divided by M, rank is the global number of the device, and size is the memory size occupied by the fragmented data block of the device.

[0013] Thus, the position of the fragment data block of each device in the first memory is determined based on the device rank, such that multiple devices with the same local number satisfy the following: the offsets of the fragment data blocks of the M first devices arranged in sequence in their own first memory increase sequentially; among the M first devices arranged in sequence, the difference between the offsets of the fragment data blocks of two adjacent first devices in their own first memory is the occupancy value, and the occupancy value is the size of the memory occupied by the fragment data block with the smaller offset among the two fragment data blocks of the two adjacent first devices.

[0014] In some implementations of the first aspect, each device performs a first operation and a second operation sequentially based on a data block, including: each device performing a first operation based on a data block, and each device obtaining M consecutively stored data blocks; each device performing a second operation based on the M consecutively stored data blocks, and each device obtaining N*M consecutively stored data blocks; when each device performs the first operation between different computing nodes, one data block is transmitted between devices at a time; when each device performs the second operation within the same computing node, M data blocks are transmitted between devices at a time, thereby increasing the communication volume between devices within a computing node and reducing the communication volume between devices on different computing nodes.

[0015] In some implementations of the first aspect, if each of the devices provides a data block, then the collection communication operation is an AllGather operation.

[0016] In some implementations of the first aspect, each device stores a data block it provides into its own first memory, including: obtaining characteristic information of the computing cluster, the characteristic information including the communication volume of the computing cluster and the number of devices in the computing cluster; if the communication volume of the computing cluster is less than a first threshold and the number of devices in the computing cluster is greater than a second threshold, then each device stores a data block it provides into its own first memory.

[0017] In this application, if the communication volume of the computing cluster is less than a first threshold, it indicates that the communication volume of the computing cluster is low; if the number of devices in the computing cluster is greater than a second threshold, it indicates that the number of devices performing the collective communication operation is large. In this case, the collective communication operation is performed using the communication method of this embodiment. Since there are many devices, there is a lot of communication between devices during the collective communication operation. The communication method provided in this embodiment reduces the communication volume between devices on different computing nodes and increases the communication volume between devices on the same computing node, thereby improving the execution efficiency of the collective communication operation.

[0018] Secondly, a communication method is provided for a computing cluster, the computing cluster comprising M computing nodes, each computing node comprising N devices, each device providing M*N data blocks, the M*N data blocks comprising fragmented data blocks from the M*N devices of the computing cluster, where M and N are both integers greater than or equal to 2, the method comprising: each device storing its provided M*N data blocks into its own first memory, wherein the M*N devices of the computing cluster comprise M first devices, the M first devices having the same local number, and the fragmented data blocks of the M first devices arranged sequentially in their own first memory. The offsets corresponding to the positions increase sequentially, and among the M first devices arranged sequentially, the difference in the offsets of the data blocks of two adjacent first devices in their own first memory is the occupancy value, which is the size of the memory occupied by one data block. The local number is used to indicate the arrangement order of the first devices in the computing node. Each device performs a second operation and a first operation sequentially based on the M*N data blocks, wherein the second operation is a collective communication operation performed with devices within the same computing node, and the first operation is a collective communication operation performed with devices with the same local number in different computing nodes.

[0019] Thus, when each of the M*N devices provides M*N data blocks, each device stores the M*N data blocks in its own first memory. The M*N data blocks in each device's first memory include its own fragmented data blocks and fragmented data blocks from the other M*N-1 devices. The M devices in the M computing nodes have the same local ID, and the M devices with the same local ID satisfy characteristic two: the offsets of the M fragmented data blocks of the M devices with the same local ID arranged sequentially in the first memory of each device increase sequentially, and among the M devices with the same local ID arranged sequentially, the difference in the offsets of the fragmented data blocks of two adjacent devices in their own first memory is equal to the occupied value, which is the size of the memory occupied by the fragmented data block with the smaller offset among the two fragmented data blocks of the two adjacent devices. Based on this, using the M*N data blocks provided by each device, devices within a compute node perform a collective communication operation. Each device receives M first-protocol data blocks, each of which is a protocol of N data blocks. When performing the collective communication operation within a compute node, each device transmits M data blocks at a time. Then, based on the M first-protocol data blocks provided by each device, M devices with the same local ID in the M compute nodes perform a collective communication operation between devices on different compute nodes. Each device receives one second-protocol data block, which is a protocol of M*N data blocks. The M devices with the same local ID in the M compute nodes then perform... In a collective communication operation between devices on different computing nodes, each device transmits one data block of the first protocol at a time. Therefore, when M devices with the same local ID on M computing nodes perform a collective communication operation, each device transmits one data block of the first protocol at a time. However, when N devices on the same computing node perform a collective communication operation, each device transmits M data blocks at a time. By increasing the number of data blocks transmitted at a time within the same computing node and decreasing the number of data blocks transmitted at a time between devices on different computing nodes, the communication volume between devices within a computing node is increased, while the communication volume between devices on different computing nodes is decreased, thereby improving the execution efficiency of collective communication.

[0020] In some implementations of the second aspect, after each device sequentially executes the second operation and the first operation, each device stores a second reduction data block in its first memory. The second reduction data block is a reduction of M*N data blocks. The method further includes: each device storing the second reduction data block in its first memory into its own second memory; wherein the position of the second reduction data block in the device's first memory is the same as the position of the device's fragmented data blocks in its first memory. Thus, each device can determine the position of the second reduction data in its memory based on the position of its fragmented data blocks.

[0021] In some implementations of the second aspect, if the memory size occupied by the fragmented data blocks of M*N devices is equal, the offset of the position of each fragmented data block of the device in the first memory is j*size, where j satisfies: j=A*M+B, where A is the remainder of rank divided by M, B is the quotient of rank divided by M, rank is the global number of the device, and size is the memory size occupied by the fragmented data block of the device.

[0022] In some implementations of the second aspect, each device sequentially performs a second operation and a first operation based on the M*N data blocks, including: based on the M*N data blocks, each device performs the first operation, and each device obtains M first-reduction data blocks, where the first-reduction data blocks are a reduction of the N data blocks; based on the M first-reduction data blocks, each device performs the second operation, and each device obtains a second-reduction data block, where the second-reduction data block is a reduction of the M*N data blocks. When each device performs the second operation within the same computing node, M data blocks are transmitted between devices at a time; when each device performs the first operation between different computing nodes, one data block is transmitted between devices at a time. This increases the communication volume between devices within a computing node and reduces the communication volume between devices on different computing nodes.

[0023] In some implementations of the second aspect, if each device provides N*M data blocks, then the set communication operation is a ReduceScatter operation.

[0024] In some implementations of the second aspect, each of the devices stores the data block it provides into its own first memory, including:

[0025] Obtain the characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices in the computing cluster;

[0026] If the communication volume of the computing cluster is less than a first threshold and the number of devices in the computing cluster is greater than a second threshold, then each device will store its own N*M data blocks into its own first memory.

[0027] Thirdly, a communication method is provided for use in a computing cluster, the computing cluster comprising M*N devices, the M*N devices being deployed in M ​​computing nodes, each computing node comprising N devices, where M and N are integers greater than or equal to 2; the method comprising: each device performing a third operation X and a fourth operation Y in parallel;

[0028] The third operation is a collective communication operation performed by the device with other devices within the same computing node based on the first data block it provides. The fourth operation is the operation of the device sending the second data block it provides to the downstream device and receiving the second data block provided by the upstream device. The upstream and downstream devices of the device are devices in other computing nodes that form a ring topology with the device. X and Y are both integers greater than or equal to 1.

[0029] In this embodiment, since M*N devices are deployed across multiple computing nodes, when the M*N devices perform aggregated communication operations, each device needs to communicate with other devices within the same computing node, as well as with devices in different computing nodes. This application eliminates the data block dependency between the third operation within a computing node and the fourth operation between computing nodes, allowing each device to execute the third and fourth operations in parallel. This enables parallel execution of communication between devices within the same computing node and between devices on different computing nodes, thereby improving the efficiency of aggregated communication.

[0030] The third operation is the flow of data blocks within a compute node, and the fourth operation is the flow of data blocks between compute nodes. The two operations are executed in parallel, which can realize the flow of data blocks between multiple compute nodes, thus completing the collective communication operation executed by M*N devices.

[0031] In some implementations of the third aspect, if each of the devices provides a first data block, then the second data block is obtained by the device through performing the (Y-1)th fourth operation, where Y is an integer greater than 1.

[0032] If each of the devices provides M*N of the first data blocks, then the second data block is obtained by the device through performing the (X-1)th third operation, where X is an integer greater than 1.

[0033] Among them, the M*N devices performing set communication operations can include multiple operations within the same computing node and operations on different computing nodes. The previous operation provides data blocks for the local operation to establish data block associations between different iterations of the operation.

[0034] In some implementations of the third aspect, after each device completes M third operations and M-1 fourth operations, the execution results of the N*M devices performing the first set of communication operations are obtained.

[0035] Thus, the collective communication operations performed by M*N devices can be divided into M third operations and M-1 fourth operations, and each device can perform M-1 third and fourth operations in parallel.

[0036] In some implementations of the third aspect, if each device provides a first data block, then the offsets in the memory of the first data block provided by each device during the Xth third operation and the second data block provided by each device during the Yth fourth operation are both x*size, where x satisfies:

[0037] x = A + ((B + M - X + 1) % M) * N, where A is the remainder when rank is divided by N, B is the quotient when rank is divided by N, and % is the identifier for the remainder or modulo operation, such as (B + M - X + 1) % M is the remainder when (B + M - X + 1) is divided by M; where rank is the global number of the device, and size is the size of the memory occupied by one of the first data blocks.

[0038] In this embodiment, each device provides a data block each time it performs the third and fourth operations, so that after multiple executions of the third and fourth operations, the collective communication operation can be completed and the execution result of the collective communication operation can be obtained.

[0039] In some implementations of the third aspect, if each device provides N*M first data blocks, then the offsets of the N first data blocks provided by each device when performing the Xth third operation are located at the N positions in its own memory: y*size to (y+N-1)*size, where y satisfies: y=(rank / N+X)%M*N;

[0040] When each device performs the Yth fourth operation, the offset of the location of the second data block in its own memory is z*size, where z satisfies: z = rank%N + ((rank / N + X - 1)%M)*N.

[0041] Wherein, rank is the global number of the device, and size is the memory size occupied by one of the first data blocks.

[0042] In this embodiment, each device provides a data block each time it performs the third and fourth operations, so that after multiple executions of the third and fourth operations, the collective communication operation can be completed and the execution result of the collective communication operation can be obtained.

[0043] In some implementations of the third aspect, each of the devices performs the Xth third operation and the Yth fourth operation in parallel, including:

[0044] Obtain the characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices;

[0045] If the communication volume of the computing cluster is greater than the first threshold, or if the communication volume of the computing cluster is less than the first threshold and the number of devices is less than the second threshold, then each device executes the Xth third operation and the Yth fourth operation in parallel.

[0046] In some implementations of the third aspect, if each of the devices provides a first data block, the collection communication operation is an AllGather operation;

[0047] If each of the devices provides N*M of the first data blocks, the set communication operation is a ReduceScatter operation.

[0048] Fourthly, an electronic device is provided, comprising at least one processor; and

[0049] A memory storing a computer program executable on the processor, wherein the processor, when executing the computer program, performs steps performed by any device in the method described in any of the first, second, or third aspects described above.

[0050] Fifthly, a computing cluster is provided, the computing cluster including multiple computing nodes, each computing node including multiple devices, the devices performing the communication method described in any one of the first, second or third aspects above.

[0051] In a sixth aspect, a program product is provided that, when the program product is run on multiple devices of a computing cluster, causes the devices to perform the communication method described in any one of the first, second, or third aspects above.

[0052] A seventh aspect provides a computer-readable storage medium including a program or instructions that, when executed by a device of a computing cluster, implements the communication method as described in any one of the first, second, or third aspects above.

[0053] The technical effects achieved by the second, fourth, fifth, and sixth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect, and will not be repeated here. Attached Figure Description

[0054] Figure 1 is a schematic diagram of the execution process of an AllGather operation provided in an embodiment of this application;

[0055] Figure 2 is a schematic diagram of the execution process of a ReduceScatter operation provided in an embodiment of this application;

[0056] Figure 3 is a schematic diagram of the architecture of a computing cluster provided in an embodiment of this application;

[0057] Figure 4 is a schematic diagram of the structure of a computing node provided in an embodiment of this application;

[0058] Figure 5 is a flowchart illustrating a communication method provided in an embodiment of this application;

[0059] Figure 6 is a schematic diagram showing the location of a fragmented data block in memory according to an embodiment of this application;

[0060] Figure 7 is a schematic diagram of the process of a computing cluster performing the AllGather operation according to an embodiment of this application;

[0061] Figure 8 is a flowchart illustrating a communication method provided in an embodiment of this application;

[0062] Figure 9 is a schematic diagram showing the location of a fragmented data block in memory according to an embodiment of this application;

[0063] Figure 10 is a schematic diagram of a computing cluster performing a ReduceScatter operation according to an embodiment of this application;

[0064] Figure 11 is a flowchart illustrating a communication method provided in an embodiment of this application;

[0065] Figures 12A to 12E are schematic diagrams of an AllGather operation provided in an embodiment of this application;

[0066] Figures 13A to 13E are schematic diagrams of a ReduceScatter operation provided in an embodiment of this application. Detailed Implementation

[0067] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0068] To facilitate understanding, the terminology used in the embodiments of this application will be briefly introduced first.

[0069] The global rank is a logical identifier for devices within the communication domain, ranging from 0 to N-1 (where N is the total number of devices in the communication domain). It uniquely identifies each device performing a collective communication operation within the communication domain. During a collective communication operation, data blocks provided by multiple devices are logically treated as an ordered set. In each device's receive buffer, data must be stored in rank order. For clarity, in the following description, the rank of device i is assumed to be i.

[0070] Local numbers are used to indicate the order of devices in a compute node. A compute cluster may include multiple compute nodes, and each compute node may include multiple devices. Multiple compute nodes may define the number of each device in the compute node according to different formats. Multiple devices in each compute node are arranged sequentially, and each device has a corresponding local number. For example, the four devices in compute node 1 are numbered a to d, and the four devices in compute node 2 are numbered 0 to 3. The four devices numbered a to d are arranged sequentially, and the four devices numbered 0 to 3 are arranged sequentially. The local numbers a and 0 are the same, both indicating that the device is the first device in the sequential arrangement of multiple devices in the compute node.

[0071] In one example, a device's local ID can be determined based on its rank. If each compute node has N devices, the local ID of a device is the remainder when its rank is divided by N. For instance, a compute cluster might have two servers: Server 0 and Server 1. Server 0 contains two devices: Device 0 and Device 1. Server 1 contains two devices: Device 2 and Device 3. Then, the local ID of Device 0 is 0 divided by 2, and the local ID of Device 2 is 2 divided by 2, both with a remainder of 0.

[0072] It is easy to understand that the local number of each computing node can also be described in other ways, or the devices in different computing nodes can use different local numbering formats. For example, the local numbers of the four devices in computing node 1 are 1 to 4, and the local numbers of the four devices in computing node 2 are A to D. If two devices are arranged in the same order in their respective computing nodes, it can also be determined that the two devices have the same local number. For example, device 1 in computing node 1 and device A in computing node 2 have the same local number.

[0073] Each computing node has a corresponding node number, which indicates the order in which the computing node is arranged in the computing cluster. Adjacent computing nodes are two computing nodes that are adjacent in order, such as computing node 1 and computing node 2 arranged in sequence. The node number can also be the sequential number of the computing node in the computing cluster. For example, if the computing cluster includes four computing nodes, the four computing nodes are arranged in sequence, and the corresponding node numbers are 0, 1, 2, and 3.

[0074] The device's memory can store data blocks. Each data block's position in the device's memory corresponds to an offset, which indicates the relative distance between the data block's position in a segment of the device's memory and the starting address of that segment. In the device's memory, the absolute address of a data block = starting address + offset. In this embodiment, the starting address is the starting address of the device's pre-allocated memory, such as the memory pre-allocated to each device before N collective communication operations. The device's memory can be divided into multiple segments, each with a starting address. Typically, the offset of a data block's position in a segment of the device's memory is the offset of that data block relative to the starting address of that segment. The device's memory can also be considered as a whole, in which case the device's memory has only one starting address. This starting address can also be called the base address.

[0075] Collective communications is a global communication operation involving all devices within a computing cluster. The basic operations involved include sending, receiving, copying, and inter-device process synchronization. These basic operations are combined to form collective communication operations such as broadcasting, all gathering, all reducing, and reducing scattering.

[0076] The following explains the logical consistency of aggregated communication operations. Logical consistency in aggregated communication operations means that regardless of device distribution or communication path selection, all participating devices must maintain a consistent logical view of the data. Specifically, if devices performing aggregated communication operations need to provide data blocks, the size of the data blocks provided by each device must be the same. Each device performing aggregated communication operations needs to pre-allocate a receive buffer. For example, the size of the receive buffer for each device performing the AllGather operation is size * N, where size is the memory size occupied by each data block, and N is the total number of devices performing the AllGather operation.

[0077] The following explanation uses the AllGather operation as an example. AllGather is a many-to-many communication primitive with multiple senders and receivers of data blocks. It is used to achieve global data synchronization, ensuring that all devices executing the AllGather operation obtain a completely consistent and complete dataset. Each device executing the AllGather operation has its own send buffer and receive buffer. Each device sends its provided data blocks to other devices and receives data blocks sent by other devices. When receiving a data block, each device stores the received data block in the corresponding position of its receive buffer according to the sender's rank. For example, for a data block sent by device i, other devices, after receiving the data block sent by device i, store that data block in the i-th position of their receive buffer. After the AllGather operation is completed, each device's receive buffer contains multiple identical data blocks, and the order of these data blocks in the receive buffers of multiple devices is also the same.

[0078] The ReduceScatter operation is explained below. ReduceScatter is a many-to-many communication primitive with multiple senders and multiple receivers of data blocks. The i-th data block provided by each device executing the ReduceScatter operation is reduced with the i-th data block provided by all other devices. Therefore, it is essential to ensure that data blocks with the same index among the data blocks sent by multiple devices belong to the same reduction group. The reduction results are then distributed according to the device's rank. For example, the i-th reduction result (i.e., the reduction result of the i-th data in the memory of all devices) will be sent to the device with rank i.

[0079] The execution process of the AllGather operation is explained below. Please refer to Figure 1, which is a schematic diagram of the execution process of the AllGather operation.

[0080] The AllGather operation in Figure 1 is executed by a computing cluster, which consists of two servers: Server 0 and Server 1. Server 0 has two devices deployed: Device 0 and Device 1. Server 1 has two devices deployed: Device 2 and Device 3.

[0081] S11, each device performing the AllGather operation in the server provides a data block, and the location of the data block provided by each device in its memory corresponds to the rank of that device. As shown in Figure 1, data block A provided by device 0 is located at location 0 in its memory, data block B provided by device 1 is located at location 1 in its memory, data block C provided by device 2 is located at location 2 in its memory, and data block D provided by device 3 is located at location 3 in its memory.

[0082] To facilitate understanding, the location of data blocks in memory is explained here. Before multiple devices perform a collective communication operation, each device reserves corresponding memory. For example, if N devices are performing an AllGather operation, each device needs to reserve size*N memory, where size is the size of the memory occupied by the data block provided by each device. The memory reserved by each device has a starting address. The location of each data block in memory can be determined by the starting address of the memory and the corresponding offset. For example, if data block A is located at position i in memory, then the offset of data block A is size*i. The actual address of data block A in memory is determined based on the starting address and size*i.

[0083] S12, each device within the server performs the AllGather operation. In Figure 1, devices 0 and 1 in server 0 perform the AllGather operation, and devices 2 and 3 in server 1 perform the AllGather operation. Specifically, in server 0, device 0 sends data block A to device 1, and device 1 stores the received data block A in memory location 0; device 1 sends data block B to device 0, and device 0 stores the received data block B in memory location 1; in server 1, device 2 sends data block C to device 3, and device 3 stores the received data block C in memory location 2; device 3 sends data block D to device 2, and device 2 stores the received data block D in memory location 3.

[0084] S13, based on the AllGather operation performed between devices within the same server, each device obtains data blocks, and then performs AllGather operations between devices on different servers. As shown in Figure 1, devices 0 and 2 perform the AllGather operation between servers, and devices 1 and 3 perform the AllGather operation between servers. Specifically, device 0 of server 0 sends data block A and data block B to device 2 of server 1. Device 2 of server 1 stores data block A and data block B in memory locations 0 and 1 respectively. Device 2 of server 1 sends data block C and data block D to device 0 of server 0. Device 0 of server 0 stores data block C and data block D in memory locations 2 and 3 respectively. Similarly, device 1 of server 0 sends data block A and data block B to server 1. Device 3 of server 1 stores data block A and data block B in memory locations 0 and 1 respectively. Device 3 of server 1 sends data block C and data block D to device 1 of server 0. Device 1 of server 0 stores data block C and data block D in memory locations 2 and 3 respectively.

[0085] At this point, the four devices have completed the AllGather operation. Each device receives the data blocks provided by all the devices, and the location of the data block in memory corresponds to the rank of the device that provided the data block.

[0086] The ReduceScatter operation will be introduced next.

[0087] Please refer to Figure 2, which is a schematic diagram of the execution process of a ReduceScatter operation.

[0088] In Figure 2, the compute cluster executes the ReduceScatter operation. The compute cluster consists of two servers: Server 0 and Server 1. Server 0 includes two devices: Device 0 and Device 1. Server 1 includes two devices: Device 2 and Device 3.

[0089] Specifically, device 0 stores data blocks A0, B0, C0, and D0, which are located at positions 0-3 in the memory of device 0, respectively; device 1 stores data blocks A1, B1, C1, and D1, which are located at positions 0-3 in the memory of device 1, respectively; device 2 stores data blocks A2, B2, C2, and D2, which are located at positions 0-3 in the memory of device 2, respectively; and device 3 stores data blocks A3, B3, C3, and D3, which are located at positions 0-3 in the memory of device 3, respectively.

[0090] S21, execute the ReduceScatter operation between servers. In Figure 2, device 0 and device 2 execute the ReduceScatter operation between servers, and device 1 and device 3 execute the ReduceScatter operation between servers.

[0091] Specifically, device 0 of server 0 will send data block C0 and data block D0 to device 2 of server 1. Device 2 of server 1 will store the protocol H20 of data block C0 and data block C2 in location 2 of its memory, and store the protocol H21 of data block D0 and data block D2 in location 3 of its memory. Device 2 of server 1 will send data block A2 and data block B2 to device 0 of server 0. Device 0 of server 0 will store the protocol H00 of data block A0 and data block A2 in location 0 of its memory, and store the protocol H01 of data block B0 and data block B2 in location 1 of its memory.

[0092] Device 1 of server 0 sends data block D1 and data block C1 to device 3 of server 1. Device 3 of server 1 stores the protocol H30 of data block C1 and data block C3 in location 2 of its memory and stores the protocol H31 of data block D1 and data block D3 in location 3 of its memory. Device 3 of server 1 sends data block B3 and data block A3 to device 1 of server 0. Device 1 of server 0 stores the protocol H10 of data block A1 and data block A3 in location 2 of its memory and stores the protocol H11 of data block B1 and data block B3 in location 3 of its memory.

[0093] S22, execute the ReduceScatter operation within the server. As shown in Figure 2, devices 0 and 1 execute the ReduceScatter operation within the server, and devices 2 and 3 execute the ReduceScatter operation within the server.

[0094] Specifically, device 0 of server 0 stores the H00 provided by device 0 and the protocol H03 of H10 provided by device 1 in location 0 of device 0; device 1 of server 0 stores the H01 provided by device 0 and the protocol H13 of H11 provided by device 1 in location 1 of device 1; device 2 of server 1 stores the H20 provided by device 2 and the protocol H23 of H30 provided by device 3 in location 3 of device 2; device 2 of server 1 stores the H21 provided by device 3 and the protocol H33 of H31 provided by device 3 in location 3 of device 3.

[0095] S23, Server 0 can obtain H03 from location 0 in the memory of Device 0 and H13 from location 1 in the memory of Device 1. Server 1 can obtain H23 from location 2 in the memory of Device 2 and H33 from location 3 in the memory of Device 3. That is, the execution results of the ReduceScatter operation performed by the four devices.

[0096] In the execution process of the aforementioned aggregated communication operations, the link bandwidth between devices is mismatched with the communication traffic transmitted between devices. As shown in Figure 1, during the AllGather operation between devices within a server, each device transmits one data block at a time; during the AllGather operation between devices on different servers, each device transmits two data blocks at a time. Similarly, in Figure 2, during the ReduceScatter operation between devices within the same server, each device transmits one data block at a time; during the ReduceScatter operation between devices on different servers, each device transmits two data blocks at a time. This demonstrates that the communication traffic transmitted between devices on different compute nodes is greater than the communication traffic transmitted between devices within the same compute node. However, the existing link bandwidth between devices on different compute nodes is often less than the link bandwidth between devices within the same compute node. This mismatch between the link bandwidth and the communication traffic transmitted between devices results in the communication links between devices within the same compute node not being fully utilized, thus affecting the execution efficiency of aggregated communication.

[0097] Based on this, the present application provides a communication method that rearranges the positions of the device's fragmented data in memory and adjusts the execution order of collective communication operations between devices on the same computing node and between devices on different computing nodes based on the positions of the rearranged data blocks. This improves the communication volume between devices on the same computing node during collective communication operations and reduces the communication volume between devices on different computing nodes, thereby improving the execution efficiency of collective communication.

[0098] In one example, N devices perform a collective communication operation, with each device providing a data block. After the collective communication operation is completed, the execution result obtained by each device includes N data blocks. These N data blocks are provided by the N devices. Each data block provided by a device can contribute to the execution result of each device performing the collective communication operation. Therefore, the data block provided by each device is the fragmented data block of that device. The collective communication operation includes the AllGather operation and the AllGatherV operation.

[0099] In one example, N devices perform a collective communication operation, with each device providing N data blocks. Upon completion of the collective communication operation, each device receives a reduction data block as its execution result. This reduction data block is a reduction of the N data blocks, where the N data blocks are fragments of that device's data blocks. Each fragment of a device contributes to the execution result of that device performing the collective communication operation. Each device's N fragments include the data block provided by that device and the N-1 data blocks provided by the other N-1 devices during the collective communication operation. Alternatively, each device's N data blocks can be described as including its own fragments and the fragments of the other N-1 devices. The N fragments of each device have the same offset in the memory of all N devices. The collective communication operation includes ReduceScatter and ReduceScatterV operations.

[0100] For example, in a ReduceScatter operation executed by four devices (device 1 to device 4), device 1 provides four contiguous data blocks stored in its memory: 1, 2, 3, 4; device 2 provides four contiguous data blocks stored in its memory: 11, 12, 13, 14; device 3 provides four contiguous data blocks stored in its memory: 21, 22, 23, 24; and device 4 provides four contiguous data blocks stored in its memory: 31, 32, 33, 34. Data block 1, data block 11, data... Block 21 and data block 31 are fragmented data blocks of device 1; data block 2, data block 12, data block 22, and data block 32 are fragmented data blocks of device 2; data block 3, data block 13, data block 23, and data block 33 are fragmented data blocks of device 3; and data block 4, data block 14, data block 24, and data block 34 are fragmented data blocks of device 4. That is, the N fragmented data blocks of each device are provided by N devices, and the offsets of the N fragmented data blocks of each device in the memory of the N devices are the same.

[0101] The communication method provided in this application embodiment can be applied to a computing cluster. Please refer to Figure 3. Figure 3 is a schematic diagram of the architecture of a computing cluster provided in this application embodiment. The computing cluster in Figure 3 includes M computing nodes, and each computing node is deployed with n devices.

[0102] Within each compute node, multiple devices can communicate via a high-speed bus or through direct memory access (DMA) technology. Multiple devices between compute nodes can communicate via a network interface card (NIC).

[0103] The device in Figure 3 can be an acceleration card, also known as a computing power card, which can be a graphics processing unit (GPU). Acceleration cards can also be other types of acceleration cards, such as field-programmable gate arrays (FPGAs) and application-specific integrated circuits (ASICs).

[0104] In Figure 3, the computing node can be a server, such as a general-purpose GPU server, or a smart terminal. It's easy to understand that the computing node in Figure 3 can also include other modules, such as a network interface card (NIC), a disk, and dynamic random access memory (DRAM). The disk is local storage, used to store the operating system, applications, input data, and computation results. The disk can be a solid-state drive (SSD) or a high-speed non-volatile memory express solid-state drive (NVMe SSD). DRAM is the main memory of the computing node, such as double data rate (DDR) SDRAM on a server, providing fast (compared to disk) access space for applications running on the node's processor and device, and the data being processed.

[0105] Figure 4 is a schematic diagram of the structure of an electronic device according to an embodiment of this application. This electronic device may be the computing node shown in Figure 3. As shown in Figure 4, an electronic device 40 is provided in this embodiment of the application. This electronic device 40 may specifically be a terminal device or a server. In some embodiments, the electronic device 40 may specifically be a central control module in a server, or its functions may be implemented by the central control module in a server. In some embodiments, the electronic device 40 may specifically be a central control module in a terminal device, or its functions may be implemented by the central control module in a terminal device. As shown in Figure 4, the electronic device may include a processor 401, a memory 402, a communication bus 403, a communication interface 404, and multiple devices 405. The processor 401 is connected to the memory 402, the communication interface 404, and the multiple devices 405 through the communication bus 403. It should be noted that the device structure shown in Figure 4 does not constitute a limitation on the electronic device 40. The electronic device 40 may include more or fewer components than shown, or combine certain components, or have different component arrangements. This embodiment of the application does not limit this. The various components of the electronic device 40 will be described in detail below with reference to Figure 4.

[0106] The processor 401 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, used to execute relevant programs to perform the memory allocation method described in the method embodiments of this application.

[0107] Processor 401 can also be an integrated circuit chip with signal processing capabilities. In implementation, each step of the memory allocation method of this application can be completed by the integrated logic circuits in the hardware of processor 401 or by instructions in software form. The processor 401 described above can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 402. Processor 401 reads the information in memory 402 and executes the memory allocation method of the method embodiment of this application in conjunction with its hardware.

[0108] The memory 402 may be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 402 may store programs and data, such as the program for the memory allocation method in the embodiments of this application. When the program stored in the memory 402 is executed by the processor 401, the processor 401 performs the various steps of the memory allocation method in the embodiments of this application.

[0109] The communication interface 404 uses transceiver devices, such as, but not limited to, transceivers, to enable communication between the electronic device 40 and other devices or communication networks. For example, the communication interface 404 can interact with an electronic device containing a trained neural network.

[0110] Device 405 can be a Network Processing Unit (NPU), Tensor Processing Unit (TPU), or Graphics Processing Unit (GPU), or any processor suitable for large-scale XOR operations. Device 405 can be mounted as a coprocessor on the host CPU, which allocates tasks to it. Device 405 can perform one or more of the operations involved in the memory allocation methods described above. For example, taking an NPU as an example, the core of the NPU is the arithmetic circuitry, which is controlled by a controller to retrieve matrix data from memory 402 and perform multiplication and addition operations.

[0111] Please refer to Figure 5, which is a flowchart illustrating a communication method provided in an embodiment of this application. The following description uses an application of this communication method to a computing cluster as an example. This computing cluster includes M*N devices, deployed across M computing nodes. Each computing node includes N devices, where M and N are integers greater than or equal to 2. In Figure 5, each device in the computing cluster provides a data block, which is a fragmented data block for that device.

[0112] The communication method in Figure 5 includes steps S501 to S502.

[0113] S501. Each device stores a data block it provides into its own first memory. Among the M*N devices in the computing cluster, there are M first devices. The M first devices have the same local number. The offsets of the fragmented data blocks of the M first devices in their own first memory increase sequentially. The difference between the offsets of the fragmented data blocks of two adjacent first devices in their own first memory is the occupied value. The occupied value is the size of the memory occupied by the fragmented data block with the smaller offset among the two fragmented data blocks of the two adjacent first devices. The local number is used to indicate the arrangement order of the first devices in the computing nodes.

[0114] Optionally, the first memory of the device can be the output buffer of the device. Before the device performs the AllGather operation, each device needs to reserve an output buffer in advance. If M*N devices perform the AllGather operation, then each device reserves an output buffer of size M*N*size, where size is the size of the memory occupied by a data block provided by each device. If M*N devices perform the AllGatherV operation, then the output buffer reserved by each device in advance is equal to the sum of the memory size occupied by the data blocks provided by the M*N devices performing the AllGatherV operation.

[0115] In one example, in this embodiment of the application, M devices arranged sequentially can form a one-dimensional and linear sequence, with each device having a unique and ordered position in the sequence. Among the M devices arranged sequentially, the adjacent devices of each device are the devices that are adjacent to or next to the position of that device. For example, for N+1 devices arranged sequentially: device 0 to device N, if i is 0, device i has one adjacent device: device 1; if i is N, device i has one adjacent device; device N-1, if N > i > 0, device i has two adjacent devices: device i-1 and device i+1.

[0116] In one example, if each of the M sequentially arranged devices has an index indicating its order within the sequence, then two adjacent devices in the sequence are considered to be consecutively indexed. For instance, if the M sequentially arranged devices form a one-dimensional and linear sequence, and each device in the sequence has an index indicating its order within the sequence, then two adjacent devices in the sequence are considered to be consecutively indexed.

[0117] In one example, among M devices arranged sequentially, if the node numbers of the two computing nodes containing two adjacent devices are consecutive, or in other words, if the node numbers of two computing nodes are consecutive, then the two devices located on those two computing nodes are considered adjacent devices. The M first devices have the same local ID, and the offsets of the fragmented data blocks of the M first devices in their respective first memory locations increase sequentially. These offsets are: 0, A1, A2…A… M-1 , where A i Let A be the offset of the (i+1)th fragment data block of the first device in the memory of the first device arranged sequentially, where M-1≥i≥0. i This is equal to the sum of the offsets of the data blocks of the first first device in the memory of the first device and the offsets of the data blocks of the i-th first device in the memory of the first device in the M sequentially arranged first devices. Therefore, for the M sequentially arranged first devices, the offset of the data block of the i-th first device in its own memory is greater than the offset of the data block of the i-th first device in its own memory, and the difference between the two is the size of the memory occupied by the data block of the i-th first device.

[0118] Optionally, the computing cluster includes M computing nodes, and among the M computing nodes are M devices with the same local ID. These M devices with the same local ID can be arranged sequentially such that the offsets of the data blocks in their respective first memory locations increase sequentially. If the memory sizes occupied by the data blocks of the M devices are all equal, then the difference in the offsets of the data blocks of any two adjacent devices in their respective memory locations is the size of the memory occupied by one data block. Alternatively, the memory sizes occupied by the data blocks of the M devices can be different. In the M sequentially arranged devices, the difference in the offsets of the fragment data blocks of two adjacent devices in their own memory is the occupied value. The occupied value is the size of the memory occupied by the fragment data block with the smaller offset among the two fragment data blocks of the two adjacent first devices. For example, if devices 1 and 2 have the same local number and are adjacent devices, the offset of fragment data block 1 of device 1 is A, and the offset of fragment data block 2 of device 2 is B, where B is greater than A. Then, the difference in the offsets of the fragment data blocks of devices 1 and 2 in memory is the size of the memory occupied by fragment data block 1.

[0119] In one example, each computing node in a computing cluster has its own node number. Electronic devices can arrange M devices with the same local number according to the node number of the computing node to which each device belongs. For example, the M devices have the same local number, the node numbers of the computing nodes to which the M devices are arranged in sequence are sequentially increased, and the offsets of the fragment data blocks of the M devices in their own first memory are sequentially increased.

[0120] For example, a computing cluster includes two servers: Server 0 and Server 1. Server 0 includes two devices: Device 0 and Device 1, with local IDs 0 and 1, respectively. Server 1 includes two devices: Device 2 and Device 3, with local IDs 0 and 1, respectively. The node IDs of Server 0 and Server 1 are 0 and 1, respectively. Each device provides a data block, which is a fragment of that device's data block. The fragments of the data blocks on all four devices occupy the same amount of memory. The offset of the fragment of the data block on Device 0 in the first memory location of Device 0 is 0*size, the offset of the fragment of the data block on Device 1 in the first memory location of Device 1 is 2*size, the offset of the fragment of the data block on Device 2 in the first memory location of Device 2 is 1*size, and the offset of the fragment of the data block on Device 3 in the first memory location of Device 3 is 3*size. Device 0 and Device 2 have the same local ID. The node IDs of the servers where Device 0 and Device 2 reside are sequentially increasing. The offsets of the two data blocks of each device in their respective first memory locations are sequentially increasing, and the difference between the offsets of the two data blocks of each device in their respective first memory locations is size. Similarly, Device 1 and Device 3 have the same local ID. The server IDs of Device 1 and Device 3 reside are sequentially increasing. The offsets of the two data blocks of each device in their respective first memory locations are sequentially increasing, and the difference between the offsets of the two data blocks of each device in their respective first memory locations is size. Size is the memory size occupied by the data blocks of each device's data blocks.

[0121] In one example, before each device stores a data block it provides into its own first memory, each device first determines the location of its own fragmented data block in the first memory.

[0122] In one example, if the memory size occupied by the data blocks of M*N devices is equal, and the offset of the data block of each device in the first memory is j*size, where j satisfies:

[0123] j = A*M+B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, rank is the global ID of the device, and size is the memory size occupied by the fragmented data blocks of the device.

[0124] In one example, if M*N devices perform a set communication operation and each device provides a data block, then the first memory of each device has M*N locations;

[0125] If the memory sizes occupied by the data blocks of M*N devices are not equal, and the position j of the data block of each device in the first memory, j satisfies:

[0126] j = A*M + B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, and rank is the device's global identifier. The offset corresponding to position j in the first memory is the sum of the memory size occupied by the data block at position 0 in the first memory and the memory size occupied by the data block at position j-1 in the first memory. That is, the electronic device can first determine the position of the data block in the first memory, and then determine the offset corresponding to its own data block's position in the first memory based on the position of each data block in the first memory and the memory size occupied by each data block.

[0127] For example, 16 devices perform a collective communication operation, each device providing one piece of data. The 16 devices are deployed on 4 servers. Server 0 includes devices 0 to 3, server 1 includes devices 4 to 7, server 2 includes devices 8 to 11, and server 3 includes devices 12 to 15. The positions of the fragmented data blocks of the 16 devices in their own first memory are: position 0, position 4, position 8, position 12, position 1, position 5, position 9, position 13, position 2, position 6, position 10, position 14, position 3, position 7, position 11, and position 15, respectively. If the fragmented data block of device 2 is located at position 4 in its own first memory, then the offset corresponding to position 4 in the first memory is equal to the sum of the memory size occupied by the fragmented data at position 0, the fragmented data at position 1, the fragmented data at position 2, and the fragmented data at position 3.

[0128] Please refer to Figure 6, which is a schematic diagram of the location of a fragmented data block in memory according to an embodiment of this application. As shown in Figure 6, the computing cluster includes 16 devices: devices 0 to 15. The 16 devices are deployed on 4 servers. Server 0 includes devices 0 to 3, server 1 includes devices 4 to 7, server 2 includes devices 8 to 11, and server 3 includes devices 12 to 15. Each device provides a data block, as shown in Figure 6, where device i provides data block i (15≥i≥0). This data block is the fragmented data block of that device. The memory size occupied by each device's fragmented data block is size. The offsets of the fragmented data blocks of the 16 devices in their own first memory locations are: 0*size, 4*size, 8*size, 12*size, 1*size, 5*size, 9*size, 13*size, 2*size, 6*size, 10*size, 14*size, 3*size, 7*size, 11*size, and 15*size. Four devices with the same local ID are arranged sequentially according to their server IDs, such that the offsets of the fragment data blocks of the four devices with the same local ID in their respective first memory locations increase arithmetically. For example, the local IDs of devices 0, 4, 8, and 12 are all 0. The offsets of the fragment data blocks of the four devices from server 0 to server 3 in their respective first memory locations are 0*size, 1*size, 2*size, and 3*size, respectively, and they increase sequentially. Among the four devices arranged sequentially, the difference between the offsets of the fragment data blocks of any two adjacent devices in their respective first memory locations is size. For example, the difference between the offsets of the fragment data blocks of device 4 and device 8 in their respective first memory locations is 2*size - 1*size = size.

[0129] S502. Each device, based on a data block, sequentially executes a first operation and a second operation, wherein the first operation is a collective communication operation performed with devices having the same local number in different computing nodes, and the second operation is a collective communication operation performed with devices in the same computing node.

[0130] In one example, based on a data block provided by each device, each device performs a first operation. After the first operation is completed, each device obtains M contiguous data blocks. Then, based on the M contiguous data blocks provided by each device, each device performs a second operation. After the second operation is completed, each device obtains N*M contiguous data blocks. When each device performs the first operation between computing nodes, one data block is transferred between devices at a time; when each device performs the second operation within a computing node, M data blocks are transferred between devices at a time. This increases the communication volume between devices within a computing node and reduces the communication volume between devices on different computing nodes.

[0131] In one example, when each of the M*N devices provides a data block, that data block is called a fragmented data block for that device. The M devices in the M compute nodes have the same local ID. These M devices with the same local ID satisfy characteristic one: the offsets of the M fragmented data blocks of the sequentially arranged M devices within their respective first memory locations increase sequentially; the difference in the offsets of the fragmented data blocks of two adjacent devices within their respective first memory locations is equal to the size of the fragmented data block occupied by one of those adjacent devices. Based on this, the M devices with the same local ID in the M compute nodes first perform a collective communication operation between devices on different compute nodes. After this collective communication operation is completed, each device receives M data blocks. Since the M devices with the same local ID satisfy characteristic one, after the collective communication operation, each device will have M contiguously stored data blocks in its first memory. When the devices perform subsequent collective communication operations, the devices can transmit the M contiguous data blocks in a single transmission. Then, each device performs a collective communication operation with other devices on the same compute node, based on M contiguous data blocks. After all N devices on the compute node have completed the collective communication operation, each device will have M*N contiguous data blocks in its first memory. In summary, when M devices with the same local ID on M compute nodes perform a collective communication operation, one data block is transmitted between devices at a time. However, when N devices on the same compute node perform a collective communication operation, M data blocks are transmitted between devices at a time. By increasing the number of data blocks transmitted at a time within the same compute node and decreasing the number of data blocks transmitted at a time between devices on different compute nodes, the communication volume between devices on the same compute node is increased, while the communication volume between devices on different compute nodes is decreased, thereby improving the efficiency of the collective communication operation.

[0132] In one example, if each device provides one data block, after each device sequentially executes the first and second operations, each device's first memory will store N*M data blocks. In this case, each device can also store the data blocks in its first memory into its second memory. Here, each device's N*M data blocks include N*M fragmented data blocks from each device. The offset of the fragmented data block of the device with rank i in the second memory is the sum of the memory sizes occupied by the fragmented data blocks of the device with rank 0 to the fragmented data blocks of the device with rank i-1, where N*M-1≥i≥0, and rank is the global ID of the device. For example, the offset of the fragmented data block of the device with rank 3 in the second memory is the sum of the memory sizes occupied by the fragmented data blocks of the devices with rank 0, rank 1, and rank 2. By rearranging the positions of the N*M data blocks in the memory of each device to meet the requirements of the execution result obtained by the N*M set communication operation, the execution result of the N*M set communication operation can be obtained.

[0133] In one example, the data blocks of N*M devices occupy equal amounts of memory. Each device's first memory stores N*M data blocks, which are the data blocks of the N*M devices. Then, the offset of each device's data block in the second memory is j*size, and the offset of each data block in the first memory is i*size, where j satisfies:

[0134] j = A*M + B, where A is the remainder when i is divided by M, B is the quotient when i is divided by M, and M is the total number of devices in each computing node.

[0135] In one example, the memory sizes occupied by the fragmented data blocks of N*M devices can be unequal. Each device's first memory stores N*M data blocks, which are the fragmented data blocks of the N*M devices. Each device's first memory has N*M locations. Then, the location j of each device's fragmented data block in the second memory and the location i of each fragmented data block in the first memory, where j satisfies:

[0136] j = A*M + B, where A is the remainder of i divided by M, B is the quotient of i divided by M, and M is the total number of devices in each computing node. The offset corresponding to position j in the second memory is the sum of the memory size occupied by the data block at position 0 in the second memory to the memory size occupied by the data block at position j-1 in the first memory. The electronic device can first determine the position of the data block in the second memory, and then determine the offset corresponding to its own data block position in the second memory based on the position of each data block in the second memory and the memory size occupied by each data block.

[0137] Each device determines the position of a data block in its second memory based on the position of the data block in its first memory. The position of each data block in the second memory corresponds to the rank of the device that provided the data block. In other words, each data block is a data block of a device. After each device completes the first and second operations, it obtains N*M data blocks. The N*M data blocks obtained by each device are the data blocks of N*M devices. The arrangement order of the N*M data blocks in the second memory of each device corresponds to the arrangement order of the ranks of the N*M devices. For example, the ranks of the N*M devices are 0 to N*M-1, and the offsets corresponding to the positions of the data blocks of the N*M devices in the second memory are 0, size to (N*M-1)*size, respectively. This ensures that the position of each device's data block in the second memory satisfies the semantic requirements of the set communication operation, that is, the execution result of the N*M set communication operation is obtained.

[0138] Please refer to Figure 7, which is a schematic diagram of the process of multiple devices in a computing cluster performing the AllGather operation according to an embodiment of this application.

[0139] In Figure 7, the computing cluster performing the AllGather operation includes two servers: server 0 and server 1. Each server includes two devices. Server 0 includes two devices: device 0 and device 1, and server 1 includes two devices: device 2 and device 3. Device 0 and device 2 have the same local ID, which is 0. Device 1 and device 3 have the same local ID, which is 1. The ranks of devices 0 to 3 are 0 to 3, respectively. The node numbers of server 0 and server 1 are 0 and 1, respectively.

[0140] S71. Each device determines the location of a data block it provides in the first memory and stores the data block in its own first memory.

[0141] In this case, the memory occupied by the data blocks of the four devices performing the AllGather operation is equal.

[0142] Specifically, each device provides a data block, which is a fragmented data block for that device. If multiple devices with the same local number are arranged sequentially, such that the offsets of the fragmented data blocks of the multiple devices with the same local number in their respective first memory locations increase sequentially, and the difference between the offsets of the two fragmented data blocks of two adjacent devices in their respective first memory locations is size, where size is the size of the memory occupied by each data block.

[0143] As shown in Figure 7, in server 0, the offset of fragment data block A of device 0 at position 0 in the first memory of device 0 is 0*size, and the offset of fragment data block B of device 1 at position 2 in the first memory of device 1 is 2*size; in server 1, the offset of fragment data block C of device 2 at position 1 in the first memory of device 2 is 1*size, and the offset of fragment data block D of device 3 at position 3 in the first memory of device 3 is 3*size. In this setup, devices 0 and 2 have the same local ID, and the node IDs of the servers on which the two devices reside increase sequentially. The offsets of the data blocks in memory for the two devices, arranged sequentially, increase sequentially and are 0*size and 1*size, respectively. The difference between the offsets of the data blocks in memory for the two devices is size. Similarly, devices 1 and 3 have the same local ID, and the node IDs of the servers on which the two devices reside increase sequentially. The offsets of the data blocks in memory for the two devices, arranged sequentially, increase sequentially and are 2*size and 3*size, respectively. The difference between the offsets of the data blocks in memory for the two devices is size.

[0144] S72. Based on a data block provided by each device, multiple devices with the same local number in multiple servers perform the AllGather operation, or in other words, each device in a server performs the AllGather operation with other devices with the same local number in other servers.

[0145] As shown in Figure 7, device 0 and device 2 have the same local number. Device 0 and device 2 perform the AllGather operation, that is, device 0 of server 0 sends data block A to device 2 of server 1, and device 2 of server 1 stores data block A in the first memory location 0 of device 2. Device 2 of server 1 sends data block C to device 0 of server 0, and device 0 of server 0 stores data block C in the first memory location 1 of device 0.

[0146] Device 1 and Device 3 have the same local number. Device 1 and Device 3 perform an AllGather operation, that is, Device 1 of Server 0 sends data block B to Device 3 of Server 1, Device 3 of Server 1 stores data block B in the first memory location 2 of Device 3, Device 3 of Server 1 sends data block D to Device 1 of Server 0, Device 1 of Server 0 stores data block D in the first memory location 3 of Device 1.

[0147] In S72, after the AllGather operation is completed, devices 0 and 2 each receive two data blocks: data block A and data block C, which are stored contiguously in the first memory of devices 0 and 2, respectively. Devices 1 and 3 each receive two data blocks: data block B and data block D, which are also stored contiguously in the first memory of devices 1 and 3, respectively. Furthermore, as described above, during the AllGather operation performed by devices on different servers in S72, only one data block is transferred between devices on different servers at a time.

[0148] S73. Based on two contiguous data blocks provided by each device, multiple devices within each server perform the AllGather operation.

[0149] As shown in Figure 7, devices 0 and 1 in server 0 perform the AllGather operation. That is, device 0 in server 0 sends data block A and data block C to device 1. Device 1 stores the received data blocks into positions 0 and 1 in its first memory, respectively. Device 1 in server 0 sends data block B and data block D to device 0. Device 0 stores the received data block B and data block D into positions 2 and 3 in its first memory, respectively.

[0150] Devices 2 and 3 in server 1 perform the AllGather operation, that is, device 2 in server 1 sends data block A and data block C to device 3, and device 3 stores the received data block A and data block C into positions 0 and 1 of the first memory in device 3, respectively. Device 3 in server 1 sends data block B and data block D to device 2, and device 2 stores the received data block B and data block D into positions 2 and 3 of the first memory in device 2, respectively.

[0151] After the AllGather operation in S73 is completed, devices 0, 1, 2, and 3 each receive four data blocks: data block A to data block D. The locations of data blocks A to D in the device's first memory are position 0, position 2, position 1, and position 3, respectively.

[0152] As described above, during the AllGather operation performed by devices on the same server, two data blocks are transferred between devices at a time.

[0153] S74. Each device determines the location of four data blocks in the second memory and stores the four data blocks into the second memory based on the determined location.

[0154] As shown in Figure 7, the four data blocks are located in the second memory of the device: data blocks A to D are located at positions 0 to 3 in the second memory, respectively. Data blocks A to D are fragmented data blocks of the four devices, and the ranks of the four devices are 0 to 3, respectively. The ranks of the four devices correspond to the positions of the four data blocks in the second memory. This satisfies the requirements of the AllGather operation performed by the four devices.

[0155] Thus, for the AllGather operation performed by N*M devices deployed within M compute nodes in a computing cluster, this AllGather operation can be divided into AllGather operations performed by devices with the same local ID across different compute nodes and AllGather operations performed by devices within a compute node. Based on this, firstly, the data blocks provided by each device are stored in the device's first memory, such that the offsets of the data blocks provided by multiple M devices with the same local ID, arranged sequentially, in their respective first memory locations increase arithmetically, with the difference being size; then, based on the data blocks in the first memory of each device, the AllGather operations between different compute nodes and the AllGather operations within the same compute node are performed sequentially. Since the offsets of data blocks provided by devices with the same local ID in the first memory of each device increase arithmetically, and the difference is the size of the memory occupied by each device's fragmented data block, after devices with the same local ID perform the AllGather operation between different computing nodes, each device will have M contiguous data blocks in its first memory, and the devices will transfer one data block at a time. Based on the M contiguous data blocks, when devices within the same computing node perform the AllGather operation, they can transfer M contiguous data blocks at a time, thereby improving the communication traffic between devices within the same computing node and reducing the communication traffic between devices on different computing nodes. Finally, each device stores the resulting N*M data blocks in its second memory, and the position of each data block in the second memory corresponds to the rank of the device that provided the data block, thus satisfying the requirements of the AllGather operation performed by N devices.

[0156] Please refer to Figure 8, which is a flowchart illustrating a communication method provided in an embodiment of this application. The following description uses an application of the communication method to a computing cluster as an example. This computing cluster includes M*N devices deployed across M computing nodes. Each computing node includes N devices, where M and N are integers greater than or equal to 2. In Figure 8, each device in the computing cluster provides M*N data blocks. Each device's M*N data blocks include its own fragmented data blocks and fragmented data blocks from the other M*N-1 devices. The M*N fragmented data blocks from each device are provided by the M*N devices performing the collective communication operation.

[0157] The communication method in Figure 8 includes steps S801 to S802.

[0158] S801. Each device stores its own M*N data blocks into its own first memory. Among the M*N devices in the computing cluster, there are M first devices. The M first devices have the same local number. The offsets of the fragmented data blocks of the M first devices in their own first memory increase sequentially. The difference between the offsets of the fragmented data blocks of two adjacent first devices in their own first memory is the occupied value. The occupied value is the size of the memory occupied by the fragmented data block with the smaller offset among the two fragmented data blocks of the two adjacent devices. The local number is used to indicate the arrangement order of the first devices in the computing nodes.

[0159] Optionally, if each device performing the aggregated communication operation provides N*M data blocks, the N*M data blocks of each device include both the fragmented data blocks of that device and the fragmented data blocks of N*M-1 other devices. In other words, the N*M fragmented data blocks of each device include a data block provided by that device and N*M-1 data blocks provided by other devices. That is, the N*M fragmented data blocks of each device are provided by N*M devices, and the offsets corresponding to the positions of the N*M fragmented data blocks of each device in the first memory of the N*M devices are the same. The computing cluster consists of M computing nodes, each containing M devices with the same local ID. If N*M devices execute a ReduceScatter operation, the M devices with the same local ID are arranged sequentially, and the offsets of the data blocks in the first memory of each device increase arithmetically, with the difference being the size of the memory occupied by any one data block. If N*M devices execute a ReduceScatterV operation, the M devices with the same local ID are arranged sequentially, and the offsets of the data blocks in the first memory of each device increase arithmetically, with the difference in the offsets of the data blocks in the first memory of two adjacent devices being the size of the memory occupied by the data block with the smaller offset.

[0160] In one example, each computing node in a computing cluster has its own node number. Electronic devices can arrange M devices with the same local number according to the node number of the computing node to which each device belongs. For example, the M devices have the same local number, the node numbers of the computing nodes to which the M devices are arranged in sequence are sequentially increasing, and the offsets of the fragment data blocks of the M devices in the first memory of each device are sequentially increasing.

[0161] For example, a computing cluster includes two servers: Server 0 and Server 1, with node numbers 0 and 1 respectively. Server 0 includes two devices: Device 0 and Device 1, with local numbers 0 and 1 respectively. Server 1 includes two devices: Device 2 and Device 3, with local numbers 0 and 1 respectively. The four devices in the computing cluster perform ReduceScatter operations. Each device provides four data blocks. The four data blocks in the first memory of each device include the data shards of that device and the data shards of the other three devices. The offsets of the four data shards of each device in the first memory of the four devices are the same. For example, in the first memory of device 0, the data block at position 0 is the fragmented data block of device 0, the data block at position 1 is the fragmented data block of device 1, the data block at position 2 is the fragmented data block of device 2, and the data block at position 3 is the fragmented data block of device 3. Correspondingly, the offset of the fragmented data block of device 0 in the first memory of device 0 is 0*size, the offset of the fragmented data block of device 1 in the first memory of device 0 is 2*size, the offset of the fragmented data block of device 2 in the first memory of device 0 is 1*size, and the offset of the fragmented data block of device 3 in the first memory of device 0 is 3*size. The node numbers of server 0 and server 1 are sequentially increased. Device 0 in server 0 and device 2 in server 1 have the same local number. The offsets of the fragment data blocks of the two devices in the first memory of device 0 are sequentially increased, and the difference between the two offsets is size. Correspondingly, device 1 in server 0 and device 3 in server 1 have the same local number. The offsets of the fragment data blocks of device 1 and device 3 in the first memory of device 0 are sequentially increased, and the difference between the two offsets is size, where size is the size of the memory occupied by the fragment data block of each device.

[0162] In one example, before each device stores its own M*N data blocks into its own first memory, each device first determines the location of its own data blocks in the first memory.

[0163] In one example, since each device provides M*N data blocks, which include fragmented data blocks from M*N devices, and each fragmented data block from the M*N devices occupies memory of size size, the offset of each device's fragmented data block in the first memory location is j*size, where j satisfies:

[0164] j = A*M+B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, rank is the global number of the device corresponding to the data block, and M is the total number of devices in each computing node.

[0165] In one example, each device provides M*N data blocks, which include fragmented data blocks for M*N devices. Each device's first memory has M*N locations, where the memory sizes occupied by the fragmented data blocks for the M*N devices may be unequal. The location j of each device's fragmented data block in the first memory satisfies:

[0166] j = A*M + B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, rank is the global ID of the device corresponding to the fragmented data block, and M is the total number of devices in each computing node. The offset corresponding to position j in the first memory is the sum of the memory size occupied by the fragmented data block at position 0 in the first memory and the memory size occupied by the fragmented data block at position j-1 in the first memory. The electronic device can first determine the position of the fragmented data block in the first memory, and then determine the offset corresponding to its own fragmented data block's position in the first memory based on the position of each fragmented data block in the first memory and the memory size occupied by each fragmented data block.

[0167] Please refer to Figure 9, which is a schematic diagram of the location of fragmented data blocks in memory according to an embodiment of this application. As shown in Figure 9, the computing cluster includes 16 devices: devices 0 to 15. The 16 devices are deployed on 4 servers, and each server has four devices deployed. For example, server 0 includes devices 0 to 3, server 1 includes devices 4 to 7, server 2 includes devices 8 to 11, and server 3 includes devices 12 to 15. Each device provides 16 data blocks of the same size: data block 0 to data block 15. Each device stores its 16 data blocks in its own first memory. The 16 data blocks in the first memory of each device include the fragmented data blocks of that device and the fragmented data blocks of the other 15 devices. Taking device 0 in Figure 9 as an example, the 16 data blocks in the first memory of device 0 are 0 to 15, and they are fragmented data blocks of the 16 devices in the computing cluster. For example, data block i in the first memory is the fragmented data block of device i, and 15 ≥ i ≥ 0. The offsets of the M data blocks from the first device in the first memory are sequentially increasing. Among the 16 devices, 4 devices share the same local ID. Following the ascending order of the node IDs of the servers where the devices reside, the offsets of the data blocks in memory corresponding to the positions of the data blocks from these 4 devices with the same local ID are sequentially increasing arithmetically, with the difference being the size of any single data block in memory. For example, devices 0, 4, 8, and 12 share the same local ID, and the node IDs of the servers where the four devices reside are sequentially increasing. The data blocks for devices 0, 4, 8, and 12 are 0, 4, 8, and 12, respectively. The offsets of the four data blocks (0, 4, 8, 12) in the first memory location of device 0 are 0*size, 1*size, 2*size, and 3*size, respectively, increasing sequentially with a difference of size.

[0168] S802. Each device executes the second operation and the first operation sequentially based on M*N data blocks.

[0169] The first operation is a collective communication operation performed with devices that have the same local ID in different computing nodes, and the second operation is a collective communication operation performed with devices in the same computing node.

[0170] In one example, based on M*N data blocks provided by each device, each device performs a second operation. After the second operation is completed, each device obtains M contiguous first-reduction data blocks, which are reductions of the N data blocks. Then, based on the M contiguous first-reduction data blocks provided by each device, each device performs a first operation. After the first operation is completed, each device obtains one second-reduction data block. When each device performs the first operation between different computing nodes, one data block is transmitted between devices at a time. When each device performs the second operation within the same computing node, M first-reduction data blocks are transmitted between devices at a time. This increases the communication volume between devices within a computing node and reduces the communication volume between devices on different computing nodes.

[0171] In one example, when each of the M*N devices provides M*N data blocks, each device stores the M*N data blocks in its own first memory. The M*N data blocks in each device's first memory include its own fragmented data blocks and fragmented data blocks from the other M*N-1 devices. The M devices in the M compute nodes have the same local ID, and the M devices with the same local ID satisfy feature two: the offsets of the M fragmented data blocks of the M devices with the same local ID arranged sequentially in the first memory of each device increase sequentially, and among the M devices with the same local ID arranged sequentially, the difference in the offsets of the fragmented data blocks of two adjacent devices in their own first memory is equal to the occupied value, which is the memory occupied by the fragmented data block with the smaller offset among the two fragmented data blocks of the two adjacent devices. Based on this, using the M*N data blocks provided by each device, devices within the same compute node perform a collective communication operation. Each device receives M first-protocol data blocks, each first-protocol data block being a protocol of N data blocks. When devices within a compute node perform a collective communication operation, each device transmits M data blocks at a time. Then, based on the M first-protocol data blocks provided by each device, M devices with the same local ID in the M compute nodes perform a collective communication operation between devices on different compute nodes. Each device receives a second-protocol data block, the second-protocol data block being a protocol of M*N data blocks. (The last sentence appears to be incomplete and possibly refers to a separate, unrelated statement.) In a collective communication operation between devices on different computing nodes, each device transmits one data block of the first protocol at a time. In summary, when M devices with the same local ID on M computing nodes perform a collective communication operation, each device transmits one data block of the first protocol at a time. However, when N devices on the same computing node perform a collective communication operation, each device transmits M data blocks at a time. By increasing the number of data blocks transmitted at a time within the same computing node and decreasing the number of data blocks transmitted at a time between devices on different computing nodes, the communication volume between devices within a computing node is increased, while the communication volume between devices on different computing nodes is decreased, thereby improving the execution efficiency of collective communication.

[0172] In one example, if each device provides N*M data blocks, after each device sequentially executes the second operation and the first operation, each device's first memory stores a second reduced data block, which is a reduction of the N*M data blocks. In this case, each device can also store the second reduced data block from its first memory into its own second memory. The location of the second reduced data block in the device's first memory is the same as the location of the device's fragmented data blocks in its first memory. Thus, the second reduced data block in the first memory can be retrieved based on the location of each device's fragmented data blocks in its first memory.

[0173] N*M devices perform a collective communication operation. Each device provides N*M data blocks. M devices with the same local ID are arranged sequentially. The offsets of the data blocks of these M devices in the first memory of each device increase arithmetically, with the difference being the occupied value. The occupied value is the memory size occupied by the data block with the smaller offset between two adjacent data blocks of the same device. First, based on the N*M data blocks provided by each device, the N devices within the same computing node perform a collective communication operation, and each device obtains M contiguous first-reduction data blocks. Then, based on the M first-reduction data blocks provided by each device, the M devices with the same local ID perform a collective communication operation, and each device obtains a second-reduction data block. Finally, each device stores the second-reduction data block from the first memory into its own second memory, thus obtaining the execution result of the N*M collective communication operation.

[0174] In one example, if each device provides N*M data blocks, and each data block occupies memory of size size, then after each device sequentially executes the second operation and the first operation, each device's first memory stores a second reduced data block. This second reduced data block is a reduction of the N*M data blocks. The offset of the second reduced data block in the first memory is j*size, where j satisfies:

[0175] j = A*M + B, where A is the remainder when i is divided by M, B is the quotient when i is divided by M, M is the total number of devices in each computing node, and i is the global ID of the device.

[0176] In one example, if each device provides N*M data blocks, each device's first memory has N*M locations, and the memory size occupied by each data block can be unequal, then after each device sequentially executes the second operation and the first operation, each device's first memory stores a second reduced data block, which is a reduction of the N*M data blocks. The location j of this second reduced data block in the first memory satisfies:

[0177] j = A*M + B, where A is the remainder of i divided by M, B is the quotient of i divided by M, M is the total number of devices in each computing node, and i is the global ID of the device. The offset corresponding to position j in the first memory is the sum of the memory size occupied by the fragment data block located at position 0 in the first memory and the memory size occupied by the fragment data block located at position j-1 in the first memory. The electronic device can first determine the position of the fragment data block in the first memory, and then determine the offset corresponding to the position of its own second reduction data block in the first memory based on the position of each fragment data block in the first memory and the memory size occupied by each fragment data block.

[0178] Please refer to Figure 10, which is a schematic diagram of the process of multiple devices in a computing cluster performing ReduceScatter operation according to an embodiment of this application.

[0179] In Figure 10, the computing cluster that executes the ReduceScatter operation includes two servers: server 0 and server 1. Server 0 includes two devices: device 0 and device 1, and server 1 includes two devices: device 2 and device 3. Device 0 and device 2 have the same local ID, which is 0, and device 1 and device 3 have the same local ID, which is 1.

[0180] S101. Each device determines the location of each data block it provides in the first memory, and stores each data block into the first memory based on that location.

[0181] In Figure 10, four devices perform the ReduceScatter operation, each providing four data blocks. Device 0 provides four data blocks: A0, B0, C0, and D0; Device 1 provides four data blocks: A1, B1, C1, and D1; Device 2 provides four data blocks: A2, B2, C2, and D2; and Device 3 provides four data blocks: A3, B3, C3, and D3. Each device's four data blocks are sharded data blocks for the four devices, and these sharded data blocks are deployed in the memory of the four devices respectively. For example, Device 0's sharded data blocks include A0, A1, A2, and A3.

[0182] For example, positions 0 to 3 in the first memory of device 0 store A0, C0, B0, and D0 respectively; positions 0 to 3 in the first memory of device 1 store A1, C1, B1, and D1 respectively; positions 0 to 3 in the first memory of device 2 store A2, C2, B2, and D2 respectively; and positions 0 to 3 in the first memory of device 3 store A3, C3, B3, and D3 respectively. Therefore, the offset corresponding to position i in the first memory is i*size. In the first memory of each device, the offsets of the data blocks of two devices with the same local number are arranged in sequence, and the difference is the size of the memory occupied by one data block. For example, in the first memory of device 0, the offsets of data block A0 of device 0 and data block C0 of device 2 are arranged in sequence, and the difference is the size of the memory occupied by one data block. Device 1 and device 3 have the same local number, and the offsets of data block B0 of device 1 and data block D0 of device 3 are arranged in sequence, and the difference is the size of the memory occupied by one data block.

[0183] S102, the devices within each server execute the ReduceScatter operation. In Figure 10, based on the four data blocks provided by each device, devices 0 and 1 execute the ReduceScatter operation, and devices 2 and 3 execute the ReduceScatter operation.

[0184] Specifically, within server 0, device 1 sends A1 and data block C1 to device 0. Device 0 stores the reduced data block I00 of data block A0 and data block A1 into location 0 of the first memory of device 0, and stores the reduced data block I01 of data block C0 and data block C1 into location 1 of the first memory of device 0. Device 0 sends data block B0 and data block D0 to device 1. Device 1 stores the reduced data block I10 of data block B0 and data block B1 into location 2 of the first memory of device 1, and stores the reduced data block I11 of data block D0 and data block D1 into location 3 of the first memory of device 1.

[0185] Within server 1, device 3 sends data block A3 and data block C3 to device 2. Device 2 stores the reduced data block I20 of data block A2 and data block A3 into location 0 of the first memory of device 2, and stores the reduced data block I21 of data block C2 and data block C3 into location 1 of the first memory of device 2. Device 2 sends data block B2 and data block D2 to device 3. Device 3 stores the reduced data block I30 of data block B2 and data block B3 into location 2 of the first memory of device 3, and stores the reduced data block I31 of data block D2 and data block D3 into location 3 of the first memory of device 3.

[0186] When executing the ReduceScatter operation within the server, two consecutively stored data blocks can be transferred between devices at a time. The receiving device can perform two reductions based on the two received data blocks. After the ReduceScatter operation is completed, the first reduced data blocks of the two sets of data blocks are stored in the first memory of each device.

[0187] S103, ReduceScatter operations are performed between devices on different servers. In Figure 10, based on the two first protocol data blocks provided by each device, devices 0 and 2 with the same local ID perform ReduceScatter operations, and devices 1 and 3 with the same local ID perform ReduceScatter operations.

[0188] Specifically, device 0 of server 0 sends I01 to device 2 of server 1, and device 2 of server 1 stores the protocol data block J2 of I01 provided by device 0 and I21 provided by device 2 into location 1 of the first memory of device 2; device 2 of server 1 sends I20 to device 0 of server 0, and device 0 of server 0 stores the protocol data block J0 of I00 provided by device 0 and I20 provided by device 2 into location 0 of the first memory of device 0.

[0189] Device 1 of server 0 sends I11 to device 3 of server 1. Device 3 of server 1 stores the protocol data block J3 of I11 and I31 provided by device 1 into location 3 of the first memory of device 3. Device 3 of server 1 sends I30 to device 1 of server 0. Device 1 of server 0 stores the protocol data block J1 of I10 and I30 provided by device 3 into location 2 of the first memory of device 1.

[0190] Therefore, it can be seen that during the ReduceScatter operation between devices on different servers, only one data block is transferred between devices at a time (this data block is a reduction block of two data blocks).

[0191] S104, each device determines the location of the second reduction data block in its first memory in the second memory, and stores the second reduction data block in the second memory based on the location, thus obtaining the execution result of the ReduceScatter operation performed by the four devices.

[0192] The offset of each second protocol data block in the first memory of the device is j*size, where j satisfies: j=A*M+B, where A is the remainder of i divided by M, B is the quotient of i divided by M, M=2, and i is the global number of the device.

[0193] Thus, for the ReduceScatter operation performed by N*M devices deployed within M compute nodes in a compute cluster, this ReduceScatter operation can be divided into ReduceScatter operations performed by devices with the same local ID across different compute nodes and ReduceScatter operations performed by devices within the same compute node. Based on this, firstly, the position of each data block in the first memory is determined, and then the data block is stored in the device's first memory based on this position. This ensures that the offsets of the data blocks in the first memory of the M devices with the same local ID, arranged sequentially, increase sequentially, and that the difference in the offsets of the data blocks in the first memory of two adjacent first devices is the occupancy value. The occupancy value is the memory occupied by the data block with the smaller offset among the two data blocks of two adjacent first devices. Then, based on the data blocks in the first memory of each device, each device sequentially executes the second operation within the compute node and the first operation between compute nodes. Since the offsets of the fragmented data blocks from M devices with the same local ID in the first memory of each device increase arithmetically, when performing the second operation within a compute node, each device can transfer M contiguous data blocks at a time; when performing the first operation between compute nodes, devices can transfer one reduced data block (i.e., a reduced data block of multiple data blocks) at a time, thereby improving the communication traffic between devices within a compute node and reducing the communication traffic between devices between compute nodes. Then, the reduced data blocks of N*M data blocks are retrieved from the first memory of each device to obtain the execution results of the ReduceScatter operation performed by the N*M devices.

[0194] In one example, M devices with the same local ID on different compute nodes can perform aggregate communication operations using a ring algorithm. That is, the M devices are logically arranged in a ring, with each device communicating only with its left and right neighbors (i.e., the first and last devices are connected). Ultimately, each device receives M data blocks from the M devices. Of course, the M devices can also use other algorithms to perform aggregate communication operations between compute nodes, such as the Nonuniform Hierarchical Ring (NHR), Nonuniform Hierarchical Ring v1 (NHRv1), Nonuniform Bruck (NB), and Halving-Doubling (HD).

[0195] As an example, N devices in the same compute node can use a mesh algorithm to perform collective communication operations within the compute node.

[0196] Thus, in the N*M devices of the computing cluster, each device stores its own data blocks in the first memory. The difference in offsets between the positions of adjacent data blocks of two first devices arranged sequentially in the first memory within the M computing nodes is the occupancy value. This occupancy value is the memory occupied by the data block with the smaller offset among the two adjacent data blocks of the first devices. Then, based on the number of data blocks provided by each device, the execution order of the aggregate communication operations between computing nodes and within computing nodes is selected to reduce the number of data blocks transmitted per transaction between devices on different computing nodes, increase the amount of communication transmitted between devices within computing nodes, and thus improve the execution efficiency of aggregate communication.

[0197] It's easy to understand that when multiple devices in a computing cluster perform aggregated communication operations, since these devices are deployed on multiple different computing nodes, the aggregated communication operations are typically divided into inter-node aggregated communication operations and intra-node aggregated communication operations. For example, when multiple devices perform an AllGather operation, first, multiple devices within the same computing node perform the AllGather operation, and then multiple devices deployed on different computing nodes perform the AllGather operation. The serial execution of AllGather operations between devices on different computing nodes and the serial execution of AllGather operations within the same computing node cannot fully utilize the link bandwidth between devices, thus affecting the execution efficiency of aggregated communication.

[0198] Based on this, the embodiments of this application also provide a communication method, which, during the process of multiple devices performing a collective communication operation, executes the communication operations between devices on different computing nodes and the communication operations within the same computing node in parallel, so as to make full use of the link bandwidth between devices and improve the execution efficiency of the collective communication.

[0199] Please refer to Figure 11. Figure 11 is a flowchart of a communication method provided in an embodiment of this application. The following description takes the application of the communication method to a computing cluster as an example. The computing cluster includes M*N devices, which are deployed in M ​​computing nodes. Each computing node includes N devices, where M and N are integers greater than or equal to 2. The communication method in Figure 11 includes step S1101.

[0200] S1101, Each device executes the Xth third operation and the Yth fourth operation in parallel.

[0201] The third operation is a set of communication operations performed by each device with other devices within the same computing node based on the first data block it provides. The fourth operation is the operation of a device sending the second data block it provides to a downstream device and receiving the second data block provided by an upstream device. The upstream and downstream devices of a device are devices in other computing nodes that form a ring topology with the device. X and Y are integers greater than or equal to 1.

[0202] In the computing cluster, when the M*N devices perform a collective communication operation, each device can perform communication operations with devices on different computing nodes and with devices within the same computing node. The third operation is a communication operation with devices within the same computing node, and the fourth operation is a communication operation with devices on different computing nodes.

[0203] The Xth third operation performed by each device is not based on the execution result of the Yth fourth operation performed by each device, nor is the Yth fourth operation performed by each device based on the execution result of the Xth third operation. That is, for each device, the Yth fourth operation and the Xth third operation have no data dependency relationship, which allows each device to execute the Xth third operation and the Yth fourth operation in parallel. By overlapping operations, communication latency is hidden, thereby reducing communication latency in the collective communication process and improving the execution efficiency of collective communication.

[0204] In one example, the third operation is a collective communication operation performed by each device with N-1 other devices within the same compute node. For example, within the same compute node, each device sends a first data block it provides to other devices within the same compute node and receives first data blocks sent by other devices within the same compute node. In other words, by performing a collective communication operation, each device in the compute node can receive first data blocks provided by all other devices in the same compute node. For example, if the aggregate communication operation is AllGather, the computing nodes executing the first operation include four devices: Device 0 to Device 3. Each device provides a data block. Device 0 sends its provided data to the other three devices and receives three data blocks sent by the other three devices. After the third operation is completed, each device can obtain four identical data blocks. If the aggregate communication operation is ReduceScatter, the computing nodes executing the third operation include four devices: Device 0 to Device 3. Each device provides four first data blocks. Device 0 sends its three first data blocks to the other three devices and receives three first data blocks sent by the other three devices. Each device reduces its own first data block and the three received first data blocks. After the third operation is completed, each device can obtain a reduced data block of four first data blocks.

[0205] Devices within a compute node can use a mesh algorithm to perform aggregate communication operations.

[0206] In one example, any device within a computing node can form a ring topology with M-1 other devices across M-1 computing nodes. The fourth operation could refer to each device sending its own second data block to a downstream device in the ring topology and receiving a second data block from an upstream device in the ring topology. The upstream and downstream devices for each device can be determined based on the data flow direction within the ring topology; data flows from the upstream device to the current device and from the current device to the downstream device.

[0207] If M=2, then the two devices form a ring topology, and each device is both an upstream device and a downstream device of the other device.

[0208] For example, a computing cluster includes four computing nodes, each of which includes two devices. Devices 0, 3, 5, and 7 of the four computing nodes form a ring topology. When performing the fourth operation, device 0 sends its second data block to the downstream device, i.e., device 3, and receives the second data block sent by the upstream device, i.e., device 7. Device 3 receives the second data block sent by the upstream device, i.e., device 0, and sends its second data block to the downstream device, i.e. device 5. Device 5 receives the second data block sent by the upstream device, i.e. device 3, and sends its second data block to the downstream device, i.e. device 7. Device 7 receives the second data block sent by the upstream device, i.e. device 5, and sends its second data block to the downstream device, i.e. device 0.

[0209] In one example, each device forms a ring topology with M-1 other devices in the other compute nodes. The M devices forming the ring topology are deployed in M ​​compute nodes, and these M devices have the same local number, which is used to indicate the order in which each device is arranged in the compute nodes.

[0210] In one example, in a ring topology formed by M devices, each device has an upstream device, and each computing node where the device is located has a node number. The node number is used to indicate the order of the computing node in the computing cluster. The node number of the computing node where each device is located is interRankId, and the first number of the computing node where the upstream device is located is nextInterRankId. nextInterRankId satisfies: nextInterRankId = (interRankId + 1) % M.

[0211] Optionally, if each device provides a first data block, then the second data block sent and received by each device when performing the Yth fourth operation is obtained by the device through performing the (Y-1)th fourth operation, where Y is an integer greater than 1.

[0212] Each device performs the first third operation and the first fourth operation in parallel based on the first data block it provides.

[0213] In one example, if the second data block sent and received by each device during the Yth fourth operation is obtained by the device through the (Y-1)th fourth operation, then the first data block during the Xth third operation and the second data block during the Yth fourth operation are the same data block provided by that device. That is, based on the same first or second data block provided by each device, each device performs the Xth third operation and the Yth fourth operation in parallel, so that the data blocks provided by each device can be transmitted between devices within the same computing node and between devices on different computing nodes.

[0214] In one example, if each device provides a first data block, then 1≤Y=X≤M-1, meaning that during the process of each device performing a collective communication operation, each device can execute the third and fourth operations in parallel M-1 times. By executing the third operation within the same computing node and the fourth operation between different computing nodes in parallel multiple times, the execution efficiency of the entire collective communication operation can be improved.

[0215] In one example, with M*N devices, after each device completes M third operations and M-1 fourth operations, the execution result of the collective communication operation performed by N devices can be obtained. Alternatively, each device first performs M-1 third and fourth operations in parallel, and then each device performs the Mth third operation, thus obtaining the execution result of the collective communication operation performed by N devices. Dividing the collective communication operation performed by N devices into M third operations and M-1 fourth operations, and allowing the M-1 third and fourth operations to be performed in parallel, improves the execution efficiency of collective communication by executing operations within the same computing node and between different computing nodes in parallel.

[0216] In one example, X = Y, that is, while each device completes M-1 third and fourth operations, the Xth third operation and the Xth fourth operation are performed in parallel.

[0217] In one example, based on a first data block or a second data block provided by each device, each device performs a third operation X and a fourth operation Y in parallel, wherein the offset of the location of the first data block or the second data block in the first memory of the device is x*size, and x satisfies: x=Rank%(N)+(Rank / (N)+M-X+1)%M*N.

[0218] In one example, the set communication operation is the AllGather operation. Based on a first data block provided by each device, M*N devices perform the AllGather operation, where the offset of the first data block provided by device i in its own memory is i*size. Each device executes the first third operation and the first fourth operation in parallel.

[0219] Then, based on the data block acquired by each device during the execution of the first fourth operation, each device executes the second third operation and the second fourth operation in parallel. The offset of the data in the device's memory is j*size, where j satisfies: j=Rank%(N)+(Rank / (N)+M-1)%M*N.

[0220] Based on the data block acquired by each device during the second fourth operation, each device executes the third and third fourth operations in parallel. The offset of the data block in the device's memory is j*size, where j satisfies: j=Rank%(N)+(Rank / (N)+M-2)%M*N;

[0221] This process continues until each device has completed M-1 third and fourth operations. Based on the data block obtained by each device during the M-1 fourth operation, each device performs M third operations to obtain the execution results of the AllGather operation performed by M*N devices. The offset of the data block in the device's memory is j*size, where j satisfies: j = Rank%(N) + (Rank / (N) + 1)%M*N.

[0222] Please refer to Figures 12A to 12E, which are schematic diagrams of an AllGather operation provided in an embodiment of this application.

[0223] In Figure 12A, the computing cluster performing the AllGather operation consists of 16 devices deployed across four servers: servers 0 through 3, devices 0 through 3 on server 0, devices 4 through 7 on server 1, devices 8 through 11 on server 2, and devices 12 through 15 on server 3. Each device provides one data block. As shown in Figure 12A, the 16 devices perform the AllGather operation, and each device reserves 16 * size of memory, where size is the memory size occupied by the data block provided by each device. In Figure 12A, device i provides data block i (15 ≥ i ≥ 0), and the data block i provided by device i is located at position i in its memory, with an offset of i * size. For example, data block 1 provided by device 1 is located at position 1 in device 1's memory, with an offset of 1 * size; data block 15 provided by device 15 is located at position 15 in its memory, with an offset of 15 * size.

[0224] Since 16 devices are performing the AllGather operation, and these 16 devices are deployed on 4 servers, the AllGather operation can be divided into a fourth operation between compute nodes and a third operation within a compute node.

[0225] Please refer to Figure 12A. Based on a data block provided by each device within the dashed box in Figure 12A, each device performs the first third operation and the first fourth operation in parallel.

[0226] Specifically, the third operation is an AllGather operation performed by each device with three other devices within the same server. The fourth operation is an operation where each device sends its own second data block to downstream devices and receives second data blocks from upstream devices. Each device forms a ring topology with three other devices on its three compute nodes that share the same local ID. Each device's upstream and downstream devices are the devices adjacent to it within this ring topology. The local ID is the remainder when the device's rank is divided by the number of devices in the compute nodes.

[0227] In the parallel execution of the third and fourth operations for the Xth time, the offset of the data block provided by each device in memory is x*size, where x satisfies: x=Rank%4+(Rank / 4+5-X)%4*4.

[0228] Taking device 0 on server 0 as an example, device 0 sends data block 0 to devices 1 to 3 on server 0; device 0 receives data block 1 sent by device 1, data block 2 sent by device 2, and data block 3 sent by device 3. The AllGather operation is completed, and each device on server 0 receives the same four data blocks.

[0229] Each device forms a ring topology with three other devices in the other three computing nodes. The four devices transmit data blocks along the ring topology. Taking device 0 as an example, device 0 forms a ring topology with device 4, device 8 and device 12. Device 0 sends data block 0 to device 4 in server 1 and receives data block 12 sent by device 12 in server 3. Device 4 sends data block 4 to device 8 and receives data block 0 sent by device 1. Device 8 sends data block 8 to device 12 and receives data block 4 sent by device 4. Device 12 sends data block 12 to device 0 and receives data block 8 sent by device 8. Similarly, devices 1, 5, 9, and 13 form a ring topology. Device 1 of server 0 sends data block 1 to device 5 in server 1 and receives data block 13 sent by device 13 of server 3, and so on. Devices 2, 6, 10, and 14 form a ring topology. Device 2 of server 0 sends data block 2 to device 6 in server 1 and receives data block 14 sent by device 14 of server 3, and so on. Devices 3, 7, 11, and 15 form a ring topology. Device 3 of server 0 sends data block 3 to device 7 in server 1 and receives data block 15 sent by device 15 of server 3, and so on.

[0230] After the first third operation and the first fourth operation are completed, each device receives five data blocks.

[0231] Please refer to Figure 12B. Based on the data blocks obtained by each device during the first fourth operation (i.e., the data blocks within the dashed boxes in Figure 12B), each device executes the second third and second fourth operations in parallel. The specific execution process is similar to that in Figure 12A, and will not be described again here.

[0232] After the second and third operations and the second and fourth operations are completed, each device receives nine data blocks.

[0233] Please refer to Figure 12C. Based on the data blocks obtained by each device during the second and fourth operations (i.e., the data blocks within the dashed boxes in Figure 12C), each device executes the third and fourth operations in parallel. The specific execution process is similar to that in Figure 12A, and will not be described again here.

[0234] After the third and fourth operations were performed, each device received thirteen data blocks.

[0235] Please refer to Figure 12D. Based on the data blocks obtained by each device during the third and fourth operations (i.e., the data blocks in the dashed boxes in Figure 12D), each device performs the fourth third operation, as shown in Figure 12E. Each device obtains 16 data blocks provided by 16 devices, which is the execution result after the 16 devices perform the AllGather operation.

[0236] Thus, when N*M devices in the computing cluster execute the AllGather operation, with N*M devices deployed on M computing nodes and each computing node having N devices, the AllGather operation executed by the N*M devices can be divided into M third operations and M-1 fourth operations. Each device executes the M-1 third and fourth operations in parallel. By executing operations within and between computing nodes in parallel, communication latency is hidden through overlapping communication, thereby reducing communication latency in the aggregate communication process and improving the execution efficiency of aggregate communication.

[0237] Optionally, if each device provides M*N first data blocks, then the second data blocks sent and received by each device when performing the Yth fourth operation are obtained by the device through performing the (X-1)th third operation.

[0238] As an example, if the second data block sent and received by each device when performing the fourth operation for the Yth time is obtained by each device when performing the third operation for the (X-1)th time, then the second data block is a specification of (X-1)*N first data blocks.

[0239] In one example, Y≤M-1, each device can execute the third and fourth operations in parallel M-1 times. By executing the third and fourth operations in parallel multiple times, the execution efficiency of the entire set of communication can be improved.

[0240] In one example, X = Y + 1, each device performs the third operation X and the fourth operation X-1 in parallel.

[0241] For example, based on the first data block at N locations in the memory provided by each device, the computing node performs the Xth third operation, and based on the second data block at location z in the memory provided by each device, the computing node performs the Yth fourth operation.

[0242] In one example, each device can perform the Xth third operation based on its own N first data blocks, where the offsets of the N first data blocks at N locations in the device's first memory are from y*size to (y+N-1)*size, and y satisfies:

[0243] y = (rank / N+X)%M*N, where % is the identifier for the remainder or modulo operation. For example, (rank / N+X)%M is the remainder of (rank / N+X) divided by M.

[0244] In one example, if each device provides M*N first data blocks, and each device performs M third operations and M-1 fourth operations, the execution result of the collective communication operation performed by M*N devices can be obtained. Alternatively, each device first performs the first third operation, and then performs M-1 third and fourth operations in parallel, thus obtaining the execution result of the collective communication operation performed by M*N devices. By dividing the collective communication operation performed by M*N devices into M third operations and M-1 fourth operations, and performing the M-1 third and fourth operations in parallel—that is, by performing operations within the same computing node and operations between different computing nodes in parallel—the execution efficiency of collective communication can be improved.

[0245] In one example, the collection communication operation is a ReduceScatter operation. The process of M*N devices executing a ReduceScatter operation is as follows:

[0246] First, each device performs the first third operation based on the N first data blocks it provides; the offset of the N data blocks provided by each device in its memory is from y*size to (y+N-1)size, where y satisfies y=(Rank / (N)+1)%M*N.

[0247] Then, each device executes the second and third operations and the first and fourth operations in parallel. The third operation is performed based on N data blocks provided by itself, where the offsets of these N data blocks in memory are from y*size to (y+N-1)size, and y satisfies: y=(Rank / (N)+2)%M*N; the fourth operation is performed based on one data block provided by itself, where the offset of this data block in memory is z*size, and z satisfies: z=Rank%(N)+(Rank / (N)+1)%M*N.

[0248] Then, each device executes the third operation and the second fourth operation in parallel. The third operation is performed based on N data blocks provided by itself. At this point, the offsets of these N data blocks in memory are y*size to (y+N-1)size, where y satisfies: y=(Rank / (N)+3)%M*N. The fourth operation is performed based on one data block provided by itself. The offset of this data block in memory is z*size, where z satisfies: z=Rank%(N)+(Rank / (N)+2)%M*N.

[0249] This process continues until each device executes the third and fourth operations in parallel M-1 times, resulting in the execution results of N*M devices performing the ReduceScatter operation.

[0250] Please refer to Figures 13A to 13E, which are schematic diagrams illustrating the process of a ReduceScatter operation provided in an embodiment of this application. The computing cluster executing the ReduceScatter operation in Figure 13A includes 16 devices deployed across 4 servers: Servers 0 to 3, devices 0 to 3 are deployed on Server 0, devices 4 to 7 are deployed on Server 1, devices 8 to 11 are deployed on Server 2, and devices 12 to 15 are deployed on Server 3. Each device provides 16 data blocks. As shown in Figure 13A, the 16 devices execute the ReduceScatter operation. Each device reserves 16 * size of memory, where size is the memory size occupied by the data blocks provided by each device. The 16 data blocks provided by each device are stored in its memory at positions 0 to 15, with offsets corresponding to positions 0 to 15, respectively.

[0251] Please refer to Figure 13A. Based on the four data blocks provided by each device, each device performs the first third operation, or in other words, the four devices within each server perform the first ReduceScatter operation.

[0252] The positions of the four data blocks in memory are related to the rank of the device. When each device performs the third operation for the Xth time, the data blocks provided by each device are located from position y to position y+3 in memory, where y = (Rank / 4 + X) % 4 * 4.

[0253] For example, in server 0, the four data blocks provided by each device are located at positions 4 to 7 in memory; in server 1, the data blocks provided by each device are located at positions 8 to 11 in memory; in server 2, the data blocks provided by each device are located at positions 12 to 15 in memory; and in server 3, the data blocks provided by each device are located at positions 0 to 3 in memory.

[0254] Based on the four data blocks provided by each device (the data blocks in the dashed box in Figure 13A), the four devices in each server execute the ReduceScatter operation. After the ReduceScatter operation is completed, each device stores the reduction of the four data blocks in its memory. The reduction in Figure 13A is the sum of these reductions.

[0255] Specifically, each device in each server sends its own data block to other devices in the server and receives data blocks sent by other devices. It then reduces the received data block to its own data block and stores the reduced data block in its memory. For example, in server 0, device 0 sends its own data block at memory location 5 to device 1, its own data block at memory location 6 to device 2, and its own data block at memory location 7 to device 3. It also receives data blocks at memory location 4 from devices 1, 2, and 3. Each device reduces (i.e., adds) its own data block to the received data block. Device 0 receives the reduced data blocks at memory location 4 from the four devices in server 0; device 1 receives the reduced data blocks at memory location 5 from the four devices in server 0; device 2 receives the reduced data blocks at memory location 6 from the four devices in server 0; and device 3 receives the reduced data blocks at memory location 7 from the four devices in server 0. Other servers perform similar operations.

[0256] Please refer to Figure 13B, where each device performs the second and third operations and the first and fourth operations in parallel.

[0257] Specifically, based on the data blocks in the four locations of memory provided by each device (the data blocks in the dashed box in Figure 13B), the four devices in each server perform the second and third operations. Based on the reduced data blocks obtained by each device after the first and third operations, each device performs the first and fourth operations.

[0258] The second and third operations performed by the four devices within each server are similar to the first and third operations performed by the four devices within each server. The difference is that when performing the second and third operations, the four data blocks provided by each device are located in memory from y to y+3, where y satisfies: y = (Rank / (N) + 2)%M*N. When performing the first and fourth operations, the reduced data block provided by each device is located in its own memory at position z, where z satisfies: z = Rank%4 + (Rank / 4 + 1)%4*4.

[0259] In this setup, each device forms a ring topology with three other devices from the other three servers. All four devices in the ring topology share the same local identifier. Within the ring topology, each device sends its own protocol data blocks to the upstream device and receives protocol data blocks from the downstream device.

[0260] After each device performs the second and third operations and the first and fourth operations, it will reduce the received data block with its own data block to obtain 8 reduced data blocks of the first data block.

[0261] Please refer to Figure 13C, where each device performs the third operation and the second operation in parallel.

[0262] After the third operation and the second and fourth operations are completed, each device receives 12 first data blocks of reduced data blocks.

[0263] Please refer to Figure 13D, where each device performs the fourth third operation and the third fourth operation in parallel.

[0264] After the fourth third operation and the third fourth operation are completed, each device obtains 16 first data blocks (i.e. second data blocks) as shown in Figure 13E.

[0265] Please refer to Figure 13E. The reduced data blocks (i.e., second data blocks) of 16 first data blocks are obtained from the memory of each device. For example, the corresponding second data block is obtained from position i in the memory of device i. The execution results of the ReduceScatter operation of 16 devices can be obtained.

[0266] Thus, when N*M devices in the computing cluster execute ReduceScatter operations, with these N*M devices deployed across M computing nodes, and each computing node containing N devices, the ReduceScatter operations executed by the N devices can be divided into M intra-node third operations and M-1 inter-node fourth operations. Each device can execute the M-1 third and fourth operations in parallel. By executing the intra-node and inter-node operations in parallel, communication latency during the aggregate communication process is reduced, thereby improving the execution efficiency of aggregate communication.

[0267] This application provides three communication methods as shown in Figures 5, 8 and 11. Before performing a collection communication operation, the corresponding communication method can be selected based on the specific scenario to meet the needs of that scenario.

[0268] Optionally, before performing the collective communication operation, each device may also obtain characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices in the computing cluster. If the communication volume of the computing cluster is greater than a first threshold, or if the communication volume of the computing cluster is less than the first threshold and the number of devices in the computing cluster is less than or equal to a second threshold, the collective communication operation can be performed using the communication method shown in Figure 11. If the communication volume of the computing cluster is less than the first threshold and the number of devices in the computing cluster is greater than the second threshold, the collective communication operation can be performed using the communication method shown in Figure 5 or Figure 8.

[0269] Among them, communication volume refers to the total amount of data exchanged between different devices to collaboratively complete tasks, and the communication volume in the computing cluster can be obtained through network packet capture and other methods.

[0270] If the communication volume of the computing cluster is greater than the first threshold, it indicates that the total amount of data to be exchanged between the devices in the computing cluster is large, or that the communication volume of the computing cluster is large. In this case, the communication method shown in Figure 11 can be used to perform the collective communication operation, which can make full use of the advantages of parallel execution between computing nodes and within computing nodes, and improve the communication efficiency of collective communication.

[0271] If the communication volume of the computing cluster is less than or equal to the first threshold, it indicates that the total amount of data to be exchanged between devices in the computing cluster is small, or in other words, the communication volume of the computing cluster is small. Therefore, the implementation method of the aggregated communication operation can be selected based on the number of devices in the computing cluster. For example, if the number of devices in the computing cluster is less than or equal to the second threshold, it indicates that the number of devices in the computing cluster is small, and the communication method shown in Figure 11 can be used to perform the aggregated communication operation. This can fully utilize the advantages of parallel execution between and within computing nodes, improving the communication efficiency of aggregated communication. If the number of devices in the computing cluster is greater than the second threshold, it indicates that there are many devices in the computing cluster, and the total amount of data to be transmitted between devices is small. Therefore, the communication method shown in Figure 5 or Figure 8 can be used to perform the aggregated communication operation, reducing the amount of data transmitted between devices within different computing nodes and increasing the amount of data transmitted between devices within the same computing node, thus improving the communication efficiency of aggregated communication. In one example, the first threshold is 1M and the second threshold is 4. Of course, in other embodiments, the corresponding first and second thresholds can be selected based on the actual network environment.

[0272] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital versatile discs (DVDs)), or semiconductor media (e.g., solid-state disks (SSDs)).

[0273] In the various embodiments of this application, unless otherwise specified or logically conflicting, the terminology and / or descriptions between different embodiments are consistent and can be referenced mutually. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships. In the embodiments of this application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone, where A and B can be singular or plural. In the textual description of the embodiments of this application, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. In this application, "first," "second," and various numerical designations are only for ease of description and are not used to limit the scope of the embodiments of this application. For example, they are used to distinguish different messages, rather than to describe a specific order or sequence.

[0274] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. The order of the process numbers does not imply the order of execution; the execution order of each process should be determined by its function and internal logic.

[0275] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A communication method characterized by comprising: Applied to a computing cluster, the computing cluster includes M computing nodes, each computing node includes N devices, each device provides a data block, the data block is a fragmented data block of the device, M and N are both integers greater than or equal to 2, the method includes: Each device stores one of its own data blocks in its own first memory. The computing cluster comprises M*N devices, including M first devices with the same local ID. The offsets of the data blocks in the first memory of the M first devices, arranged sequentially, increase sequentially. The difference in offsets between the data blocks of two adjacent first devices in their own first memory is the occupancy value. This occupancy value represents the memory size occupied by the data block with the smaller offset among the two adjacent data blocks of the first devices. The local ID indicates the arrangement order of the first devices in the computing node. Each device performs a first operation and a second operation sequentially based on a data block, wherein the first operation is a collective communication operation performed with devices having the same local number in different computing nodes, and the second operation is a collective communication operation performed with devices in the same computing node.

2. The method of claim 1, wherein, After each device sequentially executes the first operation and the second operation, each device stores N*M data blocks in its first memory. The method further includes: Each device stores the N*M data blocks in the first memory into its own second memory; wherein, the N*M data blocks of each device include the fragment data blocks of the N*M devices, and the offset of the position of the fragment data block of the device with rank i in the second memory is the sum of the memory size occupied by the fragment data block of the device with rank 0 to the memory size occupied by the fragment data block of the device with rank i-1, N*M-1≥i≥0, and rank is the global number of the device.

3. The method according to claim 1 or 2, characterized in that, If the memory sizes occupied by the data blocks of M*N devices are all equal, and the offset of the data block of each device in the first memory is j*size, where j satisfies: j = A*M + B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, rank is the global number of the device, and size is the memory size occupied by the fragmented data block of the device.

4. The method according to any one of claims 1 to 3, characterized in that, Each of the devices, based on one of the data blocks, sequentially performs a first operation and a second operation, including: Based on one of the data blocks, each of the devices performs a first operation, and each of the devices obtains M consecutively stored data blocks; Based on the M consecutively stored data blocks, each device performs a second operation, and each device obtains N*M consecutively stored data blocks.

5. The method according to any one of claims 1 to 4, characterized in that, The set communication operation is the AllGather operation.

6. The method according to any one of claims 1 to 5, characterized in that, Each of the devices stores a data block it provides into its own first memory, including: Obtain the characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices in the computing cluster; If the communication volume of the computing cluster is less than a first threshold and the number of devices in the computing cluster is greater than a second threshold, then each device will store a data block provided by itself into its own first memory.

7. A communication method characterized by comprising: Applied to a computing cluster, the computing cluster includes M computing nodes, each computing node includes N devices, each device provides M*N data blocks, the M*N data blocks include fragmented data blocks from the M*N devices of the computing cluster, where M and N are both integers greater than or equal to 2, the method includes: Each device stores the M*N data blocks it provides into its own first memory. The M*N devices in the computing cluster include M first devices with the same local number. The offsets of the data blocks of the M first devices in their respective first memory locations increase sequentially. The difference between the offsets of the data blocks of two adjacent first devices in their respective first memory locations is the occupancy value. The occupancy value is the memory occupied by the data block with the smaller offset among the two data blocks of the two adjacent first devices. The local number is used to indicate the arrangement order of the first devices in the computing node. Each device performs a second operation and a first operation sequentially based on the M*N data blocks, wherein the second operation is a collective communication operation performed with devices within the same computing node, and the first operation is a collective communication operation performed with devices having the same local number within different computing nodes.

8. The method of claim 7, wherein, After each device sequentially executes the second operation and the first operation, each device stores a second reduction data block in its first memory. The second reduction data block is a reduction of M*N data blocks. The method further includes: Each device stores the second protocol data block from the first memory into its own second memory; wherein the location of the second protocol data block in the first memory of the device is the same as the location of the fragment data block of the device in the first memory.

9. The method according to claim 7 or 8, characterized in that, If the memory sizes occupied by the data blocks of M*N devices are all equal, and the offset of the data block of each device in the first memory is j*size, where j satisfies: j = A*M + B, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by M, rank is the global ID of the device, and size is the memory size occupied by the fragmented data blocks of the device.

10. The method according to any one of claims 7 to 9, characterized in that, Each of the devices, based on the M*N data blocks, sequentially performs a second operation and a first operation, including: Based on the M*N data blocks, each device performs the second operation, and each device obtains M first reduction data blocks, where the first reduction data blocks are the reductions of the N data blocks; Based on the M first protocol data blocks, each device performs the first operation, and each device obtains a second protocol data block, which is a protocol of M*N data blocks.

11. The method according to any one of claims 7 to 10, characterized in that, The set communication operation is the ReduceScatter operation.

12. The method according to any one of claims 7 to 11, characterized in that, Each of the aforementioned devices stores the data blocks it provides into its own first memory, including: Obtain the characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices in the computing cluster; If the communication volume of the computing cluster is less than a first threshold and the number of devices in the computing cluster is greater than a second threshold, then each device will store its own M*N data blocks into its own first memory.

13. A method of communication, comprising: Applied to a computing cluster, the computing cluster comprising M computing nodes, each computing node comprising N devices, where M and N are integers greater than or equal to 2; the method includes: Each of the aforementioned devices performs the Xth third operation and the Yth fourth operation in parallel; The third operation is a collective communication operation performed by the device with other devices within the same computing node based on the first data block it provides. The fourth operation is the operation of the device sending the second data block it provides to the downstream device and receiving the second data block provided by the upstream device. The upstream and downstream devices of the device are devices in other computing nodes that form a ring topology with the device. X and Y are both integers greater than or equal to 1.

14. The method according to claim 13, characterized in that, If each of the devices provides a first data block, then the second data block is obtained by the device through performing the (Y-1)th fourth operation, where Y is an integer greater than 1; If each of the devices provides M*N of the first data blocks, then the second data is obtained by the device through performing the (X-1)th third operation, where X is an integer greater than 1.

15. The method according to claim 13 or 14, characterized in that, After each device completes M third operations and M-1 fourth operations, the execution results of the first set of communication operations performed by the N*M devices are obtained.

16. The method according to any one of claims 13 to 15, characterized in that, If each device provides a first data block, then the offsets in its own memory corresponding to the positions of the first data block provided by each device during the Xth third operation and the second data block provided by each device during the Yth fourth operation are both x*size, where x satisfies: x = A + ((B + M - X + 1) % M) * N, where A is the remainder when rank is divided by M, B is the quotient when rank is divided by N, and (B + M - X + 1) % M is the remainder when (B + M - X + 1) is divided by M. Wherein, rank is the global number of the device, and size is the memory size occupied by one of the first data blocks.

17. The method according to any one of claims 13 to 16, characterized in that, If each device provides N*M of the first data blocks, then the offsets of the N first data blocks provided by each device during the Xth third operation at the N locations in its own memory are: y*size to (y+N-1)*size, where y satisfies: y = (rank / N+X)%M*N, where (rank / N+X)%M is the remainder of (rank / N+X) divided by M; When each device performs the Yth fourth operation, the offset of the location of the second data block in its own memory is z*size, where z satisfies: z=rank%N+((rank / N+X-1)%M)*N; Wherein, rank is the global number of the device, and size is the memory size occupied by one of the first data blocks.

18. The method according to any one of claims 13 to 17, characterized in that, Each of the devices performs the Xth third operation and the Yth fourth operation in parallel, including: Obtain the characteristic information of the computing cluster, including the communication volume of the computing cluster and the number of devices; If the communication volume of the computing cluster is greater than the first threshold, or if the communication volume of the computing cluster is less than the first threshold and the number of devices is less than the second threshold, then each device executes the Xth third operation and the Yth fourth operation in parallel.

19. The method according to any one of claims 13 to 18, characterized in that, If each of the devices provides one of the first data blocks, the aggregate communication operation is an AllGather operation; If each of the devices provides N*M of the first data blocks, the set communication operation is a ReduceScatter operation.

20. An electronic device, comprising: Includes at least one processor; and A memory storing a computer program executable on the processor, wherein the processor, when executing the computer program, performs the steps performed by any device in the method as described in any one of claims 1-19.

21. A computing cluster, comprising: The computing cluster includes multiple computing nodes, and each computing node includes multiple devices, wherein the devices perform the communication method according to any one of claims 1-19.

22. A program product, characterized by When the program product is run on multiple devices of the computing cluster, the devices are made to perform the communication method of any one of claims 1-19.

23. A computer-readable storage medium, characterized in that, Includes programs or instructions that, when executed by devices of a computing cluster, implement the communication method as described in any one of claims 1-19.