Skip to content

[Feature] Add DAPO preset and Soft Overlong support - #362

Open
CalvinXKY wants to merge 7 commits into
vllm-project:mainfrom
CalvinXKY:feature/dapo-advantage-estimator
Open

CalvinXKY wants to merge 7 commits into
vllm-project:mainfrom
CalvinXKY:feature/dapo-advantage-estimator

Conversation

@CalvinXKY

@CalvinXKY CalvinXKY commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Expose --advantage-estimator dapo as a preset over the existing GRPO implementation.
  • Enable Clip-Higher, token-level loss, the default dynamic-sampling filter, and Soft Overlong defaults.
  • Add --soft-overlong-cache and apply its length penalty before existing reward normalization.
  • Document the preset in English and Chinese.

Design

DAPO does not add a second advantage, loss, or normalization path. Argument validation expands it to the existing GRPO primitives; the only new rollout behavior is Soft Overlong reward shaping.

Test plan

  • Pre-commit on all changed files
  • pytest tests/test_megatron_argument_validation.py (18 passed)
  • Local DAPO preset smoke validation
  • Author GPU/NPU smoke evidence in PR comments

Signed-off-by: kaiyuan <kyxiezju@163.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 22, 2026

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the DAPO (Decoupled Clip and Dynamic sAmpling Policy Optimization) algorithm, adding its documentation, configuration arguments, default recipe validation, and the implementation of Soft Overlong Punishment in reward post-processing. The review feedback points out potential TypeError crashes during argument validation and rollout if rollout_max_response_len is not specified while DAPO or Soft Overlong is enabled, and suggests adding explicit checks and clearer error messages to prevent these issues.

Comment thread vime/utils/arguments.py
Comment on lines +1886 to +1887
if args.soft_overlong_cache is None:
args.soft_overlong_cache = max(1, int(args.rollout_max_response_len) // 4)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If --rollout-max-response-len is not specified (i.e., it is None), calling int(args.rollout_max_response_len) will raise a TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'. Since DAPO defaults to enabling Soft Overlong, we should check if args.rollout_max_response_len is None and raise a clear ValueError to guide the user.

        if args.soft_overlong_cache is None:
            if args.rollout_max_response_len is None:
                raise ValueError("DAPO requires --rollout-max-response-len to be set to enable Soft Overlong.")
            args.soft_overlong_cache = max(1, int(args.rollout_max_response_len) // 4)

Comment thread vime/utils/arguments.py Outdated
Comment on lines +1901 to +1902
if args.soft_overlong_cache is not None and args.soft_overlong_cache < 0:
raise ValueError(f"--soft-overlong-cache must be >= 0, got {args.soft_overlong_cache}.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If the user explicitly sets --soft-overlong-cache to a positive value but does not specify --rollout-max-response-len, a TypeError will occur later during rollout when calculating L_max. We should validate this condition here and raise a clear ValueError.

    if args.soft_overlong_cache is not None:
        if args.soft_overlong_cache < 0:
            raise ValueError(f"--soft-overlong-cache must be >= 0, got {args.soft_overlong_cache}.")
        if args.soft_overlong_cache > 0 and args.rollout_max_response_len is None:
            raise ValueError("--rollout-max-response-len must be set when --soft-overlong-cache is enabled.")

@CalvinXKY

Copy link
Copy Markdown
Collaborator Author

NPU tests:
image

Signed-off-by: kaiyuan <kyxiezju@163.com>
@CalvinXKY CalvinXKY changed the title Add DAPO advantage estimator and Soft Overlong support [Feature] Add DAPO advantage estimator and Soft Overlong support Jul 22, 2026
@CalvinXKY

CalvinXKY commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

GPU tests:

  • Qwen3-4B
  • vime (commit 5cabf1f)
  • vllm/vime:latest
image image

CalvinXKY and others added 5 commits July 22, 2026 22:06
Signed-off-by: kaiyuan <kyxiezju@163.com>
Signed-off-by: kaiyuan <kyxiezju@163.com>
…ure/dapo-advantage-estimator

Signed-off-by: kaiyuan <kyxiezju@163.com>
…ure/dapo-advantage-estimator

Signed-off-by: kaiyuan <kyxiezju@163.com>
Signed-off-by: aoshen02 <aoshen@inferact.ai>
@aoshen02 aoshen02 changed the title [Feature] Add DAPO advantage estimator and Soft Overlong support [Feature] Add DAPO preset and Soft Overlong support Aug 28, 2026
Comment thread vime/utils/arguments.py
if args.dynamic_sampling_filter_path is None:
args.dynamic_sampling_filter_path = (
"vime.rollout.filter_hub.dynamic_sampling_filters.check_reward_nonzero_std"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of the ability of dapo is already support in vime, and for the soft overlong cache, I would say we recommend just use the --custom-reward-post-process-path instead of merging it, I'm still ok with merging this amount of code if it is needed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Let's leave this as the solution for now.

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.

2 participants