Merged
fix(mc2): 补充A5非量化scales的窗口与CCL buffer核算 #15295
zhang_xin_yuAdd on 11 days ago
fix(mc2): 补充A5非量化scales的窗口与CCL buffer核算 #15295
Merged
Total: 12 files changed+307-65
| @@ -35,6 +35,8 @@ | |||
| 35 | 35 | ||
| 36 | 其中max_out_dtype_size为token类型转为字节数,scale_expand_index_buffer为scale(32B)+ expand_idx(3 × 4B) | 36 | 其中max_out_dtype_size为token类型转为字节数,scale_expand_index_buffer为scale(32B)+ expand_idx(3 × 4B) |
| 37 | 37 | ||
| 38 | + 对于<term>Ascend 950PR&950DT系列产品</term>,按scales最大占位(`hidden * 4B`)计算,`token_actual_len`取上式与`Align32(Align32(hidden * max_out_dtype_size) + hidden * 4) + 12B(expand_idx) + 4B(expert scale)`中的较大值。 | ||
| 39 | + | ||
| 38 | - 根据`comm_alg`计算dispatch阶段每个token所需大小: | 40 | - 根据`comm_alg`计算dispatch阶段每个token所需大小: |
| 39 | 41 | ||
| 40 | 若`comm_alg`为"fullmesh_v2": | 42 | 若`comm_alg`为"fullmesh_v2": |
| @@ -49,6 +51,10 @@ | |||
| 49 | 51 | ||
| 50 | $$token\_need\_size\_combine = Align512(hidden * max\_out\_dtype\_size)$$ | 52 | $$token\_need\_size\_combine = Align512(hidden * max\_out\_dtype\_size)$$ |
| 51 | 53 | ||
| 54 | + 对于<term>Ascend 950PR&950DT系列产品</term>,combine阶段按480B对齐: | ||
| 55 | + | ||
| 56 | + $$token\_need\_size\_combine = Align480(hidden * max\_out\_dtype\_size) / full\_mesh\_data\_align * win\_addr\_align$$ | ||
| 57 | + | ||
| 52 | 其中,full_mesh_data_align为480B对齐,win_addr_align为512B对齐 | 58 | 其中,full_mesh_data_align为480B对齐,win_addr_align为512B对齐 |
| 53 | 59 | ||
| 54 | - 计算ccl_buffer_size大小: | 60 | - 计算ccl_buffer_size大小: |
| @@ -57,6 +63,8 @@ | |||
| 57 | $$combine\_buffer\_size = 2 * num\_max\_dispatch\_tokens\_per\_rank * token\_need\_size\_combine * (topk + num\_shared\_expert)$$ | 63 | $$combine\_buffer\_size = 2 * num\_max\_dispatch\_tokens\_per\_rank * token\_need\_size\_combine * (topk + num\_shared\_expert)$$ |
| 58 | $$ccl\_buffer\_size = Align2(Align1MB(dispatch\_buffer\_size + combine\_buffer\_size + 1MB) / 1MB) / 2$$ | 64 | $$ccl\_buffer\_size = Align2(Align1MB(dispatch\_buffer\_size + combine\_buffer\_size + 1MB) / 1MB) / 2$$ |
| 59 | 65 | ||
| 66 | + 对于<term>Ascend 950PR&950DT系列产品</term>,上式中还需额外加入 `world_size * 1024B` 的 rank offset 预留。 | ||
| 67 | + | ||
| 60 | ## 函数原型 | 68 | ## 函数原型 |
| 61 | 69 | ||
| 62 | ```python | 70 | ```python |
| @@ -88,7 +96,7 @@ MoeDistributeBuffer.get_low_latency_ccl_buffer_size(world_size, num_max_dispatch | |||
| 88 | <td>world_size</td> | 96 | <td>world_size</td> |
| 89 | <td>int</td> | 97 | <td>int</td> |
| 90 | <td>必选</td> | 98 | <td>必选</td> |
| 91 | - <td>表示通信域的大小。取值范围[2, 768]。</td> | 99 | + <td>表示通信域的大小。取值范围[2, 768];对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[2, 1024]。</td> |
| 92 | <td>int</td> | 100 | <td>int</td> |
| 93 | <td>-</td> | 101 | <td>-</td> |
| 94 | </tr> | 102 | </tr> |
| @@ -112,7 +120,7 @@ MoeDistributeBuffer.get_low_latency_ccl_buffer_size(world_size, num_max_dispatch | |||
| 112 | <td>num_moe_expert</td> | 120 | <td>num_moe_expert</td> |
| 113 | <td>int</td> | 121 | <td>int</td> |
| 114 | <td>必选</td> | 122 | <td>必选</td> |
| 115 | - <td>MoE专家数量,取值范围[1, 1024],并且满足以下条件:num_experts % (ep_world_size - shared_expert_rank_num) = 0。</td> | 123 | + <td>MoE专家数量,取值范围[1, 1024];对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[1, 2048]。并且满足以下条件:num_experts % (ep_world_size - shared_expert_rank_num) = 0。</td> |
| 116 | <td>int</td> | 124 | <td>int</td> |
| 117 | <td>-</td> | 125 | <td>-</td> |
| 118 | </tr> | 126 | </tr> |
| @@ -189,6 +197,7 @@ MoeDistributeBuffer.get_low_latency_ccl_buffer_size(world_size, num_max_dispatch | |||
| 189 | - 该接口支持单算子模式和torchair图模式调用。 | 197 | - 该接口支持单算子模式和torchair图模式调用。 |
| 190 | - get_low_latency_ccl_buffer_size、low_latency_dispatch和low_latency_combine必须配套使用。 | 198 | - get_low_latency_ccl_buffer_size、low_latency_dispatch和low_latency_combine必须配套使用。 |
| 191 | - 本文公式中的“/”表示整除。 | 199 | - 本文公式中的“/”表示整除。 |
| 200 | +- 对于<term>Ascend 950PR&950DT系列产品</term>,local_moe_expert_num * world_size应满足0 < local_moe_expert_num * world_size ≤ 4096;其余产品应满足0 < local_moe_expert_num * world_size ≤ 2048。 | ||
| 192 | 201 | ||
| 193 | 变量说明: | 202 | 变量说明: |
| 194 | 203 | ||
| @@ -122,7 +122,7 @@ MoeDistributeBuffer.low_latency_combine(x, topk_idx, topk_weights, assist_info_f | |||
| 122 | <td>num_experts</td> | 122 | <td>num_experts</td> |
| 123 | <td>int</td> | 123 | <td>int</td> |
| 124 | <td>可选</td> | 124 | <td>可选</td> |
| 125 | - <td>MoE专家数量,取值范围[1, 1024],并且满足以下条件:num_experts%(ep_world_size - shared_expert_rank_num)=0。对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[1, 2048]。默认值为0。</td> | 125 | + <td>MoE专家数量,取值范围[1, 1024],并且满足以下条件:num_experts%(ep_world_size - shared_expert_rank_num)=0。默认值为0。具体产品差异见下方说明。</td> |
| 126 | <td>int</td> | 126 | <td>int</td> |
| 127 | <td>-</td> | 127 | <td>-</td> |
| 128 | </tr> | 128 | </tr> |
| @@ -275,6 +275,10 @@ MoeDistributeBuffer.low_latency_combine(x, topk_idx, topk_weights, assist_info_f | |||
| 275 | </tbody> | 275 | </tbody> |
| 276 | </table> | 276 | </table> |
| 277 | 277 | ||
| 278 | +<!-- npu="950" id9 --> | ||
| 279 | +- num_experts:对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[1, 2048]。 | ||
| 280 | +<!-- end id9 --> | ||
| 281 | + | ||
| 278 | ## 返回值说明 | 282 | ## 返回值说明 |
| 279 | 283 | ||
| 280 | <table style="undefined;table-layout: fixed; width:1200px"><colgroup> | 284 | <table style="undefined;table-layout: fixed; width:1200px"><colgroup> |
| @@ -419,7 +423,10 @@ MoeDistributeBuffer.low_latency_combine(x, topk_idx, topk_weights, assist_info_f | |||
| 419 | - local_expert_num:表示本卡专家数量。 | 423 | - local_expert_num:表示本卡专家数量。 |
| 420 | - 对于共享专家卡,local_expert_num=1。 | 424 | - 对于共享专家卡,local_expert_num=1。 |
| 421 | - 对于MoE专家卡,local_expert_num=num_experts/(ep_world_size-shared_expert_rank_num)。 | 425 | - 对于MoE专家卡,local_expert_num=num_experts/(ep_world_size-shared_expert_rank_num)。 |
| 422 | - - 应满足0 < local_expert_num \* ep_world_size ≤ 2048;对于<term>Ascend 950PR&950DT系列产品</term>,应满足0 < local_expert_num \* ep_world_size ≤ 4096。 | 426 | + - 应满足0 < local_expert_num \* ep_world_size ≤ 2048。 |
| 427 | + <!-- npu="950" id10 --> | ||
| 428 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,应满足0 < local_expert_num \* ep_world_size ≤ 4096。 | ||
| 429 | + <!-- end id10 --> | ||
| 423 | 430 | ||
| 424 | - `low_latency_dispatch`和`low_latency_combine`必须配套使用。 | 431 | - `low_latency_dispatch`和`low_latency_combine`必须配套使用。 |
| 425 | - 在不同产品型号、不同通信算法或不同版本中,`low_latency_dispatch`的Tensor输出`assist_info_for_combine`、`ep_recv_counts`、`expand_scales`中的元素值可能不同,使用时直接将上述Tensor传给`low_latency_combine`对应参数即可,模型其他业务逻辑不应对其存在依赖。 | 432 | - 在不同产品型号、不同通信算法或不同版本中,`low_latency_dispatch`的Tensor输出`assist_info_for_combine`、`ep_recv_counts`、`expand_scales`中的元素值可能不同,使用时直接将上述Tensor传给`low_latency_combine`对应参数即可,模型其他业务逻辑不应对其存在依赖。 |
| @@ -441,6 +448,10 @@ MoeDistributeBuffer.low_latency_combine(x, topk_idx, topk_weights, assist_info_f | |||
| 441 | - 该场景仅支持通过环境变量HCCL_BUFFSIZE配置,该环境变量按通信域粒度管理,每个通信域独占一组“2\*HCCL_BUFFSIZE”大小的内存。 | 448 | - 该场景仅支持通过环境变量HCCL_BUFFSIZE配置,该环境变量按通信域粒度管理,每个通信域独占一组“2\*HCCL_BUFFSIZE”大小的内存。 |
| 442 | - ep通信域内:设置大小要求 >= 2且满足>= 2 \* (local_expert_num \* max_bs \* ep_world_size \* Align512(Align32(2 \* h) + 64) + (k + shared_expert_num) \* max_bs\* Align512(2 \* h))。 | 449 | - ep通信域内:设置大小要求 >= 2且满足>= 2 \* (local_expert_num \* max_bs \* ep_world_size \* Align512(Align32(2 \* h) + 64) + (k + shared_expert_num) \* max_bs\* Align512(2 \* h))。 |
| 443 | - 其中480Align512(x) = ((x+480-1)/480)\*512,Align512(x) = ((x+512-1)/512)\*512,Align32(x) = ((x+32-1)/32)\*32。 | 450 | - 其中480Align512(x) = ((x+480-1)/480)\*512,Align512(x) = ((x+512-1)/512)\*512,Align32(x) = ((x+32-1)/32)\*32。 |
| 451 | + <!-- npu="950" id11 --> | ||
| 452 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,当dispatch侧quant\_mode=0且x\_smooth\_scale非空时,dispatch token长度取max(Align32(2 \* h) + 64, Align32(Align32(2 \* h) + 4 \* h) + 16),再按上述规则对齐。 | ||
| 453 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,上式中 combine 项按 `480Align512(2 * h)` 计算。 | ||
| 454 | + <!-- end id11 --> | ||
| 444 | - 通信域内开设大小可通过调用MoeDistributeBuffer.get_low_latency_ccl_buffer_size接口计算。 | 455 | - 通信域内开设大小可通过调用MoeDistributeBuffer.get_low_latency_ccl_buffer_size接口计算。 |
| 445 | 456 | ||
| 446 | - 本文公式中的“/”表示整除。 | 457 | - 本文公式中的“/”表示整除。 |
| @@ -268,7 +268,7 @@ MoeDistributeBuffer.low_latency_dispatch(x, topk_idx, num_experts, *, quant_mode | |||
| 268 | <td>num_experts</td> | 268 | <td>num_experts</td> |
| 269 | <td>int</td> | 269 | <td>int</td> |
| 270 | <td>必选</td> | 270 | <td>必选</td> |
| 271 | - <td>MoE专家数量,取值范围[1, 1024],并且满足以下条件:num_experts%(ep_world_size - shared_expert_rank_num)=0。对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[1, 2048]。</td> | 271 | + <td>MoE专家数量,取值范围[1, 1024],并且满足以下条件:num_experts%(ep_world_size - shared_expert_rank_num)=0。具体产品差异见下方说明。</td> |
| 272 | <td>int</td> | 272 | <td>int</td> |
| 273 | <td>-</td> | 273 | <td>-</td> |
| 274 | </tr> | 274 | </tr> |
| @@ -411,7 +411,6 @@ MoeDistributeBuffer.low_latency_dispatch(x, topk_idx, num_experts, *, quant_mode | |||
| 411 | <td> | 411 | <td> |
| 412 | <ul> | 412 | <ul> |
| 413 | <li>表示`expand_x`输出的逻辑数据类型,默认值为None,由`quant_mode`和输入类型推导。</li> | 413 | <li>表示`expand_x`输出的逻辑数据类型,默认值为None,由`quant_mode`和输入类型推导。</li> |
| 414 | - <li>Ascend 950场景可通过该参数指定低精度输出类型。</li> | ||
| 415 | <li>`quant_mode=1`支持int8、hifloat8。</li> | 414 | <li>`quant_mode=1`支持int8、hifloat8。</li> |
| 416 | <li>`quant_mode=2`支持int8、float8_e4m3fn、float8_e5m2。</li> | 415 | <li>`quant_mode=2`支持int8、float8_e4m3fn、float8_e5m2。</li> |
| 417 | <li>`quant_mode=3`支持float8_e4m3fn、float8_e5m2。</li> | 416 | <li>`quant_mode=3`支持float8_e4m3fn、float8_e5m2。</li> |
| @@ -441,6 +440,13 @@ MoeDistributeBuffer.low_latency_dispatch(x, topk_idx, num_experts, *, quant_mode | |||
| 441 | </tbody> | 440 | </tbody> |
| 442 | </table> | 441 | </table> |
| 443 | 442 | ||
| 443 | +<!-- npu="950" id15 --> | ||
| 444 | +- num_experts:对于<term>Ascend 950PR&950DT系列产品</term>,取值范围为[1, 2048]。 | ||
| 445 | +<!-- end id15 --> | ||
| 446 | +<!-- npu="950" id17 --> | ||
| 447 | +- y_dtype:<term>Ascend 950PR&950DT系列产品</term>场景可通过该参数指定低精度输出类型。 | ||
| 448 | +<!-- end id17 --> | ||
| 449 | + | ||
| 444 | ## 返回值说明 | 450 | ## 返回值说明 |
| 445 | 451 | ||
| 446 | <table style="undefined;table-layout: fixed; width:1200px"><colgroup> | 452 | <table style="undefined;table-layout: fixed; width:1200px"><colgroup> |
| @@ -603,7 +609,10 @@ MoeDistributeBuffer.low_latency_dispatch(x, topk_idx, num_experts, *, quant_mode | |||
| 603 | 609 | ||
| 604 | - local\_expert\_num:表示本卡专家数量。 | 610 | - local\_expert\_num:表示本卡专家数量。 |
| 605 | - 对于共享专家卡,local\_expert\_num为1。 | 611 | - 对于共享专家卡,local\_expert\_num为1。 |
| 606 | - - 对于MoE专家卡,local\_expert\_num=num\_experts/\(ep\_world\_size-shared\_expert\_rank\_num),应满足0 < local_expert_num * ep_world_size ≤ 2048;对于<term>Ascend 950PR&950DT系列产品</term>,应满足0 < local_expert_num * ep_world_size ≤ 4096。 | 612 | + - 对于MoE专家卡,local\_expert\_num=num\_experts/\(ep\_world\_size-shared\_expert\_rank\_num),应满足0 < local_expert_num * ep_world_size ≤ 2048。 |
| 613 | + <!-- npu="950" id16 --> | ||
| 614 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,应满足0 < local_expert_num * ep_world_size ≤ 4096。 | ||
| 615 | + <!-- end id16 --> | ||
| 607 | 616 | ||
| 608 | - 在不同产品型号、不同通信算法或不同版本中,`low_latency_dispatch`的Tensor输出`assist_info_for_combine`、`ep_recv_counts`、`expand_scales`中的元素值可能不同,使用时直接将上述Tensor传给`low_latency_combine`对应参数即可,模型其他业务逻辑不应对其存在依赖。 | 617 | - 在不同产品型号、不同通信算法或不同版本中,`low_latency_dispatch`的Tensor输出`assist_info_for_combine`、`ep_recv_counts`、`expand_scales`中的元素值可能不同,使用时直接将上述Tensor传给`low_latency_combine`对应参数即可,模型其他业务逻辑不应对其存在依赖。 |
| 609 | - 调用接口过程中使用的`num_experts`、`expert_shard_type`、`shared_expert_num`、`shared_expert_rank_num`、`num_max_dispatch_tokens_per_rank`参数取值所有卡需保持一致,`expert_shard_type`、`num_max_dispatch_tokens_per_rank`网络中不同层中也需保持一致,且和[low_latency_combine](torchapi_low_latency_combine.md)对应参数也保持一致。 | 618 | - 调用接口过程中使用的`num_experts`、`expert_shard_type`、`shared_expert_num`、`shared_expert_rank_num`、`num_max_dispatch_tokens_per_rank`参数取值所有卡需保持一致,`expert_shard_type`、`num_max_dispatch_tokens_per_rank`网络中不同层中也需保持一致,且和[low_latency_combine](torchapi_low_latency_combine.md)对应参数也保持一致。 |
| @@ -638,6 +647,10 @@ MoeDistributeBuffer.low_latency_dispatch(x, topk_idx, num_experts, *, quant_mode | |||
| 638 | - ep通信域内,comm\_alg配置为"fullmesh_v1"或"": 设置大小要求 \>= 2 \* \(local\_expert\_num \* max\_bs \* ep\_world\_size \* Align512\(Align32\(2 \* H\) + <b>44</b>\) + \(K + shared\_expert\_num\) \* max\_bs \* Align512\(2 \* H\)\)。 | 647 | - ep通信域内,comm\_alg配置为"fullmesh_v1"或"": 设置大小要求 \>= 2 \* \(local\_expert\_num \* max\_bs \* ep\_world\_size \* Align512\(Align32\(2 \* H\) + <b>44</b>\) + \(K + shared\_expert\_num\) \* max\_bs \* Align512\(2 \* H\)\)。 |
| 639 | - ep通信域内,comm\_alg配置为"fullmesh_v2": 设置大小要求 \>= 2 \* \(local\_expert\_num \* max\_bs \* ep\_world\_size \* 480Align512\(Align32\(2 \* H\) + <b>44</b>\) + \(K + shared\_expert\_num\) \* max\_bs \* Align512\(2 \* H\)\)。 | 648 | - ep通信域内,comm\_alg配置为"fullmesh_v2": 设置大小要求 \>= 2 \* \(local\_expert\_num \* max\_bs \* ep\_world\_size \* 480Align512\(Align32\(2 \* H\) + <b>44</b>\) + \(K + shared\_expert\_num\) \* max\_bs \* Align512\(2 \* H\)\)。 |
| 640 | - 其中480Align512(x) = ((x+480-1)/480)\*512,Align512(x) = ((x+512-1)/512)\*512,Align32(x) = ((x+32-1)/32)\*32。 | 649 | - 其中480Align512(x) = ((x+480-1)/480)\*512,Align512(x) = ((x+512-1)/512)\*512,Align32(x) = ((x+32-1)/32)\*32。 |
| 650 | + <!-- npu="950" id18 --> | ||
| 651 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,当quant\_mode=0且x\_smooth\_scale非空时,dispatch token长度取max(Align32(2 \* H) + 44, Align32(Align32(2 \* H) + 4 \* H) + 16),再按上述规则对齐。 | ||
| 652 | + - 对于<term>Ascend 950PR&950DT系列产品</term>,上式中 combine 项按 `480Align512(2 * H)` 计算。 | ||
| 653 | + <!-- end id18 --> | ||
| 641 | - 通信域开设大小可通过调用MoeDistributeBuffer.get_low_latency_ccl_buffer_size接口计算。 | 654 | - 通信域开设大小可通过调用MoeDistributeBuffer.get_low_latency_ccl_buffer_size接口计算。 |
| 642 | 655 | ||
| 643 | - 本文公式中的“/”表示整除。 | 656 | - 本文公式中的“/”表示整除。 |
| @@ -17,6 +17,10 @@ def _empty_topk_weights_like(tensor): | |||
| 17 | return tensor.new_empty((0,), dtype=torch.float32) | 17 | return tensor.new_empty((0,), dtype=torch.float32) |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | +def _is_a5_device(): | ||
| 21 | + return "Ascend950" in torch_npu.npu.get_device_name() | ||
| 22 | + | ||
| 23 | + | ||
| 20 | def _get_hccl_comm_name(group, rank_id): | 24 | def _get_hccl_comm_name(group, rank_id): |
| 21 | if hasattr(group, "get_hccl_comm_name"): | 25 | if hasattr(group, "get_hccl_comm_name"): |
| 22 | return group.get_hccl_comm_name(rank_id, init_comm=False) | 26 | return group.get_hccl_comm_name(rank_id, init_comm=False) |
| @@ -30,7 +34,7 @@ class MoeDistributeBuffer: | |||
| 30 | self.rank_id = torch.distributed.get_rank(group) | 34 | self.rank_id = torch.distributed.get_rank(group) |
| 31 | self.world_size = torch.distributed.get_world_size(group) | 35 | self.world_size = torch.distributed.get_world_size(group) |
| 32 | self.group_name = _get_hccl_comm_name(group, self.rank_id) | 36 | self.group_name = _get_hccl_comm_name(group, self.rank_id) |
| 33 | - self._is_a5 = "Ascend950" in torch_npu.npu.get_device_name() | 37 | + self._is_a5 = _is_a5_device() |
| 34 | self._ctx_manager = None | 38 | self._ctx_manager = None |
| 35 | self.context = None | 39 | self.context = None |
| 36 | self.ccl_buffer_size = ccl_buffer_size | 40 | self.ccl_buffer_size = ccl_buffer_size |
| @@ -63,9 +67,16 @@ class MoeDistributeBuffer: | |||
| 63 | def inline_align(value, base): | 67 | def inline_align(value, base): |
| 64 | return (value + base - 1) // base * base | 68 | return (value + base - 1) // base * base |
| 65 | 69 | ||
| 70 | + is_a5 = _is_a5_device() | ||
| 71 | + max_world_size = 1024 if is_a5 else 768 | ||
| 72 | + max_moe_expert = 2048 if is_a5 else 1024 | ||
| 73 | + max_local_expert_product = 4096 if is_a5 else 2048 | ||
| 74 | + | ||
| 66 | torch._check( | 75 | torch._check( |
| 67 | - ((world_size >= 2) and (world_size <= 768)), # world_size当前仅支持[2,768] | 76 | + ((world_size >= 2) and (world_size <= max_world_size)), |
| 68 | - lambda: (f"world_size only support in [2, 768], but got {world_size=}."), | 77 | + lambda: ( |
| 78 | + f"world_size only support in [2, {max_world_size}], but got {world_size=}." | ||
| 79 | + ), | ||
| 69 | ) | 80 | ) |
| 70 | torch._check( | 81 | torch._check( |
| 71 | ((hidden >= 1024) and (hidden <= 8192)), # hidden当前仅支持[1024,8192] | 82 | ((hidden >= 1024) and (hidden <= 8192)), # hidden当前仅支持[1024,8192] |
| @@ -83,11 +94,9 @@ class MoeDistributeBuffer: | |||
| 83 | ), | 94 | ), |
| 84 | ) | 95 | ) |
| 85 | torch._check( | 96 | torch._check( |
| 86 | - ( | 97 | + ((num_moe_expert >= 1) and (num_moe_expert <= max_moe_expert)), |
| 87 | - (num_moe_expert >= 1) and (num_moe_expert <= 1024) | ||
| 88 | - ), # num_moe_expert当前仅支持[1,1024] | ||
| 89 | lambda: ( | 98 | lambda: ( |
| 90 | - f"num_moe_expert only support in [1, 1024], but got {num_moe_expert=}." | 99 | + f"num_moe_expert only support in [1, {max_moe_expert}], but got {num_moe_expert=}." |
| 91 | ), | 100 | ), |
| 92 | ) | 101 | ) |
| 93 | torch._check( | 102 | torch._check( |
| @@ -109,15 +118,15 @@ class MoeDistributeBuffer: | |||
| 109 | f"but got {world_size=} {num_shared_expert_ranks=}." | 118 | f"but got {world_size=} {num_shared_expert_ranks=}." |
| 110 | ), | 119 | ), |
| 111 | ) | 120 | ) |
| 112 | - # local_moe_expert_num*world_size仅支持(0,2048] | ||
| 113 | local_moe_expert_num = num_moe_expert // (world_size - num_shared_expert_ranks) | 121 | local_moe_expert_num = num_moe_expert // (world_size - num_shared_expert_ranks) |
| 114 | torch._check( | 122 | torch._check( |
| 115 | ( | 123 | ( |
| 116 | (local_moe_expert_num * world_size > 0) | 124 | (local_moe_expert_num * world_size > 0) |
| 117 | - and (local_moe_expert_num * world_size <= 2048) | 125 | + and (local_moe_expert_num * world_size <= max_local_expert_product) |
| 118 | ), | 126 | ), |
| 119 | lambda: ( | 127 | lambda: ( |
| 120 | - f"local_moe_expert_num * world_size only support in (0, 2048], " | 128 | + f"local_moe_expert_num * world_size only support in " |
| 129 | + f"(0, {max_local_expert_product}], " | ||
| 121 | f"but got {world_size=} {num_shared_expert_ranks=}, " | 130 | f"but got {world_size=} {num_shared_expert_ranks=}, " |
| 122 | f"local_moe_expert_num = num_moe_expert // (world_size - num_shared_expert_ranks), " | 131 | f"local_moe_expert_num = num_moe_expert // (world_size - num_shared_expert_ranks), " |
| 123 | f"{local_moe_expert_num=}" | 132 | f"{local_moe_expert_num=}" |
| @@ -128,6 +137,8 @@ class MoeDistributeBuffer: | |||
| 128 | mb_conversion = 1024 * 1024 | 137 | mb_conversion = 1024 * 1024 |
| 129 | ub_align = 32 # 32B | 138 | ub_align = 32 # 32B |
| 130 | scale_expand_index_buffer = 44 # scale 32B + 3 * 4 expand_idx | 139 | scale_expand_index_buffer = 44 # scale 32B + 3 * 4 expand_idx |
| 140 | + expand_idx_info = 3 # 3 int32 expand_idx | ||
| 141 | + expert_scale_bytes = 4 # sizeof(float) | ||
| 131 | full_mesh_data_align = 480 | 142 | full_mesh_data_align = 480 |
| 132 | win_addr_align = 512 | 143 | win_addr_align = 512 |
| 133 | 144 | ||
| @@ -139,10 +150,16 @@ class MoeDistributeBuffer: | |||
| 139 | ), | 150 | ), |
| 140 | ) | 151 | ) |
| 141 | 152 | ||
| 142 | - token_actual_len = ( | 153 | + token_align = inline_align(hidden * max_out_dtype_size, ub_align) |
| 143 | - inline_align(hidden * max_out_dtype_size, ub_align) | 154 | + token_actual_len = token_align + scale_expand_index_buffer |
| 144 | - + scale_expand_index_buffer | 155 | + if is_a5: |
| 145 | - ) | 156 | + max_scale_bytes = hidden * 4 |
| 157 | + dispatch_token_bytes = ( | ||
| 158 | + inline_align(token_align + max_scale_bytes, ub_align) | ||
| 159 | + + expand_idx_info * 4 | ||
| 160 | + + expert_scale_bytes | ||
| 161 | + ) | ||
| 162 | + token_actual_len = max(token_actual_len, dispatch_token_bytes) | ||
| 146 | if comm_alg == "fullmesh_v2": | 163 | if comm_alg == "fullmesh_v2": |
| 147 | token_need_size_dispatch = ( | 164 | token_need_size_dispatch = ( |
| 148 | inline_align(token_actual_len, full_mesh_data_align) | 165 | inline_align(token_actual_len, full_mesh_data_align) |
| @@ -151,10 +168,13 @@ class MoeDistributeBuffer: | |||
| 151 | ) | 168 | ) |
| 152 | else: | 169 | else: |
| 153 | token_need_size_dispatch = inline_align(token_actual_len, win_addr_align) | 170 | token_need_size_dispatch = inline_align(token_actual_len, win_addr_align) |
| 154 | - # A3 Combine uses raw 512-byte-aligned data, including fullmesh_v2. | 171 | + # A3 combine uses 512-byte-aligned data; A5 uses 480-byte-aligned data. |
| 155 | # Keep this reservation consistent with the host check and Dispatch offset. | 172 | # Keep this reservation consistent with the host check and Dispatch offset. |
| 156 | - token_need_size_combine = inline_align( | 173 | + combine_data_align = full_mesh_data_align if is_a5 else win_addr_align |
| 157 | - hidden * max_out_dtype_size, win_addr_align | 174 | + token_need_size_combine = ( |
| 175 | + inline_align(hidden * max_out_dtype_size, combine_data_align) | ||
| 176 | + // combine_data_align | ||
| 177 | + * win_addr_align | ||
| 158 | ) | 178 | ) |
| 159 | minimum_buffer_size = ( | 179 | minimum_buffer_size = ( |
W | |||
| 160 | 2 | 180 | 2 |
| @@ -173,6 +193,8 @@ class MoeDistributeBuffer: | |||
| 173 | ) | 193 | ) |
| 174 | + mb_conversion | 194 | + mb_conversion |
| 175 | ) | 195 | ) |
| 196 | + if is_a5: | ||
| 197 | + minimum_buffer_size += world_size * 1024 | ||
| 176 | # Return the HCCL configuration in MiB, not the data-window size. | 198 | # Return the HCCL configuration in MiB, not the data-window size. |
| 177 | # HCCL allocates twice this value; the first MiB is reserved for state. | 199 | # HCCL allocates twice this value; the first MiB is reserved for state. |
| 178 | ccl_buffer_size = ( | 200 | ccl_buffer_size = ( |
| @@ -423,7 +423,11 @@ | |||
| 423 | - `sharedExpertRankNum`取值范围[0, epWorldSize);为0时需满足sharedExpertNum为0或1,不为0时需满足sharedExpertRankNum % sharedExpertNum = 0。 | 423 | - `sharedExpertRankNum`取值范围[0, epWorldSize);为0时需满足sharedExpertNum为0或1,不为0时需满足sharedExpertRankNum % sharedExpertNum = 0。 |
| 424 | - `commQuantMode`取值范围0或2(0表示不量化,2表示int8量化)。 | 424 | - `commQuantMode`取值范围0或2(0表示不量化,2表示int8量化)。 |
| 425 | - `performanceInfoOptional`:预留参数,当前版本不支持,传空指针即可。 | 425 | - `performanceInfoOptional`:预留参数,当前版本不支持,传空指针即可。 |
| 426 | - - `HCCL_BUFFSIZE`:调用本算子前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。要求 >= 2且满足>= 2 *(`localExpertNum`* `maxBS` *`epWorldSize`* Align512(Align32(2 *`H`) + 64) + (`K` + `sharedExpertNum`)* `maxBS` *Align512(2* `H`)),`localExpertNum`需使用MoE专家卡的本卡专家数,其中Align512(x) = ((x + 512 - 1) / 512) *512,Align32(x) = ((x + 32 - 1) / 32)* 32。 | 426 | + - `HCCL_BUFFSIZE`:调用本算子前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。要求 >= 2且满足: |
| 427 | + - `commAlg` = "fullmesh_v1"或"":>= 2 * (`localExpertNum` * `maxBS` * `epWorldSize` * Align512(Align32(2 * `H`) + 64) + (`K` + `sharedExpertNum`) * `maxBS` * 480Align512(2 * `H`))。 | ||
| 428 | + - `commAlg` = "fullmesh_v2":>= 2 * (`localExpertNum` * `maxBS` * `epWorldSize` * 480Align512(Align32(2 * `H`) + 64) + (`K` + `sharedExpertNum`) * `maxBS` * 480Align512(2 * `H`))。 | ||
| 429 | + - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | ||
| 430 | + - 对于<term>Ascend 950DT系列产品</term>,当dispatch侧`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 44, Align32(Align32(2 * H) + 4 * H) + 16)`,再按fullmesh_v1的512B或fullmesh_v2的480B对齐。 | ||
W 问题:这条把 dispatch 侧 scales 的占位补上了,但 950DT 段整个式子的 combine 项还留着 Align512(2 * H)——A5 上 host 校验(CheckActualWinSize,非 2201 平台统一 480 对齐)和同一笔改动里 get_low_latency_ccl_buffer_size 的文档、Python 实现用的都是 Align480(2 * H) / 480 * 512,H=7168 时每 token 就差 1024B。照这版公式设 HCCL_BUFFSIZE 会偏小,跑起来直接报 HCCL_BUFFSIZE_EP is too SMALL;另外 dispatch/combine 的 V2 和 combine 的 V3/V4 这几个 950 段连 fullmesh_v2 的 480Align512 变体也还没写。 修复意见:950 段的 combine 项统一同步成 480 对齐口径,缺 fullmesh_v2 480 变体的几处一并补上,跟 torchapi 那份文档拉齐。 ![]() ![]() | |||
| 427 | 431 | ||
| 428 | ## 调用说明 | 432 | ## 调用说明 |
| 429 | 433 | ||
| @@ -589,11 +589,33 @@ aclnnStatus aclnnMoeDistributeCombineV2( | |||
| 589 | | 变量 | 定义与取值范围 | | 589 | | 变量 | 定义与取值范围 | |
| 590 | | :----------- | :----------------------------------------------------------------------------- | | 590 | | :----------- | :----------------------------------------------------------------------------- | |
| 591 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。</li></ul>| | 591 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。</li></ul>| |
| 592 | - | H |表示hidden size隐藏层大小:<ul><li> <term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。</li><li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:[1024, 8192]。 </li></ul>| | 592 | + | H | 表示hidden size隐藏层大小: 具体产品差异见下方说明。 | |
| 593 | - | BS | 表示batch sequence size(本卡最终输出的token数量):<ul><li> <term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512];</li><li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:0 < BS ≤512。</li></ul> | | 593 | + | BS | 表示batch sequence size(本卡最终输出的token数量): 具体产品差异见下方说明。 | |
| 594 | | K |表示选取topK个专家,取值范围为(0 < K ≤ 16)且满足(0 < K ≤ moeExpertNum)。 | | 594 | | K |表示选取topK个专家,取值范围为(0 < K ≤ 16)且满足(0 < K ≤ moeExpertNum)。 | |
| 595 | - | serverNum | 服务器节点数:<br><term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量,仅支持2、4、8。 | 595 | + | serverNum | 服务器节点数:具体产品差异见下方说明。 | |
| 596 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li><term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。</li><li><term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。</li></ul>| | 596 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 597 | + | ||
| 598 | + <!-- npu="910b" id22 --> | ||
| 599 | + - H:<term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。 | ||
| 600 | + <!-- end id22 --> | ||
| 601 | + <!-- npu="950,A3" id23 --> | ||
| 602 | + - H:<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:[1024, 8192]。 | ||
| 603 | + <!-- end id23 --> | ||
| 604 | + <!-- npu="910b" id24 --> | ||
| 605 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512]。 | ||
| 606 | + <!-- end id24 --> | ||
| 607 | + <!-- npu="950,A3" id25 --> | ||
| 608 | + - BS:<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:0 < BS ≤512。 | ||
| 609 | + <!-- end id25 --> | ||
| 610 | + <!-- npu="910b" id26 --> | ||
| 611 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量,仅支持2、4、8。 | ||
| 612 | + <!-- end id26 --> | ||
| 613 | + <!-- npu="A3" id27 --> | ||
| 614 | + - localExpertNum:<term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。 | ||
| 615 | + <!-- end id27 --> | ||
| 616 | + <!-- npu="950" id28 --> | ||
| 617 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。 | ||
| 618 | + <!-- end id28 --> | ||
| 597 | 619 | ||
| 598 | - **环境变量约束**: | 620 | - **环境变量约束**: |
| 599 | - **HCCL_BUFFSIZE**:调用本接口前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 | 621 | - **HCCL_BUFFSIZE**:调用本接口前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 |
| @@ -610,7 +632,11 @@ aclnnStatus aclnnMoeDistributeCombineV2( | |||
| 610 | - tp通信域内:设置大小要求\>=A \* (H \* 2 + 128) \* 2。 | 632 | - tp通信域内:设置大小要求\>=A \* (H \* 2 + 128) \* 2。 |
| 611 | <!-- end id12 --> | 633 | <!-- end id12 --> |
| 612 | <!-- npu="950" id13 --> | 634 | <!-- npu="950" id13 --> |
| 613 | - - <term>Ascend 950DT系列产品</term>:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。 | 635 | + - <term>Ascend 950DT系列产品</term>: |
| 636 | + - 当commAlg为"fullmesh_v1"或""时:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。 | ||
| 637 | + - 当commAlg为"fullmesh_v2"时:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。 | ||
| 638 | + - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | ||
| 639 | + - 当dispatch侧`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 44, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 614 | 640 | ||
| 615 | <!-- end id13 --> | 641 | <!-- end id13 --> |
| 616 | 642 | ||
| @@ -718,11 +718,33 @@ aclnnStatus aclnnMoeDistributeCombineV3( | |||
| 718 | | 变量 | 定义与取值范围 | | 718 | | 变量 | 定义与取值范围 | |
| 719 | | :----------- | :----------------------------------------------------------------------------- | | 719 | | :----------- | :----------------------------------------------------------------------------- | |
| 720 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。</li></ul>| | 720 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。</li></ul>| |
| 721 | - | H |表示hidden size隐藏层大小:<ul><li> <term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。</li><li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:[1024, 8192]。 </li></ul>| | 721 | + | H | 表示hidden size隐藏层大小: 具体产品差异见下方说明。 | |
| 722 | - | BS | 本卡最终输出token数:<ul><li> <term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512];</li><li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:0 < BS ≤512。</li></ul> | | 722 | + | BS | 本卡最终输出token数: 具体产品差异见下方说明。 | |
| 723 | | K |表示选取topK个专家:<br> 0 < K ≤16,且0 < K ≤ <code>moeExpertNum+zeroExpertNum+copyExpertNum+constExpertNum</code>。 | | 723 | | K |表示选取topK个专家:<br> 0 < K ≤16,且0 < K ≤ <code>moeExpertNum+zeroExpertNum+copyExpertNum+constExpertNum</code>。 | |
| 724 | - | serverNum | 服务器节点数:<br><term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量,仅支持2、4、8。 | 724 | + | serverNum | 服务器节点数:具体产品差异见下方说明。 | |
| 725 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li><term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。</li><li><term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。</li></ul>| | 725 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 726 | + | ||
| 727 | + <!-- npu="910b" id21 --> | ||
| 728 | + - H:<term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。 | ||
| 729 | + <!-- end id21 --> | ||
| 730 | + <!-- npu="950,A3" id22 --> | ||
| 731 | + - H:<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:[1024, 8192]。 | ||
| 732 | + <!-- end id22 --> | ||
| 733 | + <!-- npu="910b" id23 --> | ||
| 734 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512]。 | ||
| 735 | + <!-- end id23 --> | ||
| 736 | + <!-- npu="950,A3" id24 --> | ||
| 737 | + - BS:<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:0 < BS ≤512。 | ||
| 738 | + <!-- end id24 --> | ||
| 739 | + <!-- npu="910b" id25 --> | ||
| 740 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量,仅支持2、4、8。 | ||
| 741 | + <!-- end id25 --> | ||
| 742 | + <!-- npu="A3" id26 --> | ||
| 743 | + - localExpertNum:<term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。 | ||
| 744 | + <!-- end id26 --> | ||
| 745 | + <!-- npu="950" id27 --> | ||
| 746 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。 | ||
| 747 | + <!-- end id27 --> | ||
| 726 | 748 | ||
| 727 | - **环境变量约束**: | 749 | - **环境变量约束**: |
| 728 | - **HCCL_BUFFSIZE**:调用本接口前需检查HCCL_BUFFSIZE环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 | 750 | - **HCCL_BUFFSIZE**:调用本接口前需检查HCCL_BUFFSIZE环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 |
| @@ -733,13 +755,20 @@ aclnnStatus aclnnMoeDistributeCombineV3( | |||
| 733 | - commAlg配置为"fullmesh": 设置大小要求 <code>= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* H \* sizeof(uint16) + 2MB)</code>。 | 755 | - commAlg配置为"fullmesh": 设置大小要求 <code>= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* H \* sizeof(uint16) + 2MB)</code>。 |
| 734 | - commAlg配置为"hierarchy": 设置大小要求(≥ (`moeExpertNum` + `epWorldSize` / 4) \* Align512(`maxBS` \* (`H` \* 2 + 16 \* Align8(`K`))) \* 1B + 8MB,其中Align8(x) = ((x + 8 - 1) / 8) \* 8,Align512(x) = ((x + 512 - 1) / 512) \* 512)。 | 756 | - commAlg配置为"hierarchy": 设置大小要求(≥ (`moeExpertNum` + `epWorldSize` / 4) \* Align512(`maxBS` \* (`H` \* 2 + 16 \* Align8(`K`))) \* 1B + 8MB,其中Align8(x) = ((x + 8 - 1) / 8) \* 8,Align512(x) = ((x + 512 - 1) / 512) \* 512)。 |
| 735 | <!-- end id11 --> | 757 | <!-- end id11 --> |
| 736 | - <!-- npu="950,A3" id12 --> | 758 | + <!-- npu="A3" id12 --> |
| 737 | - - <term>Atlas A3系列产品</term>、Ascend 950DT系列产品: | 759 | + - <term>Atlas A3系列产品</term>: |
| 738 | - ep通信域内:设置大小要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | 760 | - ep通信域内:设置大小要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 |
| 739 | - tp通信域内:设置大小要求\>=A \* (H \* 2 + 128) \* 2。 | 761 | - tp通信域内:设置大小要求\>=A \* (H \* 2 + 128) \* 2。 |
| 740 | - | ||
| 741 | <!-- end id12 --> | 762 | <!-- end id12 --> |
| 742 | 763 | ||
| 764 | + <!-- npu="950" id28 --> | ||
| 765 | + - <term>Ascend 950DT系列产品</term>: | ||
| 766 | + - 当commAlg为"fullmesh_v1"或""时:设置大小要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | ||
| 767 | + - 当commAlg为"fullmesh_v2"时:设置大小要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | ||
| 768 | + - 其中<code>480Align512(x) = ((x + 480 - 1) / 480) \* 512,Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | ||
| 769 | + - 当dispatch侧`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 44, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 770 | + <!-- end id28 --> | ||
| 771 | + | ||
| 743 | - **HCCL_INTRA_PCIE_ENABLE/HCCL_INTRA_ROCE_ENABLE**: | 772 | - **HCCL_INTRA_PCIE_ENABLE/HCCL_INTRA_ROCE_ENABLE**: |
| 744 | 773 | ||
| 745 | <!-- npu="910b" id13 --> | 774 | <!-- npu="910b" id13 --> |
| @@ -723,11 +723,39 @@ aclnnStatus aclnnMoeDistributeCombineV4( | |||
| 723 | | 变量 | 定义与取值范围 | | 723 | | 变量 | 定义与取值范围 | |
| 724 | | :----------- | :----------------------------------------------------------------------------- | | 724 | | :----------- | :----------------------------------------------------------------------------- | |
| 725 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。 </li></ul>| | 725 | | A | 本卡需分发的最大token数,取值范围如下: <ul><li>对于共享专家,要满足<code>A = BS \* epWorldSize \* sharedExpertNum / sharedExpertRankNum</code>。</li><li>对于MoE专家,当globalBs为0时,要满足<code>A >= BS \* epWorldSize \* min(localExpertNum, K)</code>;当globalBs非0时,要满足<code>A >= globalBs \* min(localExpertNum, K)</code>。 </li></ul>| |
| 726 | - | H |表示hidden size隐藏层大小:<ul><li> <term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。</li><li><term>Atlas A3系列产品</term> :依commAlg取值,当commAlg为"hierarchy"时,H取值范围为[1024, 7168],且为32的整数倍;其余场景下取值范围[1024, 8192]。</li><li><term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。</li></ul> | | 726 | + | H | 表示hidden size隐藏层大小: 具体产品差异见下方说明。 | |
| 727 | - | BS | 本卡最终输出token数:<ul><li> <term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512];</li><li><term>Atlas A3系列产品</term> :依commAlg取值,"fullmesh_v2"和"hierarchy"取值范围为(0 < BS ≤ 256), "fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。</li><li><term>Ascend 950DT系列产品</term>:0 < BS ≤512。 </li></ul>| | 727 | + | BS | 本卡最终输出token数: 具体产品差异见下方说明。 | |
| 728 | | K |表示选取topK个专家:<br> 0 < K ≤16,且0 < K ≤ <code>moeExpertNum+zeroExpertNum+copyExpertNum+constExpertNum</code>。 | | 728 | | K |表示选取topK个专家:<br> 0 < K ≤16,且0 < K ≤ <code>moeExpertNum+zeroExpertNum+copyExpertNum+constExpertNum</code>。 | |
| 729 | - | serverNum | 服务器节点数:<br>Atlas A2训练系列产品/Atlas A2推理系列产品:仅该场景的shape使用了该变量,仅支持2、4、8。 | 729 | + | serverNum | 服务器节点数:具体产品差异见下方说明。 | |
| 730 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li><term>Atlas A3系列产品</term> :应满足0 < localExpertNum \* epWorldSize ≤ 2048;当commAlg="hierarchy"时,需满足localExpertNum ≤ 24且localExpertNum \* epWorldSize ≤ 512。</li><li><term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum \* epWorldSize ≤ 4096。</li></ul>| | 730 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,localExpertNum > 1时不支持TP通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 731 | + | ||
| 732 | + <!-- npu="910b" id23 --> | ||
| 733 | + - H:<term>Atlas A2系列产品</term>:(0, 10240]且为32的整数倍。 | ||
| 734 | + <!-- end id23 --> | ||
| 735 | + <!-- npu="A3" id24 --> | ||
| 736 | + - H:<term>Atlas A3系列产品</term> :依commAlg取值,当commAlg为"hierarchy"时,H取值范围为[1024, 7168],且为32的整数倍;其余场景下取值范围[1024, 8192]。 | ||
| 737 | + <!-- end id24 --> | ||
| 738 | + <!-- npu="950" id25 --> | ||
| 739 | + - H:<term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。 | ||
| 740 | + <!-- end id25 --> | ||
| 741 | + <!-- npu="910b" id26 --> | ||
| 742 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"支持(0, 256];"hierarchy"并且驱动版本≥25.0.RC1.1时支持(0, 512]。 | ||
| 743 | + <!-- end id26 --> | ||
| 744 | + <!-- npu="A3" id27 --> | ||
| 745 | + - BS:<term>Atlas A3系列产品</term> :依commAlg取值,"fullmesh_v2"和"hierarchy"取值范围为(0 < BS ≤ 256), "fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。 | ||
| 746 | + <!-- end id27 --> | ||
| 747 | + <!-- npu="950" id28 --> | ||
| 748 | + - BS:<term>Ascend 950DT系列产品</term>:0 < BS ≤512。 | ||
| 749 | + <!-- end id28 --> | ||
| 750 | + <!-- npu="910b" id29 --> | ||
| 751 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量,仅支持2、4、8。 | ||
| 752 | + <!-- end id29 --> | ||
| 753 | + <!-- npu="A3" id30 --> | ||
| 754 | + - localExpertNum:<term>Atlas A3系列产品</term> :应满足0 < localExpertNum \* epWorldSize ≤ 2048;当commAlg="hierarchy"时,需满足localExpertNum ≤ 24且localExpertNum \* epWorldSize ≤ 512。 | ||
| 755 | + <!-- end id30 --> | ||
| 756 | + <!-- npu="950" id31 --> | ||
| 757 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum \* epWorldSize ≤ 4096。 | ||
| 758 | + <!-- end id31 --> | ||
| 731 | 759 | ||
| 732 | - **环境变量约束**: | 760 | - **环境变量约束**: |
| 733 | - **HCCL_BUFFSIZE**:调用本接口前需检查HCCL_BUFFSIZE环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 | 761 | - **HCCL_BUFFSIZE**:调用本接口前需检查HCCL_BUFFSIZE环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。 |
| @@ -745,7 +773,10 @@ aclnnStatus aclnnMoeDistributeCombineV4( | |||
| 745 | <!-- end id12 --> | 773 | <!-- end id12 --> |
| 746 | <!-- npu="950" id13 --> | 774 | <!-- npu="950" id13 --> |
| 747 | - <term>Ascend 950DT系列产品</term>: | 775 | - <term>Ascend 950DT系列产品</term>: |
| 748 | - - commAlg配置为""或者未配置时:要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | 776 | + - 当commAlg配置为""或者未配置时:要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 |
| 777 | + - 当commAlg配置为"fullmesh_v2"时:要求 <code>>= 2且满足>= 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 44) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))</code>,<code>localExpertNum</code>需使用MoE专家卡的本卡专家数,其中<code>Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | ||
| 778 | + - 其中<code>480Align512(x) = ((x + 480 - 1) / 480) \* 512,Align512(x) = ((x + 512 - 1) / 512) \* 512,Align32(x) = ((x + 32 - 1) / 32) \* 32</code>。 | ||
| 779 | + - 当dispatch侧`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 44, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 749 | 780 | ||
| 750 | <!-- end id13 --> | 781 | <!-- end id13 --> |
| 751 | 782 | ||
| @@ -71,7 +71,7 @@ $$ | |||
| 71 | 其中,$emax$表示该类型最大正规数对应的指数部分的值。 | 71 | 其中,$emax$表示该类型最大正规数对应的指数部分的值。 |
| 72 | 72 | ||
| 73 | - <term>Atlas A2系列产品</term>:该算子必须与`MoeDistributeCombineV2`配套使用。 | 73 | - <term>Atlas A2系列产品</term>:该算子必须与`MoeDistributeCombineV2`配套使用。 |
| 74 | -- <term>Atlas A3系列产品</term>、Ascend 950DT系列产品:该算子必须与`MoeDistributeCombineV2`或`MoeDistributeCombineAddRmsNorm`配套使用。 | 74 | +- <term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:该算子必须与`MoeDistributeCombineV2`或`MoeDistributeCombineAddRmsNorm`配套使用。 |
| 75 | 75 | ||
| 76 | > 说明:MoeDistributeCombineV2、MoeDistributeCombineAddRmsNorm算子在后续文档中统称为CombineV2系列算子。 | 76 | > 说明:MoeDistributeCombineV2、MoeDistributeCombineAddRmsNorm算子在后续文档中统称为CombineV2系列算子。 |
| 77 | ・ | 77 | ・ |
| @@ -432,7 +432,11 @@ $$ | |||
| 432 | - 参数说明里shape格式说明: | 432 | - 参数说明里shape格式说明: |
| 433 | - `H`:表示hidden size隐藏层大小,取值范围[1024, 8192]。 | 433 | - `H`:表示hidden size隐藏层大小,取值范围[1024, 8192]。 |
| 434 | - `BS`:表示batch sequence size,即本卡最终输出的token数量,取值范围(0, 512]。 | 434 | - `BS`:表示batch sequence size,即本卡最终输出的token数量,取值范围(0, 512]。 |
| 435 | - - `HCCL_BUFFSIZE`:调用本算子前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。要求 >= 2且满足>= 2 *(`localExpertNum`* `maxBS` *`epWorldSize`* Align512(Align32(2 *`H`) + 64) + (`K` + `sharedExpertNum`)* `maxBS` *Align512(2* `H`)),`localExpertNum`需使用MoE专家卡的本卡专家数,其中Align512(x) = ((x + 512 - 1) / 512) *512,Align32(x) = ((x + 32 - 1) / 32)* 32。 | 435 | + - `HCCL_BUFFSIZE`:调用本算子前需检查`HCCL_BUFFSIZE`环境变量取值是否合理,该环境变量表示单个通信域占用内存大小,单位MB,不配置时默认为200MB。要求 >= 2且满足: |
| 436 | + - `commAlg` = "fullmesh_v1"或"":>= 2 * (`localExpertNum` * `maxBS` * `epWorldSize` * Align512(Align32(2 * `H`) + 64) + (`K` + `sharedExpertNum`) * `maxBS` * 480Align512(2 * `H`))。 | ||
| 437 | + - `commAlg` = "fullmesh_v2":>= 2 * (`localExpertNum` * `maxBS` * `epWorldSize` * 480Align512(Align32(2 * `H`) + 64) + (`K` + `sharedExpertNum`) * `maxBS` * 480Align512(2 * `H`))。 | ||
| 438 | + - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | ||
| 439 | + - 对于<term>Ascend 950DT系列产品</term>,当`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 64, Align32(Align32(2 * H) + 4 * H) + 16)`,再按fullmesh_v1的512B或fullmesh_v2的480B对齐。 | ||
| 436 | 440 | ||
| 437 | ## 调用说明 | 441 | ## 调用说明 |
| 438 | 442 | ||
| @@ -625,11 +625,33 @@ aclnnStatus aclnnMoeDistributeDispatchV2( | |||
| 625 | | 变量 | 定义与取值范围 | | 625 | | 变量 | 定义与取值范围 | |
| 626 | | :----------- | :----------------------------------------------------------------------------- | | 626 | | :----------- | :----------------------------------------------------------------------------- | |
| 627 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li> <li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li> </ul>| | 627 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li> <li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li> </ul>| |
| 628 | - | H(hidden size) | 表示hidden size隐藏层大小。<ul><li><term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。</li> <li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:取值范围[1024, 8192]。</li> </ul> | | 628 | + | H(hidden size) | 表示hidden size隐藏层大小。 具体产品差异见下方说明。 | |
| 629 | - | BS | 表示本卡最终输出token数。<ul><li><term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512);</li><li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:0 < BS ≤ 512。 </li> </ul> | | 629 | + | BS | 表示本卡最终输出token数。 具体产品差异见下方说明。 | |
| 630 | | K | 表示选取topK个专家,取值范围为(0 < K ≤ 16)且满足(0 < K ≤ moeExpertNum)。| | 630 | | K | 表示选取topK个专家,取值范围为(0 < K ≤ 16)且满足(0 < K ≤ moeExpertNum)。| |
| 631 | - | serverNum | 表示服务器节点数,仅支持2、4、8。<br>Atlas A2训练系列产品/Atlas A2推理系列产品:仅该场景的shape使用了该变量。 | | 631 | + | serverNum | 表示服务器节点数,仅支持2、4、8。具体产品差异见下方说明。 | |
| 632 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum / (epWorldSize - sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li><term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。</li><li><term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。</li></ul>| | 632 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum / (epWorldSize - sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 633 | + | ||
| 634 | + <!-- npu="910b" id27 --> | ||
| 635 | + - H(hidden size):<term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。 | ||
| 636 | + <!-- end id27 --> | ||
| 637 | + <!-- npu="950,A3" id28 --> | ||
| 638 | + - H(hidden size):<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。 | ||
| 639 | + <!-- end id28 --> | ||
| 640 | + <!-- npu="910b" id29 --> | ||
| 641 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512)。 | ||
| 642 | + <!-- end id29 --> | ||
| 643 | + <!-- npu="950,A3" id30 --> | ||
| 644 | + - BS:<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:0 < BS ≤ 512。 | ||
| 645 | + <!-- end id30 --> | ||
| 646 | + <!-- npu="910b" id31 --> | ||
| 647 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量。 | ||
| 648 | + <!-- end id31 --> | ||
| 649 | + <!-- npu="A3" id32 --> | ||
| 650 | + - localExpertNum:<term>Atlas A3系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 2048。 | ||
| 651 | + <!-- end id32 --> | ||
| 652 | + <!-- npu="950" id33 --> | ||
| 653 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < localExpertNum * epWorldSize ≤ 4096。 | ||
| 654 | + <!-- end id33 --> | ||
| 633 | 655 | ||
| 634 | - **quantMode相关约束**: | 656 | - **quantMode相关约束**: |
| 635 | 657 | ||
| @@ -696,7 +718,11 @@ aclnnStatus aclnnMoeDistributeDispatchV2( | |||
| 696 | - ep通信域内:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。当前不支持TP通信域。 | 718 | - ep通信域内:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。当前不支持TP通信域。 |
| 697 | <!-- end id17 --> | 719 | <!-- end id17 --> |
| 698 | <!-- npu="950" id18 --> | 720 | <!-- npu="950" id18 --> |
| 699 | - - <term>Ascend 950DT系列产品</term>:ep通信域内设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。不支持TP通信域。 | 721 | + - <term>Ascend 950DT系列产品</term>: |
| 722 | + - 当commAlg为"fullmesh_v1"或空字符串或空指针时:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align512(x) = ((x + 512 - 1) / 512) * 512`;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。不支持TP通信域。 | ||
| 723 | + - 当commAlg为"fullmesh_v2"时:设置大小要求(≥ 2)且满足(≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H)))(`localExpertNum`需使用MoE专家卡的本卡专家数;`Align32(x) = ((x + 32 - 1) / 32) * 32`)。不支持TP通信域。 | ||
| 724 | + - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | ||
| 725 | + - 当`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 64, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 700 | 726 | ||
| 701 | <!-- end id18 --> | 727 | <!-- end id18 --> |
| 702 | 728 | ||
| @@ -656,11 +656,39 @@ aclnnStatus aclnnMoeDistributeDispatchV3( | |||
| 656 | | 变量 | 定义与取值范围 | | 656 | | 变量 | 定义与取值范围 | |
| 657 | | :----------- | :----------------------------------------------------------------------------- | | 657 | | :----------- | :----------------------------------------------------------------------------- | |
| 658 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li> <li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li> </ul>| | 658 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li> <li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li> </ul>| |
| 659 | - | H(hidden size) | 表示hidden size隐藏层大小。<ul><li><term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。</li> <li><term>Atlas A3系列产品</term>、Ascend 950DT系列产品:取值范围[1024, 8192]。</li> </ul> | | 659 | + | H(hidden size) | 表示hidden size隐藏层大小。 具体产品差异见下方说明。 | |
| 660 | - | BS | 表示本卡最终输出token数。<ul><li><term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512);</li><li><term>Atlas A3训练系列产品/Atlas A3推理系列产品</term>:依commAlg取值,"fullmesh_v2"取值范围为(0 < BS ≤ 256),"fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。</li><li><term>Ascend 950DT系列产品</term>:0 < BS ≤512。</li></ul> | | 660 | + | BS | 表示本卡最终输出token数。 具体产品差异见下方说明。 | |
| 661 | - | K | 表示选取topK个专家,取值范围为0 < K ≤16,且<code>0 < K ≤ moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum</code>。<br> <term>Atlas A3系列产品</term>:当commAlg为"fullmesh_v2"时,取值范围为0 < K ≤ 12。| | 661 | + | K | 表示选取topK个专家,取值范围为0 < K ≤16,且<code>0 < K ≤ moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum</code>。具体产品差异见下方说明。 | |
| 662 | - | serverNum | 表示服务器节点数,仅支持2、4、8。<br>Atlas A2训练系列产品/Atlas A2推理系列产品:仅该场景的shape使用了该变量。 | | 662 | + | serverNum | 表示服务器节点数,仅支持2、4、8。具体产品差异见下方说明。 | |
| 663 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li><term>Atlas A3系列产品</term>:应满足0 < <code>localExpertNum * epWorldSize</code> ≤ 2048。</li><li><term>Ascend 950DT系列产品</term>:应满足0 < <code>localExpertNum * epWorldSize</code> ≤ 4096。</li></ul>| | 663 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 664 | + | ||
| 665 | + <!-- npu="910b" id26 --> | ||
| 666 | + - H(hidden size):<term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。 | ||
| 667 | + <!-- end id26 --> | ||
| 668 | + <!-- npu="950,A3" id27 --> | ||
| 669 | + - H(hidden size):<term>Atlas A3系列产品</term>、<term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。 | ||
| 670 | + <!-- end id27 --> | ||
| 671 | + <!-- npu="910b" id28 --> | ||
| 672 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512)。 | ||
| 673 | + <!-- end id28 --> | ||
| 674 | + <!-- npu="A3" id29 --> | ||
| 675 | + - BS:<term>Atlas A3系列产品</term>:依commAlg取值,"fullmesh_v2"取值范围为(0 < BS ≤ 256),"fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。 | ||
| 676 | + <!-- end id29 --> | ||
| 677 | + <!-- npu="950" id30 --> | ||
| 678 | + - BS:<term>Ascend 950DT系列产品</term>:0 < BS ≤512。 | ||
| 679 | + <!-- end id30 --> | ||
| 680 | + <!-- npu="A3" id31 --> | ||
| 681 | + - K:<term>Atlas A3系列产品</term>:当commAlg为"fullmesh_v2"时,取值范围为0 < K ≤ 12。 | ||
| 682 | + <!-- end id31 --> | ||
| 683 | + <!-- npu="910b" id32 --> | ||
| 684 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量。 | ||
| 685 | + <!-- end id32 --> | ||
| 686 | + <!-- npu="A3" id33 --> | ||
| 687 | + - localExpertNum:<term>Atlas A3系列产品</term>:应满足0 < <code>localExpertNum * epWorldSize</code> ≤ 2048。 | ||
| 688 | + <!-- end id33 --> | ||
| 689 | + <!-- npu="950" id34 --> | ||
| 690 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < <code>localExpertNum * epWorldSize</code> ≤ 4096。 | ||
| 691 | + <!-- end id34 --> | ||
| 664 | 692 | ||
| 665 | - **quantMode相关约束**: | 693 | - **quantMode相关约束**: |
| 666 | 694 | ||
| @@ -723,14 +751,21 @@ aclnnStatus aclnnMoeDistributeDispatchV3( | |||
| 723 | - commAlg配置为"fullmesh": 当`x`的数据类型为`INT32`时,设置大小要求 >= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* (H \* sizeof(int32) + 32Byte) + 2MB);其他数据类型设置大小要求 >= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* H \* sizeof(uint16) + 2MB)。 | 751 | - commAlg配置为"fullmesh": 当`x`的数据类型为`INT32`时,设置大小要求 >= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* (H \* sizeof(int32) + 32Byte) + 2MB);其他数据类型设置大小要求 >= 2 \* (BS \* epWorldSize \* min(localExpertNum, K) \* H \* sizeof(uint16) + 2MB)。 |
| 724 | - commAlg配置为"hierarchy": 设置大小要求 >= (`moeExpertNum` + `epWorldSize` / 4) \* Align512(`maxBS` \* (`H` \* 2 + 16 \* Align8(`K`))) \* 1Byte + 8MB,其中Align8(x) = ((x + 8 - 1) / 8) \* 8,Align512(x) = ((x + 512 - 1) / 512) \* 512。 | 752 | - commAlg配置为"hierarchy": 设置大小要求 >= (`moeExpertNum` + `epWorldSize` / 4) \* Align512(`maxBS` \* (`H` \* 2 + 16 \* Align8(`K`))) \* 1Byte + 8MB,其中Align8(x) = ((x + 8 - 1) / 8) \* 8,Align512(x) = ((x + 512 - 1) / 512) \* 512。 |
| 725 | <!-- end id16 --> | 753 | <!-- end id16 --> |
| 726 | - <!-- npu="950,A3" id17 --> | 754 | + <!-- npu="A3" id17 --> |
| 727 | - - <term>Atlas A3系列产品</term>、Ascend 950DT系列产品: | 755 | + - <term>Atlas A3系列产品</term>: |
| 728 | - ep通信域内,当commAlg为"fullmesh_v1"或空字符串或空指针时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 | 756 | - ep通信域内,当commAlg为"fullmesh_v1"或空字符串或空指针时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 |
| 729 | - ep通信域内,当commAlg为"fullmesh_v2"时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 | 757 | - ep通信域内,当commAlg为"fullmesh_v2"时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 |
| 730 | - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | 758 | - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 |
| 731 | - | ||
| 732 | <!-- end id17 --> | 759 | <!-- end id17 --> |
| 733 | 760 | ||
| 761 | + <!-- npu="950" id35 --> | ||
| 762 | + - <term>Ascend 950DT系列产品</term>: | ||
| 763 | + - 当commAlg为"fullmesh_v1"或空字符串或空指针时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))。 | ||
| 764 | + - 当commAlg为"fullmesh_v2"时:设置大小要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))。 | ||
| 765 | + - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | ||
| 766 | + - 当`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 64, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 767 | + <!-- end id35 --> | ||
| 768 | + | ||
| 734 | - **HCCL_INTRA_PCIE_ENABLE**和**HCCL_INTRA_ROCE_ENABLE**: | 769 | - **HCCL_INTRA_PCIE_ENABLE**和**HCCL_INTRA_ROCE_ENABLE**: |
| 735 | 770 | ||
| 736 | <!-- npu="910b" id18 --> | 771 | <!-- npu="910b" id18 --> |
| @@ -656,11 +656,42 @@ aclnnStatus aclnnMoeDistributeDispatchV4( | |||
| 656 | | 变量 | 定义与取值范围 | | 656 | | 变量 | 定义与取值范围 | |
| 657 | | :----------- | :----------------------------------------------------------------------------- | | 657 | | :----------- | :----------------------------------------------------------------------------- | |
| 658 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li><li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li></ul>| | 658 | | A | 表示本卡需要分发的最大token数量,取值范围如下:<ul> <li>对于共享专家,令 <code>ranksPerSharedExpert = sharedExpertRankNum / sharedExpertNum</code>、<code>maxBS = (globalBs == 0 ? BS : globalBs / epWorldSize)</code>,要满足 <code>A >= maxBS * ((epWorldSize + ranksPerSharedExpert - 1) / ranksPerSharedExpert)</code>。</li><li>对于MoE专家,当globalBs为0时,要满足A >= BS \* epWorldSize \* min(localExpertNum, K);当globalBs非0时,要满足A >= globalBs \* min(localExpertNum, K)。</li></ul>| |
| 659 | - | H(hidden size) | 表示hidden size隐藏层大小。<ul><li><term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。</li> <li><term>Atlas A3系列产品</term>:依commAlg取值,当commAlg="hierarchy"时,H取值范围为[1024, 7168],且为32的整数倍;其余场景下取值范围[1024, 8192]。</li><li><term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。</li></ul> | | 659 | + | H(hidden size) | 表示hidden size隐藏层大小。 具体产品差异见下方说明。 | |
| 660 | - | BS | 表示本卡最终输出token数。<ul><li><term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512);</li><li><term>Atlas A3训练系列产品/Atlas A3推理系列产品</term>:依commAlg取值,"fullmesh_v2"和"hierarchy"取值范围为(0 < BS ≤ 256),"fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。</li><li><term>Ascend 950DT系列产品</term>:0 < BS ≤ 512。</li></ul> | | 660 | + | BS | 表示本卡最终输出token数。 具体产品差异见下方说明。 | |
| 661 | - | K | 表示选取topK个专家,取值范围为0 < K ≤16,且<code>0 < K ≤ moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum</code>。<br> <term>Atlas A3系列产品</term>:当commAlg为"fullmesh_v2"时,取值范围为0 < K ≤ 12。| | 661 | + | K | 表示选取topK个专家,取值范围为0 < K ≤16,且<code>0 < K ≤ moeExpertNum + zeroExpertNum + copyExpertNum + constExpertNum</code>。具体产品差异见下方说明。 | |
| 662 | - | serverNum | 表示服务器节点数,仅支持2、4、8。<br>Atlas A2训练系列产品/Atlas A2推理系列产品:仅该场景的shape使用了该变量。 | | 662 | + | serverNum | 表示服务器节点数,仅支持2、4、8。具体产品差异见下方说明。 | |
| 663 | - | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li><term>Atlas A3系列产品</term>:应满足0 < <code>localExpertNum \* epWorldSize</code> ≤ 2048。当commAlg="hierarchy"时,需满足localExpertNum ≤ 24且 <code>localExpertNum \* epWorldSize</code> ≤ 512</li><li><term>Ascend 950DT系列产品</term>:应满足0 < <code>localExpertNum \* epWorldSize</code> ≤ 4096。</li></ul>| | 663 | + | localExpertNum | 本卡专家数:<ul><li>对于共享专家卡,localExpertNum = 1;</li><li>对于MoE专家卡,localExpertNum = <code>moeExpertNum/(epWorldSize-sharedExpertRankNum)</code>,当前版本不支持TP域通信。 </li><li>具体产品差异见下方说明。</li></ul> | |
| 664 | + | ||
| 665 | + <!-- npu="910b" id28 --> | ||
| 666 | + - H(hidden size):<term>Atlas A2系列产品</term>:当`x`的数据类型为INT32时,取值范围为(0, 5120]且为32的整数倍;其他数据类型的取值范围为(0, 10240]且为32的整数倍。 | ||
| 667 | + <!-- end id28 --> | ||
| 668 | + <!-- npu="A3" id29 --> | ||
| 669 | + - H(hidden size):<term>Atlas A3系列产品</term>:依commAlg取值,当commAlg="hierarchy"时,H取值范围为[1024, 7168],且为32的整数倍;其余场景下取值范围[1024, 8192]。 | ||
| 670 | + <!-- end id29 --> | ||
| 671 | + <!-- npu="950" id30 --> | ||
| 672 | + - H(hidden size):<term>Ascend 950DT系列产品</term>:取值范围[1024, 8192]。 | ||
| 673 | + <!-- end id30 --> | ||
| 674 | + <!-- npu="910b" id31 --> | ||
| 675 | + - BS:<term>Atlas A2系列产品</term>:依commAlg取值,"fullmesh"取值范围为(0 < BS ≤ 256);"hierarchy"并且驱动版本≥25.0.RC1.1时取值范围为(0 < BS ≤ 512)。 | ||
| 676 | + <!-- end id31 --> | ||
| 677 | + <!-- npu="A3" id32 --> | ||
| 678 | + - BS:<term>Atlas A3系列产品</term>:依commAlg取值,"fullmesh_v2"和"hierarchy"取值范围为(0 < BS ≤ 256),"fullmesh_v1"和""取值范围为(0 < BS ≤ 512)。 | ||
| 679 | + <!-- end id32 --> | ||
| 680 | + <!-- npu="950" id33 --> | ||
| 681 | + - BS:<term>Ascend 950DT系列产品</term>:0 < BS ≤ 512。 | ||
| 682 | + <!-- end id33 --> | ||
| 683 | + <!-- npu="A3" id34 --> | ||
| 684 | + - K:<term>Atlas A3系列产品</term>:当commAlg为"fullmesh_v2"时,取值范围为0 < K ≤ 12。 | ||
| 685 | + <!-- end id34 --> | ||
| 686 | + <!-- npu="910b" id35 --> | ||
| 687 | + - serverNum:<term>Atlas A2系列产品</term>:仅该场景的shape使用了该变量。 | ||
| 688 | + <!-- end id35 --> | ||
| 689 | + <!-- npu="A3" id36 --> | ||
| 690 | + - localExpertNum:<term>Atlas A3系列产品</term>:应满足0 < <code>localExpertNum \* epWorldSize</code> ≤ 2048。当commAlg="hierarchy"时,需满足localExpertNum ≤ 24且 <code>localExpertNum \* epWorldSize</code> ≤ 512。 | ||
| 691 | + <!-- end id36 --> | ||
| 692 | + <!-- npu="950" id37 --> | ||
| 693 | + - localExpertNum:<term>Ascend 950DT系列产品</term>:应满足0 < <code>localExpertNum \* epWorldSize</code> ≤ 4096。 | ||
| 694 | + <!-- end id37 --> | ||
| 664 | 695 | ||
| 665 | - **quantMode相关约束**: | 696 | - **quantMode相关约束**: |
| 666 | 697 | ||
| @@ -731,9 +762,10 @@ aclnnStatus aclnnMoeDistributeDispatchV4( | |||
| 731 | <!-- end id17 --> | 762 | <!-- end id17 --> |
| 732 | <!-- npu="950" id18 --> | 763 | <!-- npu="950" id18 --> |
| 733 | - <term>Ascend 950DT系列产品</term>: | 764 | - <term>Ascend 950DT系列产品</term>: |
| 734 | - - 当commAlg为"fullmesh_v1"或空字符串或空指针时:要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 | 765 | + - 当commAlg为"fullmesh_v1"或空字符串或空指针时:要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))。 |
| 735 | - - 当commAlg为"fullmesh_v2"时:要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* Align512(2 \* H))。 | 766 | + - 当commAlg为"fullmesh_v2"时:要求取值满足 ≥ 2 \* (localExpertNum \* maxBS \* epWorldSize \* 480Align512(Align32(2 \* H) + 64) + (K + sharedExpertNum) \* maxBS \* 480Align512(2 \* H))。 |
| 736 | - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 | 767 | - 其中`480Align512(x) = ((x + 480 - 1) / 480) * 512`,`Align512(x) = ((x + 512 - 1) / 512) * 512`,`Align32(x) = ((x + 32 - 1) / 32) * 32`。 |
| 768 | + - 当`quantMode`为0(非量化)且`scalesOptional`非空时,式中每个token的长度取`max(Align32(2 * H) + 64, Align32(Align32(2 * H) + 4 * H) + 16)`,再按上述规则对齐。 | ||
| 737 | 769 | ||
| 738 | <!-- end id18 --> | 770 | <!-- end id18 --> |
| 739 | 771 | ||
| @@ -1762,4 +1794,4 @@ aclnnStatus aclnnMoeDistributeDispatchV4( | |||
| 1762 | 1794 | ||
| 1763 | return 0; | 1795 | return 0; |
| 1764 | } | 1796 | } |
| 1765 | - ``` | 1797 | + ``` |


问题:这行没改动,但 A5 新核算最后就是汇到这条公式里——最低窗口只加了 1MB 状态区,而 host 侧 tiling 校验(moe_distribute_check_win_size.h 的 CheckActualWinSize)在 A5 上除了数据区外还要再加 epWorldSize * 1024B 的 rank offset 预留,报错公式里也明写着"+ epWorldSize * 1024"。epWorldSize 顶到 1024 时这块最多 1MB,而这里只向上取整到偶数 MB,余量可能刚好是 0,这种组合下按返回值设的 buffer 会过不了 tiling 校验,跑起来直接报 HCCL_BUFFSIZE_EP is too SMALL。 修复意见:is_a5 时把 epWorldSize * 1024 一并加进 minimum_buffer_size,跟 host 侧的核算口径对齐。