Skip to content

Commit dd838e7

Browse files
Fix test bugs (#5484)
1 parent 3d2bded commit dd838e7

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

examples/export/quantize/bert/gptq.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ CUDA_VISIBLE_DEVICES=0 swift export \
44
--output_dir output/swift_test_bert_merged \
55
--merge_lora true
66

7+
EXIT_CODE=$?
8+
9+
if [ $EXIT_CODE -ne 0 ]; then
10+
echo "Error: LoRA merge failed with exit code $EXIT_CODE"
11+
exit $EXIT_CODE
12+
fi
13+
714
# gptq quantize
815
CUDA_VISIBLE_DEVICES=0 swift export \
916
--model output/swift_test_bert_merged \
@@ -13,6 +20,14 @@ CUDA_VISIBLE_DEVICES=0 swift export \
1320
--quant_method gptq \
1421
--max_length 512
1522

23+
24+
EXIT_CODE=$?
25+
26+
if [ $EXIT_CODE -ne 0 ]; then
27+
echo "Error: GPTQ quantization failed with exit code $EXIT_CODE"
28+
exit $EXIT_CODE
29+
fi
30+
1631
# infer
1732
CUDA_VISIBLE_DEVICES=0 swift infer \
1833
--model output/swift_test_bert_gptq_int4

swift/llm/argument/base_args/base_args.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def _prepare_training_args(self, training_args: Dict[str, Any]) -> None:
104104

105105
def _init_lazy_tokenize(self):
106106
if self.lazy_tokenize is None:
107-
if self.model_meta.is_multimodal and not self.streaming and not self.packing:
107+
if (self.model_meta is not None and self.model_meta.is_multimodal and not self.streaming
108+
and not self.packing):
108109
self.lazy_tokenize = True
109110
else:
110111
self.lazy_tokenize = False
@@ -172,7 +173,7 @@ def __post_init__(self):
172173
QuantizeArguments.__post_init__(self)
173174
TemplateArguments.__post_init__(self)
174175
DataArguments.__post_init__(self)
175-
if self.max_length is None:
176+
if self.max_length is None and self.model_info is not None:
176177
self.max_length = self.model_info.max_model_len
177178
if self.packing and self.packing_length is None:
178179
self.packing_length = self.max_length

swift/llm/argument/base_args/template_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TemplateArguments:
4747
template_backend: Literal['swift', 'jinja'] = 'swift'
4848

4949
def __post_init__(self):
50-
if self.template is None and hasattr(self, 'model_meta'):
50+
if self.template is None and getattr(self, 'model_meta', None):
5151
self.template = self.model_meta.template
5252
if self.use_chat_template is None:
5353
self.use_chat_template = True

swift/llm/argument/sampling_args.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class SamplingArguments(BaseArguments):
5656
def _init_model_info(self):
5757
if self.sampler_engine != 'client':
5858
return super()._init_model_info()
59+
else:
60+
self.model_info = None
61+
self.model_meta = None
5962
self.task_type = 'causal_lm'
6063
return
6164

swift/llm/train/tuner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def prepare_adapter(args: TrainArguments, model, *, template=None, train_dataset
243243
logger.info(f'adalora_config: {adalora_config}')
244244
elif args.train_type == 'llamapro':
245245
llamapro_config = LLaMAProConfig(
246-
model_type=model.model_meta.model_arch,
246+
model_type=model.model_meta.model_arch.arch_name,
247247
num_new_blocks=args.llamapro_num_new_blocks,
248248
num_groups=args.llamapro_num_groups)
249249
model = Swift.prepare_model(model, llamapro_config)

0 commit comments

Comments
 (0)