verl icon indicating copy to clipboard operation
verl copied to clipboard

[rollout] Shared prompt cap ignores documented data.truncation policies

Open Jackmeson1 opened this issue 1 month ago • 1 comments

System Info

verl 0.10.0.dev, commit 4b26c788d41ce932ce7706c5ee8e249ab52f4c51. Python 3.12.15, Linux/WSL2. CPU reproduction; no model or rollout server.

Information

Overlong text prompts are left-truncated with a warning regardless of data.truncation, including error, right, and middle. The documented policies conflict with the shared cap, which always keeps the suffix. Leading instructions can therefore be discarded even when error is configured.

#4759 removed the dataset's postprocess_data(..., truncation=...) call and four-way raw_prompt_ids handling; policy enforcement was not carried into the agent loop. The unconditional cap arrived later in caf9fee.

Related PR #4600 targets pre-refactor tokenization and #2069's postprocess tensor-size mismatch. Current initial token construction already caps prompts before that PR's proposed check. This issue tracks the remaining shared-cap contract decision, while linking the existing work.

Tasks

Text-only RL initial prompts in SingleTurnAgentLoop and ToolAgentLoop. Multimodal prompts have a separate alignment-preserving rejection path.

Reproduction

Run from this checkout in an environment with verl dependencies installed:

from types import SimpleNamespace
from omegaconf import OmegaConf
from verl.experimental.agent_loop.agent_loop import AgentLoopBase

for policy in ("error", "left", "right", "middle"):
    stub = SimpleNamespace(
        rollout_config=SimpleNamespace(prompt_length=4),
        data_config=OmegaConf.create({"truncation": policy, "max_prompt_length": 4}),
    )
    print(policy, AgentLoopBase._cap_text_prompt_length(stub, list(range(10))))

Actual output:

error [6, 7, 8, 9]
left [6, 7, 8, 9]
right [6, 7, 8, 9]
middle [6, 7, 8, 9]

Each call logs a left-truncation warning. In training, an overlong rendered prompt reaches this path when filtering is disabled or does not exclude it.

Expected behavior

Please choose the contract before implementation:

  1. Honour the documented policies at the shared cap: error rejects the prompt, left keeps [6, 7, 8, 9], right keeps [0, 1, 2, 3], and middle keeps [0, 1, 8, 9]. Define whether error aborts training or rejects/replaces a prompt group, including validation accounting and compatibility with the default error setting.
  2. Declare unconditional left truncation the text-rollout contract and update configuration and documentation accordingly.

For option 1, raising alone does not define trainer behavior: V1 catches failures per prompt group. Async training refills failed groups; sync refill is opt-in, and a sync batch with no materializable trajectories can error.

This report was prepared with AI assistance (Claude Code and OpenAI Codex); the reproduction was run on 4b26c78.

Jackmeson1 avatar Oct 19 '26 04:10 Jackmeson1

Thanks for reporting this — we had independently noticed and verified the same issue on our side, and your analysis matches exactly.

A fix is already in place in PR #8313 (reopened): the shared cap now honors data.truncation — error raises, left/right/middle truncate as documented. We also fixed a middle edge case at cap=1 and verified with 12 CPU tests plus a GPU e2e smoke.

Would be great if you could help review it and we can improve it together.

Jackie2049 avatar Oct 22 '26 08:10 Jackie2049