From 6a63ec443a1931f0239e43301af877c3dc7e4272 Mon Sep 17 00:00:00 2001 From: feng <471899214@qq.com> Date: Sat, 28 Mar 2026 00:50:55 +0800 Subject: [PATCH 1/4] add support qwen3.5 --- demo.py | 10 +++++----- requirements.txt | 11 +++++------ utils/constants.py | 36 +++++++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/demo.py b/demo.py index 4fb1b73..37e6455 100644 --- a/demo.py +++ b/demo.py @@ -5,7 +5,7 @@ from peft import LoraConfig from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig from trl import SFTTrainer, SFTConfig - +from datasets import Dataset from dataset import SFTDataCollator, SFTDataset from utils.constants import model2template @@ -23,7 +23,6 @@ class LoraTrainingArguments: def train_lora( model_id: str, context_length: int, training_args: LoraTrainingArguments ): - assert model_id in model2template, f"model_id {model_id} not supported" lora_config = LoraConfig( r=training_args.lora_rank, target_modules=[ @@ -53,7 +52,6 @@ def train_lora( optim="paged_adamw_8bit", remove_unused_columns=False, num_train_epochs=training_args.num_train_epochs, - max_seq_length=context_length, ) tokenizer = AutoTokenizer.from_pretrained( model_id, @@ -74,10 +72,12 @@ def train_lora( template=model2template[model_id], ) + dataset_dict = [dataset[i] for i in range(len(dataset))] + hf_dataset = Dataset.from_list(dataset_dict) # Define trainer trainer = SFTTrainer( model=model, - train_dataset=dataset, + train_dataset=hf_dataset, args=training_args, peft_config=lora_config, data_collator=SFTDataCollator(tokenizer, max_seq_length=context_length), @@ -108,7 +108,7 @@ def train_lora( ) # Set model ID and context length - model_id = "Qwen/Qwen1.5-0.5B" + model_id = "Qwen/Qwen3.5-2B" context_length = 2048 # Start LoRA fine-tuning diff --git a/requirements.txt b/requirements.txt index 4b610f6..51f0559 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ -torch>=1.13.1 -transformers>=4.43.0,<=4.45.0 -peft>=0.10.0,<=0.13.2 -loguru -trl>=0.9.3,<=0.9.6 -bitsandbytes pyyaml +torch>=1.13.1 +transformers==5.3.0 +peft==0.18.1 +loguru>=0.6.0 +huggingface-hub==1.5.0 \ No newline at end of file diff --git a/utils/constants.py b/utils/constants.py index 572c9ad..e9c3249 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -9,19 +9,37 @@ } model2template = { - "Qwen/Qwen2.5-0.5B-Instruct": qwen_template, - "Qwen/Qwen2.5-1.5B-Instruct": qwen_template, - "Qwen/Qwen2.5-7B-Instruct": qwen_template, + "Qwen/Qwen3.5-0.8B": qwen_template, + "Qwen/Qwen3.5-0.8B-Base": qwen_template, + "Qwen/Qwen3.5-2B": qwen_template, + "Qwen/Qwen3.5-2B-Base": qwen_template, + "Qwen/Qwen3.5-4B": qwen_template, + "Qwen/Qwen3.5-4B-Base": qwen_template, + "Qwen/Qwen3.5-9B": qwen_template, + "Qwen/Qwen3.5-9B-Base": qwen_template, + "Qwen/Qwen3.5-27B": qwen_template, } model2size = { - "Qwen/Qwen2.5-0.5B-Instruct": 494_000_000, - "Qwen/Qwen2.5-1.5B-Instruct": 1_540_000_000, - "Qwen/Qwen2.5-7B-Instruct": 7_620_000_000, + "Qwen/Qwen3.5-0.8B": 853_000_000, + "Qwen/Qwen3.5-0.8B-Base": 853_000_000, + "Qwen/Qwen3.5-2B": 2_213_000_000, + "Qwen/Qwen3.5-2B-Base": 2_213_000_000, + "Qwen/Qwen3.5-4B": 4_539_000_000, + "Qwen/Qwen3.5-4B-Base": 4_539_000_000, + "Qwen/Qwen3.5-9B": 8_392_000_000, + "Qwen/Qwen3.5-9B-Base": 8_392_000_000, + "Qwen/Qwen3.5-27B": 26_085_000_000, } model2base_model = { - "Qwen/Qwen2.5-0.5B-Instruct": "qwen1.5", - "Qwen/Qwen2.5-1.5B-Instruct": "qwen1.5", - "Qwen/Qwen2.5-7B-Instruct": "qwen1.5", + "Qwen/Qwen3.5-0.8B": "qwen3.5", + "Qwen/Qwen3.5-0.8B-Base": "qwen3.5", + "Qwen/Qwen3.5-2B": "qwen3.5", + "Qwen/Qwen3.5-2B-Base": "qwen3.5", + "Qwen/Qwen3.5-4B": "qwen3.5", + "Qwen/Qwen3.5-4B-Base": "qwen3.5", + "Qwen/Qwen3.5-9B": "qwen3.5", + "Qwen/Qwen3.5-9B-Base": "qwen3.5", + "Qwen/Qwen3.5-27B": "qwen3.5", } From 0f2b021d88eb4199546cb2ad09a955acb012d262 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Mar 2026 16:51:39 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- requirements.txt | 2 +- utils/constants.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/requirements.txt b/requirements.txt index 51f0559..cad390c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ torch>=1.13.1 transformers==5.3.0 peft==0.18.1 loguru>=0.6.0 -huggingface-hub==1.5.0 \ No newline at end of file +huggingface-hub==1.5.0 diff --git a/utils/constants.py b/utils/constants.py index e9c3249..bc0d24b 100644 --- a/utils/constants.py +++ b/utils/constants.py @@ -9,15 +9,15 @@ } model2template = { - "Qwen/Qwen3.5-0.8B": qwen_template, - "Qwen/Qwen3.5-0.8B-Base": qwen_template, - "Qwen/Qwen3.5-2B": qwen_template, - "Qwen/Qwen3.5-2B-Base": qwen_template, - "Qwen/Qwen3.5-4B": qwen_template, - "Qwen/Qwen3.5-4B-Base": qwen_template, - "Qwen/Qwen3.5-9B": qwen_template, - "Qwen/Qwen3.5-9B-Base": qwen_template, - "Qwen/Qwen3.5-27B": qwen_template, + "Qwen/Qwen3.5-0.8B": qwen_template, + "Qwen/Qwen3.5-0.8B-Base": qwen_template, + "Qwen/Qwen3.5-2B": qwen_template, + "Qwen/Qwen3.5-2B-Base": qwen_template, + "Qwen/Qwen3.5-4B": qwen_template, + "Qwen/Qwen3.5-4B-Base": qwen_template, + "Qwen/Qwen3.5-9B": qwen_template, + "Qwen/Qwen3.5-9B-Base": qwen_template, + "Qwen/Qwen3.5-27B": qwen_template, } model2size = { From 909ad80efc6281f3678880b49d22e57f278dfe30 Mon Sep 17 00:00:00 2001 From: feng <471899214@qq.com> Date: Sat, 28 Mar 2026 17:18:02 +0800 Subject: [PATCH 3/4] fix some dependency bug --- demo.py | 1 + requirements.txt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/demo.py b/demo.py index 37e6455..1c6ee73 100644 --- a/demo.py +++ b/demo.py @@ -23,6 +23,7 @@ class LoraTrainingArguments: def train_lora( model_id: str, context_length: int, training_args: LoraTrainingArguments ): + assert model_id in model2template, f"model_id {model_id} not supported" lora_config = LoraConfig( r=training_args.lora_rank, target_modules=[ diff --git a/requirements.txt b/requirements.txt index 51f0559..648aab1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,6 @@ torch>=1.13.1 transformers==5.3.0 peft==0.18.1 loguru>=0.6.0 -huggingface-hub==1.5.0 \ No newline at end of file +huggingface-hub==1.5.0 +trl>=0.20.0,<=0.29.1 +bitsandbytes \ No newline at end of file From 5d09324ddb6d411a0f8b8f64785ccf4eed5a550d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Mar 2026 09:19:16 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 648aab1..41df922 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ peft==0.18.1 loguru>=0.6.0 huggingface-hub==1.5.0 trl>=0.20.0,<=0.29.1 -bitsandbytes \ No newline at end of file +bitsandbytes