Skip to content

fix(critic): report clipfrac 0 when value_clip is not set - #513

Open
flyingdoubleG wants to merge 1 commit into
alibaba:mainfrom
flyingdoubleG:fix/critic-clipfrac
Open

flyingdoubleG wants to merge 1 commit into
alibaba:mainfrom
flyingdoubleG:fix/critic-clipfrac

Conversation

@flyingdoubleG

Copy link
Copy Markdown

What

In CriticWorker.loss_func (roll/pipeline/base_worker.py), the branch without value_clip sets

loss = (values - returns) ** 2
vf_clipfrac = masked_mean(loss, response_mask, dim=-1).mean()

so the logged critic/clipfrac is the squared value error (it duplicates critic/error and can exceed 1), not a clipped fraction. Nothing is clipped in this branch, so the fraction is 0; the change reports that. The loss and the other metrics are unchanged.

Tests

tests/utils/test_critic_loss.py calls loss_func with and without value_clip and checks the loss and that critic/clipfrac is 0 / 1 respectively. The case without value_clip fails before the change (clipfrac 1.0 = the squared error) and passes after (CPU).

🤖 Generated with Claude Code

Without value_clip, CriticWorker.loss_func set
vf_clipfrac = masked_mean(loss, ...), i.e. the squared value error, so
the logged "critic/clipfrac" was the value loss rather than a fraction
(it can exceed 1). Nothing is clipped in that branch; report 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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