Skip to content

causal_conv1d kernel improvement using PTO kernel & benchmark results - #601

Open
ChristosMatzoros wants to merge 23 commits into
sgl-project:mainfrom
ChristosMatzoros:causal-conv1d-tiling-onmain
Open

causal_conv1d kernel improvement using PTO kernel & benchmark results#601
ChristosMatzoros wants to merge 23 commits into
sgl-project:mainfrom
ChristosMatzoros:causal-conv1d-tiling-onmain

Conversation

@ChristosMatzoros

@ChristosMatzoros ChristosMatzoros commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

causal_conv1d: PTO-ISA tiling kernel vs main (AscendC) — benchmark results

Requires #663 : the A5 path uses TMULADDDST, which is not in the currently pinned pto-isa. Without that PR merged, A5 builds fail with "use of undeclared identifier 'TMULADDDST'". A2/A3 builds are unaffected.

Reimplements causal_conv1d (Mamba/GDN depthwise causal conv1d + bias + optional SiLU) on the PTO tile ISA, and improves the launch tiling. Closes #596

Head-to-head of this branch's PTO-ISA causal_conv1d against the AscendC kernel on main, on an Ascend 910B2 (48 AIV cores).

  • baseline mainf451a59 (AscendC)
  • branchcausal-conv1d-tiling-onmain@13ad3a2 (PTO-ISA), rebased onto main (f451a59)
  • 400 shapes, both layouts (3D dense + varlen/packed), 0 correctness failures (max-abs vs an fp32 reference, tol 6e-3).
  • Two metrics per shape, each a geometric mean over 100 warmed iterations: end-to-end per-call latency (torch.npu.Event, per-iteration synchronized) and kernel on-device time (torch_npu.profiler).
  • speedup = main / branch (>1 ⇒ this branch is faster). One idle NPU, idle-gated before + after each run.

