Skip to content

SSM

7 ops, 36 workloads.

One table per op, one row per workload. Ratio is the fastest other implementation's device time divided by ours, so green is faster than it, plain is level with it, red is slower. Times are in ms. How these numbers are taken.

Mamba2Fwd

x: [Bsz, S, H, P]dt: [Bsz, S, H], f32A: [H], f32B, C: [Bsz, S, G, N]

  • mamba2-2p7bx: [1, 2048, 80, 64]dt: [1, 2048, 80], f32A: [80], f32B, C: [1, 2048, 1, 128]dtype=bf16
  • mamba2-1p3bx: [1, 8192, 64, 64]dt: [1, 8192, 64], f32A: [64], f32B, C: [1, 8192, 1, 128]dtype=f16

x: [Bsz, S, H, P]dt: [Bsz, S, H], f32A, dt_bias: [H], f32B, C: [Bsz, S, G, N]

  • mamba2-2p7b-dt-biasx: [1, 2048, 80, 64]dt: [1, 2048, 80], f32A, dt_bias: [80], f32B, C: [1, 2048, 1, 128]dtype=bf16
  • mamba2-1p3b-dt-biasx: [1, 8192, 64, 64]dt: [1, 8192, 64], f32A, dt_bias: [64], f32B, C: [1, 8192, 1, 128]dtype=f16

x: [Bsz, S, H, P]dt: [Bsz, S, H], f32A: [H], f32B, C: [Bsz, S, G, N]initial_states: [Bsz, H, P, N], f32

  • mamba2-2p7b-initx: [1, 2048, 80, 64]dt: [1, 2048, 80], f32A: [80], f32B, C: [1, 2048, 1, 128]initial_states: [1, 80, 64, 128], f32dtype=bf16
  • mamba2-1p3b-initx: [1, 8192, 64, 64]dt: [1, 8192, 64], f32A: [64], f32B, C: [1, 8192, 1, 128]initial_states: [1, 64, 64, 128], f32dtype=f16

x: [Bsz, S, H, P]dt: [Bsz, S, H], f32A, dt_bias: [H], f32B, C: [Bsz, S, G, N]initial_states: [Bsz, H, P, N], f32

  • mamba2-2p7b-dt-bias-initx: [1, 2048, 80, 64]dt: [1, 2048, 80], f32A, dt_bias: [80], f32B, C: [1, 2048, 1, 128]initial_states: [1, 80, 64, 128], f32dtype=bf16
  • mamba2-1p3b-dt-bias-initx: [1, 8192, 64, 64]dt: [1, 8192, 64], f32A, dt_bias: [64], f32B, C: [1, 8192, 1, 128]initial_states: [1, 64, 64, 128], f32dtype=f16
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-2p7bbf161.34×0.1069mamba
torch-compile
torch-ref
0.1433
0.6923
2.1725
76.214%mem
mamba2-1p3bf161.48×0.2863mamba
torch-compile
torch-ref
0.4245
2.0283
6.9406
91.216%mem
mamba2-2p7b-dt-biasbf161.35×0.1068mamba
torch-compile
torch-ref
0.1438
0.6930
2.1734
76.214%mem
mamba2-1p3b-dt-biasf161.48×0.2861mamba
torch-compile
torch-ref
0.4247
2.0229
6.9409
91.316%mem
mamba2-2p7b-initbf161.34×0.1081mamba
torch-compile
torch-ref
0.1448
0.6847
2.1694
75.314%mem
mamba2-1p3b-initf161.48×0.2862mamba
torch-compile
torch-ref
0.4248
2.0262
6.9403
91.216%mem
mamba2-2p7b-dt-bias-initbf161.35×0.1078mamba
torch-compile
torch-ref
0.1455
0.6854
2.1706
75.514%mem
mamba2-1p3b-dt-bias-initf161.48×0.2867mamba
torch-compile
torch-ref
0.4248
2.0227
6.9421
91.116%mem

SSDChunkCumsumFwd

dt: [B, S, H], f32A: [H], f32

chunk_len=256dt_softplus=true

  • mamba2-780mdt: [1, 4096, 48], f32A: [48], f32dtype=f16
  • mamba2-1p3bdt: [8, 2048, 64], f32A: [64], f32dtype=bf16

dt: [B, S, H], f32A, dt_bias: [H], f32

