Description: Quantizes token data (optional). When there is TP domain communication, AllToAllV communication in the EP domain is performed first, and then AllGatherV TP domain communication is performed. When there is no such communication, AllToAllV communication in the EP domain is performed.
Compared with the
[object Object]API, this API has the following changes:- Outputs more detailed token information to assist CombineV2 series operators in performing efficient all-rank synchronization. Therefore, the
[object Object]output (shape (Bs × K,)) in the original interface is replaced by the[object Object]parameter (shape (A × 128,)). - Adds the
[object Object]parameter to replace the[object Object]and[object Object]environment variables.
For details, see the following parameter description.
- Outputs more detailed token information to assist CombineV2 series operators in performing efficient all-rank synchronization. Therefore, the
Formula:
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: This API must be used together with
[object Object]. - [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: This API must be used together with
[object Object]or[object Object].
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: This API must be used together with
[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]:
[object Object]must be passed as a null pointer when[object Object]is[object Object], or when HCCL_INTRA_PCIE_ENABLE=1 and HCCL_INTRA_ROCE_ENABLE=0[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.- The value of
[object Object]must be a 2D tensor with the shape of (Bs, K). - The value of
[object Object]depends on the[object Object]value: For[object Object], it supports 16, 32, 64, 128, 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.- The current version does not support
[object Object],[object Object],[object Object],[object Object], and[object Object]. Pass 0 for these parameters. - 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 data transmission. - The shape of
[object Object]is (moeExpertNum + 2globalBsK × serverNum,). (The first[object Object]elements indicate the number of received tokens, and the remaining elements indicate the[object Object]information before communication.) - Currently, TP domain communication is not supported.
[object Object]must be a 1D tensor with shape (A ).
[object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
[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 not supported in the current version. Pass a null pointer.- The value of
[object Object]must be in the range [2, 768]. - The value of
[object Object]must be in the range (0, 1024]. - The string length of
[object Object]must be in the range [1, 128). It cannot have the same value as[object Object]. - 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. [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]is not supported in the current version.
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:
[object Object]defaults to a deterministic implementation.
[object Object]and[object Object]must be used together. For details, see .The element values in the
[object Object],[object Object],[object Object], and[object Object]tensor output of[object Object]may vary depending on the product model, communication algorithm, or version. Pass the tensors directly to the corresponding parameters of[object Object]. Other service logics of the model should not depend on the element values.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]used during API calling must be the same for all ranks, at all network layers, and the same as those of[object Object].The shape format is described as follows:
- A: Maximum number of tokens that can be received by the current rank. The value range is as follows:
- For shared experts, A = Bs × epWorldSize × sharedExpertNum / sharedExpertRankNum.
- For MoE experts, when
[object Object]is 0, A ≥ Bs × epWorldSize × min(localExpertNum, K). When[object Object]is not 0, A ≥ globalBs × min(localExpertNum, K).
- H: Hidden layer size.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: The value depends on commAlg. "fullmesh" must be in the range (0, 7168] and be an integer multiple of 32. If "hierarchy" is used and the driver version is 25.0.RC1.1 or later, the value must be in the range (0, 10*1024] and be an integer multiple of 32.
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The value range is [1024, 8192].
- Bs: Batch sequence size, that is, the number of tokens output by the current rank.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: The value range is (0 < Bs ≤ 256).
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The value range is (0 < Bs ≤ 512).
- K: Number of top K experts, which must be in the ranges 0 < K ≤ 16 and 0 < K ≤ moeExpertNum.
- serverNum: Number of server nodes. The value can only be 2, 4, or 8.
- localExpertNum: Number of experts on the current rank.
- For shared expert ranks, localExpertNum = 1.
- For MoE expert ranks, localExpertNum = moeExpertNum/(epWorldSize - sharedExpertRankNum). If localExpertNum > 1, TP domain communication is not supported.
- A: Maximum number of tokens that can be received by the current rank. The value range is as follows:
quantMode constraints:
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
- If
[object Object]is set to 2, it indicates the pertoken dynamic quantization scenario. The data type of[object Object]can be INT8.- For
[object Object], you can pass a null pointer. - If valid data is passed to
[object Object], the shape is (moeExpertNum, H).
- For
- If
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
- If
[object Object]is set to 2, it indicates the pertoken dynamic quantization scenario. The data type of[object Object]can be INT8.- For
[object Object], you can pass a null pointer. - If valid data is passed to
[object Object]and shared expert ranks exist, the shape is (sharedExpertNum + moeExpertNum, H). - If valid data is passed to
[object Object]but no shared expert ranks exist, the shape is (moeExpertNum, H).
- For
- If
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
HCCL_BUFFSIZE:
Before calling this API, check whether the value of the
[object Object]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 "" or a null pointer, select the "fullmesh" or "hierarchy" formula based on the HCCL environment variable. - If
[object Object]is set to "fullmesh", the value requirement is (≥ 2 × (Bs × epWorldSize × min(localExpertNum, K) × H × sizeof(uint16) + 2 MB)). - If commAlg is set to "hierarchy", the value requirement is (≥ moeExpertNum × Bs × (H × sizeof(dtypeX) + 4 × ((K + 7) / 8 × 8) × sizeof(uint32)) + 4 MB + 100 MB), where (moeExpertNum / (epWorldSize - sharedExpertRankNum) ≤ 24) is not required.
- If
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
- Within an EP communication domain: The value must be greater than or equal to 2 and satisfy (≥ 2 × (localExpertNum × maxBs × epWorldSize × Align512(Align32(2 × H) + 64) + (K + sharedExpertNum) × maxBs × Align512(2 × H))) (
[object Object]indicates the number of experts assigned to the current rank when using MoE;[object Object];[object Object]. - Within a TP communication domain: The value must satisfy ≥ A × (H × 2 + 128) × 2.
- Within an EP communication domain: The value must be greater than or equal to 2 and satisfy (≥ 2 × (localExpertNum × maxBs × epWorldSize × Align512(Align32(2 × H) + 64) + (K + sharedExpertNum) × maxBs × Align512(2 × H))) (
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
HCCL_INTRA_PCIE_ENABLE and 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
[object Object]to[object Object].In the formulas in this document, / denotes integer division.
Constraints on the use of the communication domain:
[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.
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
Preparing files:
Create the
[object Object]file and modify it according to the following instructions.Copy the project to the two servers and configure the
[object Object]file based on the device IP addresses of the servers. Ensure that the[object Object]files on the two servers are the same.
About rankTable:
You can configure the NPU resource information involved in collective communication through the ranktable file. For details, see "Communication Function Development > Cluster Information Configuration > Configuring Resource Information Through the Ranktable File" in .
Run
[object Object]or[object Object]to query the device IP address. Then, set the JSON file following instructions in the collective communication guide.
[object Object]
Environment variable settings:
[object Object]Set the number of servers: In 2-server 16-rank scenarios, set
[object Object]to 2.[object Object]You do not need to set this variable in single-server 16-rank scenarios.
[object Object]Atlas A3 training products/Atlas A3 inference products[object Object]:
You do not need to configure the
[object Object]file or the environment variables[object Object]and[object Object].
The following example is for reference only. For details, see .
[object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]:
[object Object]