4949 UnsupportedGGUFArchitectureError ,
5050)
5151from mobius .integrations .gguf ._header import _gguf_architecture_from_header
52- from mobius .integrations .gguf ._spec import Support
52+ from mobius .integrations .gguf ._spec import Support , TensorRole
5353
5454_HUB_PREFLIGHT_TRANSPORT_ERRORS : tuple [type [BaseException ], ...] = (OSError ,)
5555try :
@@ -1638,7 +1638,10 @@ def _raise_for_invalid_plamo2_tensor_contract(gguf_model) -> None:
16381638 raise ValueError ("PLaMo2 requires attention.layer_norm_rms_epsilon=1e-6" )
16391639 activation = metadata .get (f"{ arch } .feed_forward.activation" , "silu" )
16401640 if activation not in {"silu" , "swiglu" }:
1641- raise ValueError (f"PLaMo2 supports only fused SwiGLU, got { activation !r} " )
1641+ raise ValueError (
1642+ "PLaMo2 feed_forward.activation must be 'silu' or 'swiglu' "
1643+ f"(both select fused SwiGLU), got { activation !r} "
1644+ )
16421645 if bool (metadata .get (f"{ arch } .ssm.use_predefined_initial_state" , False )):
16431646 raise ValueError ("PLaMo2 predefined initial state is unsupported" )
16441647
@@ -1690,6 +1693,15 @@ def _raise_for_invalid_plamo2_tensor_contract(gguf_model) -> None:
16901693 name : tuple (int (dim ) for dim in gguf_model .get_tensor_shape (name ))
16911694 for name in gguf_model .tensor_names
16921695 }
1696+ from mobius .integrations .gguf ._config_mapping import (
1697+ _infer_plamo2_attention_widths ,
1698+ )
1699+
1700+ key_width , value_width = _infer_plamo2_attention_widths (
1701+ gguf_model ,
1702+ tuple (head_counts ),
1703+ tuple (kv_counts ),
1704+ )
16931705 required : dict [str , tuple [int , ...]] = {
16941706 "token_embd.weight" : (
16951707 int (
@@ -1706,7 +1718,6 @@ def _raise_for_invalid_plamo2_tensor_contract(gguf_model) -> None:
17061718 "output.weight" : (required ["token_embd.weight" ][0 ], hidden )
17071719 }
17081720 dt_rank = max (64 , hidden // 16 )
1709- inferred_widths : set [tuple [int , int ]] = set ()
17101721 for layer , (heads , kv_heads ) in enumerate (zip (head_counts , kv_counts )):
17111722 prefix = f"blk.{ layer } ."
17121723 required .update (
@@ -1744,18 +1755,6 @@ def _raise_for_invalid_plamo2_tensor_contract(gguf_model) -> None:
17441755 raise ValueError (f"PLaMo2 layer { layer } has invalid attention head geometry" )
17451756 qkv_name = prefix + "attn_qkv.weight"
17461757 output_name = prefix + "attn_output.weight"
1747- if qkv_name not in actual_shapes or output_name not in actual_shapes :
1748- continue
1749- value_width , value_remainder = divmod (actual_shapes [output_name ][1 ], heads )
1750- key_width , key_remainder = divmod (
1751- actual_shapes [qkv_name ][0 ] - kv_heads * value_width ,
1752- heads + kv_heads ,
1753- )
1754- if value_remainder or key_remainder or min (key_width , value_width ) <= 0 :
1755- raise ValueError (
1756- f"PLaMo2 layer { layer } key/value widths cannot be inferred exactly"
1757- )
1758- inferred_widths .add ((key_width , value_width ))
17591758 required .update (
17601759 {
17611760 qkv_name : (
@@ -1768,9 +1767,6 @@ def _raise_for_invalid_plamo2_tensor_contract(gguf_model) -> None:
17681767 }
17691768 )
17701769
1771- if len (inferred_widths ) != 1 :
1772- raise ValueError ("PLaMo2 attention tensor widths are missing or contradictory" )
1773- key_width , value_width = inferred_widths .pop ()
17741770 if key_width != value_width or key_width * max (head_counts ) != hidden :
17751771 raise ValueError ("PLaMo2 attention widths do not reconstruct embedding_length" )
17761772 if inner != ssm_heads * key_width :
@@ -5040,7 +5036,7 @@ def repack_gguf_weight_to_target(
50405036 target_block_size : int ,
50415037 target_symmetric : bool ,
50425038 tensor_name : str ,
5043- tensor_role = None ,
5039+ tensor_role : TensorRole | None = None ,
50445040):
50455041 """Repack one 2-D GGUF weight to the graph's common MatMulNBits target.
50465042
@@ -5072,7 +5068,7 @@ def repack_gguf_weight_to_target(
50725068 repack_dequantized_tensor ,
50735069 repack_gguf_tensor ,
50745070 )
5075- from mobius .integrations .gguf ._spec import QuantImportRoute , TensorRole
5071+ from mobius .integrations .gguf ._spec import QuantImportRoute
50765072
50775073 if tensor_role is None :
50785074 tensor_role = TensorRole .PROJECTION
@@ -5561,8 +5557,8 @@ def _load_quantized_state_dict(
55615557 offset = end
55625558 if offset != int (np_shape [0 ]):
55635559 raise ValueError (
5564- f"Fused QKV tensor { hf_name !r} has { np_shape [0 ]} rows, "
5565- f"but Q/K/V targets require { offset } "
5560+ f"Fused projection tensor { hf_name !r} has { np_shape [0 ]} rows, "
5561+ f"but its split targets require { offset } "
55665562 )
55675563 n_repacked += len (fused_projection_targets )
55685564 elif native_targets and native_spec is not None :
0 commit comments