Repository navigation
fix(tau-bench): train on sampled token ids instead of retokenized chat text - #2467
Open
PlanckChang wants to merge 1 commit into
Open
PlanckChang wants to merge 1 commit into
PlanckChang wants to merge 1 commit into
Conversation
…t text Multi-turn rollouts discarded SGLang ids and rebuilt the loss mask from the chat template, so BPE merges and template rewrites trained on tokens the model did not generate.
5 tasks
This branch has not been deployed
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.
Summary
Tau-bench multi-turn RL was training on a retokenized chat-template rendering, not on the tokens SGLang sampled. The loss mask for that rendering was also wrong whenever the template inserted text the model did not generate.
What was wrong
Each turn sent the full conversation as text. The sampled token ids were discarded. Training targets came from
apply_chat_templateplusencode. BPE does not round-trip, soencode(decode(ids))is often a different sequence. Qwen3-style templates can also rewrite earlier<think>blocks when a new user turn arrives, so the next inference context and the training tokens diverged.The assistant span was then labeled with one mask bit per retokenized id:
<|im_end|>stripped, and the template appended<|im_end|>\nagain. That closer and the following newline were allloss_mask=1. The newline is not a sampled token.<|im_start|>assistant(and a generation prompt such as<think>\n) was supposed to be masked. The mask length waslen(encode(prefix)), measured separately fromencode(prefix + content). If BPE merges across that boundary, template tokens fall inside the loss.Tool and user turns were already
loss_mask=0. The bug was the assistant span.What this does
input_idsprefix andreturn_logprob=true.output_token_logprobsas the assistant tokens (loss_mask=1), including a sampled<|im_end|>. Decode them only to parse the tool call.loss_mask=0. If the sample did not emit the end token, insert one copy and leave it masked.git maintenancewas removingobjects/maintenance.lockduringshutil.copytree.Test plan
python tests/test_tau_bench_token_delta.pypython tests/test_agent/test_swe_workspace_diff.pyencode(decode(ids))stay intact in the training sequence<|im_start|>assistant, the newline after<|im_end|>, and tool/user text areloss_mask=0<|im_end|>stays in the masked suffix