chunk_len=256dt_softplus=true

  • mamba2-780m-dt-biasdt: [1, 4096, 48], f32A, dt_bias: [48], f32dtype=f16
  • mamba2-1p3b-dt-biasdt: [8, 2048, 64], f32A, dt_bias: [64], f32dtype=bf16
  • mamba2-2p7bdt: [2, 32768, 80], f32A, dt_bias: [80], f32dtype=f16
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-780mf161.53×0.00307mamba
torch-compile
torch-ref
0.0047
0.00483
0.0727
0.44814%lat
mamba2-1p3bbf161.48×0.00602mamba
torch-compile
torch-ref
0.00893
0.0114
0.0939
1.2239%lat
mamba2-780m-dt-biasf161.55×0.00307mamba
torch-compile
torch-ref
0.00477
0.0048
0.0754
0.51214%lat
mamba2-1p3b-dt-biasbf161.47×0.00608mamba
torch-compile
torch-ref
0.00893
0.0115
0.0989
1.3838%lat
mamba2-2p7bf161.26×0.0238mamba
torch-compile
torch-ref
0.0301
0.0368
0.2465
1.7649%mem

SSDChunkCouplingFwd

C_mat, B_mat: [B, S, G, N]

chunk_len=256

  • mamba2-780mC_mat, B_mat: [1, 4096, 1, 128]dtype=f16
  • mamba2-2p7bC_mat, B_mat: [4, 2048, 1, 128]dtype=bf16
  • mamba2-grouped-prefillC_mat, B_mat: [3, 3072, 8, 128]dtype=f16
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-780mf161.42×0.0072mamba
torch
0.0102
0.0381
18.613%lat
mamba2-2p7bbf161.36×0.0118mamba
torch
0.0161
0.0532
22.716%lat
mamba2-grouped-prefillf161.80×0.0589mamba
torch
0.1060
0.4685
4128%mem

SSDChunkStateFwd

x: [B, NC * Q, H, P]Bmat: [B, NC * Q, G, N]dt, dA_cumsum: [B, H, NC, Q], f32

  • mamba2-780mx: [1, 4096, 48, 64]Bmat: [1, 4096, 1, 128]dt, dA_cumsum: [1, 48, 16, 256], f32dtype=f16/f32, bf16/f32
  • mamba2-2p7bx: [4, 2048, 80, 64]Bmat: [4, 2048, 1, 128]dt, dA_cumsum: [4, 80, 8, 256], f32dtype=bf16/f32

x: [B, NC * Q, H, P]Bmat: [B, NC * Q, G, N]dt, dA_cumsum: [B, H, NC, Q], f32seq_idx: [B, NC * Q], i32

  • mamba2-780m-seq-idxx: [1, 4096, 48, 64]Bmat: [1, 4096, 1, 128]dt, dA_cumsum: [1, 48, 16, 256], f32seq_idx: [1, 4096], i32dtype=f16/f32, bf16/f32
  • mamba2-1p3bx: [2, 32768, 64, 64]Bmat: [2, 32768, 1, 128]dt, dA_cumsum: [2, 64, 128, 256], f32seq_idx: [2, 32768], i32dtype=f16/f32
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-780mf16/f321.04×0.0238mamba
torch-compile
torch-ref
0.0249
0.6339
8.1111
13649%mem
bf16/f321.11×0.0240mamba
torch-compile
torch-ref
0.0266
0.6782
8.1141
13549%mem
mamba2-2p7bbf16/f321.21×0.0658mamba
torch-compile
torch-ref
0.0798
2.4492
27.0212
16459%mem
mamba2-780m-seq-idxf16/f321.20×0.0289mamba
torch-compile
torch-ref
0.0346
0.7518
8.1288
11241%mem
bf16/f321.01×0.0292mamba
torch-compile
torch-ref
0.0293
0.7894
8.1290
11140%mem
mamba2-1p3bf16/f321.39×0.4532mamba
torch-compile
torch-ref
0.6315
16.9932
172.5820
15255%mem

SSDStatePassingFwd

states: [B, NC, H, N]dA_chunk_cumsum: [B, H, NC], f32

  • mamba2-1p3bstates: [1, 16, 64, 128]dA_chunk_cumsum: [1, 64, 16], f32dtype=f16, bf16
  • mamba2-2p7bstates: [2, 128, 80, 128]dA_chunk_cumsum: [2, 80, 128], f32dtype=f16

states: [B, NC, H, N]dA_chunk_cumsum: [B, H, NC], f32initial_states: [B, H, N], f32

  • mamba2-1p3b-initstates: [1, 16, 64, 128]dA_chunk_cumsum: [1, 64, 16], f32initial_states: [1, 64, 128], f32dtype=f16, bf16

