Repository navigation
Keep the pre-filled thinking block out of the Nemotron 3 assistant-only loss - #8217
Merged
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
qgallouedec
approved these changes
Nov 10, 2026
qgallouedec
left a comment
Member
There was a problem hiding this comment.
Thanks, checked on my side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR stops the Nemotron 3 training templates from training the part of the thinking block that the generation prompt already ends with (
<think>\n, or<think></think>withenable_thinking=False).Fix #8216.
Part of #8109.
Solution
Render the assistant turn first, then emit what the generation prompt pre-fills just before the
{% generation %}block when the turn starts with it, and the rest inside. The rendered text is unchanged: only the assistant mask changes.Changes
nemotron_3_nano_training.jinja,nemotron_3_super_training.jinja,nemotron_3_ultra_training.jinjaandnemotron_3_5_lightning_training.jinja.test_assistant_masks_exclude_generation_promptandtest_assistant_masks_exclude_generation_prompt_without_reasoning.Note
Medium Risk
Changes which tokens get gradient during Nemotron 3 SFT; incorrect masking would skew training, but scope is limited to training templates and mask boundaries.
Overview
Updates Nemotron 3 training chat templates (Nano, Super, Ultra, 3.5 Lightning) so SFT with
assistant_only_lossdoes not apply loss on tokens the generation prompt already pre-fills at the start of the thinking block (<think>\n, or empty<think></think>whenenable_thinking=False).Each template now builds the assistant turn as a string, prints the matching prefill outside
{% generation %}, and wraps only the remainder in{% generation %}— rendered text stays the same; only assistant token masks change. Nemotron 3 entries are removed from the strict xfails ontest_assistant_masks_exclude_generation_prompt*intests/test_chat_template_utils.py, and the chat template docs/README describe this placement.Reviewed by Cursor Bugbot for commit dc7873a. Bugbot is set up for automated code reviews on this repo. Configure here.