model.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. --- a/vllm/model.py
  2. +++ b/vllm/model.py
  3. @@ -770,6 +770,33 @@
  4. for args in weights:
  5. name, loaded_weight = args[:2]
  6. kwargs: dict = args[2] if len(args) > 2 else {}
  7. + # Checkpoint layout shim (NVFP4 export uses newer serialization):
  8. + # renames verified shape/byte-equivalent against the fp8 export.
  9. + for _hc_from, _hc_to in (
  10. + ("attn_hc.base", "hc_attn_base"),
  11. + ("attn_hc.fn", "hc_attn_fn"),
  12. + ("attn_hc.scale", "hc_attn_scale"),
  13. + ("ffn_hc.base", "hc_ffn_base"),
  14. + ("ffn_hc.fn", "hc_ffn_fn"),
  15. + ("ffn_hc.scale", "hc_ffn_scale"),
  16. + (".self_attn.forget_gate.A_log", ".self_attn.A_log"),
  17. + (".self_attn.forget_gate.dt_bias", ".self_attn.dt_bias"),
  18. + (".self_attn.forget_gate.f_a_proj.", ".self_attn.f_a_proj."),
  19. + (".self_attn.forget_gate.f_b_proj.", ".self_attn.f_b_proj."),
  20. + ):
  21. + if _hc_from in name:
  22. + name = name.replace(_hc_from, _hc_to)
  23. + break
  24. + # Fused linear-attn conv: split [3*C,1,4] into q/k/v convs.
  25. + if ".self_attn.conv1d.weight" in name:
  26. + _c = loaded_weight.shape[0] // 3
  27. + for _j, _nm in enumerate(("q_conv1d", "k_conv1d", "v_conv1d")):
  28. + _sub = name.replace(".conv1d.weight", ".%s.weight" % _nm)
  29. + _p = params_dict[_sub]
  30. + _wl = getattr(_p, "weight_loader", default_weight_loader)
  31. + _wl(_p, loaded_weight[_j * _c : (_j + 1) * _c])
  32. + loaded_params.add(_sub)
  33. + continue
  34. if "rotary_emb.inv_freq" in name:
  35. continue