patch_dspark_skip_bias_vl.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. """Skip Vision-Exp gate tensors the B12X DSpark draft loader cannot bind."""
  3. from pathlib import Path
  4. import vllm
  5. base = Path(vllm.__file__).parent / "models" / "deepseek_v4" / "nvidia"
  6. for name in ("dspark.py", "dspark_v2.py"):
  7. if (base / name).exists():
  8. p = base / name
  9. break
  10. else:
  11. raise SystemExit("no dspark.py/dspark_v2.py under " + str(base))
  12. text = p.read_text()
  13. old = ''' if name.endswith(".ffn.gate.bias"):
  14. name = name.replace(
  15. ".ffn.gate.bias", ".ffn.gate.e_score_correction_bias"
  16. )
  17. param = params_dict[name]
  18. '''
  19. new = ''' if name.endswith(".ffn.gate.bias_vl"):
  20. continue
  21. if name.endswith(".ffn.gate.bias"):
  22. name = name.replace(
  23. ".ffn.gate.bias", ".ffn.gate.e_score_correction_bias"
  24. )
  25. if name not in params_dict:
  26. continue
  27. param = params_dict[name]
  28. '''
  29. if old not in text:
  30. raise SystemExit(f"patch target missing in {p}")
  31. p.write_text(text.replace(old, new, 1))