Skip to content

fix(args): reject --kl-coef with GRPO-family advantage estimators - #2368

Open
QJSQJS wants to merge 1 commit into
THUDM:mainfrom
QJSQJS:fix/kl-coef-ignored-by-grpo-estimators
Open

fix(args): reject --kl-coef with GRPO-family advantage estimators#2368
QJSQJS wants to merge 1 commit into
THUDM:mainfrom
QJSQJS:fix/kl-coef-ignored-by-grpo-estimators

Conversation

@QJSQJS

@QJSQJS QJSQJS commented Sep 8, 2026

Copy link
Copy Markdown

Problem

--kl-coef is silently ignored by the grpo / gspo / cispo advantage estimators: get_grpo_returns (slime/utils/ppo_utils.py) only uses the per-token KL tensors for their shape, so the KL penalty never enters rewards or loss. Users who set --kl-coef 0.01 with the default estimator (grpo) get zero regularization with no warning — while the reference-model forward cost is still paid and KL metrics are still logged, which makes the configuration look effective.

Fix

  • Fail fast in slime_validate_args: reject --kl-coef != 0 when advantage_estimator is one of grpo/gspo/cispo, pointing to --use-kl-loss --kl-loss-coef instead. Skipped when --custom-advantage-function-path is set (a custom advantage function replaces the estimator branch and may consume kl_coef itself).
  • Clarify the --kl-coef help text with the estimators that actually apply it.

Estimators that do consume --kl-coef (unchanged, covered by tests): ppo, reinforce_plus_plus, reinforce_plus_plus_baseline.

Tests

Added to tests/test_megatron_argument_validation.py:

  • rejects kl_coef with each of grpo/gspo/cispo
  • allows kl_coef with ppo / reinforce_plus_plus / reinforce_plus_plus_baseline
  • allows kl_coef with a custom advantage function

All 27 tests in the file pass.

--kl-coef was silently ignored by the grpo/gspo/cispo estimators:
get_grpo_returns only uses the per-token KL for its shape, so the
penalty never entered rewards or loss, while the reference-model
forward cost and KL metrics were still paid. Fail fast in
slime_validate_args and point users to --use-kl-loss instead.
@QJSQJS
QJSQJS force-pushed the fix/kl-coef-ignored-by-grpo-estimators branch from 28aca97 to b3950b5 Compare September 8, 2026 07:54
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