mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-07-28 11:46:09 +08:00
[v1] add muon optimizer (#10618)
Co-authored-by: mhh111 <mahonghao1@huawei.com>
This commit is contained in:
committed by
GitHub
parent
d1049d650a
commit
5f653cb96a
@@ -17,9 +17,13 @@ from dataclasses import dataclass, field
|
||||
from typing import Literal
|
||||
from uuid import uuid4
|
||||
|
||||
from ..utils.logging import get_logger
|
||||
from .arg_utils import BatchingStrategy, PluginConfig, get_plugin_config
|
||||
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrainingArguments:
|
||||
output_dir: str = field(
|
||||
@@ -146,6 +150,17 @@ class TrainingArguments:
|
||||
self.optim_config = get_plugin_config(self.optim_config)
|
||||
self.lr_scheduler_config = get_plugin_config(self.lr_scheduler_config)
|
||||
|
||||
# The optimizer learning rate has a single source of truth: ``learning_rate``.
|
||||
# Propagate it into ``optim_config["lr"]`` so optimizer plugins (e.g. Muon) pick it up
|
||||
# via ``optim_config.get("lr")`` without each plugin needing a separate ``learning_rate`` arg.
|
||||
if self.optim_config is not None:
|
||||
if "lr" in self.optim_config:
|
||||
logger.warning_rank0(
|
||||
"`optim_config.lr` is overridden by `learning_rate`; set the learning rate via "
|
||||
"`learning_rate` instead and remove `lr` from `optim_config`."
|
||||
)
|
||||
self.optim_config["lr"] = self.learning_rate
|
||||
|
||||
if str(self.batching_strategy) == str(BatchingStrategy.DYNAMIC_BATCHING):
|
||||
if self.max_steps is None or self.max_steps <= 0:
|
||||
raise ValueError("`dynamic_batching` requires `max_steps` because it is step-driven.")
|
||||
|
||||
Reference in New Issue
Block a user