This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
pip install "transformers<4.52"
|
||||
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-72B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
--device_map cpu \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 2048 \
|
||||
--quant_method awq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-72B-Instruct-AWQ
|
||||
@@ -0,0 +1,16 @@
|
||||
# merge-lora
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--adapters swift/test_bert \
|
||||
--output_dir output/swift_test_bert_merged \
|
||||
--merge_lora true
|
||||
|
||||
# bnb quantize
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--model output/swift_test_bert_merged \
|
||||
--output_dir output/swift_test_bert_bnb_int4 \
|
||||
--quant_bits 4 \
|
||||
--quant_method bnb
|
||||
|
||||
# infer
|
||||
CUDA_VISIBLE_DEVICES=0 swift infer \
|
||||
--model output/swift_test_bert_bnb_int4
|
||||
@@ -0,0 +1,33 @@
|
||||
# merge-lora
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--adapters swift/test_bert \
|
||||
--output_dir output/swift_test_bert_merged \
|
||||
--merge_lora true
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -ne 0 ]; then
|
||||
echo "Error: LoRA merge failed with exit code $EXIT_CODE"
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
# gptq quantize
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--model output/swift_test_bert_merged \
|
||||
--load_data_args true \
|
||||
--output_dir output/swift_test_bert_gptq_int4 \
|
||||
--quant_bits 4 \
|
||||
--quant_method gptq \
|
||||
--max_length 512
|
||||
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -ne 0 ]; then
|
||||
echo "Error: GPTQ quantization failed with exit code $EXIT_CODE"
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
# infer
|
||||
CUDA_VISIBLE_DEVICES=0 swift infer \
|
||||
--model output/swift_test_bert_gptq_int4
|
||||
@@ -0,0 +1,8 @@
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-1.5B-Instruct \
|
||||
--quant_method bnb \
|
||||
--quant_bits 4 \
|
||||
--bnb_4bit_quant_type nf4 \
|
||||
--bnb_4bit_use_double_quant true \
|
||||
--output_dir Qwen2.5-1.5B-Instruct-BNB-NF4
|
||||
@@ -0,0 +1,9 @@
|
||||
# Due to the structural changes made to MoE architecture in `transformers>=5.0`,
|
||||
# if you need to apply FP8 quantization to MoE models, please use `megatron export`
|
||||
# (compatible with vLLM inference).
|
||||
# Reference: https://github.com/modelscope/ms-swift/blob/main/examples/megatron/fp8/quant.sh
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-3B-Instruct \
|
||||
--quant_method fp8 \
|
||||
--output_dir Qwen2.5-3B-Instruct-FP8
|
||||
@@ -0,0 +1,13 @@
|
||||
# OMP_NUM_THREADS=14 please Check issue: https://github.com/AutoGPTQ/AutoGPTQ/issues/439
|
||||
OMP_NUM_THREADS=14 \
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-1.5B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 2048 \
|
||||
--quant_method gptq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-1.5B-Instruct-GPTQ-Int4
|
||||
@@ -0,0 +1,14 @@
|
||||
# You need to install gptqmodel.
|
||||
# OMP_NUM_THREADS=14 please Check issue: https://github.com/AutoGPTQ/AutoGPTQ/issues/439
|
||||
OMP_NUM_THREADS=14 \
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-1.5B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 2048 \
|
||||
--quant_method gptq_v2 \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-1.5B-Instruct-GPTQ-V2-Int4
|
||||
@@ -0,0 +1,18 @@
|
||||
pip install "transformers==4.51.*"
|
||||
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
MAX_PIXELS=1003520 \
|
||||
VIDEO_MAX_PIXELS=50176 \
|
||||
FPS_MAX_FRAMES=12 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-VL-3B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
'modelscope/coco_2014_caption:validation#500' \
|
||||
'swift/VideoChatGPT:Generic#500' \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size -1 \
|
||||
--max_length 2048 \
|
||||
--quant_method awq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-VL-3B-Instruct-AWQ
|
||||
@@ -0,0 +1,6 @@
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-VL-3B-Instruct \
|
||||
--quant_method bnb \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-VL-3B-Instruct-BNB-Int4
|
||||
@@ -0,0 +1,10 @@
|
||||
# use transformers==5.2.0
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen3.5-4B \
|
||||
--quant_method fp8 \
|
||||
--output_dir Qwen3.5-4B-FP8
|
||||
|
||||
# CUDA_VISIBLE_DEVICES=0 \
|
||||
# swift infer \
|
||||
# --model Qwen3.5-4B-FP8
|
||||
@@ -0,0 +1,18 @@
|
||||
# OMP_NUM_THREADS=14 please Check issue: https://github.com/AutoGPTQ/AutoGPTQ/issues/439
|
||||
OMP_NUM_THREADS=14 \
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
MAX_PIXELS=1003520 \
|
||||
VIDEO_MAX_PIXELS=50176 \
|
||||
FPS_MAX_FRAMES=12 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-VL-3B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
'modelscope/coco_2014_caption:validation#500' \
|
||||
'swift/VideoChatGPT:Generic#500' \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 2048 \
|
||||
--quant_method gptq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-VL-3B-Instruct-GPTQ-Int4
|
||||
@@ -0,0 +1,13 @@
|
||||
pip install "transformers<4.52"
|
||||
|
||||
CUDA_VISIBLE_DEVICES=0,1 \
|
||||
swift export \
|
||||
--model Qwen/Qwen3-30B-A3B \
|
||||
--dataset 'swift/Qwen3-SFT-Mixin' \
|
||||
--device_map auto \
|
||||
--quant_n_samples 64 \
|
||||
--quant_batch_size -1 \
|
||||
--max_length 8192 \
|
||||
--quant_method awq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen3-30B-A3B-AWQ
|
||||
@@ -0,0 +1,6 @@
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen3-30B-A3B \
|
||||
--quant_method bnb \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen3-30B-A3B-BNB-Int4
|
||||
@@ -0,0 +1,11 @@
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
swift export \
|
||||
--model Qwen/Qwen3-30B-A3B \
|
||||
--quant_method fp8 \
|
||||
--output_dir Qwen3-30B-A3B-FP8
|
||||
|
||||
# CUDA_VISIBLE_DEVICES=0 \
|
||||
# swift infer \
|
||||
# --model Qwen3-30B-A3B-FP8 \
|
||||
# --infer_backend vllm \
|
||||
# --stream true
|
||||
@@ -0,0 +1,13 @@
|
||||
# 2 * 80GB
|
||||
OMP_NUM_THREADS=14 \
|
||||
CUDA_VISIBLE_DEVICES=0,1 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2-57B-A14B-Instruct \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#1000' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#1000' \
|
||||
--quant_n_samples 512 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 4096 \
|
||||
--quant_method gptq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2-57B-A14B-Instruct-GPTQ-Int4
|
||||
@@ -0,0 +1,18 @@
|
||||
# OMP_NUM_THREADS=14 please Check issue: https://github.com/AutoGPTQ/AutoGPTQ/issues/439
|
||||
OMP_NUM_THREADS=14 \
|
||||
CUDA_VISIBLE_DEVICES=0 \
|
||||
MAX_PIXELS=1003520 \
|
||||
VIDEO_MAX_PIXELS=50176 \
|
||||
FPS_MAX_FRAMES=12 \
|
||||
swift export \
|
||||
--model Qwen/Qwen2.5-Omni-7B \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
|
||||
'AI-ModelScope/alpaca-gpt4-data-en#500' \
|
||||
'modelscope/coco_2014_caption:validation#500' \
|
||||
'swift/VideoChatGPT:Generic#500' \
|
||||
--quant_n_samples 256 \
|
||||
--quant_batch_size 1 \
|
||||
--max_length 2048 \
|
||||
--quant_method gptq \
|
||||
--quant_bits 4 \
|
||||
--output_dir Qwen2.5-Omni-7B-GPTQ-Int4
|
||||
@@ -0,0 +1,12 @@
|
||||
# bnb quantize
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--model Shanghai_AI_Laboratory/internlm2-1_8b-reward \
|
||||
--output_dir output/internlm2-1_8b-reward-bnb-int4 \
|
||||
--quant_bits 4 \
|
||||
--quant_method bnb
|
||||
|
||||
# infer
|
||||
CUDA_VISIBLE_DEVICES=0 swift infer \
|
||||
--model output/internlm2-1_8b-reward-bnb-int4 \
|
||||
--val_dataset 'AI-ModelScope/alpaca-gpt4-data-zh#1000' \
|
||||
--max_batch_size 16
|
||||
@@ -0,0 +1,14 @@
|
||||
# gptq quantize
|
||||
CUDA_VISIBLE_DEVICES=0 swift export \
|
||||
--model Shanghai_AI_Laboratory/internlm2-1_8b-reward \
|
||||
--output_dir output/internlm2-1_8b-reward-gptq-int4 \
|
||||
--quant_bits 4 \
|
||||
--max_length 2048 \
|
||||
--quant_method gptq \
|
||||
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#1000' 'AI-ModelScope/alpaca-gpt4-data-en#1000'
|
||||
|
||||
# infer
|
||||
CUDA_VISIBLE_DEVICES=0 swift infer \
|
||||
--model output/internlm2-1_8b-reward-gptq-int4 \
|
||||
--val_dataset 'AI-ModelScope/alpaca-gpt4-data-zh#1000' \
|
||||
--max_batch_size 16
|
||||
Reference in New Issue
Block a user