Skip to content

Last step checkpoint save for GRPO creates a checkpoint that doesn't have val_reward in training_info.json #1415

Description

@soluwalana

Describe the bug

Unless the max_steps % val_period == 0 the val_metrics is not calculated for the last checkpoint so when it is saved it doesn't have a val_reward field. in GRPO

This causes the code in get_best_checkpoint_path in utils/checkpoint.py to fail with the following error:

Traceback (most recent call last):
  File "/app/services/customizer/src/training/nemo/config/../rl/run_grpo_penguin.py", line 277, in <module>
    main()
  File "/app/services/customizer/src/training/nemo/config/../rl/run_grpo_penguin.py", line 245, in main
    best_checkpoint = checkpointer.get_best_checkpoint_path()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/nemo-rl/nemo_rl/utils/checkpoint.py", line 246, in get_best_checkpoint_path
    checkpoint_history.sort(
  File "/app/src/nemo-rl/nemo_rl/utils/checkpoint.py", line 247, in <lambda>
    key=lambda x: x[2][self.metric_name], reverse=self.higher_is_better
                  ~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'val_reward'

Recommend changing this code in the grpo.py algorithm where determining whether to run validations:

if val_period > 0 and (step + 1) % val_period == 0 :

to

if (val_period > 0 and (step + 1) % val_period == 0) or is_last_step:

https://github.com/NVIDIA-NeMo/RL/blob/main/nemo_rl/algorithms/grpo.py#L1937

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingqa_rcca_donewhen RCCA finished for the issue, the qa will mark with this label .

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions