Pull Request has been successfully merged by CANN-robot.
(Thank you for 贾剑勇's contribution.)变更摘要
该 PR 针对 DropOutV3 算子(random/drop_out_v3)做两方面改动:一是通过展开 Philox 随机数生成流水提升性能,二是修复输入含 nan/inf 时的精度错误。核心实现位于 drop_out_v3_simd_impl.h:ComputeContinuousSimd 将原来"逐 batch 生成随机数并 dropout"的单循环重构为多阶段流水(先映射并暂存 counter,再分 3 轮执行 Philox 变换 SpNetworkKernel<4>/<4>/<2>,最后统一计算 dropout),各阶段以 LocalMemBar 同步,尾 batch 单独处理;PhiloxCtrConvertAndDropout 新增 oneFloatReg 参数,mask 应用由 Select 改为先生成 mask 位寄存器再与缩放输入 Mul,避免 nan/inf 经 mask 传播。同时 Tiling 侧移除 transportMode 字段并简化 totalThreads 计算,kernel 调度改为按 vec == 1 选择实现,尾 mask 清零逻辑由首核 Fill<uint16_t> 改为末核逐字节 WriteGmByPassDCache。
主要改动
- Philox 流水展开(性能优化):
ComputeContinuousSimd将随机数生成拆分为 counter 映射、3 轮 Philox 变换(SpNetworkKernel<4>/<4>/<2>)、dropout 计算三组循环,counter 经ctrBufPtr暂存并插入LocalMemBar同步,尾 batch 单独走SpNetworkKernel<10>逻辑。 - 修复
nan/inf输入精度错误:PhiloxCtrConvertAndDropout增加oneFloatReg形参,输出改为scaledInput与 mask 位(Select生成 1/0)相乘,且连续处理路径的分支阈值由outputSize >= 524288改为outputSize > UINT32_MAX_VALUE。 - Tiling 数据简化:
drop_out_v3_tiling_data_arch35.h删除transportMode字段;tiling 中totalThreads改为固定AIC_CLUSTER_COUNT * MAX_THREADS_PER_AIC,UB 中 random float buffer 数量按vec == NUM_2取 2、否则取 1,并相应调整perBlockBytes与对齐校验。 - 调度与尾 mask 清零调整:
drop_out_v3.cpp由按transportMode改为按tilingData.vec == 1分发到DropOutV3Impl/DropOutV3SimdImpl;Process中尾字节清零从blockIdx_ == 0的Fill<uint16_t>改为末核(usedCoreNum - 1)逐字节WriteGmByPassDCache,并移除SyncAll()。 - 单测期望值更新:
test_drop_out_v3_tiling.cpp同步更新 tiling 数据期望串(移除transportMode、更新totalThreads)。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-math | ✅ xuejinghui, 汤平川 (2/2) | ✅ 汤平川, xuejinghui (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
jia-jianyong, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm
/approve


描述
DropOutV3 perf improve by unroll philox & fix nan/inf input precision error
关联的Issue
https://gitcode.com/cann/ops-math/issues/3186
测试
精度、性能、冒烟验证ok
文档更新
不涉及
类型标签