Repository navigation
[4/4] fix(data): align thinking-model chat templates and masks - #5541
Merged
Merged
Conversation
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Contributor
Author
|
/ok to test 6f3db7f |
Contributor
|
Light review - LGTM Docs + unit-test-only PR. Verified the new test against the source it exercises:
No critical bugs, typos, or doc inaccuracies found. Could not execute the test in this sandbox, but its assumptions are consistent with the source paths. Suggested test cases
|
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Contributor
Author
|
/ok to test 49a164c |
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Contributor
Author
|
/ok to test 14cadec |
Contributor
Author
|
/ok to test 14cadec |
Contributor
Author
|
/ok to test 4c92760 |
This branch was previously 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
thinking_mode="adaptive"unchangedThis PR is stacked on #5538.
Fixes
truncate_history_thinkingto nativeclear_thinking; use conversation-prefix renders because completed assistant turns have no explicit end tokenenable_thinkingto nativethinking; detect the custom XTML assistant structure without depending on the remote-code class namechat_template_kwargsand top-leveltoolswhen re-rendering a conversation to derive its maskThe review also removed unconditional signature/vocabulary inspection from the per-row path. Vocabulary probing now occurs only for template-less tokenizers that expose the Kimi-style
thinkingparameter.Official template audit
Pinned snapshots checked on 2026-08-13:
zai-org/GLM-5.2b4734de4facf877f85769a911abafc5283eab3d9moonshotai/Kimi-K39f62e4e9fffbd0a83ddd60e1c209d828994b3569MiniMaxAI/MiniMax-M3f0e1c1e04d40177e4673a22097036854f536e9c0The four cases for each model are with/without tools × with/without thinking. Raw OpenAI JSON-string
function.argumentsis used in tool cases.The existing Qwen audit remains exact in all 8 Qwen 3.5/3.6 cases.
Loss-mask audit
MBridge masks system/user/tool-response content and assistant role headers. It supervises retained thinking, assistant responses, assistant tool calls, and model-defined assistant turn terminators where present.
Against ms-swift
ca937fbaf8e0c3dc4ea34358889430e36475463b:Rows with different input IDs are reported as render differences rather than misleading index-level mask differences.
Tests
uv run --no-sync pre-commit run --all-filesuv run --no-sync python -m compileall -q src/megatron/bridge/data/conversation_processing.py tests/unit_tests/models/test_glm52_kimi_k3_minimax_m3_chat.pyA normal project-environment pytest startup is not available on the local manylinux 2.31 host because the pinned
nvidia-resiliency-extwheel requires manylinux 2.39; CI provides the authoritative project-environment run.