@@ -123,7 +123,14 @@ def is_supported(self, *args, **kwargs) -> bool:
123123
124124
125125def _select_mla_generation_fmha (
126- monkeypatch , * , sm : int , num_heads : int , seq_len_q : int , fp8_kv : bool , helix : bool
126+ monkeypatch ,
127+ * ,
128+ sm : int ,
129+ num_heads : int ,
130+ seq_len_q : int ,
131+ fp8_kv : bool ,
132+ helix : bool ,
133+ batch_size : int = 4 ,
127134):
128135 """Run FmhaManager._select_mla over [CuteDslMlaFmha, TRTLLM-Gen stub] on CPU."""
129136 from tensorrt_llm ._torch .attention .backends .fmha import cute_dsl_mla
@@ -145,7 +152,6 @@ def _select_mla_generation_fmha(
145152 CuteDslMlaFmha , "_kernel_can_implement" , staticmethod (lambda * args , ** kwargs : (True , "" ))
146153 )
147154
148- batch_size = 4
149155 num_tokens = batch_size * seq_len_q
150156 attn = SimpleNamespace (
151157 num_heads = num_heads ,
@@ -185,6 +191,7 @@ def _select_mla_generation_fmha(
185191 return "cute_dsl_mla" if selected is cute else "trtllm_gen"
186192
187193
194+ @pytest .mark .cpu_only
188195@pytest .mark .parametrize (
189196 "sm, num_heads, seq_len_q, fp8_kv, helix, expected" ,
190197 [
@@ -222,3 +229,34 @@ def test_mla_generation_routes_wide_head_fp8_verify_away_from_trtllm_gen(
222229 )
223230 == expected
224231 )
232+
233+
234+ @pytest .mark .cpu_only
235+ @pytest .mark .parametrize ("sm" , [100 , 103 ])
236+ @pytest .mark .parametrize (
237+ "fp8_kv, batch_size, expected" ,
238+ [
239+ (True , 4 , "trtllm_gen" ),
240+ (True , 7 , "trtllm_gen" ),
241+ (True , 8 , "cute_dsl_mla" ),
242+ (True , 9 , "cute_dsl_mla" ),
243+ (False , 1 , "cute_dsl_mla" ),
244+ (False , 4 , "cute_dsl_mla" ),
245+ ],
246+ )
247+ def test_mla_generation_single_token_batch_threshold (
248+ monkeypatch , sm , fp8_kv , batch_size , expected
249+ ) -> None :
250+ """The measured FP8 batch floor applies at its boundary, without gating BF16."""
251+ assert (
252+ _select_mla_generation_fmha (
253+ monkeypatch ,
254+ sm = sm ,
255+ num_heads = 96 ,
256+ seq_len_q = 1 ,
257+ fp8_kv = fp8_kv ,
258+ helix = False ,
259+ batch_size = batch_size ,
260+ )
261+ == expected
262+ )
0 commit comments