Skip to content

Commit 6285ead

Browse files
authored
Fix awq quant (#5072)
1 parent 54d8d77 commit 6285ead

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

swift/llm/dataset/data/dataset_info.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,5 +716,9 @@
716716
"prompt": "messages"
717717
},
718718
"tags": ["docqa", "rl", "long-sequence"]
719+
},
720+
{
721+
"ms_dataset_id": "swift/Chinese-Qwen3-235B-2507-Distill-data-110k-SFT",
722+
"tags": ["🔥", "distill", "sft"]
719723
}
720724
]

swift/llm/export/quant.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ def awq_model_quantize(self) -> None:
161161
quantizer.get_calib_dataset = _origin_get_calib_dataset # recover
162162
if self.model.quant_config.modules_to_not_convert:
163163
model_arch = get_model_arch(args.model_meta.model_arch)
164-
lm_head_key = model_arch.lm_head or 'lm_head'
165-
self.model.quant_config.modules_to_not_convert.append(lm_head_key)
164+
lm_head_key = getattr(model_arch, 'lm_head', None) or 'lm_head'
165+
if lm_head_key not in self.model.quant_config.modules_to_not_convert:
166+
self.model.quant_config.modules_to_not_convert.append(lm_head_key)
166167

167168
@contextmanager
168169
def _patch_gptq(self):

swift/plugin/optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ def create_muon_optimizer(args: 'TrainingArguments', model, dataset):
7676
optim_args[key] = value
7777

7878
model_arch = get_model_arch(model.model_meta.model_arch)
79-
embed_key = model_arch.embedding or 'embed_tokens'
80-
lm_head_key = model_arch.lm_head or 'lm_head'
79+
embed_key = getattr(model_arch, 'embedding', None) or 'embed_tokens'
80+
lm_head_key = getattr(model_arch, 'lm_head', None) or 'lm_head'
8181
muon_params = [
8282
p for n, p in model.named_parameters()
8383
if p.requires_grad and p.ndim >= 2 and embed_key not in n and lm_head_key not in n

0 commit comments

Comments
 (0)