Description: When there is TP domain communication, ReduceScatterV communication is performed first, followed by AllToAllV communication, and finally the received data is combined (multiplied by the weight and then summed). When there is no TP domain communication, AllToAllV communication is performed, and then the received data is combined (multiplied by the weight and then summed).
Compared with the
[object Object]API, this API has the following changes:- Dynamic scale-in support: The operator can run properly without recompilation after faulty ranks are removed after the created communication domain. Enable this feature by passing the
[object Object]parameter. - Special expert scenarios are supported:
- zeroExpertNum≠0: Enabled by setting the
[object Object]parameter to a value greater than 0.
- copyExpertNum≠0: Enabled by setting the
[object Object]parameter to a value greater than 0 and setting a valid value for the oriXOptional parameter.
- constExpertNum≠0: Enabled by setting the constExpertNum parameter to a value greater than 0 and setting valid values for the oriXOptional, constExpertAlpha1Optional, constExpertAlpha2Optional, and constExpertVOptional parameters.
- Dynamic scale-in support: The operator can run properly without recompilation after faulty ranks are removed after the created communication domain. Enable this feature by passing the
Formula:
[object Object]
Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.
Parameters
[object Object][object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
- The value of
[object Object]can be[object Object],[object Object],[object Object], or[object Object]. It is recommended to use[object Object]with driver version 25.0.RC1.1 or later. When set to[object Object]or[object Object], the communication algorithm is selected based on HCCL environment variables (not recommended).[object Object]indicates that tokens are directly transmitted through RDMA.[object Object]indicates a two-stage communication process: intra-server communication followed by inter-server communication, which reduces cross-server traffic. - Shared experts are not supported.
- The shape of
[object Object]is (moeExpertNum + 2 globalBs K serverNum, ), where K indicates the number of top K experts, moeExpertNum indicates the number of tokens received from each rank in the EP communication domain, and 2 globalBs K serverNum indicates the number of tokens and communication area offset that can be combined for the reduce operation before communication across storage servers or within a storage server. If[object Object]is 0, the value is calculated as follows: Bs * epWorldSize. - Currently, TP domain communication is not supported.
[object Object]depends on the[object Object]value: For[object Object], it requires a 1D tensor with shape (Bs, ), where[object Object]must precede[object Object](for example, {true, false, true} is invalid); for[object Object], it is currently not supported and a null pointer should be passed.[object Object]must be a 1D tensor with shape (A, ).[object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.- The value of
[object Object]depends on the[object Object]value: For[object Object], it supports 16, 32, 64, 128, 192, and 256; for[object Object], it supports 16, 32, and 64. - The value of
[object Object]must be in the range (0, 512] and satisfy moeExpertNum / (epWorldSize - sharedExpertRankNum) <= 24. [object Object]is not supported in the current version. Pass an empty string.[object Object]is not supported in the current version. Pass 0.[object Object]is not supported in the current version. Pass 0.[object Object]is not supported in the current version. Pass 0.[object Object]is not supported in the current version. Pass 0.[object Object]is not supported in the current version. Pass 0.- The value of
[object Object]is 0 or 2 (0 indicates no quantization and 2 indicates int8 quantization). The value 2 is supported only when commAlg is[object Object], or when HCCL_INTRA_PCIE_ENABLE=1, HCCL_INTRA_ROCE_ENABLE=0, and the driver version is 25.0.RC1.1 or later. [object Object]must be a 1D tensor.[object Object]is not supported in the current version. Pass a null pointer.[object Object]is not supported in the current version when commAlg is[object Object]. Pass a null pointer.[object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.[object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.[object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.- When commAlg is
[object Object], the value of[object Object]must be in the range [0, MAX_INT32), where MAX_INT32 = 2^31 - 1. Valid zero expert IDs must be in the range [[object Object]moeExpertNum[object Object], [object Object]moeExpertNum + zeroExpertNum[object Object]). - When commAlg is
[object Object], the value of[object Object]must be in the range [0, MAX_INT32), where MAX_INT32 = 2^31 - 1. Valid copy expert IDs must be in the range [[object Object]moeExpertNum + zeroExpertNum[object Object], [object Object]moeExpertNum + zeroExpertNum + copyExpertNum[object Object]). [object Object]is not supported in the current version. Pass 0.
- The value of
[object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
[object Object]is not supported in the current version. Pass a null pointer.- The shape of
[object Object]is (epWorldSize max(tpWorldSize, 1) localExpertNum, ). - When there is TP domain communication,
[object Object]is a 1D tensor with shape (tpWorldSize, ). [object Object]must be a 1D tensor with shape (BS, ) or a 2D tensor with shape (BS, K). If it is a 1D tensor,[object Object]must be placed before[object Object]. If it is a 2D tensor and the K values corresponding to tokens are all[object Object], the tokens do not participate in communication.[object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.[object Object]must be a 2D tensor with shape (Bs, H) or a 3D tensor (the product of the first two dimensions equals Bs and the third dimension equals H). This parameter is optional. When it is provided,[object Object]must be set to 0.- The value of
[object Object]must be in the range [2, 768]. - The value of
[object Object]must be in the range (0, 1024]. - groupTp must be a string of length [0, 128) and cannot be the same as groupEp. This parameter can be left empty only when there is no TP domain communication.
- The value of
[object Object]must be in the range [0, 2]. 0 and 1 indicate no TP domain communication. 2 is required when TP domain communication is used. - The value of
[object Object]must be in the range [0, 1].[object Object]of each rank in the same TP domain must be unique. If TP domain communication is not used, pass 0. - The value of
[object Object]must be 0, indicating that shared expert ranks are placed in front of MoE expert ranks. - The value of
[object Object]must be in the range [0, 4]. - The value of
[object Object]must be in the range [0, epWorldSize). If the value is 0,[object Object]is 0 or 1. If the value is not 0,[object Object]is 0. - The value of
[object Object]is 0 or 2 (0 indicates no quantization and 2 indicates int8 quantization). The value 2 is supported only when tpWorldSize < 2. [object Object]is a reserved parameter, which is not supported in the current version. Pass a null pointer.- You can pass valid data or a null pointer for
[object Object]. If a null pointer is passed, the dynamic scale-in feature is disabled. If valid data is passed, it must be a 1D tensor with shape [object Object](4 + 2 epWorldSize, )[object Object]. The first four numbers in the tensor indicate: whether scale-in is performed, the actual number of ranks after scale-in, the number of ranks used by shared experts after scale-in, and the number of MoE experts after scale-in. The remaining 2 epWorldSize indicates two rank mapping tables. After scale-in, some ranks on the current device may be removed from the EP communication domain due to failures. The mapping for the first table is[object Object]Table1[epRankId]=localEpRankId[object Object] or [object Object]Table1[epRankId]=-1[object Object]. Here,[object Object]denotes the rank index in the new EP communication domain, and[object Object]indicates that the rank with the corresponding epRankId has been removed from the communication domain. The mapping for the second table is [object Object]Table2[localEpRankId] = epRankId[object Object]. - You can pass valid data or a null pointer for
[object Object]. When[object Object]is not 0, a valid input is required. If valid data is passed, it must be a 2D tensor with shape [object Object](constExpertNum, H)[object Object] and the same data type as expandX. - You can pass valid data or a null pointer for
[object Object]. When[object Object]is not 0, a valid input is required. If valid data is passed, it must be a 2D tensor with shape [object Object](constExpertNum, H)[object Object] and the same data type as expandX. - You can pass valid data or a null pointer for
[object Object]. When[object Object]is not 0, a valid input is required. If valid data is passed, it must be a 2D tensor with shape [object Object](constExpertNum, H)[object Object] and the same data type as expandX. - The value of
[object Object]must be in the range [0, MAX_INT32), where MAX_INT32 = 2^31 - 1. Valid zero expert IDs must be in the range [[object Object]moeExpertNum[object Object], [object Object]moeExpertNum + zeroExpertNum[object Object]). - The value of
[object Object]must be in the range [0, MAX_INT32), where MAX_INT32 = 2^31 - 1. Valid copy expert IDs must be in the range [[object Object]moeExpertNum + zeroExpertNum[object Object], [object Object]moeExpertNum + zeroExpertNum + copyExpertNum[object Object]). - The value of
[object Object]must be in the range [0, MAX_INT32), where MAX_INT32 = 2^31 - 1. Valid constant expert IDs must be in the range [[object Object]moeExpertNum + zeroExpertNum + copyExpertNum[object Object], [object Object]moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum[object Object]).
Returns:
[object Object]: status code. For details, see .The first-phase API implements input parameter verification. The following errors may be thrown.
[object Object]
Deterministic computing:
- aclnnMoeDistributeCombineV3 defaults to a deterministic implementation.
API constraints::
[object Object]and[object Object]must be used together. The[object Object],[object Object],[object Object], and[object Object]outputs of[object Object]must be directly passed to the corresponding parameters of[object Object]. The service logic cannot depend on the specific values of these tensors.
Parameter consistency constraints:
- The values of
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object], and[object Object]must be consistent across all ranks, and be the same as the value of[object Object]. - The deployment information after dynamic scale-in is transferred to the operator through the
[object Object]parameter. Other parameters do not need to be modified. After dynamic scale-in, the number of MoE experts deployed on the current rank must be the same as that before scale-in. Configurations where no MoE expert ranks remain after scale-in are not supported.
- The values of
Product constraints:
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: In this scenario, a single rank contains dual dies. Therefore, the "rank" in the parameter description indicates a single die.
- Dynamic scale-in cannot be enabled in TP parallelism scenarios. That is, this function takes effect only when
[object Object]is set to 1.
Shape variable constraints:
[object Object]undefined
Environment variables constraints:
HCCL_BUFFSIZE: Before calling this API, check whether the value of the HCCL_BUFFSIZE environment variable is proper. This environment variable indicates the buffer size occupied by a single communication domain, in MB. If this environment variable is not set, the default value 200 MB is used.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
- If
[object Object]is set to[object Object]or[object Object], select the[object Object]or[object Object]formula based on the HCCL_INTRA_PCIE_ENABLE and HCCL_INTRA_ROCE_ENABLE environment variables. - If
[object Object]is set to[object Object], the value must satisfy [object Object]>= 2 * (Bs * epWorldSize * min(localExpertNum, K) * H * sizeof(uint16) + 2MB)[object Object]. - If
[object Object]is set to[object Object], the value must satisfy [object Object]= moeExpertNum * Bs * (H * sizeof(dtypeX) + 4 * ((K + 7) / 8 * 8) * sizeof(uint32)) + 4MB + 100MB[object Object] and does not need to satisfy [object Object]moeExpertNum / (epWorldSize - sharedExpertRankNum) <= 24[object Object].
- If
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
- Within an EP communication domain: The value must satisfy [object Object]>= 2[object Object] and [object Object]>= 2 * (localExpertNum * maxBs * epWorldSize * Align512(Align32(2 * H) + 44) + (K + sharedExpertNum) * maxBs * Align512(2 * H))[object Object]. Set [object Object]localExpertNum[object Object] to the number of experts assigned to the current rank when using MoE, where [object Object]Align512(x) = ((x + 512 - 1) / 512) * 512[object Object] and [object Object]Align32(x) = ((x + 32 - 1) / 32) * 32[object Object].
- Within a TP communication domain: The value must satisfy >=A (H 2 + 128) * 2.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
HCCL_INTRA_PCIE_ENABLE/HCCL_INTRA_ROCE_ENABLE:
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: This environment variable is not recommended. You are advised to set commAlg to
[object Object].
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: This environment variable is not recommended. You are advised to set commAlg to
Constraints on the use of communication domains:
[object Object]and[object Object]in a model support only the same EP communication domain, and no other operators are allowed in the communication domain.[object Object]and[object Object]in a model support only the same TP communication domain or both do not support a TP communication domain. If a TP communication domain is supported, no other operators are allowed in the communication domain.- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: Nodes in a communication domain must be in the same SuperPoD. Cross-SuperPoD nodes are not supported.
Networking constraints:
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: In multi-server scenarios, only switch-based networking is supported, and direct point-to-point networking between two servers is not supported.
Other constraints:
- In the formulas,
[object Object]denotes integer division. - [object Object]moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum < MAX_INT32[object Object]
- In the formulas,
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: Similar to the following example for [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]. For the new scenario parameters of V3 compared with V2, set the parameter values based on the preceding parameter description.
[object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The sample code is as follows (for reference only). Call the [object Object] and [object Object] APIs.
Preparing files:
Create a
[object Object]directory. Follow the instructions to create[object Object]and[object Object]files in the[object Object]directory, and modify them according to the code.Install the CANN package and compile and run
[object Object].
Compilation script:
[object Object]Compilation and execution:
[object Object]The sample code is as follows:
[object Object]