Skip to content

fix(train): use the verl length budget when it rounds down to SequenceLength - #6573

Open
ananth102 wants to merge 1 commit into
aws:masterfrom
ananth102:fix/rl-sequence-length-ceiling
Open

ananth102 wants to merge 1 commit into
aws:masterfrom
ananth102:fix/rl-sequence-length-ceiling

Conversation

@ananth102

Copy link
Copy Markdown
Collaborator

Summary

validate_length_constraints() enforced the recipe's SequenceLength label as the prompt+response ceiling. verl recipe publishers round that label down to a power of 2 for the hub enum and publish the exact token budget as the length params' override max, so the SDK rejected verl recipes' own defaults. Example: verl-grpo-rlvr-gemma-4-e4b-it-lora defaults to 16384 + 4096 against a 20480-token budget labelled "16K", so every RLVR job that kept the defaults failed before submission.

A length param's max is now the ceiling only when it rounds down to the label (label <= max < 2 * label) and every such param agrees on it. Any other max is not the recipe's budget, and params that disagree are not trusted, so in both cases the label stays the ceiling:

Recipe Label Length param max Ceiling before Ceiling after
verl Gemma 4 E4B RLVR LoRA 16K 20480 16384 (rejects defaults) 20480
llmft Llama 3.2 1B SFT 4K dataset_max_len 131072 4096 4096
params disagree (hypothetical; none in the hub) 16K 20480 and 30000 16384 16384
no SequenceLength - any no check no check

The sum check itself is unchanged: prompt + response over the ceiling is still rejected.

Testing

  • Unit tests for _sequence_length_ceiling covering the verl budget, a generic max outside the label's bucket (llmft), a max below the label, params that disagree, and a missing label; plus an end-to-end case using the Gemma recipe's real override shape (defaults pass, 16384 + 4097 is rejected).
  • test_finetune_utils.py, test_common.py, test_rlvr_trainer.py, test_rlaif_trainer.py: 242 passed, 6 skipped.
  • Reverting to the label-only ceiling fails the verl tests; dropping the bucket condition fails the llmft tests; taking the largest of disagreeing params fails the disagreement test.
  • Full sagemaker-train unit suite: 3508 passed, 19 skipped, 4 failed. The 4 failures are in training_session/test_clients.py, fail identically on master, and come from the test host having no default AWS profile.

Catalog diff. Old and new ceilings computed with the real functions for every recipe in the us-west-2 SageMakerPublicHub (767 models, 437 recipes with override params):

Outcome Recipes
Ceiling unchanged (llmft, Nova, eval, mtrl, power-of-2 verl budgets) 350
Ceiling raised, all verl-*, new ceiling = the length params' declared max 87
Any other change 0
Defaults that passed before and fail now 0
Defaults rejected before, accepted now (every Gemma-4 GRPO RLVR/RLAIF recipe, FFT and LoRA) 12

Live hub probe. RLVRTrainer built for huggingface-vlm-gemma-4-e4b-it LoRA (hub 1.8.3) with default lengths, then validate_length_constraints() called directly: master raises 20480 exceeds ... (16384); this branch passes; this branch with max_response_length=4097 raises 20481 exceeds ... (20480).

GPU run. One serverless RLVR LoRA job on verl-grpo-rlvr-gemma-4-e4b-it-lora with this branch and the recipe's default lengths (16384 + 4096), max_epochs=1. train(dry_run=True) passed, then the job completed all 10 steps with no length assert or OOM, and registered its model package. The container ran with data.max_prompt_length 16384, max_response_length 4096, vLLM --max_model_len 20480 and ppo_max_token_len_per_gpu 20480. Billable time was 2315 s.

…eLength

verl recipe publishers round the SequenceLength label down to a power of 2 for the hub enum and publish the exact token budget as the length params' override max, so enforcing the label rejected recipes' own defaults (verl-grpo-rlvr-gemma-4-e4b-it-lora: 16384 + 4096 against a 20480 budget labelled "16K"). A length param's max is now the ceiling only when it rounds down to the label and every such param agrees on it; otherwise the label stays the ceiling, so a generic bound such as llmft's 131072 on a "4K" recipe, or params that disagree, never loosen the check.

X-AI-Tool: Kiro
X-AI-Prompt: Fix the SDK length check rejecting RLVR recipe defaults on Gemma 4 E4B without loosening it for other recipe families
@ananth102
ananth102 deployed to auto-approve November 9, 2026 18:17 — with GitHub Actions Active
@ananth102
ananth102 deployed to auto-approve November 9, 2026 18:17 — with GitHub Actions Active

@github-actions github-actions 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.

🤖 AI code review

This PR refines the sequence-length ceiling used by validate_length_constraints(). Instead of always treating the recipe's SequenceLength label (rounded to a power of 2) as the ceiling, _sequence_length_ceiling() now adopts a length param's declared max as the budget when it rounds down to the label (label <= max < 2*label) and all such params agree; otherwise it falls back to the label. This fixes verl recipes (e.g. Gemma-4 GRPO RLVR) whose own defaults were rejected before submission. The change is well-scoped, the options_dict variable is in scope at the call site, imports (Dict, Any, Optional) are present, and it is covered by targeted unit tests plus an end-to-end case. I found no correctness, security, or backward-compatibility problems.

Reviewed commit a6d5e98. Automated review; verify before acting.

This branch was successfully deployed

1 active deployment
auto-approve — a6d5e988 Deployed Nov 9, 2026 by ananth102 via wait-for-approval #832
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