benchmark
benchmark copied to clipboard
Optimize XLnet performance
模型提供的测试报告:
V100 单机单卡自测值: paddle 版本:develop 速度:0.961218 steps/s tf 1.15 速度: 1.61 step/s
从profile结果看 stack 和stack_grad op的 cpu耗时太多
从tracing文件来看 stack_grad耗时很多,很大可能在等待GPU的操作
paddle | tf | |||||
---|---|---|---|---|---|---|
op | Calls | time cost(ms) | op | calls | time cost(ms) | |
stack_grad | 12 | 719.9 | ||||
stack | 15 | 347.6 | ||||
elementwise_mul | 305 | 96 | Mul | 1203 | 132.4 | |
matmul_grad | 186 | 191.4 | BatchMatMulV2 | 370 | 315.8 | |
transpose2_grad | 383 | 179.8 | ||||
transpose2 | 406 | 197.3 | Transpose | 1236 | 260.6 | |
matmul | 193 | 74 | MatMul | 373 | 154.8 | |
total | 1806 | 863.6 |
OP对比如上图所示,完整的OP没有贴出来,首先针对这些占比较大的进行优化
优化stack op:https://github.com/PaddlePaddle/Paddle/pull/21940 优化后xlnet-ernie: 1.005,提升~4%
优化transpose后:1.337516 steps/s
在计算element_wise之前 大量时间被浪费在CPU和GPU的sync
优化了data transform之后性能提升~8%