File tree Expand file tree Collapse file tree
src/mobius/integrations/gguf Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import re
2323import struct
2424from collections import Counter
25- from collections .abc import Callable , Iterable , Mapping
25+ from collections .abc import Callable , Collection , Iterable , Mapping
2626from pathlib import Path
2727from typing import TYPE_CHECKING
2828from urllib .parse import urlparse
@@ -3337,6 +3337,7 @@ def _load_quantized_state_dict(
33373337 name_mapper : Callable [[str , str ], str | None ] | None = None ,
33383338 warn_unmapped : bool = True ,
33393339 reuse_candidates : dict | None = None ,
3340+ dequantize_float_linear_types : Mapping [str , Collection [str ]] | None = None ,
33403341) -> dict :
33413342 """Load tensors, preserving native blocks or normalizing to MatMulNBits.
33423343
@@ -3554,6 +3555,11 @@ def _load_quantized_state_dict(
35543555 }
35553556 and not should_repack
35563557 and not fused_projection_targets
3558+ and (
3559+ dequantize_float_linear_types is None
3560+ or module_stem not in dequantize_float_linear_types
3561+ or quant_spec .name not in dequantize_float_linear_types [module_stem ]
3562+ )
35573563 ):
35583564 raise ValueError (
35593565 f"Cannot keep { quant_spec .name } { tensor_role .value } { hf_name } "
Original file line number Diff line number Diff line change @@ -350,8 +350,9 @@ def validate_mtp_tensor_contract(gguf_model) -> None:
350350 )
351351 if count != 1 :
352352 raise ValueError (
353- f"{ architecture } GGUF declares { count } MTP heads; ModelPackage can represent "
354- "exactly one and will not silently truncate the remaining heads"
353+ f"{ architecture } GGUF declares { count } MTP heads and has { count } MTP blocks, "
354+ "but only exactly one appended MTP block can be represented; refusing to "
355+ "silently truncate the remaining heads"
355356 )
356357 if legacy_tensors :
357358 raise ValueError (
@@ -620,6 +621,7 @@ def _mapper(gguf_name: str, _arch: str) -> str | None:
620621 mtp_config ,
621622 name_mapper = _mapper ,
622623 warn_unmapped = False ,
624+ dequantize_float_linear_types = {"lm_head" : {"Q4_1" }},
623625 )
624626 # Mirror the backbone (build_from_gguf steps 7/7b): run process_tensors
625627 # over only the float tensors (native quant blocks were already
Original file line number Diff line number Diff line change @@ -164,17 +164,17 @@ def _add_decoder_block(idx: int) -> None:
164164 matrix (f"{ prefix } .nextn.embed_tokens.weight" , (_VOCAB , _H ))
165165 if dedicated_norm :
166166 f32 (f"{ prefix } .nextn.shared_head_norm.weight" , (_H ,))
167+ if unknown_nextn :
168+ f32 (f"{ prefix } .nextn.unknown.weight" , (_H ,))
169+ if extra_mtp_tensor is not None :
170+ f32 (extra_mtp_tensor , (_H ,))
171+ _add_decoder_block (index )
167172 if dedicated_head :
168173 matrix (
169174 f"{ prefix } .nextn.shared_head_head.weight" ,
170175 (_VOCAB , _H ),
171176 asymmetric = asymmetric_dedicated_head ,
172177 )
173- if unknown_nextn :
174- f32 (f"{ prefix } .nextn.unknown.weight" , (_H ,))
175- if extra_mtp_tensor is not None :
176- f32 (extra_mtp_tensor , (_H ,))
177- _add_decoder_block (index )
178178
179179 if quantized_backbone_embedding :
180180 matrix ("token_embd.weight" , (_VOCAB , _H ))
You can’t perform that action at this time.
0 commit comments