* bump hf deps * upgrade liger-kernel too * install cce from fork for transformers fix * fix reference to vocab size in gemma3 patch * use padding_idx instead of pad_token_id * remove fixed gemma3 patch * use updated cce fork * fix local mllama cce patches w docstring * add test for multipack with trainer setup and fix trainer for trainer refactor upstream * bump modal version * guard for iterable datasetS * mllama model arch layout changed in latest transformers * fix batch sampler with drop_last * fix: address upstream vlm changes for lora * fix: update references to old lora target path * fix: remove mllama fa2 patch due to upstream fix * fix: lora kernel patch path for multimodal models * fix: removed mllama from quarto * run test for came optim on 2.6.0+ * fix fsdp2 patch and remove deprecated patch * make sure to set sequence_parallel_degree for grpo * Add SP test for GRPO * add sp to grpo config for trainer * use reward_funcs as kwarg to grpo trainer * fix the comprehension for reward funcs * reward funcs already passed in as args * init sp_group right before training * fix check for adding models to SP context * make sure to pass args to super * upgrade deepspeed * use updated trl and add reasoning flags for vllm * patch the worker --------- Co-authored-by: NanoCode012 <nano@axolotl.ai>
114 lines
4.0 KiB
Python
114 lines
4.0 KiB
Python
"""
|
|
E2E tests for lora llama
|
|
"""
|
|
|
|
import unittest
|
|
|
|
from axolotl.cli.args import TrainerCliArgs
|
|
from axolotl.common.datasets import load_datasets
|
|
from axolotl.train import train
|
|
from axolotl.utils.config import normalize_config, validate_config
|
|
from axolotl.utils.dict import DictDefault
|
|
|
|
from .utils import check_model_output_exists, with_temp_dir
|
|
|
|
|
|
class TestLlamaVision(unittest.TestCase):
|
|
"""
|
|
Test case for Llama Vision models
|
|
"""
|
|
|
|
@with_temp_dir
|
|
def test_lora_llama_vision_text_only_dataset(self, temp_dir):
|
|
# pylint: disable=duplicate-code
|
|
cfg = DictDefault(
|
|
{
|
|
"base_model": "axolotl-ai-co/Llama-3.2-39M-Vision",
|
|
"processor_type": "AutoProcessor",
|
|
"skip_prepare_dataset": True,
|
|
"remove_unused_columns": False,
|
|
"sample_packing": False,
|
|
"sequence_len": 1024,
|
|
"adapter": "lora",
|
|
"lora_r": 8,
|
|
"lora_alpha": 16,
|
|
"lora_dropout": 0.05,
|
|
"lora_target_modules": r"model.language_model.layers.[\d]+.(mlp|cross_attn|self_attn).(up|down|gate|q|k|v|o)_proj",
|
|
"val_set_size": 0,
|
|
"chat_template": "llama3_2_vision",
|
|
"datasets": [
|
|
{
|
|
"path": "LDJnr/Puffin",
|
|
"type": "chat_template",
|
|
"field_messages": "conversations",
|
|
"message_field_role": "from",
|
|
"message_field_content": "value",
|
|
},
|
|
],
|
|
"num_epochs": 1,
|
|
"micro_batch_size": 1,
|
|
"gradient_accumulation_steps": 2,
|
|
"output_dir": temp_dir,
|
|
"learning_rate": 0.00001,
|
|
"optimizer": "adamw_bnb_8bit",
|
|
"lr_scheduler": "cosine",
|
|
"max_steps": 5,
|
|
"save_safetensors": True,
|
|
"bf16": True,
|
|
}
|
|
)
|
|
|
|
cfg = validate_config(cfg)
|
|
normalize_config(cfg)
|
|
cli_args = TrainerCliArgs()
|
|
dataset_meta = load_datasets(cfg=cfg, cli_args=cli_args)
|
|
|
|
train(cfg=cfg, dataset_meta=dataset_meta)
|
|
check_model_output_exists(temp_dir, cfg)
|
|
|
|
@with_temp_dir
|
|
def test_lora_llama_vision_multimodal_dataset(self, temp_dir):
|
|
# pylint: disable=duplicate-code
|
|
cfg = DictDefault(
|
|
{
|
|
"base_model": "axolotl-ai-co/Llama-3.2-39M-Vision",
|
|
"processor_type": "AutoProcessor",
|
|
"skip_prepare_dataset": True,
|
|
"remove_unused_columns": False,
|
|
"sample_packing": False,
|
|
"sequence_len": 1024,
|
|
"adapter": "lora",
|
|
"lora_r": 8,
|
|
"lora_alpha": 16,
|
|
"lora_dropout": 0.05,
|
|
"lora_target_modules": r"model.language_model.layers.[\d]+.(mlp|cross_attn|self_attn).(up|down|gate|q|k|v|o)_proj",
|
|
"val_set_size": 0,
|
|
"chat_template": "llama3_2_vision",
|
|
"datasets": [
|
|
{
|
|
"path": "axolotl-ai-co/llava-instruct-mix-vsft-small",
|
|
"type": "chat_template",
|
|
"split": "train",
|
|
"field_messages": "messages",
|
|
},
|
|
],
|
|
"num_epochs": 1,
|
|
"micro_batch_size": 1,
|
|
"gradient_accumulation_steps": 2,
|
|
"output_dir": temp_dir,
|
|
"learning_rate": 0.00001,
|
|
"optimizer": "adamw_bnb_8bit",
|
|
"lr_scheduler": "cosine",
|
|
"max_steps": 5,
|
|
"save_safetensors": True,
|
|
"bf16": True,
|
|
}
|
|
)
|
|
cfg = validate_config(cfg)
|
|
normalize_config(cfg)
|
|
cli_args = TrainerCliArgs()
|
|
dataset_meta = load_datasets(cfg=cfg, cli_args=cli_args)
|
|
|
|
train(cfg=cfg, dataset_meta=dataset_meta)
|
|
check_model_output_exists(temp_dir, cfg)
|