Merged
fused_causal_conv1d修改cache_indices的拦截 #10073
xiapengcheng5Add on Aug 14
fused_causal_conv1d修改cache_indices的拦截 #10073
Merged
Total: 6 files changed+26-75
| @@ -441,7 +441,7 @@ | |||
| 441 | - prefill场景: | 441 | - prefill场景: |
| 442 | - x支持2维[cu_seq_len, dim]。 | 442 | - x支持2维[cu_seq_len, dim]。 |
| 443 | - weight必须是2维[K, dim],其中K固定为3。 | 443 | - weight必须是2维[K, dim],其中K固定为3。 |
| 444 | - - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 444 | + - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 445 | - query_start_loc必须存在。 | 445 | - query_start_loc必须存在。 |
| 446 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 446 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 447 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 447 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -450,7 +450,7 @@ | |||
| 450 | - prefill和decode混合场景: | 450 | - prefill和decode混合场景: |
| 451 | - x支持2维[cu_seq_len, dim]。 | 451 | - x支持2维[cu_seq_len, dim]。 |
| 452 | - weight必须是2维[K, dim],其中K固定为3。 | 452 | - weight必须是2维[K, dim],其中K固定为3。 |
| 453 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 453 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 454 | - query_start_loc必须存在。 | 454 | - query_start_loc必须存在。 |
| 455 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 455 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 456 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 456 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -459,7 +459,7 @@ | |||
| 459 | - decode场景(变长序列): | 459 | - decode场景(变长序列): |
| 460 | - x支持2维[cu_seq_len, dim]。 | 460 | - x支持2维[cu_seq_len, dim]。 |
| 461 | - weight必须是2维[K, dim],其中K固定为3。 | 461 | - weight必须是2维[K, dim],其中K固定为3。 |
| 462 | - - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 462 | + - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 463 | - query_start_loc必须存在。 | 463 | - query_start_loc必须存在。 |
| 464 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 464 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 465 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 465 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| @@ -468,7 +468,7 @@ | |||
| 468 | - decode场景(固定batch): | 468 | - decode场景(固定batch): |
| 469 | - x支持3维[batch, m+1, dim]。 | 469 | - x支持3维[batch, m+1, dim]。 |
| 470 | - weight必须是2维[K, dim],其中K固定为3。 | 470 | - weight必须是2维[K, dim],其中K固定为3。 |
| 471 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 471 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 472 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 472 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 473 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 473 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| 474 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 | 474 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 |
| @@ -485,7 +485,7 @@ | |||
| 485 | - blockIdxLastScheduledToken[i] < maxNumBlocks | 485 | - blockIdxLastScheduledToken[i] < maxNumBlocks |
| 486 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 | 486 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 |
| 487 | - num_computed_tokens中每个元素取值大于等于0。 | 487 | - num_computed_tokens中每个元素取值大于等于0。 |
| 488 | - - cache_indices的取值范围为[0, conv_states.dim[0]-1],且元素均不能相等。 | 488 | + - cache_indices的取值范围为[0, conv_states.dim[0]-1],且值均不能相等(除非等于pad_slot_id)。 |
| 489 | - max_query_len = batch中的最大seq_len。 | 489 | - max_query_len = batch中的最大seq_len。 |
| 490 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 | 490 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 |
| 491 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 | 491 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 |
Mattention/fused_causal_conv1d/docs/aclnnFusedCausalConv1d.md+5-5File content is under review, please try again later
| @@ -140,7 +140,13 @@ ge::graphStatus FusedCausalConv1dCutBHTiling::GetShapeInfo() | |||
| 140 | "The shape dim of weight must be 2"); | 140 | "The shape dim of weight must be 2"); |
| 141 | return ge::GRAPH_FAILED; | 141 | return ge::GRAPH_FAILED; |
| 142 | } | 142 | } |
| 143 | + | ||
| 143 | kernelSize_ = weightOriginShape.GetDim(DIM_0); | 144 | kernelSize_ = weightOriginShape.GetDim(DIM_0); |
| 145 | + if (kernelSize_ != 3) { | ||
| 146 | + OP_LOGE_FOR_INVALID_VALUE_WITH_REASON(context_->GetNodeName(), "weight", std::to_string(kernelSize_).c_str(), | ||
| 147 | + "The dim 0 of weight must be equal to 3"); | ||
| 148 | + return ge::GRAPH_FAILED; | ||
| 149 | + } | ||
| 144 | 150 | ||
| 145 | // 获取 conv_states 形状,提取 stateLen_(= kernel_size - 1 + max_seq_len) | 151 | // 获取 conv_states 形状,提取 stateLen_(= kernel_size - 1 + max_seq_len) |
| 146 | auto convStatesShape = context_->GetInputShape(CONV_STATES_INDEX); | 152 | auto convStatesShape = context_->GetInputShape(CONV_STATES_INDEX); |
| @@ -450,18 +456,6 @@ ge::graphStatus FusedCausalConv1dCutBHTiling::ValidateConvStatesShape() | |||
| 450 | auto convStatesShape = context_->GetInputShape(CONV_STATES_INDEX); | 456 | auto convStatesShape = context_->GetInputShape(CONV_STATES_INDEX); |
| 451 | OP_CHECK_NULL_WITH_CONTEXT(context_, convStatesShape); | 457 | OP_CHECK_NULL_WITH_CONTEXT(context_, convStatesShape); |
| 452 | auto convStatesOriginShape = convStatesShape->GetOriginShape(); | 458 | auto convStatesOriginShape = convStatesShape->GetOriginShape(); |
| 453 | - // 维度校验由 GetShapeInfo 完成(line 150 已检查 dim==3),此处不重复 | ||
| 454 | - | ||
| 455 | - // conv_states shape[0] 必须 >= batch,才能保证每个 batch 都能索引到有效的 cache line | ||
| 456 | - int64_t convStatesBatch = convStatesOriginShape.GetDim(DIM_0); | ||
| 457 | - if (convStatesBatch < batchSize_) { | ||
| 458 | - std::string reasonMsg = | ||
| 459 | - "Shape [0] of conv_states must be greater than or equal to batch_size (" + std::to_string(batchSize_) + ")"; | ||
| 460 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "conv_states", | ||
| 461 | - std::to_string(convStatesBatch).c_str(), reasonMsg.c_str()); | ||
| 462 | - return ge::GRAPH_FAILED; | ||
| 463 | - } | ||
| 464 | - | ||
| 465 | // conv_states shape: [-1, K-1+m, dim],state_len 需能容纳所有历史状态 | 459 | // conv_states shape: [-1, K-1+m, dim],state_len 需能容纳所有历史状态 |
| 466 | if (xInputMode_ == X_INPUT_3D) { | 460 | if (xInputMode_ == X_INPUT_3D) { |
| 467 | int64_t expectedCacheLen = kernelSize_ + seqLen_ - 2; // = (K-1) + (seqLen-1) | 461 | int64_t expectedCacheLen = kernelSize_ + seqLen_ - 2; // = (K-1) + (seqLen-1) |
| @@ -530,24 +524,6 @@ ge::graphStatus FusedCausalConv1dCutBHTiling::ValidateCacheIndicesShape() | |||
| 530 | } | 524 | } |
| 531 | } | 525 | } |
| 532 | 526 | ||
| 533 | - // conv_states.shape[0] 必须 >= cache_indices 总元素数(cache_indices 中保存的是 conv_states 的 line 索引) | ||
| 534 | - // 1D 时总元素数 = dim0;2D 时总元素数 = dim0 * dim1 | ||
| 535 | - int64_t cacheIndicesTotal = indicesOriginShape.GetDim(DIM_0); | ||
| 536 | - if (indicesOriginShape.GetDimNum() == DIM_2) { | ||
| 537 | - cacheIndicesTotal *= indicesOriginShape.GetDim(DIM_1); | ||
| 538 | - } | ||
| 539 | - auto convStatesShape = context_->GetInputShape(CONV_STATES_INDEX); | ||
| 540 | - OP_CHECK_NULL_WITH_CONTEXT(context_, convStatesShape); | ||
| 541 | - int64_t convStatesBatch = convStatesShape->GetOriginShape().GetDim(DIM_0); | ||
| 542 | - if (convStatesBatch < cacheIndicesTotal) { | ||
| 543 | - std::string reasonMsg = "Shape [0] of conv_states (" + std::to_string(convStatesBatch) + | ||
| 544 | - ") must be greater than or equal to the total element count of cache_indices (" + | ||
| 545 | - std::to_string(cacheIndicesTotal) + ")"; | ||
| 546 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "cache_indices", | ||
| 547 | - std::to_string(cacheIndicesTotal).c_str(), reasonMsg.c_str()); | ||
| 548 | - return ge::GRAPH_FAILED; | ||
| 549 | - } | ||
| 550 | - | ||
| 551 | return ge::GRAPH_SUCCESS; | 527 | return ge::GRAPH_SUCCESS; |
| 552 | } | 528 | } |
| 553 | 529 | ||
| @@ -239,15 +239,6 @@ ge::graphStatus FusedCausalConv1dCutBSHTiling::CheckCacheStatesDim() | |||
| 239 | "The shape dim of cache_states must be 3"); | 239 | "The shape dim of cache_states must be 3"); |
| 240 | return ge::GRAPH_FAILED; | 240 | return ge::GRAPH_FAILED; |
| 241 | } | 241 | } |
| 242 | - // cache_states shape[0] 必须 >= batch,保证每个 batch 都能索引到 cache line | ||
| 243 | - uint64_t cacheStatesDim0 = cacheStatesShape_.GetDim(DIM_0); | ||
| 244 | - if (cacheStatesDim0 < batch_) { | ||
| 245 | - std::string reasonMsg = | ||
| 246 | - "Shape [0] of cache_states must be greater than or equal to batch (" + std::to_string(batch_) + ")"; | ||
| 247 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "cache_states", | ||
| 248 | - std::to_string(cacheStatesDim0).c_str(), reasonMsg.c_str()); | ||
| 249 | - return ge::GRAPH_FAILED; | ||
| 250 | - } | ||
| 251 | uint64_t cacheStatesDim1 = cacheStatesShape_.GetDim(DIM_1); | 242 | uint64_t cacheStatesDim1 = cacheStatesShape_.GetDim(DIM_1); |
| 252 | if (cacheStatesDim1 < (kernelWidth_ - 1)) { | 243 | if (cacheStatesDim1 < (kernelWidth_ - 1)) { |
| 253 | std::string reasonMsg = | 244 | std::string reasonMsg = |
| @@ -325,22 +316,6 @@ ge::graphStatus FusedCausalConv1dCutBSHTiling::CheckCacheIndicesDim() | |||
| 325 | std::to_string(cacheIndicesDim0).c_str(), reasonMsg.c_str()); | 316 | std::to_string(cacheIndicesDim0).c_str(), reasonMsg.c_str()); |
| 326 | return ge::GRAPH_FAILED; | 317 | return ge::GRAPH_FAILED; |
| 327 | } | 318 | } |
| 328 | - | ||
| 329 | - // cache_states.shape[0] 必须 >= cache_indices 总元素数(cache_indices 中保存的是 cache_states 的 line 索引) | ||
| 330 | - // 1D 时总元素数 = dim0;2D 时总元素数 = dim0 * dim1 | ||
| 331 | - uint64_t cacheIndicesTotal = cacheIndicesDim0; | ||
| 332 | - if (cacheIndicesDimNum == DIM_2) { | ||
| 333 | - cacheIndicesTotal *= static_cast<uint64_t>(cacheIndicesShape.GetDim(DIM_1)); | ||
| 334 | - } | ||
| 335 | - uint64_t cacheStatesDim0 = cacheStatesShape_.GetDim(DIM_0); | ||
| 336 | - if (cacheStatesDim0 < cacheIndicesTotal) { | ||
| 337 | - std::string reasonMsg = "Shape [0] of cache_states (" + std::to_string(cacheStatesDim0) + | ||
| 338 | - ") must be greater than or equal to the total element count of cache_indices (" + | ||
| 339 | - std::to_string(cacheIndicesTotal) + ")"; | ||
| 340 | - OP_LOGE_FOR_INVALID_SHAPE_WITH_REASON(context_->GetNodeName(), "cache_indices", | ||
| 341 | - std::to_string(cacheIndicesTotal).c_str(), reasonMsg.c_str()); | ||
| 342 | - return ge::GRAPH_FAILED; | ||
| 343 | - } | ||
| 344 | return ge::GRAPH_SUCCESS; | 319 | return ge::GRAPH_SUCCESS; |
| 345 | } | 320 | } |
| 346 | 321 | ||
| @@ -436,7 +436,7 @@ | |||
| 436 | - prefill场景: | 436 | - prefill场景: |
| 437 | - x支持2维[cu_seq_len, dim]。 | 437 | - x支持2维[cu_seq_len, dim]。 |
| 438 | - weight必须是2维[K, dim],其中K固定为3。 | 438 | - weight必须是2维[K, dim],其中K固定为3。 |
| 439 | - - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 439 | + - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 440 | - query_start_loc必须存在。 | 440 | - query_start_loc必须存在。 |
| 441 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 441 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 442 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 442 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -445,7 +445,7 @@ | |||
| 445 | - prefill和decode混合场景: | 445 | - prefill和decode混合场景: |
| 446 | - x支持2维[cu_seq_len, dim]。 | 446 | - x支持2维[cu_seq_len, dim]。 |
| 447 | - weight必须是2维[K, dim],其中K固定为3。 | 447 | - weight必须是2维[K, dim],其中K固定为3。 |
| 448 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 448 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 449 | - query_start_loc必须存在。 | 449 | - query_start_loc必须存在。 |
| 450 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 450 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 451 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 451 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -454,7 +454,7 @@ | |||
| 454 | - decode场景(变长序列): | 454 | - decode场景(变长序列): |
| 455 | - x支持2维[cu_seq_len, dim]。 | 455 | - x支持2维[cu_seq_len, dim]。 |
| 456 | - weight必须是2维[K, dim],其中K固定为3。 | 456 | - weight必须是2维[K, dim],其中K固定为3。 |
| 457 | - - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 457 | + - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 458 | - query_start_loc必须存在。 | 458 | - query_start_loc必须存在。 |
| 459 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 459 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 460 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 460 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| @@ -463,7 +463,7 @@ | |||
| 463 | - decode场景(固定batch): | 463 | - decode场景(固定batch): |
| 464 | - x支持3维[batch, m+1, dim]。 | 464 | - x支持3维[batch, m+1, dim]。 |
| 465 | - weight必须是2维[K, dim],其中K固定为3。 | 465 | - weight必须是2维[K, dim],其中K固定为3。 |
| 466 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 466 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 467 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 467 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 468 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 468 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| 469 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 | 469 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 |
| @@ -480,7 +480,7 @@ | |||
| 480 | - blockIdxLastScheduledToken[i] < maxNumBlocks | 480 | - blockIdxLastScheduledToken[i] < maxNumBlocks |
| 481 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 | 481 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 |
| 482 | - num_computed_tokens中每个元素取值大于等于0。 | 482 | - num_computed_tokens中每个元素取值大于等于0。 |
| 483 | - - cache_indices的取值范围为[0, conv_states.dim[0]-1],且元素均不能相等。 | 483 | + - cache_indices的取值范围为[0, conv_states.dim[0]-1],且值均不能相等(除非等于pad_slot_id)。 |
| 484 | - max_query_len = batch中的最大seq_len。 | 484 | - max_query_len = batch中的最大seq_len。 |
| 485 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 | 485 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 |
| 486 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 | 486 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 |
| @@ -638,7 +638,7 @@ aclnnStatus aclnnInplaceFusedCausalConv1d( | |||
| 638 | - prefill场景: | 638 | - prefill场景: |
| 639 | - x支持2维[cu_seq_len, dim]。 | 639 | - x支持2维[cu_seq_len, dim]。 |
| 640 | - weight必须是2维[K, dim],其中K固定为3。 | 640 | - weight必须是2维[K, dim],其中K固定为3。 |
| 641 | - - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 641 | + - conv_states必须是3维[..., K-1, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 642 | - query_start_loc必须存在。 | 642 | - query_start_loc必须存在。 |
| 643 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 643 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 644 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 644 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -647,7 +647,7 @@ aclnnStatus aclnnInplaceFusedCausalConv1d( | |||
| 647 | - prefill和decode混合场景: | 647 | - prefill和decode混合场景: |
| 648 | - x支持2维[cu_seq_len, dim]。 | 648 | - x支持2维[cu_seq_len, dim]。 |
| 649 | - weight必须是2维[K, dim],其中K固定为3。 | 649 | - weight必须是2维[K, dim],其中K固定为3。 |
| 650 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 650 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 651 | - query_start_loc必须存在。 | 651 | - query_start_loc必须存在。 |
| 652 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 652 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 653 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 | 653 | - cu_seq_len范围[batch, 1024 * 1024],dim范围[64, 16384]且是16的倍数,且两者乘积需满足[64 * batch, 4G], batch范围[1, 256]。 |
| @@ -656,7 +656,7 @@ aclnnStatus aclnnInplaceFusedCausalConv1d( | |||
| 656 | - decode场景(变长序列): | 656 | - decode场景(变长序列): |
| 657 | - x支持2维[cu_seq_len, dim]。 | 657 | - x支持2维[cu_seq_len, dim]。 |
| 658 | - weight必须是2维[K, dim],其中K固定为3。 | 658 | - weight必须是2维[K, dim],其中K固定为3。 |
| 659 | - - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 659 | + - conv_states必须是3维[..., k-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 660 | - query_start_loc必须存在。 | 660 | - query_start_loc必须存在。 |
| 661 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 661 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 662 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 662 | - cu_seq_len范围[batch, batch * 8],每个batch的seq_len范围为[1, 8]。dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| @@ -665,7 +665,7 @@ aclnnStatus aclnnInplaceFusedCausalConv1d( | |||
| 665 | - decode场景(固定batch): | 665 | - decode场景(固定batch): |
| 666 | - x支持3维[batch, m+1, dim]。 | 666 | - x支持3维[batch, m+1, dim]。 |
| 667 | - weight必须是2维[K, dim],其中K固定为3。 | 667 | - weight必须是2维[K, dim],其中K固定为3。 |
| 668 | - - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于batch,同时大于等于cache_indices总维度大小。 | 668 | + - conv_states必须是3维[..., K-1+m, dim],第0维大小不固定且大于等于参与计算的batch个数(即cache_indices不等于pad_slot_id的batch个数)。 |
| 669 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 | 669 | - cache_indices为1维[batch, ]或2维[batch, maxNumBlocks],其中1维表示未开启APC,2维表示开启APC。 |
| 670 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 | 670 | - m范围[0, 7],dim范围[64, 16384]且是16的倍数,batch范围[1, 256]。 |
| 671 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 | 671 | - maxNumBlocks >= ceiv(max_query_len, block_size)。 |
| @@ -682,7 +682,7 @@ aclnnStatus aclnnInplaceFusedCausalConv1d( | |||
| 682 | - blockIdxLastScheduledToken[i] < maxNumBlocks | 682 | - blockIdxLastScheduledToken[i] < maxNumBlocks |
| 683 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 | 683 | - num_accepted_tokens分为None和非None,非None情况下长度为batch,prefile对应的元素值为0,decode对应的元素值大于0且小于等于当前batch的seq_len-1。 |
| 684 | - num_computed_tokens中每个元素取值大于等于0。 | 684 | - num_computed_tokens中每个元素取值大于等于0。 |
| 685 | - - cache_indices的取值范围为[0, conv_states.dim[0]-1],且元素均不能相等。 | 685 | + - cache_indices的取值范围为[0, conv_states.dim[0]-1],且值均不能相等(除非等于pad_slot_id)。 |
| 686 | - max_query_len = batch中的最大seq_len。 | 686 | - max_query_len = batch中的最大seq_len。 |
| 687 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 | 687 | - Pangu V2 模式(conv_mode = 1)下,num_computed_tokens不能为 None。 |
| 688 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 | 688 | - 算子入参与中间计算结果,在对应数据类型(float16/bfloat16)下,数值均不会超出该类型值域范围。 |