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

[args] add vllm config #5982

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion examples/extras/adam_mini/qwen2_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use_adam_mini: true
### dataset
dataset: identity,alpaca_en_demo
template: qwen
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/badam/llama3_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ badam_verbose: 2
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/fsdp_qlora/llama3_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/galore/llama3_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ galore_scale: 2.0
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/llama_pro/llama3_freeze_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use_llama_pro: true
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/loraplus/llama3_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loraplus_lr_ratio: 16.0
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/mod/llama3_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mixture_of_depths: convert
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/extras/pissa/llama3_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pissa_convert: true
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_full/llama3_full_predict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ finetuning_type: full
### dataset
eval_dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 50
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_full/llama3_full_sft_ds3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deepspeed: examples/deepspeed/ds_z3_config.json
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_full/qwen2vl_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deepspeed: examples/deepspeed/ds_z3_config.json
### dataset
dataset: mllm_demo,identity
template: qwen2_vl
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_dpo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pref_loss: sigmoid # choices: [sigmoid (dpo), orpo, simpo]
### dataset
dataset: dpo_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_kto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pref_beta: 0.1
### dataset
dataset: kto_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_ppo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_predict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ finetuning_type: lora
### dataset
eval_dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 50
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_pretrain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lora_target: all

### dataset
dataset: c4_demo
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_reward.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: dpo_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_sft_ds0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deepspeed: examples/deepspeed/ds_z0_config.json
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_lora_sft_ds3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deepspeed: examples/deepspeed/ds_z3_config.json
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llama3_preprocess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/llava1_5_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: mllm_demo
template: llava
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/qwen2vl_lora_dpo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pref_loss: sigmoid # choices: [sigmoid (dpo), orpo, simpo]
### dataset
dataset: rlhf_v
template: qwen2_vl
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_lora/qwen2vl_lora_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: mllm_demo,identity # video: mllm_video_demo
template: qwen2_vl
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_qlora/llama3_lora_sft_aqlm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_qlora/llama3_lora_sft_awq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_qlora/llama3_lora_sft_gptq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion examples/train_qlora/llama3_lora_sft_otfq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lora_target: all
### dataset
dataset: identity,alpaca_en_demo
template: llama3
cutoff_len: 1024
cutoff_len: 2048
max_samples: 1000
overwrite_cache: true
preprocessing_num_workers: 16
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_console_scripts() -> List[str]:
"gptq": ["optimum>=1.17.0", "auto-gptq>=0.5.0"],
"awq": ["autoawq"],
"aqlm": ["aqlm[gpu]>=1.1.0"],
"vllm": ["vllm>=0.4.3,<=0.6.3"],
"vllm": ["vllm>=0.4.3,<0.6.4"],
"galore": ["galore-torch"],
"badam": ["badam>=1.2.1"],
"adam-mini": ["adam-mini"],
Expand Down
3 changes: 2 additions & 1 deletion src/llamafactory/chat/vllm_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(
"enable_lora": model_args.adapter_name_or_path is not None,
"max_lora_rank": model_args.vllm_max_lora_rank,
}
engine_args.update(model_args.vllm_config)

if getattr(config, "is_yi_vl_derived_model", None):
import vllm.model_executor.models.llava
Expand Down Expand Up @@ -173,7 +174,7 @@ async def _generate(
multi_modal_data = None

result_generator = self.model.generate(
inputs={"prompt_token_ids": prompt_ids, "multi_modal_data": multi_modal_data},
{"prompt_token_ids": prompt_ids, "multi_modal_data": multi_modal_data},
sampling_params=sampling_params,
request_id=request_id,
lora_request=self.lora_request,
Expand Down
2 changes: 1 addition & 1 deletion src/llamafactory/hparams/data_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DataArguments:
metadata={"help": "Path to the folder containing the images or videos. Defaults to `dataset_dir`."},
)
cutoff_len: int = field(
default=1024,
default=2048,
metadata={"help": "The cutoff length of the tokenized inputs in the dataset."},
)
train_on_prompt: bool = field(
Expand Down
11 changes: 10 additions & 1 deletion src/llamafactory/hparams/model_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
from dataclasses import dataclass, field, fields
from typing import Any, Dict, Literal, Optional, Union

import torch
from transformers.training_args import _convert_str_dict
from typing_extensions import Self


Expand Down Expand Up @@ -125,7 +127,7 @@ class VllmArguments:
"""

vllm_maxlen: int = field(
default=2048,
default=4096,
metadata={"help": "Maximum sequence (prompt + response) length of the vLLM engine."},
)
vllm_gpu_util: float = field(
Expand All @@ -140,6 +142,10 @@ class VllmArguments:
default=32,
metadata={"help": "Maximum rank of all LoRAs in the vLLM engine."},
)
vllm_config: Optional[Union[dict, str]] = field(
default=None,
metadata={"help": "Config to initialize the vllm engine. Please use JSON strings."},
)


@dataclass
Expand Down Expand Up @@ -312,6 +318,9 @@ def __post_init__(self):
if self.export_quantization_bit is not None and self.export_quantization_dataset is None:
raise ValueError("Quantization dataset is necessary for exporting.")

if isinstance(self.vllm_config, str) and self.vllm_config.startswith("{"):
self.vllm_config = _convert_str_dict(json.loads(self.vllm_config))

@classmethod
def copyfrom(cls, source: "Self", **kwargs) -> "Self":
init_args, lazy_args = {}, {}
Expand Down
2 changes: 1 addition & 1 deletion src/llamafactory/hparams/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _check_extra_dependencies(
require_version("mixture-of-depth>=1.1.6", "To fix: pip install mixture-of-depth>=1.1.6")

if model_args.infer_backend == "vllm":
require_version("vllm>=0.4.3,<=0.6.3", "To fix: pip install vllm>=0.4.3,<=0.6.3")
require_version("vllm>=0.4.3,<0.6.4", "To fix: pip install vllm>=0.4.3,<0.6.4")

if finetuning_args.use_galore:
require_version("galore_torch", "To fix: pip install galore_torch")
Expand Down
2 changes: 1 addition & 1 deletion src/llamafactory/webui/components/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_train_tab(engine: "Engine") -> Dict[str, "Component"]:
)

with gr.Row():
cutoff_len = gr.Slider(minimum=4, maximum=131072, value=1024, step=1)
cutoff_len = gr.Slider(minimum=4, maximum=131072, value=2048, step=1)
batch_size = gr.Slider(minimum=1, maximum=1024, value=2, step=1)
gradient_accumulation_steps = gr.Slider(minimum=1, maximum=1024, value=8, step=1)
val_size = gr.Slider(minimum=0, maximum=1, value=0, step=0.001)
Expand Down