mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-04-28 02:39:03 +08:00
[v1] add init on rank0 for fsdp2 (#10264)
This commit is contained in:
@@ -140,6 +140,9 @@ class ModelEngine:
|
||||
**init_kwargs,
|
||||
)
|
||||
|
||||
init_mode = self.args.init_config.name if self.args.init_config is not None else "init_on_default"
|
||||
model._init_mode = init_mode
|
||||
|
||||
if self.args.peft_config is None:
|
||||
if self.is_train:
|
||||
logger.info_rank0("Fine-tuning mode: full tuning")
|
||||
@@ -147,6 +150,9 @@ class ModelEngine:
|
||||
else:
|
||||
logger.info_rank0("Inference the original model")
|
||||
else:
|
||||
if self.args.peft_config.name == "lora" and init_mode == "init_on_meta":
|
||||
raise ValueError("Currently lora stage does not support loading model by meta.")
|
||||
|
||||
from ..plugins.model_plugins.peft import PeftPlugin
|
||||
|
||||
model = PeftPlugin(self.args.peft_config.name)(model, self.args.peft_config, self.is_train)
|
||||
|
||||
Reference in New Issue
Block a user