states: [B, NC, H, N]dA_chunk_cumsum: [B, H, NC]initial_states: [B, H, N]

  • mamba2-1p3b-flatstates: [1, 16, 64, 8192]dA_chunk_cumsum: [1, 64, 16]initial_states: [1, 64, 8192]dtype=f32
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-1p3bf162.19×0.00189torch-compile
mamba
torch-ref
0.00413
0.00858
0.1214
0.13910%lat
bf162.10×0.00195torch-compile
mamba
torch-ref
0.0041
0.00854
0.1233
0.1359%lat
mamba2-2p7bf165.71×0.0108mamba
torch-compile
torch-ref
0.0618
0.0921
1.1655
0.48733%mem
mamba2-1p3b-initf161.78×0.00192torch-compile
mamba
torch-ref
0.00342
0.00893
0.1216
0.13710%lat
bf161.78×0.00192torch-compile
mamba
torch-ref
0.00342
0.00896
0.1232
0.13710%lat
mamba2-1p3b-flatf320.95×0.0216torch-compile
mamba
torch-ref
0.0205
0.0218
0.1255
0.77673%mem

SSDChunkScanFwd

x: [B, NC * Q, H, P]cb: [B, NC, G, Q, Q]dA_cumsum: [B, H, NC, Q], f32C: [B, NC * Q, G, N]prev_states: [B, NC, H, P, N], f32dt: [B, H, NC, Q]

  • mamba2-780mx: [1, 4096, 48, 64]cb: [1, 16, 1, 256, 256]dA_cumsum: [1, 48, 16, 256], f32C: [1, 4096, 1, 128]prev_states: [1, 16, 48, 64, 128], f32dt: [1, 48, 16, 256]dtype=f16, bf16
  • mamba2-2p7bx: [4, 2048, 80, 64]cb: [4, 8, 1, 256, 256]dA_cumsum: [4, 80, 8, 256], f32C: [4, 2048, 1, 128]prev_states: [4, 8, 80, 64, 128], f32dt: [4, 80, 8, 256]dtype=bf16
  • mamba2-1p3bx: [2, 32768, 64, 64]cb: [2, 128, 1, 256, 256]dA_cumsum: [2, 64, 128, 256], f32C: [2, 32768, 1, 128]prev_states: [2, 128, 64, 64, 128], f32dt: [2, 64, 128, 256]dtype=f16
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-780mf161.97×0.0722mamba
torch-compile
torch-ref
0.1424
0.5081
1.9714
89.332%mem
bf161.90×0.0760mamba
torch-compile
torch-ref
0.1444
0.5094
1.9712
84.831%mem
mamba2-2p7bbf161.90×0.2369mamba
torch-compile
torch-ref
0.4510
1.6433
6.5487
90.732%mem
mamba2-1p3bf162.01×1.4526mamba
torch-compile
torch-ref
2.9233
9.9604
40.2415
94.634%mem

SSDRecurrentFwd

A: [H, P, N], f32dt: [B, H, P], f32x: [B, H, P]B_in, C_in: [B, G, N]state: [B, H, P, N], f32

  • mamba2-1p3bA: [64, 64, 128], f32dt: [1, 64, 64], f32x: [1, 64, 64]B_in, C_in: [1, 1, 128]state: [1, 64, 64, 128], f32dtype=f16, bf16
  • mamba2-2p7bA: [80, 64, 128], f32dt: [8, 80, 64], f32x: [8, 80, 64]B_in, C_in: [8, 1, 128]state: [8, 80, 64, 128], f32dtype=f16
  • mamba2-780mA: [48, 64, 128], f32dt: [32, 48, 64], f32x: [32, 48, 64]B_in, C_in: [32, 1, 128]state: [32, 48, 64, 128], f32dtype=f16
Workload dtype Ratio Device time Alternatives Throughput SOL Bound
alt / ours ms name ms TFLOP/s of ceiling by
mamba2-1p3bf161.90×0.00397mamba
torch-compile
flashinfer
torch-ref
0.00752
0.00912
0.0136
0.0300
1.0635%lat
bf161.93×0.0039mamba
torch-compile
flashinfer
torch-ref
0.00752
0.00899
0.0136
0.0302
1.0736%lat
mamba2-2p7bf161.37×0.0162mamba
flashinfer
torch-compile
torch-ref
0.0222
0.0285
0.0305
0.1119
2.5962%mem
mamba2-780mf161.24×0.0361mamba
flashinfer
torch-compile
torch-ref
0.0449
0.0467
0.0697
0.2405
2.7963%mem