5656#: Number of importable architectures. Pinned so that adding support is a
5757#: deliberate act that also updates the documented support matrix, and so that
5858#: accidentally losing an architecture is a failure rather than a silence.
59- _EXPECTED_SUPPORTED_COUNT = 32
59+ _EXPECTED_SUPPORTED_COUNT = 33
6060
6161# Quantized reachability is separately pinned from float importability. A new
6262# architecture must explicitly prove that its graph exposes packed projection
7777 "granitemoe" ,
7878 "hunyuan-dense" ,
7979 "llama" ,
80- "mamba",
8180 "muse-glimmer" ,
8281 "nemotron" ,
8382 "olmo" ,
@@ -162,11 +161,12 @@ def test_every_float_importable_architecture_has_a_quantized_verdict(self) -> No
162161 if spec .is_importable
163162 }
164163 assert set (actual ) == set (supported_architectures ())
165- assert actual["internlm2"] is Support.REJECTED
164+ rejected = {"internlm2" , "mamba" , "mamba2" }
165+ assert all (actual [arch ] is Support .REJECTED for arch in rejected )
166166 assert all (
167167 verdict is Support .SUPPORTED
168168 for arch , verdict in actual .items ()
169- if arch != "internlm2"
169+ if arch not in rejected
170170 )
171171
172172
@@ -282,16 +282,23 @@ class TestPinnedTensorClosure:
282282 "qwen2moe" ,
283283 "qwen3moe" ,
284284 "granitemoe" ,
285+ "mamba" ,
286+ "mamba2" ,
285287 )
286288
287289 @staticmethod
288290 def _unmapped (architecture : str ) -> list [str ]:
289291 upstream = upstream_architectures ()[architecture ]
290292 unmapped = []
291- for family in upstream.tensor_families:
292- name = family.replace("{bid}", "0") + ".weight"
293+ names = (
294+ tuple ((name , name ) for name in upstream .tensor_names )
295+ if upstream .tensor_names
296+ else tuple ((family + ".weight" , family ) for family in upstream .tensor_families )
297+ )
298+ for pinned_name , label in names :
299+ name = pinned_name .replace ("{bid}" , "0" )
293300 if map_gguf_to_hf_names (name , architecture ) is None and not is_known_skip (name ):
294- unmapped.append(family )
301+ unmapped .append (label )
295302 return unmapped
296303
297304 @pytest .mark .parametrize ("architecture" , _NEW_ARCHITECTURES )
@@ -334,6 +341,83 @@ def test_deleting_expert_mapping_breaks_moe_closure(self) -> None:
334341 moe_mapping ["blk.{bid}.ffn_gate_exps" ] = removed
335342 _build_mapping .cache_clear ()
336343
344+ _RECURRENT_TENSOR_NAMES : ClassVar [dict [str , set [str ]]] = {
345+ "mamba" : {
346+ "token_embd.weight" ,
347+ "output_norm.weight" ,
348+ "output.weight" ,
349+ "blk.{bid}.attn_norm.weight" ,
350+ "blk.{bid}.ssm_in.weight" ,
351+ "blk.{bid}.ssm_conv1d.weight" ,
352+ "blk.{bid}.ssm_conv1d.bias" ,
353+ "blk.{bid}.ssm_x.weight" ,
354+ "blk.{bid}.ssm_dt.weight" ,
355+ "blk.{bid}.ssm_dt.bias" ,
356+ "blk.{bid}.ssm_a" ,
357+ "blk.{bid}.ssm_d" ,
358+ "blk.{bid}.ssm_out.weight" ,
359+ },
360+ "mamba2" : {
361+ "token_embd.weight" ,
362+ "output_norm.weight" ,
363+ "output.weight" ,
364+ "blk.{bid}.attn_norm.weight" ,
365+ "blk.{bid}.ssm_in.weight" ,
366+ "blk.{bid}.ssm_conv1d.weight" ,
367+ "blk.{bid}.ssm_conv1d.bias" ,
368+ "blk.{bid}.ssm_dt.bias" ,
369+ "blk.{bid}.ssm_a" ,
370+ "blk.{bid}.ssm_d" ,
371+ "blk.{bid}.ssm_norm.weight" ,
372+ "blk.{bid}.ssm_out.weight" ,
373+ },
374+ }
375+
376+ @pytest .mark .parametrize ("architecture" , ["mamba" , "mamba2" ])
377+ def test_pure_recurrent_pinned_tensor_names_are_suffix_exact (
378+ self , architecture : str
379+ ) -> None :
380+ upstream = upstream_architectures ()[architecture ]
381+ assert set (upstream .tensor_names ) == self ._RECURRENT_TENSOR_NAMES [architecture ]
382+ for pinned_name in upstream .tensor_names :
383+ name = pinned_name .replace ("{bid}" , "7" )
384+ assert map_gguf_to_hf_names (name , architecture ) is not None , name
385+
386+ @pytest .mark .parametrize (
387+ ("architecture" , "malformed" ),
388+ [
389+ ("mamba" , "blk.0.ssm_a.weight" ),
390+ ("mamba" , "blk.0.ssm_d.bias" ),
391+ ("mamba" , "blk.0.ssm_in.bias" ),
392+ ("mamba2" , "blk.0.ssm_dt.weight" ),
393+ ("mamba2" , "blk.0.ssm_a.bias" ),
394+ ("mamba2" , "blk.0.ssm_norm.bias" ),
395+ ],
396+ )
397+ def test_pure_recurrent_malformed_suffixes_do_not_map (
398+ self , architecture : str , malformed : str
399+ ) -> None :
400+ assert map_gguf_to_hf_names (malformed , architecture ) is None
401+
402+ @pytest .mark .parametrize (
403+ ("architecture" , "mapping_key" ),
404+ [
405+ ("mamba" , "blk.{bid}.ssm_x" ),
406+ ("mamba2" , "blk.{bid}.ssm_norm" ),
407+ ],
408+ )
409+ def test_deleting_recurrent_mapping_breaks_closure (
410+ self , architecture : str , mapping_key : str
411+ ) -> None :
412+ mapping = _MAPPING_TABLES [architecture ]
413+ removed = mapping .pop (mapping_key )
414+ _build_mapping .cache_clear ()
415+ try :
416+ assert any (name .startswith (mapping_key ) for name in self ._unmapped (architecture ))
417+ finally :
418+ mapping [mapping_key ] = removed
419+ _build_mapping .cache_clear ()
420+
337421
338422class TestRejectionsAreActionable :
339423 """An unsupported input must say what it is and what to do instead."""
@@ -360,8 +444,8 @@ def test_a_dead_upstream_architecture_says_so(self) -> None:
360444 get_arch_spec ("gptj" )
361445
362446 def test_an_unimported_upstream_architecture_names_its_cohort (self ) -> None :
363- with pytest.raises(UnsupportedGGUFArchitectureError, match="C05-pure-recurrent "):
364- get_arch_spec("mamba2 ")
447+ with pytest .raises (UnsupportedGGUFArchitectureError , match = "distinct RWKV " ):
448+ get_arch_spec ("rwkv6 " )
365449
366450 def test_an_unknown_architecture_is_distinguished_from_an_upstream_one (self ) -> None :
367451 with pytest .raises (UnsupportedGGUFArchitectureError , match = "not among the 147" ):
0 commit comments