Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multimodal integration - pixtral/llava/qwen2-vl #2170

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9898d0e
multimodal example config
bursteratom Dec 10, 2024
2f77c48
rebased multimodal support - lint
bursteratom Dec 10, 2024
f7a74b3
more rebasing
bursteratom Dec 10, 2024
12c655e
Merge branch 'main' into pixtral_integration2
bursteratom Dec 13, 2024
bec9bde
Merge branch 'main' into pixtral_integration2
bursteratom Dec 20, 2024
b771f30
Update src/axolotl/utils/collators/mm_chat.py
bursteratom Dec 21, 2024
6ec2677
abstraction WIP
bursteratom Dec 21, 2024
76436ad
higher level abstraction wip
bursteratom Dec 22, 2024
393b543
higher level abstraction wip
bursteratom Dec 22, 2024
b4b0c24
higher level abstraction wip
bursteratom Dec 22, 2024
6dc8820
qwen2vl get text config
bursteratom Dec 23, 2024
f9a4bb8
qwen2vl get text config
bursteratom Dec 23, 2024
fe9739b
lint
bursteratom Dec 23, 2024
1f95c99
added docstring
bursteratom Dec 23, 2024
ce91855
moved processing_strategies.py location
bursteratom Dec 26, 2024
ead8d21
Merge branch 'main' into pixtral_integration2
bursteratom Dec 27, 2024
425c7cb
Merge branch 'main' into pixtral_integration2
bursteratom Jan 6, 2025
2723e8a
Update src/axolotl/processing_strategies/__init__.py
bursteratom Jan 10, 2025
9bf2048
Update src/axolotl/processing_strategies/__init__.py
bursteratom Jan 10, 2025
9239a2f
Update src/axolotl/utils/models.py
bursteratom Jan 10, 2025
6d985ac
Update src/axolotl/utils/collators/mm_chat.py
bursteratom Jan 10, 2025
9ec8ccf
Update src/axolotl/processing_strategies/__init__.py
bursteratom Jan 10, 2025
49e9634
return Qwen2VLProcessingStrategy
bursteratom Jan 10, 2025
3bbd2a4
add type hint
bursteratom Jan 10, 2025
b254bd1
Merge branch 'main' into pixtral_integration2
bursteratom Jan 10, 2025
a50572e
Merge branch 'main' into pixtral_integration2
bursteratom Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions examples/llava/lora-7b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
base_model: llava-hf/llava-1.5-7b-hf
processor_type: AutoProcessor
strict: false

# these 3 lines are needed for now to handle vision chat templates w images
skip_prepare_dataset: true
remove_unused_columns: false
sample_packing: false

chat_template: llava
datasets:
- path: HuggingFaceH4/llava-instruct-mix-vsft
type: chat_template
split: train[:1%]
field_messages: messages
dataset_prepared_path: last_run_prepared
val_set_size: 0.0
output_dir: ./outputs/out

adapter: lora
lora_model_dir:

sequence_len: 8192
pad_to_sequence_len: false

lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules: 'language_model.model.layers.[\d]+.(mlp|cross_attn|self_attn).(up|down|gate|q|k|v|o)_proj'

wandb_project:
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model:

gradient_accumulation_steps: 4
micro_batch_size: 1
num_epochs: 1
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002

train_on_inputs: false
group_by_length: false
bf16: true
fp16:
tf32: true

gradient_checkpointing: true
local_rank:
logging_steps: 1
flash_attention: true
eager_attention:

warmup_ratio: 0.1
evals_per_epoch: 1
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
65 changes: 65 additions & 0 deletions examples/pixtral/lora-12b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
base_model: mistral-community/pixtral-12b
processor_type: AutoProcessor
strict: false

# these 3 lines are needed for now to handle vision chat templates w images
skip_prepare_dataset: true
remove_unused_columns: false
sample_packing: false

chat_template: pixtral
datasets:
- path: HuggingFaceH4/llava-instruct-mix-vsft
type: chat_template
split: train[:1%]
field_messages: messages
dataset_prepared_path: last_run_prepared
val_set_size: 0.0
output_dir: ./outputs/out

adapter: lora
lora_model_dir:

sequence_len: 8192
pad_to_sequence_len: false

lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules: 'language_model.model.layers.[\d]+.(mlp|cross_attn|self_attn).(up|down|gate|q|k|v|o)_proj'

wandb_project:
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model:

gradient_accumulation_steps: 4
micro_batch_size: 1
num_epochs: 1
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002

train_on_inputs: false
group_by_length: false
bf16: true
fp16:
tf32: true

gradient_checkpointing: true
local_rank:
logging_steps: 1
flash_attention: false # PixtralVisionModel does not support Flash Attention 2.0 yet
eager_attention:

warmup_ratio: 0.1
evals_per_epoch: 1
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
special_tokens:
pad_token: <|end_of_text|>
63 changes: 63 additions & 0 deletions examples/qwen2-vl/lora-7b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
base_model: Qwen/Qwen2-VL-7B-Instruct
processor_type: AutoProcessor
strict: false

# these 3 lines are needed for now to handle vision chat templates w images
skip_prepare_dataset: true
remove_unused_columns: false
sample_packing: false

chat_template: qwen2_vl
datasets:
- path: HuggingFaceH4/llava-instruct-mix-vsft
type: chat_template
split: train[:1%]
field_messages: messages
dataset_prepared_path: last_run_prepared
val_set_size: 0.0
output_dir: ./outputs/out

adapter: lora
lora_model_dir:

sequence_len: 8192
pad_to_sequence_len: false

lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules: 'model.layers.[\d]+.(mlp|cross_attn|self_attn).(up|down|gate|q|k|v|o)_proj'

wandb_project:
wandb_entity:
wandb_watch:
wandb_name:
wandb_log_model:

gradient_accumulation_steps: 4
micro_batch_size: 1
num_epochs: 1
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
learning_rate: 0.0002

train_on_inputs: false
group_by_length: false
bf16: true
fp16:
tf32: true

gradient_checkpointing: true
local_rank:
logging_steps: 1
flash_attention: true
eager_attention:

warmup_ratio: 0.1
evals_per_epoch: 1
saves_per_epoch: 1
debug:
deepspeed:
weight_decay: 0.0
fsdp:
fsdp_config:
6 changes: 4 additions & 2 deletions src/axolotl/core/trainer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from axolotl.integrations.base import PluginManager
from axolotl.monkeypatch.multipack import SUPPORTED_MULTIPACK_MODEL_TYPES
from axolotl.monkeypatch.relora import ReLoRACallback, ReLoRAScheduler
from axolotl.processing_strategies import get_processing_strategy
from axolotl.utils import is_comet_available, is_mlflow_available
from axolotl.utils.callbacks import (
EvalFirstStepCallback,
Expand Down Expand Up @@ -1915,8 +1916,9 @@ def build_collator(
else:
if self.cfg.processor_type and self.processor:
collator = MultiModalChatDataCollator
kwargs["processor"] = self.processor
kwargs["chat_template"] = training_args.chat_template
kwargs["processing_strategy"] = get_processing_strategy(
self.processor, training_args.chat_template, self.cfg.chat_template
)
elif self.cfg.batch_flattening:
collator = DataCollatorWithFlattening
collator_args.pop(0)
Expand Down
Loading
Loading