Skip to content

feat(grpo): optional entropy regularization for chunked GRPO loss#6

Open
dongseokmotif wants to merge 1 commit into
mainfrom
feat/grpo-entropy-bonus
Open

feat(grpo): optional entropy regularization for chunked GRPO loss#6
dongseokmotif wants to merge 1 commit into
mainfrom
feat/grpo-entropy-bonus

Conversation

@dongseokmotif

@dongseokmotif dongseokmotif commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

main 기준으로 entropy 정규화만 담도록 재작성한 PR입니다 (기존에 섞여 있던 clamp 커밋 제거).

Adds an optional entropy_coef to the chunked GRPO loss that subtracts entropy_coef * H from the per-token loss (PPO entropy bonus), where H = -Σ_v p_v log p_v is computed from the chunk's already-materialized log_probs — no extra logit pass, no extra memory. Counteracts entropy collapse in long RL runs.

Details

  • Default entropy_coef=0.0 → exact no-op (backward compatible).
  • Threaded through LigerFusedLinearPPOBase.forward / _compute_chunk_loss, LigerFusedLinearGRPOFunction.forward/backward (matching None grad), and LigerFusedLinearGRPOLoss.
  • Entropy computed differentiably from log_probs; gradient flows via the existing chunked-recompute backward.
  • Autograd arg/grad balance verified (27 apply args = 27 backward grads).

Note: assumes importance_sampling_level == "token".

@dongseokmotif
dongseokmotif force-pushed the feat/grpo-entropy-bonus branch from 8c8a706 to 9982957 Compare June 10, 2026 02:27
@ca1207

ca1207 commented Jun 10, 2026

Copy link
Copy Markdown
Member

이거 커밋이 뭔가섞인것 같네요?
2518d8c
이 내용이 포함되어있는것 같습니다

Add an `entropy_coef` parameter to the chunked GRPO loss that subtracts
`entropy_coef * H` from the per-token loss (entropy bonus), where
H = -sum_v p_v * log p_v is computed from the chunk's already-materialized
log_probs — no extra logit materialization, no extra memory. Counteracts
entropy collapse in long RL runs.

- Default entropy_coef=0.0 => exact no-op (backward compatible).
- Threaded through LigerFusedLinearPPOBase.forward, the partial /
  _compute_chunk_loss, GRPOFunction.forward / backward (matching None grad),
  and LigerFusedLinearGRPOLoss.
- Entropy computed differentiably from log_probs inside ppo_loss_fn; gradient
  flows via the existing chunked-recompute backward.

Verified: coef=0 reproduces baseline exactly; nonzero shifts loss by -coef*H
(H ~1 nat on random init), monotonic in coef, gradient changes; autograd
grad-count balanced (30 forward args = 6 grads + 24 Nones).
@dongseokmotif
dongseokmotif force-pushed the feat/grpo-entropy-bonus branch from 9982957 to 3a8fd70 Compare June 14, 2026 05:25
@dongseokmotif dongseokmotif changed the title Feat/grpo entropy bonus feat(grpo): optional entropy regularization for chunked GRPO loss Jun 14, 2026
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.

3 participants