Skip to content

Add DAPO advantage estimator and Soft Overlong support#362

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

Add DAPO advantage estimator and Soft Overlong support#362
CalvinXKY wants to merge 2 commits into
vllm-project:mainfrom
CalvinXKY:feature/dapo-advantage-estimator

Conversation

@CalvinXKY

@CalvinXKY CalvinXKY commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add --advantage-estimator dapo with default Clip-Higher, token-level loss, dynamic sampling, and Soft Overlong
  • Add --soft-overlong-cache and apply length penalty in rollout reward post-processing before group norm
  • Document DAPO usage in zh/en docs and cover defaults with a unit test

Test plan

  • pre-commit on changed files
  • pytest tests/test_megatron_argument_validation.py
  • Smoke train with --advantage-estimator dapo and --over-sampling-batch-size > --rollout-batch-size

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

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

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

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