Repository navigation
Description
Problem
With collator.mode=chat and collator.native_thinking_alignment=false (the default), a final assistant message that has both non-empty content and tool_calls is silently mis-masked:
assistant_maskcovers the prose and the<tool_call>token only.- The tool-call JSON payload,
</tool_call>and the real<|im_end|>get no CE. - The cross-tokenizer EOT pair is built from
<tool_call>on each side and is markedis_correctwhen the two surfaces match (e.g. a Qwen student with a Qwen teacher).
Nothing raises, so training runs normally with weaker supervision on tool-call turns.
Cause
_final_content_span returns only the prose span. In nemo_rl/data/xtoken/native_chat.py the EOT is then taken as the first non-whitespace token after that span:
RL/nemo_rl/data/xtoken/native_chat.py
Lines 311 to 316 in 6f6df9f
| suffix = text[end:] | |
| terminator = suffix.lstrip() | |
| eot_position = end + len(suffix) - len(terminator) | |
| doc.eot_indices.append( | |
| _eot_index(offsets, text, eot_position) if terminator else -1 | |
| ) |
For ChatML-style templates (Qwen3) the text after the prose is \n<tool_call>\n{...}\n</tool_call><|im_end|>, and <tool_call> is a single added token, so _eot_index returns it. Only the native branch reads tool_calls (native_chat.py:270). A tool-only final turn already raises (empty content span, native_chat.py:304), so the two cases behave inconsistently.
This was traced statically against the Qwen3 chat template and tokenizer config; it has not been reproduced on GPU.
Scope
- Introduced together with the chat mode in feat(xtoken): replace DP token alignment with offset-based cluster alignment #3286; main has no chat mode before it.
- Not hit by the shipped configs:
examples/configs/xtoken_native_chat.yamlusesnative_thinking_alignment: true, and the default exemplar usesmode: "text". - The guide does not say that tool conversations require
native_thinking_alignment=true, and every existingtool_callstest intests/unit/data/test_cross_tokenizer_native_chat.pyuses native mode.
Suggested fix
Raise in _tokenize_chat_text when native_semantic_messages is None and messages[-1].get("tool_calls") is set, next to the existing reasoning_content guard and in the same style, pointing to collator.native_thinking_alignment=true. Add an ordinary-mode prose + tool_calls test.
Activity