| 1 | # Sparse MLA benchmark: forward_mha vs forward_mqa crossover plot |
| 2 | # |
| 3 | # Dense pure-prefill sweep to generate a smooth speedup curve. The 100 points |
| 4 | # run from q32 through q262144, approximately even on the log2 scale, and include |
| 5 | # routing boundaries plus extra samples around the 6k-8k crossover region. |
| 6 | # Dense MHA is only benchmarked through q32768 because it dominates runtime above |
| 7 | # that range. |
| 8 | # |
| 9 | # Usage: |
| 10 | # python benchmark.py --config configs/mla_sparse_mha_vs_mqa.yaml |
| 11 | |
| 12 | mode: mha_vs_mqa |
| 13 | |
| 14 | model: |
| 15 | name: "deepseek-v3" |
| 16 | num_layers: 60 |
| 17 | num_q_heads: 16 |
| 18 | num_kv_heads: 1 |
| 19 | head_dim: 576 |
| 20 | kv_lora_rank: 512 |
| 21 | qk_nope_head_dim: 128 |
| 22 | qk_rope_head_dim: 64 |
| 23 | v_head_dim: 128 |
| 24 | block_size: 128 |
| 25 | max_model_len: 262144 |
| 26 | |
| 27 | batch_specs: |
| 28 | - "q32" |
| 29 | - "q36" |
| 30 | - "q40" |
| 31 | - "q45" |
| 32 | - "q50" |
| 33 | - "q56" |
| 34 | - "q62" |
| 35 | - "q70" |
| 36 | - "q78" |
| 37 | - "q87" |
| 38 | - "q97" |
| 39 | - "q109" |
| 40 | - "q122" |
| 41 | - "q136" |
| 42 | - "q152" |
| 43 | - "q170" |
| 44 | - "q190" |
| 45 | - "q212" |
| 46 | - "q237" |
| 47 | - "q255" |
| 48 | - "q256" |
| 49 | - "q257" |
| 50 | - "q265" |
| 51 | - "q296" |
| 52 | - "q331" |
| 53 | - "q370" |
| 54 | - "q413" |
| 55 | - "q462" |
| 56 | - "q516" |
| 57 | - "q577" |
| 58 | - "q645" |
| 59 | - "q721" |
| 60 | - "q806" |
| 61 | - "q901" |
| 62 | - "q1007" |
| 63 | - "q1125" |
| 64 | - "q1257" |
| 65 | - "q1405" |
| 66 | - "q1571" |
| 67 | - "q1756" |
| 68 | - "q1962" |
| 69 | - "q2048" |
| 70 | - "q2049" |
| 71 | - "q2193" |
| 72 | - "q2451" |
| 73 | - "q2740" |
| 74 | - "q3062" |
| 75 | - "q3422" |
| 76 | - "q3825" |
| 77 | - "q4275" |
| 78 | - "q4778" |
| 79 | - "q5340" |
| 80 | - "q5854" |
| 81 | - "q5969" |
| 82 | - "q6000" |
| 83 | - "q6144" |
| 84 | - "q6367" |
| 85 | - "q6671" |
| 86 | - "q6925" |
| 87 | - "q7168" |
| 88 | - "q7456" |
| 89 | - "q7532" |
| 90 | - "q8192" |
| 91 | - "q8193" |
| 92 | - "q8333" |
| 93 | - "q9314" |
| 94 | - "q10410" |
| 95 | - "q11635" |
| 96 | - "q13004" |
| 97 | - "q14534" |
| 98 | - "q16244" |
| 99 | - "q18156" |
| 100 | - "q20292" |
| 101 | - "q22680" |
| 102 | - "q25349" |
| 103 | - "q28332" |
| 104 | - "q31665" |
| 105 | - "q32768" |
| 106 | - "q32769" |
| 107 | - "q35391" |
| 108 | - "q39556" |
| 109 | - "q44210" |
| 110 | - "q49413" |
| 111 | - "q55227" |
| 112 | - "q61726" |
| 113 | - "q65536" |
| 114 | |
| 115 | backends: |
| 116 | - FLASHMLA_SPARSE |
| 117 | |
| 118 | device: "cuda:0" |
| 119 | profile_memory: true |
| 120 | sparse_mla_dense_mha_max_seq_len: 25349 |
| 121 | sparse_mla_masked_mha_max_seq_len: 8192 |
| 122 | sparse_mla_mha_variants: ["dense_mha", "masked_mha", "mqa"] |
| 123 | sparse_mla_topk_pattern: "random" |