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

【auto_parallel】Add checkpoint convertor #8847

Merged
merged 31 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
16 changes: 10 additions & 6 deletions paddlenlp/trainer/auto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from ..utils.log import logger
from .argparser import strtobool
from .ckpt_converter import CheckpointConverter

Check warning on line 31 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L31

Added line #L31 was not covered by tests
from .trainer import SCALER_NAME, SCHEDULER_NAME, TRAINER_STATE_NAME, TRAINING_ARGS_NAME
from .trainer_callback import TrainerState
from .trainer_utils import ( # set_hyrbid_parallel_seed,
Expand Down Expand Up @@ -695,11 +696,6 @@
)
)

ckpt_path = os.path.join(resume_from_checkpoint, DIST_CKPT_PATH)

if not os.path.isdir(ckpt_path):
raise ValueError(f"Can't find a valid checkpoint at {resume_from_checkpoint}")

if self.args.to_static:
opt_state_dict = {
key: value
Expand All @@ -726,7 +722,15 @@
OPTIMIZER_NAME: optim_state_dict,
}

self._load_ckpt_func(state_dict, ckpt_path)
if self.args.resume_form_hybrid_parallel:
CheckpointConverter(

Check warning on line 726 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L725-L726

Added lines #L725 - L726 were not covered by tests
resume_from_checkpoint, state_dict, self.model_wrapped._parameter_to_structured_name
).load_from_hybrid_parallel_checkpoint()
else:
ckpt_path = os.path.join(resume_from_checkpoint, DIST_CKPT_PATH)
if not os.path.isdir(ckpt_path):
raise ValueError(f"Can't find a valid checkpoint at {resume_from_checkpoint}")
self._load_ckpt_func(state_dict, ckpt_path)

Check warning on line 733 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L730-L733

Added lines #L730 - L733 were not covered by tests

# release memory
del state_dict
Loading
Loading