Skip to content

Commit

Permalink
[eval_llama] Add option to save checkpoint after eager transforms.
Browse files Browse the repository at this point in the history
Differential Revision: D62150021

Pull Request resolved: #5045
  • Loading branch information
iseeyuan authored Sep 7, 2024
1 parent 32d83b0 commit 3268da2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/models/llama2/eval_llama_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ def gen_eval_wrapper(
else manager.model.eval().to(device="cpu")
)

# Save the checkpoint after the eager model preparation is done.
# The reason for this option is that the checkpoint can be used
# to do evaluations in other evaluation platforms, or with data
# that is not available in this eval_llama. We save the checkpoint
# here for consistency with eval_llama. The accuracy results we
# get from eval_llama can be used as a reference to other evaluations.
if args.output_eager_checkpoint_file is not None:
torch.save(model, args.output_eager_checkpoint_file)

return EagerEvalWrapper(
model=model,
tokenizer=tokenizer,
Expand Down Expand Up @@ -196,6 +205,12 @@ def build_args_parser() -> argparse.ArgumentParser:
default=None,
help="[For ExecuTorch] Path to the Tokenizer binary for evaluating ExecuTorch models via runtime",
)
parser.add_argument(
"--output_eager_checkpoint_file",
type=str,
default=None,
help="Save the checkpoint after source transformations, for other evaluation platform to run the same checkpoint.",
)

return parser

Expand Down

0 comments on commit 3268da2

Please sign in to comment.