Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions slime/utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,17 @@ def slime_validate_args(args):
if args.save_interval is not None:
assert args.save is not None, "'--save' is required when save_interval is set."

# Checkpoints are numbered by the 0-based rollout id (N-1, 2N-1, ... for --save-interval N), while
# Megatron's retention deletes every previous checkpoint that is not a multiple of the retain
# interval, so forwarding the option would keep none of them.
if getattr(args, "save_retain_interval", None) is not None:
raise ValueError(
"--save-retain-interval is not supported: slime numbers checkpoints by the 0-based rollout id "
"(iter_{N-1}, iter_{2N-1}, ... for --save-interval N), which is never a multiple of the retain "
"interval, so Megatron would delete every previous checkpoint "
"(https://github.com/THUDM/slime/issues/2532)."
)

assert not (args.kl_coef != 0 and args.kl_loss_coef != 0), "Only one of kl_coef and kl_loss_coef can be set"

if args.advantage_estimator in ["reinforce_plus_plus", "reinforce_plus_plus_baseline"]:
Expand Down
21 changes: 21 additions & 0 deletions tests/test_megatron_argument_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,27 @@ def test_slime_validate_args_rejects_non_positive_rollout_temperature(monkeypatc
args, _ = module.slime_validate_args(args)


@pytest.mark.unit
def test_slime_validate_args_rejects_save_retain_interval(monkeypatch):
# Checkpoints are numbered by the 0-based rollout id (19, 39, ... for --save-interval 20), so
# Megatron's retention would delete every previous one (#2532).
module = load_slime_arguments_module(monkeypatch)
args = make_slime_validate_args(save="/tmp/ckpt", save_interval=20, save_retain_interval=100)

with pytest.raises(ValueError, match="--save-retain-interval is not supported"):
module.slime_validate_args(args)


@pytest.mark.unit
def test_slime_validate_args_accepts_unset_save_retain_interval(monkeypatch):
module = load_slime_arguments_module(monkeypatch)
args = make_slime_validate_args(save="/tmp/ckpt", save_interval=20, save_retain_interval=None)

args, _ = module.slime_validate_args(args)

assert args.save_retain_interval is None


@pytest.mark.unit
def test_slime_validate_args_preserves_zero_rollout_gpus_under_colocate(monkeypatch):
module = load_slime_arguments_module(monkeypatch)
Expand Down
Loading