The two layouts. Every shape is measured in both input layouts the op supports:

  • 3D dense[batch, seq, dim]: every sequence in the batch has the same length seq (a rectangular, padded tensor).
  • varlen / packed[cu_seqlen, dim]: variable-length sequences concatenated end-to-end into one flat 2D tensor, with query_start_loc marking the boundaries — the real continuous-batching / serving layout. The causal conv resets its window at each sequence boundary (a sequence never reads the previous one's tokens).

Summary

Geometric-mean speedup (main / branch, >1 ⇒ branch faster), by channel count (dim):

Qwen 3.5-4B, 35B Qwen 3.5-27B
layout metric dim=1024 dim=2048 dim=4096 dim=5120 dim=6144
3D dense kernel 1.83× 1.70× 1.49× 2.14× 1.86×
3D dense e2e 1.74× 1.62× 1.49× 1.93× 1.85×
varlen kernel 1.52× 1.38× 1.24× 1.80× 1.57×
varlen e2e 1.58× 1.55× 1.40× 1.83× 1.64×

Full per-shape results

3D dense · dim=1024 — 40 shapes (kernel median 1.78×, e2e median 1.71×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 213.3 125.0 1.71× 19.5 7.9 2.47× ok
3 128 204.9 120.0 1.71× 24.0 10.1 2.37× ok
4 128 202.7 119.9 1.69× 25.6 11.2 2.29× ok
6 128 193.7 117.3 1.65× 28.4 13.2 2.15× ok
12 128 194.9 116.3 1.68× 36.4 19.0 1.91× ok
16 128 195.8 114.6 1.71× 44.2 22.9 1.93× ok
32 128 199.9 114.6 1.74× 69.3 39.7 1.74× ok
64 128 246.7 126.5 1.95× 116.1 71.7 1.62× ok
128 128 340.1 189.0 1.80× 210.5 134.2 1.57× ok
256 128 529.5 315.1 1.68× 400.9 259.9 1.54× ok
1 256 227.2 133.2 1.71× 18.3 8.6 2.15× ok
3 256 228.6 125.2 1.83× 27.7 12.8 2.17× ok
4 256 227.0 118.4 1.92× 33.2 14.8 2.25× ok
6 256 227.5 112.3 2.03× 37.8 18.6 2.04× ok
12 256 228.3 132.5 1.72× 54.9 29.8 1.84× ok
16 256 194.8 115.8 1.68× 67.6 37.5 1.80× ok
32 256 242.9 122.8 1.98× 116.0 68.6 1.69× ok
64 256 336.4 185.5 1.81× 209.0 129.7 1.61× ok
128 256 527.9 313.4 1.68× 398.4 250.3 1.59× ok
256 256 905.3 569.8 1.59× 779.0 498.6 1.56× ok
1 512 196.4 122.5 1.60× 22.7 10.9 2.08× ok
3 512 191.6 117.0 1.64× 36.5 18.2 2.01× ok
4 512 199.2 116.9 1.70× 46.2 22.0 2.10× ok
6 512 190.8 119.4 1.60× 56.3 29.4 1.92× ok
12 512 217.3 108.7 2.00× 91.0 51.4 1.77× ok
16 512 244.8 119.6 2.05× 116.8 66.3 1.76× ok
32 512 336.4 176.0 1.91× 209.1 126.5 1.65× ok
64 512 525.8 297.1 1.77× 398.1 244.9 1.63× ok
128 512 907.3 539.5 1.68× 778.1 484.6 1.61× ok
256 512 1674.4 1015.9 1.65× 1536.7 959.1 1.60× ok
1 1024 190.2 116.3 1.64× 30.0 14.3 2.09× ok
3 1024 194.0 116.8 1.66× 54.0 29.0 1.86× ok
4 1024 195.6 121.7 1.61× 66.8 36.4 1.84× ok
6 1024 218.6 118.0 1.85× 90.9 50.9 1.79× ok
12 1024 292.1 152.7 1.91× 160.9 94.8 1.70× ok
16 1024 340.5 188.8 1.80× 208.9 124.2 1.68× ok
32 1024 528.8 300.8 1.76× 397.5 242.0 1.64× ok
64 1024 922.8 534.2 1.73× 777.6 478.5 1.62× ok
128 1024 1661.5 1208.5 1.38× 1534.8 948.2 1.62× ok
256 1024 3174.9 1960.2 1.62× 3045.5 1886.2 1.61× ok
3D dense · dim=2048 — 40 shapes (kernel median 1.62×, e2e median 1.63×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 196.8 115.1 1.71× 18.4 8.5 2.16× ok
3 128 194.6 113.8 1.71× 26.6 12.2 2.18× ok
4 128 195.8 114.5 1.71× 29.9 13.9 2.15× ok
6 128 195.1 114.2 1.71× 33.5 17.2 1.95× ok
12 128 198.0 114.2 1.73× 46.6 26.8 1.74× ok
16 128 196.6 113.9 1.73× 59.4 33.3 1.78× ok
32 128 220.1 121.0 1.82× 96.0 60.5 1.59× ok
64 128 296.8 175.3 1.69× 173.3 113.9 1.52× ok
128 128 452.2 280.1 1.61× 325.8 217.5 1.50× ok
256 128 755.8 495.0 1.53× 631.5 434.2 1.45× ok
1 256 192.0 125.6 1.53× 21.8 10.3 2.12× ok
3 256 190.0 116.8 1.63× 33.4 16.9 1.98× ok
4 256 189.3 125.6 1.51× 38.9 20.3 1.92× ok
6 256 191.8 124.5 1.54× 47.7 26.4 1.81× ok
12 256 200.1 123.1 1.63× 74.7 45.1 1.65× ok
16 256 217.8 121.6 1.79× 96.4 57.8 1.67× ok
32 256 292.8 172.6 1.70× 172.8 109.9 1.57× ok
64 256 446.0 275.8 1.62× 324.4 212.5 1.53× ok
128 256 752.5 482.2 1.56× 628.0 420.0 1.50× ok
256 256 1364.8 894.4 1.53× 1236.0 828.5 1.49× ok
1 512 191.9 122.2 1.57× 29.3 13.7 2.15× ok
3 512 195.9 114.2 1.72× 47.9 26.1 1.83× ok
4 512 200.0 121.9 1.64× 58.3 32.4 1.80× ok
6 512 208.8 120.8 1.73× 75.7 44.8 1.69× ok
12 512 264.7 206.4 1.28× 131.7 82.0 1.61× ok
16 512 305.1 248.2 1.23× 172.6 106.9 1.61× ok
32 512 457.7 269.9 1.70× 325.1 207.8 1.56× ok
64 512 760.9 469.6 1.62× 627.6 410.7 1.53× ok
128 512 1366.9 871.0 1.57× 1233.9 810.9 1.52× ok
256 512 2581.6 1676.6 1.54× 2446.7 1612.5 1.52× ok
1 1024 191.7 126.2 1.52× 39.9 19.9 2.00× ok
3 1024 201.3 117.7 1.71× 76.3 44.5 1.72× ok
4 1024 221.1 123.0 1.80× 96.0 57.1 1.68× ok
6 1024 246.6 139.8 1.76× 132.5 81.6 1.62× ok
12 1024 374.1 225.4 1.66× 245.5 155.8 1.58× ok
16 1024 451.4 278.5 1.62× 324.8 205.2 1.58× ok
32 1024 754.6 542.9 1.39× 626.6 405.8 1.54× ok
64 1024 1367.2 823.6 1.66× 1233.2 804.0 1.53× ok
128 1024 2583.2 1614.2 1.60× 2445.2 1599.1 1.53× ok
256 1024 5000.5 3247.1 1.54× 4872.9 3186.0 1.53× ok
3D dense · dim=4096 — 40 shapes (kernel median 1.40×, e2e median 1.48×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 188.1 151.1 1.25× 23.4 10.4 2.25× ok
3 128 189.6 156.4 1.21× 33.8 17.0 1.99× ok
4 128 192.4 140.1 1.37× 38.8 20.2 1.92× ok
6 128 192.2 121.3 1.58× 44.2 26.5 1.67× ok
12 128 193.4 111.9 1.73× 68.4 46.0 1.49× ok
16 128 215.0 123.9 1.74× 88.2 60.1 1.47× ok
32 128 281.4 205.8 1.37× 153.9 113.3 1.36× ok
64 128 414.3 273.3 1.52× 288.3 216.3 1.33× ok
128 128 682.7 500.4 1.36× 554.6 435.4 1.27× ok
256 128 1219.5 896.3 1.36× 1087.7 838.6 1.30× ok
1 256 198.7 121.9 1.63× 30.5 13.9 2.19× ok
3 256 189.4 121.0 1.57× 46.4 26.2 1.77× ok
4 256 188.8 123.8 1.52× 55.9 32.5 1.72× ok
6 256 196.4 123.5 1.59× 68.7 45.0 1.53× ok
12 256 242.4 145.8 1.66× 118.1 82.8 1.43× ok
16 256 279.5 172.3 1.62× 155.3 109.6 1.42× ok
32 256 414.7 272.2 1.52× 287.5 212.5 1.35× ok
64 256 682.1 479.6 1.42× 553.6 419.3 1.32× ok
128 256 1210.3 902.6 1.34× 1085.0 830.2 1.31× ok
256 256 2272.9 1715.8 1.32× 2149.6 1651.1 1.30× ok
1 512 195.3 118.6 1.65× 36.1 20.1 1.79× ok
3 512 204.0 120.2 1.70× 71.1 44.7 1.59× ok
4 512 220.7 117.5 1.88× 89.1 57.1 1.56× ok
6 512 249.7 136.6 1.83× 118.5 81.9 1.45× ok
12 512 343.9 215.5 1.60× 217.4 156.4 1.39× ok
16 512 416.3 261.7 1.59× 287.4 207.5 1.39× ok
32 512 681.9 472.4 1.44× 552.8 410.4 1.35× ok
64 512 1212.1 871.7 1.39× 1083.8 810.4 1.34× ok
128 512 2281.3 1674.8 1.36× 2147.5 1613.4 1.33× ok
256 512 4405.2 3273.7 1.35× 4272.6 3215.7 1.33× ok
1 1024 198.9 143.8 1.38× 56.0 32.3 1.73× ok
3 1024 254.6 153.1 1.66× 120.8 81.5 1.48× ok
4 1024 286.1 176.1 1.62× 155.8 106.1 1.47× ok
6 1024 351.5 228.8 1.54× 220.3 155.6 1.42× ok
12 1024 548.2 377.2 1.45× 416.9 304.0 1.37× ok
16 1024 684.5 476.1 1.44× 552.6 405.5 1.36× ok
32 1024 1215.7 876.9 1.39× 1082.9 803.5 1.35× ok
64 1024 2278.8 1660.7 1.37× 2146.1 1598.0 1.34× ok
128 1024 4414.2 3340.3 1.32× 4269.4 3187.4 1.34× ok
256 1024 8648.0 6557.6 1.32× 8519.0 6366.1 1.34× ok
3D dense · dim=5120 — 40 shapes (kernel median 2.15×, e2e median 2.13×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 189.5 134.6 1.41× 22.1 11.2 1.97× ok
3 128 195.6 183.4 1.07× 38.5 19.0 2.03× ok
4 128 192.4 145.2 1.32× 46.1 22.9 2.01× ok
6 128 195.0 132.9 1.47× 63.0 30.5 2.06× ok
12 128 238.4 187.4 1.27× 110.8 53.5 2.07× ok
16 128 272.4 132.3 2.06× 146.7 70.5 2.08× ok
32 128 409.4 199.2 2.06× 280.2 134.1 2.09× ok
64 128 679.4 318.2 2.13× 546.6 258.1 2.12× ok
128 128 1208.2 580.1 2.08× 1080.5 520.4 2.08× ok
256 128 2286.6 1066.8 2.14× 2148.4 1006.2 2.13× ok
1 256 189.4 122.5 1.55× 29.2 15.2 1.93× ok
3 256 194.5 121.7 1.60× 63.6 30.2 2.11× ok
4 256 203.7 121.5 1.68× 79.3 37.6 2.11× ok
6 256 237.0 121.1 1.96× 113.7 52.6 2.16× ok
12 256 335.4 157.8 2.13× 212.5 97.9 2.17× ok
16 256 403.1 196.1 2.06× 279.6 130.1 2.15× ok
32 256 666.7 319.6 2.09× 545.7 254.4 2.15× ok
64 256 1200.8 567.8 2.12× 1076.9 501.8 2.15× ok
128 256 2264.2 1058.0 2.14× 2142.2 995.1 2.15× ok
256 256 4403.3 2053.2 2.15× 4271.2 1986.8 2.15× ok
1 512 196.4 117.3 1.67× 46.2 22.9 2.02× ok
3 512 244.9 127.8 1.92× 112.5 52.2 2.15× ok
4 512 280.1 123.8 2.26× 147.8 67.3 2.19× ok
6 512 344.4 154.7 2.23× 212.4 97.0 2.19× ok
12 512 542.4 245.3 2.21× 412.0 186.9 2.21× ok
16 512 671.1 310.9 2.16× 543.9 248.2 2.19× ok
32 512 1201.1 550.0 2.18× 1076.2 492.3 2.19× ok
64 512 2271.8 1033.5 2.20× 2138.5 973.7 2.20× ok
128 512 4397.8 2006.5 2.19× 4264.9 1939.6 2.20× ok
256 512 8648.8 3926.5 2.20× 8519.4 3868.0 2.20× ok
1 1024 208.2 170.4 1.22× 80.1 37.4 2.15× ok
3 1024 340.1 164.3 2.07× 212.1 96.7 2.19× ok
4 1024 408.6 190.8 2.14× 280.6 126.4 2.22× ok
6 1024 541.1 247.7 2.18× 410.4 185.9 2.21× ok
12 1024 941.4 427.0 2.21× 810.9 364.7 2.22× ok
16 1024 1205.8 546.0 2.21× 1075.0 486.6 2.21× ok
32 1024 2275.0 1029.9 2.21× 2139.3 966.9 2.21× ok
64 1024 4418.4 1991.1 2.22× 4262.3 1922.2 2.22× ok
128 1024 8660.2 3906.1 2.22× 8512.2 3836.9 2.22× ok
256 1024 17148.7 7783.4 2.20× 17011.3 7664.6 2.22× ok
3D dense · dim=6144 — 40 shapes (kernel median 1.88×, e2e median 1.90×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 190.1 118.6 1.60× 21.9 12.1 1.81× ok
3 128 192.5 120.1 1.60× 37.1 20.9 1.77× ok
4 128 190.7 119.2 1.60× 49.2 25.7 1.92× ok
6 128 191.0 119.1 1.60× 63.4 34.4 1.85× ok
12 128 238.9 122.1 1.96× 112.7 61.1 1.84× ok
16 128 274.2 139.8 1.96× 147.7 80.8 1.83× ok
32 128 403.9 213.3 1.89× 280.4 154.7 1.81× ok
64 128 690.5 364.1 1.90× 548.6 301.2 1.82× ok
128 128 1211.5 667.7 1.81× 1079.4 604.5 1.79× ok
256 128 2282.4 1238.8 1.84× 2149.7 1173.5 1.83× ok
1 256 189.9 121.2 1.57× 30.3 16.7 1.82× ok
3 256 198.5 121.8 1.63× 62.2 34.0 1.83× ok
4 256 201.8 115.3 1.75× 81.2 42.7 1.90× ok
6 256 242.8 121.2 2.00× 112.8 60.3 1.87× ok
12 256 344.1 171.9 2.00× 213.7 113.3 1.89× ok
16 256 409.6 212.3 1.93× 279.9 150.6 1.86× ok
32 256 676.9 357.1 1.90× 546.3 295.3 1.85× ok
64 256 1209.7 647.8 1.87× 1078.4 583.7 1.85× ok
128 256 2274.1 1218.5 1.87× 2141.5 1159.0 1.85× ok
256 256 4395.1 2383.7 1.84× 4272.7 2319.6 1.84× ok
1 512 197.8 112.0 1.77× 47.4 25.6 1.85× ok
3 512 242.9 116.7 2.08× 112.8 60.0 1.88× ok
4 512 276.5 135.2 2.04× 146.8 77.6 1.89× ok
6 512 343.8 192.2 1.79× 213.3 112.3 1.90× ok
12 512 543.0 273.7 1.98× 410.6 216.9 1.89× ok
16 512 675.2 346.9 1.95× 545.5 289.2 1.89× ok
32 512 1202.9 634.4 1.90× 1075.8 573.0 1.88× ok
64 512 2272.3 1193.4 1.90× 2140.2 1134.7 1.89× ok
128 512 4398.2 2319.3 1.90× 4266.0 2263.2 1.89× ok
256 512 8664.2 4663.9 1.86× 8519.1 4517.9 1.89× ok
1 1024 197.5 116.1 1.70× 79.4 42.6 1.86× ok
3 1024 342.6 177.0 1.94× 212.3 112.0 1.90× ok
4 1024 412.9 209.8 1.97× 278.0 146.6 1.90× ok
6 1024 543.8 276.5 1.97× 411.8 216.1 1.91× ok
12 1024 941.9 484.8 1.94× 808.9 425.0 1.90× ok
16 1024 1160.3 628.0 1.85× 1076.8 567.3 1.90× ok
32 1024 2279.2 1190.4 1.92× 2139.2 1127.9 1.90× ok
64 1024 4393.4 2301.0 1.91× 4263.8 2244.9 1.90× ok
128 1024 8627.3 4548.2 1.90× 8512.4 4481.8 1.90× ok
256 1024 17162.3 9221.9 1.86× 17010.9 8960.5 1.90× ok
varlen / packed · dim=1024 — 40 shapes (kernel median 1.45×, e2e median 1.61×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 198.5 119.0 1.67× 18.1 8.1 2.24× ok
3 128 199.1 115.9 1.72× 21.9 10.2 2.15× ok
4 128 238.1 117.7 2.02× 25.8 12.1 2.13× ok
6 128 190.8 116.6 1.64× 27.6 14.4 1.92× ok
12 128 195.2 117.0 1.67× 35.7 23.1 1.55× ok
16 128 199.8 117.2 1.71× 42.5 28.1 1.51× ok
32 128 199.2 119.9 1.66× 66.4 45.2 1.47× ok
64 128 252.3 140.1 1.80× 119.4 81.5 1.47× ok
128 128 342.7 285.5 1.20× 211.5 146.7 1.44× ok
256 128 516.5 348.4 1.48× 391.9 293.2 1.34× ok
1 256 200.8 155.1 1.29× 16.7 8.7 1.93× ok
3 256 202.2 117.9 1.72× 28.2 15.2 1.86× ok
4 256 198.2 122.3 1.62× 28.4 17.3 1.64× ok
6 256 201.6 123.3 1.64× 37.0 22.8 1.62× ok
12 256 203.0 121.0 1.68× 59.7 38.1 1.57× ok
16 256 186.9 115.3 1.62× 63.7 48.3 1.32× ok
32 256 242.1 138.8 1.75× 115.6 83.7 1.38× ok
64 256 338.6 212.7 1.59× 211.2 158.5 1.33× ok
128 256 535.8 349.6 1.53× 402.6 294.2 1.37× ok
256 256 899.0 653.7 1.38× 755.4 546.7 1.38× ok
1 512 192.3 125.1 1.54× 19.2 8.9 2.17× ok
3 512 195.5 120.5 1.62× 36.2 20.7 1.75× ok
4 512 196.6 122.2 1.61× 42.5 28.7 1.48× ok
6 512 196.3 123.9 1.58× 56.9 39.5 1.44× ok
12 512 207.2 123.5 1.68× 91.4 70.8 1.29× ok
16 512 250.1 155.1 1.61× 118.8 92.2 1.29× ok
32 512 343.5 222.6 1.54× 196.2 159.9 1.23× ok
64 512 531.9 348.4 1.53× 399.9 289.5 1.38× ok
128 512 869.7 588.9 1.48× 738.0 518.8 1.42× ok
256 512 1686.5 1081.5 1.56× 1542.0 1029.2 1.50× ok
1 1024 196.0 122.1 1.60× 28.2 14.5 1.95× ok
3 1024 214.0 120.7 1.77× 47.5 38.2 1.24× ok
4 1024 221.7 122.9 1.80× 72.3 47.5 1.52× ok
6 1024 214.6 127.5 1.68× 91.1 70.0 1.30× ok
12 1024 319.4 258.6 1.24× 190.1 134.9 1.41× ok
16 1024 334.6 210.3 1.59× 197.2 153.2 1.29× ok
32 1024 556.7 382.1 1.46× 430.0 326.1 1.32× ok
64 1024 929.8 658.7 1.41× 792.2 584.2 1.36× ok
128 1024 1682.2 1198.6 1.40× 1553.8 1145.8 1.36× ok
256 1024 3188.4 2081.1 1.53× 3045.6 2026.6 1.50× ok
varlen / packed · dim=2048 — 40 shapes (kernel median 1.33×, e2e median 1.61×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 199.7 114.8 1.74× 19.8 9.7 2.04× ok
3 128 197.8 140.5 1.41× 26.4 14.4 1.83× ok
4 128 198.5 126.3 1.57× 27.5 15.7 1.76× ok
6 128 200.2 121.7 1.65× 32.2 19.9 1.61× ok
12 128 198.4 120.4 1.65× 49.2 34.6 1.42× ok
16 128 199.6 121.3 1.65× 50.6 43.3 1.17× ok
32 128 218.9 130.6 1.68× 88.6 70.7 1.25× ok
64 128 300.2 198.1 1.52× 169.3 134.4 1.26× ok
128 128 466.6 330.8 1.41× 335.8 265.2 1.27× ok
256 128 763.5 580.3 1.32× 635.1 520.3 1.22× ok
1 256 199.3 113.8 1.75× 20.2 10.1 2.00× ok
3 256 205.9 120.3 1.71× 30.6 20.1 1.52× ok
4 256 200.1 119.4 1.68× 43.5 25.6 1.70× ok
6 256 203.2 118.7 1.71× 41.1 29.4 1.40× ok
12 256 219.2 120.7 1.82× 88.3 60.8 1.45× ok
16 256 224.9 135.8 1.66× 100.7 80.5 1.25× ok
32 256 301.1 202.8 1.49× 171.3 143.9 1.19× ok
64 256 444.6 312.7 1.42× 308.2 256.1 1.20× ok
128 256 772.3 528.2 1.46× 636.8 470.9 1.35× ok
256 256 1332.9 955.0 1.40× 1204.9 898.8 1.34× ok
1 512 201.1 110.8 1.81× 32.5 16.6 1.96× ok
3 512 201.7 122.0 1.65× 45.5 27.1 1.68× ok
4 512 199.6 80.2 2.49× 58.4 40.8 1.43× ok
6 512 208.3 121.8 1.71× 75.8 57.9 1.31× ok
12 512 251.9 152.9 1.65× 118.7 106.1 1.12× ok
16 512 314.7 208.7 1.51× 180.1 150.7 1.20× ok
32 512 443.0 354.5 1.25× 308.5 297.8 1.04× ok
64 512 750.9 588.0 1.28× 616.7 523.4 1.18× ok
128 512 1345.5 956.4 1.41× 1211.8 911.3 1.33× ok
256 512 2495.3 1894.4 1.32× 2363.2 1840.6 1.28× ok
1 1024 199.9 118.9 1.68× 38.6 20.3 1.90× ok
3 1024 210.0 120.7 1.74× 71.7 49.6 1.44× ok
4 1024 231.9 129.6 1.79× 101.2 74.4 1.36× ok
6 1024 284.8 168.0 1.70× 133.5 112.0 1.19× ok
12 1024 404.5 282.5 1.43× 257.8 228.1 1.13× ok
16 1024 447.0 330.6 1.35× 314.1 271.6 1.16× ok
32 1024 757.4 621.8 1.22× 628.5 562.4 1.12× ok
64 1024 1392.7 1019.9 1.37× 1263.1 961.2 1.31× ok
128 1024 2528.4 1881.7 1.34× 2396.1 1811.0 1.32× ok
256 1024 5166.8 3769.4 1.37× 5032.0 3710.5 1.36× ok
varlen / packed · dim=4096 — 40 shapes (kernel median 1.20×, e2e median 1.32×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 199.1 118.4 1.68× 23.2 11.1 2.09× ok
3 128 196.6 123.4 1.59× 31.0 20.6 1.50× ok
4 128 201.4 123.6 1.63× 34.7 24.2 1.43× ok
6 128 200.7 121.0 1.66× 44.9 34.9 1.29× ok
12 128 201.0 126.6 1.59× 69.2 62.6 1.10× ok
16 128 215.8 133.2 1.62× 86.2 72.7 1.19× ok
32 128 275.2 182.1 1.51× 146.3 122.4 1.20× ok
64 128 414.7 322.8 1.28× 284.7 258.1 1.10× ok
128 128 683.4 564.6 1.21× 551.0 499.3 1.10× ok
256 128 1199.7 997.7 1.20× 1068.2 941.8 1.13× ok
1 256 200.5 117.7 1.70× 25.5 14.5 1.76× ok
3 256 201.7 115.9 1.74× 48.2 34.0 1.42× ok
4 256 201.2 115.8 1.74× 52.1 34.0 1.53× ok
6 256 202.5 115.5 1.75× 66.0 50.3 1.31× ok
12 256 277.8 165.5 1.68× 146.1 113.2 1.29× ok
16 256 297.5 219.2 1.36× 166.0 156.4 1.06× ok
32 256 414.7 326.1 1.27× 279.5 242.6 1.15× ok
64 256 709.3 557.0 1.27× 571.9 500.9 1.14× ok
128 256 1234.9 969.3 1.27× 1101.9 914.5 1.21× ok
256 256 2362.3 2048.1 1.15× 2232.4 1988.0 1.12× ok
1 512 202.4 121.0 1.67× 29.4 18.0 1.63× ok
3 512 201.1 124.0 1.62× 54.5 40.9 1.33× ok
4 512 231.9 135.0 1.72× 100.2 78.7 1.27× ok
6 512 240.8 187.3 1.29× 109.7 86.1 1.27× ok
12 512 355.0 290.9 1.22× 223.6 219.2 1.02× ok
16 512 419.4 367.3 1.14× 286.6 266.6 1.07× ok
32 512 666.9 504.1 1.32× 535.9 448.7 1.19× ok
64 512 1165.7 958.5 1.22× 1033.2 902.7 1.15× ok
128 512 2338.4 1984.7 1.18× 2208.3 1930.6 1.14× ok
256 512 4360.2 3441.4 1.27× 4225.4 3372.6 1.25× ok
1 1024 198.7 124.0 1.60× 51.7 31.2 1.66× ok
3 1024 252.0 164.2 1.53× 122.5 104.3 1.18× ok
4 1024 305.5 226.5 1.35× 171.3 148.1 1.16× ok
6 1024 309.9 247.8 1.25× 178.0 189.4 0.94× ok
12 1024 581.4 532.0 1.09× 449.9 449.8 1.00× ok
16 1024 685.4 567.8 1.21× 559.2 512.0 1.09× ok
32 1024 1200.5 917.4 1.31× 1067.2 864.1 1.24× ok
64 1024 2239.5 1900.0 1.18× 2108.8 1738.6 1.21× ok
128 1024 4525.9 3739.8 1.21× 4395.4 3679.5 1.20× ok
256 1024 8453.9 6810.9 1.24× 8304.8 6750.4 1.23× ok
varlen / packed · dim=5120 — 40 shapes (kernel median 1.83×, e2e median 1.88×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 197.5 120.6 1.64× 20.9 10.7 1.96× ok
3 128 199.9 123.4 1.62× 36.5 20.8 1.76× ok
4 128 199.6 120.4 1.66× 46.0 27.3 1.68× ok
6 128 202.5 122.8 1.65× 66.3 38.1 1.74× ok
12 128 228.3 126.0 1.81× 93.3 66.7 1.40× ok
16 128 296.2 153.4 1.93× 160.9 94.9 1.69× ok
32 128 408.1 224.8 1.81× 277.4 162.1 1.71× ok
64 128 721.2 375.5 1.92× 587.3 314.2 1.87× ok
128 128 1217.0 646.6 1.88× 1062.3 573.4 1.85× ok
256 128 2298.1 1193.8 1.93× 2167.3 1137.2 1.91× ok
1 256 199.7 120.3 1.66× 28.2 14.1 2.00× ok
3 256 197.7 119.9 1.65× 56.8 30.0 1.89× ok
4 256 211.1 120.7 1.75× 79.7 48.8 1.63× ok
6 256 262.2 136.8 1.92× 132.0 74.2 1.78× ok
12 256 368.3 203.2 1.81× 238.0 141.6 1.68× ok
16 256 412.1 209.3 1.97× 281.0 145.6 1.93× ok
32 256 728.5 389.3 1.87× 598.7 325.9 1.84× ok
64 256 1202.8 620.2 1.94× 1070.6 558.8 1.92× ok
128 256 2338.1 1177.8 1.99× 2199.3 1112.6 1.98× ok
256 256 4621.8 2322.7 1.99× 4485.9 2263.2 1.98× ok
1 512 245.1 123.0 1.99× 44.9 21.5 2.09× ok
3 512 242.8 123.4 1.97× 115.5 66.7 1.73× ok
4 512 276.2 150.8 1.83× 144.2 95.9 1.50× ok
6 512 312.3 187.6 1.67× 180.7 127.9 1.41× ok
12 512 645.1 332.0 1.94× 437.1 269.9 1.62× ok
16 512 752.9 447.6 1.68× 621.9 359.2 1.73× ok
32 512 1221.8 684.1 1.79× 1090.0 623.7 1.75× ok
64 512 2350.0 1160.3 2.02× 2193.8 1109.7 1.98× ok
128 512 4306.6 2132.1 2.02× 4146.4 2073.0 2.00× ok
256 512 8440.1 4188.1 2.02× 8303.0 4135.1 2.01× ok
1 1024 201.1 119.3 1.69× 64.5 30.7 2.10× ok
3 1024 439.9 193.1 2.28× 305.5 138.8 2.20× ok
4 1024 466.9 239.4 1.95× 330.5 181.9 1.82× ok
6 1024 500.2 337.7 1.48× 370.1 274.3 1.35× ok
12 1024 921.7 657.0 1.40× 790.9 508.7 1.55× ok
16 1024 1145.9 678.0 1.69× 1012.7 611.2 1.66× ok
32 1024 2217.2 1256.0 1.76× 2088.7 1196.1 1.75× ok
64 1024 4538.3 2388.9 1.90× 4410.9 2326.4 1.90× ok
128 1024 8495.7 4386.5 1.94× 8368.7 4328.1 1.93× ok
256 1024 16834.9 8304.9 2.03× 16698.6 8235.8 2.03× ok
varlen / packed · dim=6144 — 40 shapes (kernel median 1.58×, e2e median 1.67×)
B seq main_e2e (µs) branch_e2e (µs) e2e× main_ker (µs) branch_ker (µs) ker× ok
1 128 200.3 116.8 1.72× 19.2 11.9 1.61× ok
3 128 206.4 122.3 1.69× 33.8 20.1 1.68× ok
4 128 200.9 146.6 1.37× 50.5 32.5 1.56× ok
6 128 201.1 143.4 1.40× 60.9 44.1 1.38× ok
12 128 253.0 156.3 1.62× 117.6 84.1 1.40× ok
16 128 274.0 161.3 1.70× 137.6 80.5 1.71× ok
32 128 388.2 252.2 1.54× 268.1 189.4 1.42× ok
64 128 694.3 418.8 1.66× 558.8 348.1 1.61× ok
128 128 1245.4 717.4 1.74× 1110.2 655.8 1.69× ok
256 128 2307.0 1477.2 1.56× 2174.3 1415.3 1.54× ok
1 256 200.9 116.3 1.73× 24.2 14.2 1.71× ok
3 256 198.7 118.8 1.67× 61.2 40.4 1.52× ok
4 256 203.2 117.2 1.73× 71.4 56.5 1.26× ok
6 256 228.8 123.2 1.86× 98.2 65.8 1.49× ok
12 256 352.6 214.0 1.65× 222.6 152.1 1.46× ok
16 256 381.2 257.8 1.48× 252.8 196.2 1.29× ok
32 256 698.8 443.1 1.58× 567.1 351.8 1.61× ok
64 256 1229.1 815.1 1.51× 1095.7 748.6 1.46× ok
128 256 2280.9 1300.2 1.75× 2147.0 1235.4 1.74× ok
256 256 4316.5 2721.6 1.59× 4179.1 2657.5 1.57× ok
1 512 202.1 119.3 1.69× 47.2 25.7 1.84× ok
3 512 218.6 122.1 1.79× 89.0 51.8 1.72× ok
4 512 303.9 166.2 1.83× 173.7 106.9 1.62× ok
6 512 531.5 213.6 2.49× 245.4 153.4 1.60× ok
12 512 458.0 371.1 1.23× 442.2 305.4 1.45× ok
16 512 567.3 428.6 1.32× 529.5 372.1 1.42× ok
32 512 1221.2 731.8 1.67× 1070.3 677.9 1.58× ok
64 512 2187.8 1346.7 1.62× 2021.2 1287.3 1.57× ok
128 512 4265.1 2554.5 1.67× 4101.8 2484.7 1.65× ok
256 512 8780.2 5033.9 1.74× 8638.5 4976.0 1.74× ok
1 1024 238.1 123.9 1.92× 107.0 56.6 1.89× ok
3 1024 373.1 223.1 1.67× 240.8 162.7 1.48× ok
4 1024 426.3 290.2 1.47× 296.8 190.5 1.56× ok
6 1024 517.8 332.2 1.56× 387.2 275.0 1.41× ok
12 1024 923.0 672.2 1.37× 792.4 610.2 1.30× ok
16 1024 1093.7 680.3 1.61× 957.4 619.1 1.55× ok
32 1024 2138.7 1278.0 1.67× 2008.4 1227.6 1.64× ok
64 1024 4475.9 2595.1 1.73× 4344.2 2535.0 1.71× ok
128 1024 8498.8 4808.8 1.77× 8359.9 4756.6 1.76× ok
256 1024 17238.0 9468.4 1.82× 17084.0 9410.2 1.81× ok

Reproduce these numbers

The benchmark scripts live in the convolution_benchmarking branch of the fork:

https://github.com/ChristosMatzoros/sgl-kernel-npu/tree/convolution_benchmarking/benchmark/causal_conv1d

Take the two files from that directory — you don't need anything else from that branch:

  • bench_causal_conv1d_compare.py — the benchmark/compare tool
  • compare.md — step-by-step guide (environment setup, build, run, compare)

Then, following compare.md: build main and run it, build this branch and run it, then compare the two result files. Each run auto-detects the op signature (AscendC or PTO), times every shape both ways (e2e + kernel), checks correctness against an fp32 reference, and idle-gates the NPU. Example:

# (in each repo/branch, after building)  see compare.md step 1 for env setup
SGL_KERNEL_SO=<main-build>/.../libsgl_kernel_npu.so   python3 bench_causal_conv1d_compare.py run --label main   --out main.json
SGL_KERNEL_SO=<branch-build>/.../libsgl_kernel_npu.so python3 bench_causal_conv1d_compare.py run --label tiling --out tiling.json
python3 bench_causal_conv1d_compare.py compare main.json tiling.json --csv cmp.csv

ChristosMatzoros and others added 18 commits July 20, 2026 11:31
Replace the depthwise causal conv1d + bias + (optional) SiLU op with a
PTO-ISA tile kernel, built as its own ascendc_library (like mega_chunk_gdn).
The op name and signature are unchanged, so this is a drop-in replacement:
pytorch_extensions.cpp and the Python wrapper are untouched.

Improvements over the previous AscendC kernel:
- faster on the GDN prefill matrix (1.5-5.8x e2e on Ascend 910B2);
- numerically correct at large batch, where the previous kernel raced;
- generic over dim (the previous kernel only supported a fixed dim set).

conv_states / varlen (query_start_loc) / has_initial_state / pad_slot_id
semantics are preserved and verified against the prefill contract test
(tests/python/sgl_kernel_npu/test_conv1d_prefill.py), which also covers the
exact conv_states writeback.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
…guard

- Template the PTO kernel on the filter width K (and per-K tile width MAX_W) and
  compile a dedicated entry per supported width {2,3,4,5,8,16,32,64} x {fp16,bf16};
  the host dispatches by weight.size(0). (Previously width-4 only.)
- Fix a state-writeback race: when the writeback grid has more tasks than cores a
  core reuses its UB tiles across tasks, so the next task's load must wait for the
  previous task's store (MTE3 -> MTE2). conv_states was silently wrong at large
  batch (the common stateful-decode path) before this.
- Guard the GM_ADDR define with clang-format off: PointerAlignment: Right rewrote
  'type* name' to 'type *name', which broke the AscendC launch codegen.
- Tidy the host launcher (compact per-width dispatch, constexpr helpers, comments).

Verified vs an fp32 reference: the prefill contract test (all widths, fp16/bf16,
dense/varlen, initial-state, bias, activation, pad-slot) and a 1024-case
width x dim sweep, all exact (conv_states bit-exact).

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Replace the per-width (K) template with a per-ring-size template (RS = roundUpToPow2(K)) and pass the filter width K as a runtime argument. Six compiled variants {2,4,8,16,32,64} x {fp16,bf16} now serve any width in [2,64] (e.g. 3->rs4, 5/6/7->rs8), replacing the eight per-width entries. The UB layout is sized for the worst case K==RS so every offset stays compile-time (no codegen regression).

Collapse the (RS, MAX_W) set into one X-macro list (CC1D_RS) inlined in the kernel and host; the host forward-declares the launch stubs from it instead of including 24 generated aclrtlaunch headers, and the entry-definition macros are compacted.

Tests: extend the contract test and fp32-reference sweep to non-power-of-two widths (runtime K < RS). Validated on Ascend 910B2: contract test all-pass (conv_states bit-exact), fp32 sweep 0/1664 failures; e2e and kernel-only performance unchanged vs the per-width build.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Move the fp16/bf16 -> fp32 widening of weight/bias from the host
(.to(at::kFloat)) into the kernel: stage the native tiles into the idle
accumulator-region scratch (loads pipeline), one MTE2->V barrier, then
pipelined TCVT into the resident fp32 tiles. Matches the main/PR-555 pattern
(cast on device) and drops two per-call host cast launches.

Numerically identical (bit-exact vs fp32 ref; 1664-case sweep + contract test
pass for fp16/bf16). Faster: up to ~2.1x e2e at small batch and 1.02-1.19x
kernel-only, tied at large batch. Also adds bias dtype/shape validation.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Unify the per-sequence row-index/length space as int32 (start, len, l0, l1,
cacheIdx) and add a signed halo = K-1, so the signed<->unsigned cast churn in
the index/halo/offset arithmetic disappears. Also drop the redundant bitmask
casts (the & already converts a non-negative operand), consolidate the lanes
ternary, and remove the dead `len` parameter from convChunk. Explicit casts
40 -> 16; the rest are load-bearing (uint64_t offset-overflow guards, the halo
derivation, (int32_t)k, lanes).

Bit-exact vs the fp32 reference (contract + 1664-case sweep pass, fp16/bf16)
and perf-neutral (kernel-only TaskDur tied with the prior commit on all shapes).

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Format the PTO kernel/host to the repo clang-format style (csrc/.clang-format)
so `pre-commit run --all-files` (CI lint) passes. No functional change: the
GM_ADDR / launch-stub regions stay under `// clang-format off` because their
pointer glueing is required by the AscendC launch codegen. Rebuild confirms all
24 kernel entries still compile; whitespace-only, so numerics are unchanged.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Signed-off-by: Raphael Steiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
Signed-off-by: raphaelsteiner <raphael.steiner@huawei.com>
…ode/num_accepted)

sgl-project#592 replaced this op with the AscendC kernel and changed the registered
schema (added num_accepted_tokens + run_mode, made activation_mode an int).
The PTO kernel this PR restores uses the original signature — bias as an
optional after the required index tensors, bool activation_mode, no run_mode —
so update pytorch_extensions.cpp to match. Callers on sgl-project#592's signature (with
run_mode) must adapt; the Python wrapper and other ops are untouched.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the causal_conv1d NPU kernel and host-side implementation by replacing the legacy AscendC code with a new implementation based on the PTO tile ISA, simplifying the dispatch logic and removing several obsolete files. The code review highlights several critical correctness and robustness issues: in the kernel, negative index loading when hasInit is false can read stale history or uninitialized memory, requiring dummy loads and zeroing; on the host side, the defined MIN_CHUNK_ROWS constant is unused, leading to excessive sequence chunking overhead; there is a lack of validation for input tensor sizes (query_start_loc, cache_indices, and has_initial_state) which could cause underflows or out-of-bounds reads; and finally, the PyTorch extension wrapper needs explicit type casting for default integer and boolean tensors to prevent strict type assertion failures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread csrc/causal_conv1d/op_kernel/causal_conv1d.cpp
Comment thread csrc/causal_conv1d/op_kernel/causal_conv1d.cpp
Comment thread csrc/causal_conv1d/op_kernel/causal_conv1d.cpp
Comment thread csrc/causal_conv1d/op_host/causal_conv1d.cpp
Comment thread csrc/causal_conv1d/op_host/causal_conv1d.cpp
Comment thread csrc/causal_conv1d/op_host/causal_conv1d.cpp
Comment thread csrc/pytorch_extensions.cpp
Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
@ChristosMatzoros

ChristosMatzoros commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

All points addressed:

  • Kernel !hasInit stale-history read (1–3): rather than zeroing loaded history, we clamp the per-sequence chunk length to ≥ K−1, so no non-first chunk can start inside the causal halo. The conv_states load is then only reachable for the first chunk with has_initial_state (correct), for both 3D and varlen, matching how the AscendC kernel this replaces already handles it. It's also perf-neutral (see below).
  • Unused MIN_CHUNK_ROWS (4): removed the dead constant. Deliberately not wired as a chunk-size floor , that caps parallelism at low batch (e.g. 43→4 cores at B=1, seq=128), regressing this kernel's main advantage. The clamp above already prevents the degenerate tiny chunks that motivated the concern.
  • Input validation (5–6): added TORCH_CHECKs — query_start_loc must be 1D with ≥2 elements (varlen), and cache_indices/has_initial_state must be 1D with size ≥ batch — plus tests.
  • Wrapper dtype casts (7): the wrapper now casts query_start_loc/cache_indices → int32 and has_initial_state → bool, and makes bias contiguous (all no-ops when already correct), plus a test.

Correctness & perf: unit tests + 656/656 fp32-reference configs pass; a 400-shape kernel-time A/B (this branch vs the pre-fix commit) gives geomean 1.00× (0/400 shapes outside ±2%). No performance change.

Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
Signed-off-by: Christos Konstantinos Matzoros <christos.konstantinos.matzoros@h-partners.com>
@ChristosMatzoros

ChristosMatzoros commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Performance evaluation on A5 & A2A3 against main

Depends on #663. The A5 path uses TMULADDDST, which is not in the currently pinned pto-isa. Without that PR merged, A5 builds fail with "use of undeclared identifier 'TMULADDDST'". A2/A3 builds are unaffected.


Part 1 — A5

Complete measurements on A5 hardware.

What changed

  • causal_conv1d.cpp — the scatter accumulate becomes one fused TMULADDDST instead of a TMUL
    into a temp, a barrier, then a TADD. Per input row at K=4: 5 vector ops instead of 8; the
    RS-1 temp tiles and that barrier both disappear.

Setup

Device Ascend950 (A5, dav-c310)
Grid dim ∈ {3072, 4096, 5120, 12288} × seq ∈ {128, 256, 512} × batch ∈ {1,2,4,8,16,32,64,128,256,512,1024} = 132

Effect by shape

Kernel geomean, grouped three ways.

batchkernel
11.342×
21.257×
41.200×
81.156×
161.128×
321.113×
641.108×
1281.107×
2561.107×
5121.105×
10241.114×
dimshapeskernele2e
3072331.120×1.256×
4096331.089×1.189×
5120331.394×1.485×
12288321.048×1.130×
seqshapeskernel
128431.175×
256441.153×
512441.141×

All shapes

Kernel µs is the geometric mean of 100 profiled iterations.

dim = 3072 — 33 shapes, kernel geomean 1.120× · e2e geomean 1.256×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 17.8 11.0 1.616 59.9 51.7 1.160
128 2 19.4 14.1 1.382 63.2 36.1 1.749
128 8 29.4 24.2 1.211 61.6 40.4 1.523
128 16 42.9 38.1 1.126 129.4 57.3 2.260
128 32 69.4 65.8 1.055 103.2 108.4 0.953
128 64 125.2 121.2 1.033 179.5 137.4 1.306
128 128 235.2 228.4 1.030 263.9 243.5 1.084
128 256 454.3 441.5 1.029 486.8 457.3 1.065
128 512 890.0 869.1 1.024 922.3 883.8 1.044
128 1024 1761.5 1724.2 1.022 1796.3 1739.2 1.033
256 1 19.4 13.9 1.400 59.8 33.5 1.784
256 2 22.5 17.2 1.305 58.8 35.0 1.681
256 4 29.2 23.8 1.229 60.8 39.7 1.529
256 8 42.5 37.2 1.142 73.0 51.8 1.409
256 16 69.3 64.1 1.082 100.7 81.5 1.235
256 32 125.3 118.1 1.061 156.8 134.0 1.170
256 64 233.3 226.9 1.028 322.7 241.6 1.336
256 128 449.6 437.8 1.027 482.1 452.3 1.066
256 256 882.4 860.3 1.026 914.3 875.0 1.045
256 512 1745.4 1705.9 1.023 1777.4 1722.0 1.032
256 1024 3479.1 3397.2 1.024 3517.9 3413.7 1.031
512 1 22.6 16.9 1.334 59.7 34.2 1.744
512 2 29.1 23.6 1.234 61.8 37.9 1.633
512 4 42.6 36.8 1.158 76.6 51.3 1.494
512 8 69.2 63.3 1.094 105.7 77.8 1.358
512 16 123.4 116.5 1.059 156.0 131.9 1.183
512 32 233.0 223.2 1.044 267.9 238.5 1.123
512 64 448.5 435.7 1.029 480.3 454.4 1.057
512 128 878.1 855.3 1.027 909.8 871.5 1.044
512 256 1745.9 1695.0 1.030 1777.9 1710.0 1.040
512 512 3460.0 3375.6 1.025 3493.7 3392.7 1.030
512 1024 6907.4 6737.0 1.025 6945.2 6768.9 1.026
dim = 4096 — 33 shapes, kernel geomean 1.089× · e2e geomean 1.189×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 18.2 11.9 1.532 61.4 34.0 1.806
128 2 20.4 15.2 1.346 53.5 46.5 1.150
128 4 24.3 19.4 1.252 54.5 45.2 1.207
128 8 32.6 27.9 1.169 63.4 48.8 1.299
128 16 48.9 45.2 1.083 81.1 58.8 1.379
128 32 82.2 79.7 1.032 112.9 100.2 1.127
128 64 151.5 149.2 1.015 180.9 165.5 1.093
128 128 287.1 284.1 1.010 316.3 300.9 1.051
128 256 555.0 553.3 1.003 585.5 571.0 1.025
128 512 1093.0 1093.5 1.000 1122.3 1110.5 1.011
128 1024 2167.8 2173.9 0.997 2197.2 2191.8 1.002
256 1 20.2 14.9 1.354 53.1 35.1 1.515
256 2 24.4 19.0 1.279 54.5 36.7 1.486
256 4 32.4 27.5 1.180 62.8 45.1 1.391
256 8 49.1 44.4 1.107 79.4 62.3 1.275
256 16 81.9 78.1 1.049 112.4 97.2 1.157
256 32 150.6 146.0 1.032 180.3 161.3 1.118
256 64 284.4 282.2 1.008 376.6 297.1 1.267
256 128 551.2 549.0 1.004 580.2 565.0 1.027
256 256 1086.0 1082.5 1.003 1116.6 1098.6 1.016
256 512 2150.7 2150.4 1.000 2189.1 2171.1 1.008
256 1024 4280.0 4287.4 0.998 4309.6 4307.0 1.001
512 1 24.2 18.9 1.285 60.5 36.0 1.683
512 2 32.5 27.2 1.194 65.9 41.7 1.582
512 4 49.0 44.0 1.112 106.4 62.6 1.699
512 8 82.8 77.3 1.071 115.7 92.9 1.246
512 16 148.3 144.3 1.028 181.7 160.9 1.129
512 32 284.6 278.8 1.021 317.1 295.5 1.073
512 64 548.3 546.0 1.004 582.0 560.5 1.038
512 128 1079.8 1075.9 1.004 1116.6 1093.0 1.022
512 256 2141.2 2137.5 1.002 2174.3 2159.1 1.007
512 512 4266.6 4259.2 1.002 4300.2 4276.6 1.006
512 1024 8513.3 8509.2 1.000 8549.9 8526.4 1.003
dim = 5120 — 33 shapes, kernel geomean 1.394× · e2e geomean 1.485×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 18.5 13.5 1.369 52.7 33.0 1.595
128 2 21.0 16.4 1.281 54.5 40.8 1.336
128 4 29.3 22.4 1.310 59.9 37.8 1.582
128 8 45.8 34.5 1.325 76.4 56.5 1.353
128 16 78.8 59.0 1.337 109.6 74.2 1.476
128 32 144.9 107.6 1.347 175.7 123.8 1.419
128 64 281.7 200.4 1.406 314.3 233.9 1.344
128 128 549.5 386.6 1.422 578.5 402.8 1.436
128 256 1084.1 759.2 1.428 1118.9 780.9 1.433
128 512 2153.3 1504.4 1.431 2182.5 1522.4 1.434
128 1024 4292.3 2995.8 1.433 4323.9 3015.9 1.434
256 1 21.1 16.2 1.296 54.1 31.4 1.724
256 2 29.2 21.9 1.338 61.7 37.0 1.667
256 4 45.8 33.6 1.361 76.7 48.1 1.594
256 8 78.7 57.2 1.376 109.7 72.3 1.518
256 16 145.2 104.4 1.391 175.1 119.0 1.472
256 32 279.9 199.3 1.404 310.7 213.5 1.456
256 64 546.0 383.2 1.425 578.7 398.0 1.454
256 128 1077.5 751.2 1.434 1107.0 765.9 1.445
256 256 2140.3 1488.0 1.438 2170.4 1504.5 1.443
256 512 4265.2 2962.2 1.440 4299.0 2980.1 1.443
256 1024 8519.8 5909.1 1.442 8551.1 5930.6 1.442
512 1 29.3 21.8 1.341 63.2 37.1 1.703
512 2 45.8 33.2 1.379 80.2 48.6 1.650
512 4 78.7 56.4 1.396 111.8 71.5 1.565
512 8 144.6 102.8 1.406 178.9 119.0 1.504
512 16 280.0 196.1 1.428 312.1 213.7 1.460
512 32 544.4 381.6 1.426 576.3 398.0 1.448
512 64 1073.7 746.9 1.437 1106.8 765.9 1.445
512 128 2133.0 1478.5 1.443 2198.6 1495.6 1.470
512 256 4251.4 2941.7 1.445 4291.8 2959.8 1.450
512 512 8492.8 5869.8 1.447 8534.0 5888.4 1.449
512 1024 16974.9 11724.6 1.448 17011.1 11743.5 1.449
dim = 12288 — 32 shapes, kernel geomean 1.048× · e2e geomean 1.130×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 22.0 17.2 1.280 53.2 35.9 1.482
128 2 28.7 23.5 1.218 58.9 38.3 1.538
128 4 41.5 37.3 1.113 72.2 55.1 1.309
128 8 66.4 65.6 1.011 99.0 81.1 1.221
128 16 119.4 116.2 1.028 150.9 132.8 1.137
128 32 222.9 218.7 1.019 253.7 233.9 1.084
128 64 427.2 418.7 1.020 458.2 451.5 1.015
128 128 835.0 823.2 1.014 864.9 841.4 1.028
128 256 1649.4 1633.4 1.010 1681.9 1651.5 1.018
128 512 3280.6 3254.7 1.008 3314.1 3275.0 1.012
256 1 28.6 23.4 1.218 58.6 38.6 1.517
256 2 41.5 36.8 1.128 72.1 52.0 1.386
256 4 66.2 63.5 1.043 96.4 78.9 1.222
256 8 117.3 114.8 1.022 149.9 129.9 1.154
256 16 221.4 217.5 1.018 250.3 232.8 1.075
256 32 424.6 418.0 1.016 454.0 433.4 1.048
256 64 829.1 815.8 1.016 858.2 832.9 1.030
256 128 1640.1 1616.2 1.015 1670.6 1632.1 1.024
256 256 3260.8 3218.7 1.013 3317.6 3236.9 1.025
256 512 6506.3 6421.8 1.013 6540.4 6438.1 1.016
256 1024 12998.5 12835.3 1.013 13040.6 12871.1 1.013
512 1 41.4 36.3 1.140 75.4 52.0 1.451
512 2 66.5 63.7 1.045 99.8 79.7 1.253
512 4 119.1 116.2 1.025 151.4 132.8 1.140
512 8 221.8 215.5 1.029 256.5 231.3 1.109
512 16 423.7 416.8 1.017 455.1 432.8 1.051
512 32 826.8 814.1 1.016 860.2 831.2 1.035
512 64 1634.4 1606.3 1.017 1701.9 1624.0 1.048
512 128 3249.2 3198.9 1.016 3291.0 3216.8 1.023
512 256 6485.6 6385.1 1.016 6522.3 6406.7 1.018
512 512 12956.8 12756.1 1.016 12992.9 12774.7 1.017
512 1024 25908.3 25499.2 1.016 25942.3 25523.7 1.016

Part 2 — Ascend910B2

Effect by shape

Kernel & e2e geomean, grouped three ways.

batchkernel
11.898×
21.825×
41.753×
81.691×
161.631×
321.580×
641.561×
1281.546×
2561.549×
5121.558×
10241.584×
dimshapeskernele2e
3072331.626×1.574×
4096331.482×1.462×
5120332.128×1.911×
12288321.436×1.442×
seqshapeskernel
128441.658×
256441.650×
512431.638×

All shapes

Kernel & E2E µs are the geometric mean of 100 profiled/timed iterations.

dim = 3072 — 33 shapes, kernel geomean 1.626× · e2e geomean 1.574×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 21.9 9.8 2.227 214.5 129.7 1.654
128 2 26.1 12.3 2.114 212.1 133.9 1.583
128 4 32.5 17.2 1.892 214.7 133.7 1.607
128 8 46.5 26.2 1.772 196.5 123.7 1.589
128 16 74.3 44.0 1.690 204.8 156.8 1.306
128 32 127.3 81.7 1.559 268.9 147.2 1.826
128 64 230.6 155.5 1.483 372.1 221.9 1.676
128 128 439.8 302.6 1.454 570.3 369.5 1.544
128 256 859.2 604.6 1.421 991.0 670.7 1.477
128 512 1701.5 1174.4 1.449 1830.3 1239.5 1.477
128 1024 3384.1 2339.4 1.447 3528.6 2411.0 1.464
256 1 25.4 12.2 2.083 193.3 120.2 1.608
256 2 33.0 17.0 1.936 196.4 122.7 1.601
256 4 46.5 26.1 1.779 197.4 130.2 1.516
256 8 77.9 43.3 1.800 206.3 128.3 1.607
256 16 132.3 78.7 1.681 267.0 145.1 1.840
256 32 229.8 151.3 1.519 360.9 213.8 1.688
256 64 439.9 295.9 1.486 579.4 363.1 1.596
256 128 856.6 585.3 1.463 985.5 647.5 1.522
256 256 1693.6 1158.4 1.462 1834.5 1221.5 1.502
256 512 3368.2 2318.9 1.452 3509.6 2389.3 1.469
256 1024 6719.2 4576.6 1.468 6870.2 4653.0 1.476
512 1 32.5 16.9 1.929 197.7 126.0 1.569
512 2 46.0 25.9 1.774 200.3 122.1 1.640
512 4 71.9 43.1 1.666 203.4 123.5 1.648
512 8 124.8 78.2 1.597 255.1 144.0 1.771
512 16 230.0 147.9 1.555 360.0 213.8 1.684
512 32 439.4 289.9 1.516 577.3 361.7 1.596
512 64 855.8 573.5 1.492 981.6 643.6 1.525
512 128 1690.8 1135.7 1.489 1833.2 1203.6 1.523
512 256 3359.7 2262.0 1.485 3504.6 2336.8 1.500
512 512 6705.9 4514.8 1.485 6882.8 4595.6 1.498
512 1024 13391.5 9045.1 1.481 13561.0 9126.6 1.486
dim = 4096 — 33 shapes, kernel geomean 1.482× · e2e geomean 1.462×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 22.7 10.6 2.143 199.3 129.0 1.545
128 2 28.8 14.0 2.051 197.3 127.5 1.548
128 4 39.8 20.5 1.943 199.7 126.2 1.583
128 8 57.0 33.5 1.706 232.7 125.7 1.852
128 16 90.5 60.5 1.496 216.6 130.8 1.655
128 32 155.7 113.6 1.370 275.7 175.8 1.568
128 64 289.7 217.8 1.331 414.0 287.6 1.439
128 128 559.3 438.6 1.275 682.2 508.2 1.342
128 256 1089.3 840.2 1.296 1207.0 911.1 1.325
128 512 2158.6 1670.8 1.292 2286.6 1735.2 1.318
128 1024 4303.2 3255.6 1.322 4433.5 3325.7 1.333
256 1 28.8 14.2 2.030 213.3 125.2 1.704
256 2 37.8 20.4 1.851 189.5 127.5 1.486
256 4 54.8 32.6 1.680 188.5 130.0 1.450
256 8 88.1 58.0 1.520 206.6 134.2 1.540
256 16 155.0 109.9 1.410 272.0 179.4 1.516
256 32 290.1 212.7 1.364 409.3 279.9 1.462
256 64 558.7 419.3 1.332 680.2 485.8 1.400
256 128 1088.6 830.0 1.312 1202.0 893.7 1.345
256 256 2152.1 1651.0 1.304 2279.6 1719.6 1.326
256 512 4282.2 3265.4 1.311 4422.5 3332.9 1.327
256 1024 8547.9 6423.9 1.331 8680.9 6490.6 1.337
512 1 37.4 20.5 1.824 189.9 124.1 1.531
512 2 54.2 32.6 1.664 192.3 124.0 1.551
512 4 87.5 57.3 1.526 211.1 125.6 1.680
512 8 154.5 107.3 1.440 277.9 170.5 1.630
512 16 287.4 207.9 1.383 409.8 274.1 1.495
512 32 554.8 410.6 1.351 677.1 476.8 1.420
512 64 1086.8 811.3 1.340 1206.8 881.8 1.369
512 128 2152.0 1614.8 1.333 2276.3 1688.0 1.348
512 256 4273.9 3214.8 1.329 4409.9 3295.4 1.338
512 512 8528.2 6431.2 1.326 8665.3 6500.5 1.333
512 1024 17042.7 12761.2 1.336 17183.4 12857.2 1.336
dim = 5120 — 33 shapes, kernel geomean 2.128× · e2e geomean 1.911×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 20.8 11.2 1.866 202.3 132.3 1.529
128 2 30.0 15.3 1.965 194.7 138.8 1.402
128 4 45.8 23.0 1.995 189.7 132.7 1.430
128 8 79.6 38.1 2.088 195.9 134.1 1.462
128 16 147.6 70.5 2.094 266.7 142.8 1.868
128 32 279.8 134.0 2.088 403.8 203.4 1.986
128 64 547.8 257.8 2.125 670.3 323.2 2.074
128 128 1079.2 520.6 2.073 1201.3 593.2 2.025
128 256 2148.9 1006.8 2.134 2276.7 1075.3 2.117
128 512 4285.8 2005.2 2.137 4424.8 2077.8 2.130
128 1024 8563.0 3910.6 2.190 8702.6 3987.1 2.183
256 1 30.4 15.3 1.988 188.9 125.4 1.506
256 2 47.0 22.9 2.051 190.8 129.9 1.470
256 4 80.8 37.6 2.147 208.5 127.2 1.639
256 8 147.5 67.8 2.176 269.9 136.5 1.976
256 16 280.5 130.2 2.155 400.2 198.2 2.019
256 32 545.3 254.1 2.146 662.6 323.6 2.048
256 64 1078.2 500.9 2.152 1196.5 566.3 2.113
256 128 2141.7 993.4 2.156 2256.7 1070.5 2.108
256 256 4271.9 1984.1 2.153 4418.1 2056.6 2.148
256 512 8533.3 3920.5 2.177 8670.2 3989.1 2.173
256 1024 17056.8 7730.6 2.206 17195.5 7810.1 2.202
512 1 48.6 22.8 2.129 194.9 130.5 1.493
512 2 78.7 37.5 2.100 199.5 132.1 1.511
512 4 147.3 67.4 2.186 265.4 133.6 1.987
512 8 278.0 127.0 2.189 394.4 196.2 2.010
512 16 544.9 248.5 2.193 667.6 316.7 2.108
512 32 1077.6 492.0 2.190 1204.8 557.5 2.161
512 64 2140.4 974.5 2.196 2259.2 1042.1 2.168
512 128 4265.9 1940.4 2.198 4403.4 2020.0 2.180
512 256 8518.5 3869.1 2.202 8654.2 3946.8 2.193
512 512 17028.0 7742.5 2.199 17171.0 7823.2 2.195
512 1024 34044.3 15380.0 2.214 34203.0 15484.9 2.209
dim = 12288 — 32 shapes, kernel geomean 1.436× · e2e geomean 1.442×
seq batch main kernel µs ours kernel µs kernel × main E2E µs ours E2E µs E2E ×
128 1 26.9 16.6 1.621 199.7 139.2 1.434
128 2 40.3 25.6 1.574 202.0 132.9 1.520
128 4 63.9 43.2 1.481 197.4 132.3 1.492
128 8 114.8 80.7 1.423 235.4 149.3 1.576
128 16 215.0 154.4 1.392 343.2 226.6 1.515
128 32 415.2 300.9 1.380 539.7 372.2 1.450
128 64 815.8 604.1 1.350 941.8 669.8 1.406
128 128 1615.2 1174.0 1.376 1738.0 1243.4 1.398
128 256 3219.0 2337.7 1.377 3341.6 2408.6 1.387
128 512 6425.4 4564.0 1.408 6538.7 4637.8 1.410
128 1024 12838.3 9120.3 1.408 12958.8 9198.5 1.409
256 1 40.1 25.5 1.572 179.6 123.0 1.460
256 2 64.7 42.7 1.515 181.9 127.1 1.432
256 4 115.6 77.9 1.484 230.1 145.2 1.584
256 8 214.7 150.6 1.426 329.4 215.8 1.527
256 16 414.4 294.8 1.406 530.0 363.3 1.459
256 32 812.6 582.8 1.394 925.7 652.2 1.419
256 64 1611.9 1158.8 1.391 1725.6 1232.4 1.400
256 128 3208.6 2318.5 1.384 3351.0 2392.7 1.401
256 256 6406.0 4575.7 1.400 6527.1 4664.1 1.399
256 512 12800.6 9031.7 1.417 12955.5 9109.4 1.422
256 1024 25585.8 18059.5 1.417 25716.7 18166.0 1.416
512 1 65.3 42.6 1.533 185.9 148.3 1.254
512 2 114.1 77.5 1.472 231.0 152.9 1.511
512 4 215.0 147.1 1.461 335.5 222.8 1.506
512 8 412.7 289.1 1.428 527.2 362.1 1.456
512 16 811.8 573.0 1.417 926.6 642.1 1.443
512 32 1610.4 1135.9 1.418 1728.2 1211.5 1.426
512 64 3204.6 2262.5 1.416 3332.1 2336.7 1.426
512 128 6396.3 4517.8 1.416 6536.6 4601.1 1.421
512 256 12777.3 9044.1 1.413 12930.2 9124.0 1.417
512 512 25542.6 17969.8 1.421 25698.0 18060.6 1.423

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance regression in causal_conv1d

2 participants