Reduce AutoWeightsLoader kwargs (#53106)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2026-08-20 15:40:11 +00:00
committed by GitHub
parent 2dd17225c6
commit 1fe3a1571a
84 changed files with 577 additions and 568 deletions
+8 -11
View File
@@ -835,21 +835,18 @@ class DFlashQwen3ForCausalLM(Qwen3ForCausalLM):
model_weights["model.mask_embedding"] = mask_embedding
self.model.has_separate_mask_embedding = True
skip_substrs = []
orig_to_new_substr = {}
if not includes_draft_id_mapping:
skip_substrs.append("draft_id_to_target_id")
orig_to_new_substr["draft_id_to_target_id"] = None
if not includes_embed_tokens:
skip_substrs.append("embed_tokens")
orig_to_new_substr["embed_tokens"] = None
if not self.model.use_aux_hidden_state:
skip_substrs.append("fc.")
orig_to_new_substr["fc."] = None
if not self.model.has_separate_mask_embedding:
skip_substrs.append("mask_embedding")
loader = AutoWeightsLoader(
self,
skip_prefixes=None,
skip_substrs=skip_substrs,
)
loader.load_weights(model_weights.items())
orig_to_new_substr["mask_embedding"] = None
mapper = WeightsMapper(orig_to_new_substr=orig_to_new_substr)
loader = AutoWeightsLoader(self)
loader.load_weights(model_weights.items(), mapper=mapper)
self.model._build_fused_kv_buffers()
def _read_mask_embedding(self) -> torch.Tensor | None: