Skip to content

Mixed reasoning on/off rollouts/training #619

Closed

Description

@hrossnv

Use cases, pain points, and background
Many reasoning models have a feature in the chat template (or system prompt) to enable or disable thinking. RL runs often want to target both modes at the same time to ensure performance increases on both. It would be great to have this implemented and tested natively in Gym so that it's easy to just add a metadata flag to datapoints that the datapoint should be treated as either reasoning on or reasoning off.
Right now there's a workaround where you can make two "versions" of the policy model and two "versions" of the agent that point at different policy models, but (a) this is awkward, and would be a pain to duplicate across every resource server and (b) this needs more testing, I found that environments like xLAM appeared to break in reasoning off mode, since the tool parsing appears to break, at least with our model (Nemotron Nano v3 chat template).

Current workaround:

policy_model_reasoning_on:
  responses_api_models:
    vllm_model:
      [...]
      chat_template_kwargs:
        enable_thinking: true
policy_model_reasoning_off:
  responses_api_models:
    vllm_model:
      [...]
      chat_template_kwargs:
        enable_thinking: false

instruction_following_simple_agent_reasoning_on:
  responses_api_agents:
    simple_agent:
      [...]
      model_server:
        type: responses_api_models
        name: policy_model_reasoning_on

instruction_following_simple_agent_reasoning_off:
  responses_api_agents:
    simple_agent:
      [...]
      model_server:
        type: responses_api_models
        name: policy_model_reasoning_off

Description:

  • Add chat kwargs support to responses_api_models/vllm_model/app.py
  • Determine whether the above duplication (which would need to be for every single resource server!) is the best/only way to handle mixed reasoning on/off training
  • Implement the best solution and add example to documentation

Design:

  • responses_api_models/vllm_model/app.py
  • TBD - either all resource servers, as in the workaround, or better perhaps the base specification for resource servers in general

Out of scope:
What are some items that this issue could be mistaken to cover that this issue should explicitly NOT cover?

Acceptance Criteria:

  • Implementation
  • Proof that rollouts work and chat template is successfully applied and that reasoning/tools are correctly parsed back into the expected format (in particular, tool parsing needs to be confirmed that it works if the model does not output </think> itself)
  • Documentation

Activity

  1. added theissue type on Jan 28, 2026
  2. cmunley1 commented on Feb 5, 2026

    @cmunley1
    Contributor

    I found that environments like xLAM appeared to break in reasoning off mode, since the tool parsing appears to break, at least with our model (Nemotron Nano v3 chat template).

    do you have example of how it break?

  3. cmunley1 commented on Feb 5, 2026

    @cmunley1
    Contributor

    Add chat kwargs support to responses_api_models/vllm_model/app.py

    isnt chat template kwargs supported now? e.g.
    https://github.com/NVIDIA-NeMo/Gym/blob/main/responses_api_models/vllm_model/app.py#L155-L156

  4. cmunley1 commented on Feb 5, 2026

    @cmunley1
    Contributor
    policy_model_reasoning_on:
      responses_api_models:
        vllm_model:
          [...]
          chat_template_kwargs:
            enable_thinking: true
    policy_model_reasoning_off:
      responses_api_models:
        vllm_model:
          [...]
          chat_template_kwargs:
            enable_thinking: false
    
    instruction_following_simple_agent_reasoning_on:
      responses_api_agents:
        simple_agent:
          [...]
          model_server:
            type: responses_api_models
            name: policy_model_reasoning_on
    
    instruction_following_simple_agent_reasoning_off:
      responses_api_agents:
        simple_agent:
          [...]
          model_server:
            type: responses_api_models
            name: policy_model_reasoning_off
    
    

    I think this is not too unreasonable, what else do you suggest, something like an array of kwargs options?

  5. hrossnv commented on Feb 11, 2026

    @hrossnv
    Author

    isnt chat template kwargs supported now?

    Good catch, the WIP pull request that I based this issue on was based on an earlier version of Gym that didn't have that change yet.

    I think this is not too unreasonable, what else do you suggest, something like an array of kwargs options?

    I don't have another suggestion right now as I'm not familiar enough with Gym's internal implementation, but at least to me, having to duplicate every single resource server YAML config in Gym and duplicate all the values in it except responses_api_agents.model_server.name seems like a lot of duplicated code that might get hard to maintain in the future. Think how long that code block would be if I hadn't just given the example for instruction following only. I don't mind the policy model duplication so much, since it's a much shorter config, and that doesn't actually result in spinning up two copies of the model (as far as I understand).

    do you have example of how it break?

    So, it's possible that I might have hit the bug where chat_template_kwargs wasn't passed to /tokenize endpoint (can't find an issue for that mentioned here on GitHub, but I saw it discussed on Slack), but at any rate, I got rollouts like this:

    "prompt_str":"<|im_start|>system\nYou are a helpful AI assistant[...]<|im_start|>user\nI need a list of weed strains sorted by their names in descending order. Can you provide that?<|im_end|>\n<|im_start|>assistant\n<think>\n",
    "generation_str":"\n<tool_call>\n<function=all_strains_descending>\n<parameter=ordering>\nname\n</parameter>\n</function>\n</tool_call>\n<|im_end|>",
    "reward":0.0,"num_expected":1,"num_predicted":0,"num_correct":0,"predicted_calls":[]
    

    Specifically what happens is that the model appears to be generating reasonable tool calls, but you can see that it doesn't output </think> (which makes sense because that should be in the assistant prompt with enable thinking false, even though for some reason I don't see it in this rollout). This seems to break the verifier's tool parsing because we see that even though the model outputs a reasonable-looking tool call, it's not parsed into predicted_calls. For what it's worth, our tool parser for this model (Qwen3 or the Nemotron Nano v3 tool parser both work) does support reasoning off not generating </think>, so this shouldn't be a problem.

    Thanks for your help!

  6. cmunley1 commented on Feb 11, 2026

    @cmunley1
    Contributor

    @bxyu-nvidia @hrossnv some ideas I have ...

    what if we allow per-task chat template kwargs - so you can create a dataset with a blend of reasoning on / off - this way you can test different blends?

    Or, we could add a config for mulitple chat template configs, e.g.

      policy_model:
        responses_api_models:
          vllm_model:
            # ... existing config ...
            chat_template_configs:
              reasoning_on:
                enable_thinking: true
              reasoning_off:
                enable_thinking: false
    
  7. cmunley1 commented on Mar 4, 2026

    @cmunley1
    Contributor

    @hrossnv should be resolved by #672

    can we close this?

  8. self-assigned this
    on Mar 4, 2026
  9. hrossnv commented on Mar 4, 2026

    @hrossnv
    Author

    Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions