Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
Open
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
3 changes: 3 additions & 0 deletions llm_on_ray/finetune/finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ def train_func(config: Dict[str, Any]):
tokenizer=tokenizer, mlm=False, return_tensors="pt", pad_to_multiple_of=8
)

callbacks = config["Training"].get("callbacks", None)

if device in ["cpu", "gpu"]:
from transformers import Trainer, TrainingArguments

Expand All @@ -264,6 +266,7 @@ def train_func(config: Dict[str, Any]):
else None,
tokenizer=tokenizer,
data_collator=data_collator,
callbacks=callbacks,
)

common.logger.info("train start")
Expand Down
7 changes: 5 additions & 2 deletions llm_on_ray/finetune/finetune_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# limitations under the License.
#

from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, validator
from typing import Optional, List

from transformers import TrainerCallback

PRECISION_BF16 = "bf16"
PRECISION_FP16 = "fp16"
Expand Down Expand Up @@ -97,6 +97,9 @@ class Training(BaseModel):
gradient_accumulation_steps: int = 1
logging_steps: int = 10
deepspeed_config_file: str = ""
callbacks: Optional[List[TrainerCallback]] = None

model_config = ConfigDict(arbitrary_types_allowed=True)

@validator("device")
def check_device(cls, v: str):
Expand Down