verl icon indicating copy to clipboard operation
verl copied to clipboard

[rollout] clarify or wire `multi_turn.use_inference_chat_template` in the active rollout path

Open ruiling-smartbear opened this issue 3 months ago • 2 comments

Checked at current main (c2429f29, 2026-09-01).

Current state

The option is public and documented:

  • verl/workers/config/rollout.py:59 — MultiTurnConfig.use_inference_chat_template: bool = False
  • verl/trainer/config/rollout/rollout.yaml:217, and the generated trainer YAMLs
  • docs/sglang_multiturn/multiturn.rst recommends enabling it when rollouts should match production inference (i.e. exclude prior-turn reasoning): "If you experience context length problems or prefer rollouts that match production (i.e., exclude reasoning), you can enable actor_rollout_ref.rollout.multi_turn.use_inference_chat_template = True". It is also listed in docs/ascend_tutorial/zh/dev_guide/model_dev/parameter_and_metrics.md.

Its only runtime consumer is AsyncRolloutRequest.get_generation_prompt_ids() (verl/workers/rollout/schemas.py:374, branch at :390). As far as I can tell, that method — and verl/workers/rollout/schemas.py as a whole — is not reachable from any in-repository production path on current main:

  • get_generation_prompt_ids has three references repo-wide: the definition, and two calls in tests/workers/rollout/test_sglang_async_rollout_multimodal_delta.py.
  • No non-test module imports verl.workers.rollout.schemas (checked absolute and relative import forms); verl/workers/rollout/__init__.py does not re-export it; I found no string-based dispatch and no subclass overrides.
  • The active multi-turn implementation (verl/experimental/agent_loop/) reads eight other multi_turn.* fields (format, max_user_turns, max_parallel_calls, ...) but not this one.

So a user who sets use_inference_chat_template=True today should see no behavioral change, and gets no warning. This seems worth clarifying because the docs present the option as the mitigation for exactly the situation reasoning-model users keep hitting (prior-turn thinking accumulating in multi-turn rollout, e.g. #4109, #5576, #6854): someone following the docs would reasonably believe they selected production-equivalent prompt rendering.

Related observation

multi_turn.tokenization_sanity_check_mode (default strict) appears to be in the same state: outside tests it is only consumed by AsyncRolloutRequest.finalize() (verl/workers/rollout/schemas.py:606), so the documented default-on tokenization sanity check also does not run in the agent-loop path.

To be clear, this is a configuration/call-path question only. I am not claiming any effect on logprobs or loss masks: the agent-loop path builds and trains on the same incrementally built token stream, which is internally consistent regardless of these options.

Questions

  1. Is AsyncRolloutRequest still reachable through a path I missed (plugin/registration, or downstream projects importing verl.workers.rollout.schemas directly)?
  2. If not, are these two options best treated as partially migrated configuration to be wired into the agent-loop path, or as legacy to deprecate?

Suggested remediation

Either wire the options into the agent-loop path, or warn when they are set while unused and mark them deprecated in the docs until removal. I am happy to send a PR for either direction once maintainers indicate a preference; for tokenization_sanity_check_mode I have a working agent-loop implementation (finalize-time comparison of the incremental stream against a one-pass chat-template render, with expected difference classes reported once instead of per sample) that I can submit.

ruiling-smartbear avatar Sep 01 '26 21:09 ruiling-smartbear

Before sending a PR I wanted to confirm the intended direction for this dead key.

On current main I still see the same split:

  • actor_rollout_ref.rollout.multi_turn.use_inference_chat_template is public (dataclass + rollout.yaml + docs, including docs/sglang_multiturn/multiturn.rst).
  • The only runtime consumer is AsyncRolloutRequest.get_generation_prompt_ids(), which has no production callers.
  • The active multi-turn path (verl/experimental/agent_loop/) already reads the other multi_turn.* fields and does not read this one.

Two possible fixes, and I would like a maintainer preference before implementing either:

  1. Wire it into the agent-loop generation path so True actually excludes prior-turn reasoning / matches production inference, as the docs describe.
  2. Warn + deprecate (or delete) the key, and point users at the live agent-loop / chat-template knobs instead.

(2) is the smaller change and matches what landed for actor.router_replay in #7466. (1) is the behavior the docs currently promise.

Same question for tokenization_sanity_check_mode if you want that folded in: default strict also never runs on the production path.

Happy to send a focused PR once there is a preference.

YeonwooSung avatar Sep 05 '26 06:09 YeonwooSung

Thank you very much for taking the time to independently verify the call path and lay out the two possible directions so clearly. Your findings match mine, and I really appreciate the additional confirmation.

I have also been waiting for maintainer guidance before making any implementation change, since wiring this option into the active agent loop would change existing prompt semantics, while deprecating it would change the documented contract.

My current preference is to warn and deprecate the unused option first, unless maintainers would rather preserve the documented behavior by wiring it into the active path. I agree that tokenization_sanity_check_mode may be better handled separately because it has a different runtime contract.

Maintainers, when you have a chance, could you please advise which direction you prefer? I’m happy to help with the follow-up implementation.

ruiling-smartbear avatar Sep 05 '26 08:09 ruiling-smartbear