Skip to content

require --ref-load when KL is enabled instead of crashing with a TypeError - #2348

Open
rootkiller6788 wants to merge 2 commits into
THUDM:mainfrom
rootkiller6788:fix-kl-ref-load-validation
Open

require --ref-load when KL is enabled instead of crashing with a TypeError#2348
rootkiller6788 wants to merge 2 commits into
THUDM:mainfrom
rootkiller6788:fix-kl-ref-load-validation

Conversation

@rootkiller6788

Copy link
Copy Markdown

Enabling KL (--kl-coef 0.1 or --use-kl-loss) without --ref-load used to die in slime_validate_args with TypeError: _path_exists: path should be string, bytes, os.PathLike or integer, not NoneType, because it stat'd args.ref_load before checking it was set. The sibling OPD check just below already guards for None first.

This adds the same guard: ref_load unset now raises a ValueError telling the user to pass --ref-load, and a ref_load that points nowhere still raises the original FileNotFoundError. Two unit tests cover both cases.

slime_validate_args called os.path.exists(args.ref_load) whenever
kl_coef != 0 or use_kl_loss is on, but ref_load defaults to None. A
run with --kl-coef but no --ref-load died with a bare TypeError
("path should be string... not NoneType") instead of telling the user
the reference checkpoint is missing. Mirror the OPD check just below
and raise a clear ValueError first.
Two new slime_validate_args unit tests: a non-zero kl_coef or
use_kl_loss with ref_load unset now raises a ValueError mentioning
--ref-load, and a ref_load path that does not exist still raises
FileNotFoundError. Both follow the existing rollout-temperature test
style in this file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant