Linear Attention 与 SSM¶
2 个算子,10 个工作负载。
每个算子一张表,每个工作负载一行。比值 是同一测量口径下基准的耗时除以我们的耗时,所以 绿色 表示我们更快,无色 表示持平,红色 表示我们更慢。时间单位是 ms。这些数字是怎么来的。
扫描(Scan)¶
CumprodFwd¶
- W1x: [2048, 4096]dtype=bf16
hidden-state-scan - W2x: [2048, 4096]dtype=f16
hidden-state-scan - W3x: [64, 32768]dtype=bf16
long-seq-scan
dtype=f16
- W4input: [2, 5, 7]dim=1
non-last-axis-host-permute - W5input: [4097]
nondivisible-4097
| 工作负载 | 比值 | 耗时 | 对照实现 | 吞吐 | SOL | 瓶颈 | |
|---|---|---|---|---|---|---|---|
| 对照 / 我们 | ms | 名称 · 档位 | ms | TFLOP/s | 占天花板 | 受限于 | |
| W1 | 16.39× | 8.1635 | torch_compile_aclgraph torch_compile 基准torch_npu eager 厂商库 | 133.9033 134.0408 | · | · | · |
| W2 | 16.44× | 8.1628 | torch_compile_aclgraph torch_compile 基准torch_npu eager 厂商库 | 134.0186 134.1221 | · | · | · |
| W3 | 13.70× | 2.0857 | torch_compile_aclgraph torch_compile 基准torch_npu eager 厂商库 | 28.5701 28.5780 | · | · | · |
| W4 | 1.37× | 0.0232 | torch_compile_aclgraph torch_compiletorch_npu eager 厂商库 基准 | 0.0333 0.0309 | · | · | · |
| W5 | 3.36× | 0.0267 | torch_compile_aclgraph torch_compiletorch_npu eager 厂商库 基准 | 0.0899 0.0882 | · | · | · |
CumsumFwd¶
- W1x: [2048, 4096]dtype=bf16
hidden-state-scan - W2x: [2048, 4096]dtype=f16
hidden-state-scan - W3x: [64, 32768]dtype=bf16
long-seq-scan
dtype=f16
- W4input: [2, 5, 7]dim=1
non-last-axis-host-permute - W5input: [4097]
nondivisible-4097
| 工作负载 | 比值 | 耗时 | 对照实现 | 吞吐 | SOL | 瓶颈 | |
|---|---|---|---|---|---|---|---|
| 对照 / 我们 | ms | 名称 · 档位 | ms | TFLOP/s | 占天花板 | 受限于 | |
| W1 | 0.05× | 8.1691 | torch_compile_aclgraph torch_compiletorch_compile_ge torch_compiletorch_npu eager 厂商库 基准 | 0.4340 0.3981 0.3949 | · | · | · |
| W2 | 0.05× | 8.1645 | torch_compile_aclgraph torch_compiletorch_compile_ge torch_compiletorch_npu eager 厂商库 基准 | 0.4339 0.3956 0.3940 | · | · | · |
| W3 | 0.07× | 2.0892 | torch_compile_aclgraph torch_compiletorch_compile_ge torch_compiletorch_npu eager 厂商库 基准 | 0.1686 0.1424 0.1446 | · | · | · |
| W4 | 0.86× | 0.0238 | torch_compile_aclgraph torch_compiletorch_compile_ge torch_compiletorch_npu eager 厂商库 基准 | 0.0120 0.0107 0.0107 | · | · | · |
| W5 | 0.96× | 0.0283 | torch_compile_aclgraph torch_compiletorch_compile_ge torch_compiletorch_npu eager 厂商库 基准 | 0.0272 0.0125 0.0185 | · | · | · |