Skip to content

feat: add DAPO asymmetric GRPO clipping - #50

Closed
0z5a wants to merge 1 commit into
ViperEkura:mainfrom
0z5a:codex/add-dapo-asymmetric-clipping-0z5a
Closed

feat: add DAPO asymmetric GRPO clipping#50
0z5a wants to merge 1 commit into
ViperEkura:mainfrom
0z5a:codex/add-dapo-asymmetric-clipping-0z5a

Conversation

@0z5a

@0z5a 0z5a commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add independent lower and upper GRPO clipping epsilons for DAPO Clip-Higher
  • preserve the existing symmetric clip_eps=0.2 behavior when the new options are unset
  • expose --grpo_clip_eps_low and --grpo_clip_eps_high through CLI/YAML configuration
  • reject non-finite, negative, inverted, or invalid lower-bound settings
  • document the asymmetric objective and the DAPO 0.20/0.28 example

Objective

The importance-ratio clamp becomes:

clip(rho, 1 - clip_eps_low, 1 + clip_eps_high)

Setting both values to 0.2 is exactly the previous GRPO objective. Setting clip_eps_low=0.2 and clip_eps_high=0.28 selects the Clip-Higher component described in the DAPO technical report, without implicitly enabling DAPO's separate dynamic-sampling, token-aggregation, or overlong-reward components.

L20 microbenchmark

Exact implementation on NVIDIA L20 (SM89), PyTorch 2.11.0+cu128, CUDA 12.8. One loss vector contains 1,048,576 FP32 token ratios/advantages; 30 warmups, then A-B-B-A with 20 samples per path and 100 iterations per sample.

clamp median p90
symmetric 0.20/0.20 0.05333 ms 0.05406 ms
DAPO 0.20/0.28 0.05288 ms 0.05428 ms

The −0.8% median difference is measurement noise: both paths launch the same operations and differ only in clamp constants. The feature adds no new tensor pass to the GRPO loss hot path.

Validation

  • numerical formula test covers positive upper clipping and unchanged negative lower clipping
  • symmetric-default compatibility test
  • finite/range/order validation tests
  • focused Ruff + pytest: 14 passed
  • CUDA_VISIBLE_DEVICES=5 bash scripts/pre_commit.sh --skip-deps: 655 passed

@0z5a

0z5a commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #58, which preserves the same Clip-Higher configuration and compatibility tests while adding token/sequence aggregation, overlong shaping, and the complete L20/InfraSWE evidence. Keeping one review target avoids reviewing duplicate objective code. The commit and discussion here remain in history.

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