Skip to content

[Reasoning] Add glm47 reasoning parser for GLM-4.7 models#33349

Closed
QwertyJack wants to merge 1 commit intovllm-project:mainfrom
QwertyJack:fix/glm47-reasoning
Closed

[Reasoning] Add glm47 reasoning parser for GLM-4.7 models#33349
QwertyJack wants to merge 1 commit intovllm-project:mainfrom
QwertyJack:fix/glm47-reasoning

Conversation

@QwertyJack
Copy link
Copy Markdown
Contributor

Summary

GLM-4.7 models have a different chat template than GLM-4.5/4.6 models:

  • GLM-4.5/4.6: <think> is NOT included in the generation prompt
  • GLM-4.7: <think> IS included in the generation prompt

This means GLM-4.7 should use DeepSeekR1ReasoningParser instead of DeepSeekV3ReasoningWithThinkingParser used by GLM-4.5/4.6.

Changes

  • Add glm47 reasoning parser registration
  • Add tests for glm47 reasoning parser
  • Update documentation to include GLM-4.7 series

Test plan

  • All 24 new tests pass for glm47 reasoning parser
  • Existing glm45 tests still pass

Fixes #33348

GLM-4.7 models have a different chat template than GLM-4.5/4.6 models:
- GLM-4.5/4.6: <think> is NOT in the generation prompt
- GLM-4.7: <think> IS included in the generation prompt

This means GLM-4.7 should use DeepSeekR1ReasoningParser instead of
DeepSeekV3ReasoningWithThinkingParser used by GLM-4.5/4.6.

Changes:
- Add glm47 reasoning parser registration
- Add tests for glm47 reasoning parser
- Update documentation

Fixes vllm-project#33348

Signed-off-by: QwertyJack <7554089+QwertyJack@users.noreply.github.com>
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 29, 2026

Documentation preview: https://vllm--33349.org.readthedocs.build/en/33349/

@mergify mergify bot added the documentation Improvements or additions to documentation label Jan 29, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for GLM-4.7 reasoning models by aliasing the glm47 parser to the existing DeepSeekR1ReasoningParser. The changes are well-structured, including updates to documentation, registration of the new parser, and a comprehensive new test suite. The approach of reusing an existing parser is sound given the model's behavior.

My main feedback is regarding the new test file, which introduces significant code duplication. While the tests themselves are thorough, refactoring them to be more reusable would greatly improve the long-term maintainability of the test suite. I've left a specific comment with a suggestion on how to achieve this.

@QwertyJack
Copy link
Copy Markdown
Contributor Author

@zRzRzRzRzRzRzR PTAL

Copy link
Copy Markdown
Collaborator

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested --reasoning-parser=glm45?

@QwertyJack
Copy link
Copy Markdown
Contributor Author

After further investigation, I found that:

  1. v0.13.0 had a bug - the old Glm4MoeModelReasoningParser had issues that caused thinking to be mixed with content for GLM-4.7

  2. This was fixed in recent PRs:

  3. Current state on main: glm45 now uses DeepSeekV3ReasoningWithThinkingParser which defaults to thinking=True and delegates to DeepSeekR1ReasoningParser - this should work for both GLM-4.5/4.6 and GLM-4.7

Given that the recent refactoring has unified the parser, I can see the argument that a separate glm47 parser may not be strictly necessary anymore.

However, having glm47 as an explicit alias still provides:

  • Clear semantic mapping for users (GLM-4.7 → glm47)
  • Consistency with the existing glm47 tool parser

@chaunceyjiang What do you think? Should we keep the glm47 alias, or is the current glm45 sufficient for all GLM-4.x models?

@chaunceyjiang
Copy link
Copy Markdown
Collaborator

current glm45 sufficient for all GLM-4.x models

+1

@QwertyJack
Copy link
Copy Markdown
Contributor Author

Closing this PR based on feedback from @chaunceyjiang.

After investigation, we found that:

  1. The issue in v0.13.0 has been fixed in recent PRs (fix no think of GLM-4.5 / GLM-4.7 #31449, [Frontend] Support GLM-4.5 / GLM-4.7 with enable_thinking: false #31788, [Misc] Provide a DeepSeek ReasoningParser with thinking enabled by default #33221)
  2. Current main branch: glm45 now uses DeepSeekV3ReasoningWithThinkingParser which works correctly for all GLM-4.x models (GLM-4.5, GLM-4.6, and GLM-4.7)

A separate glm47 parser is not needed - users should use --reasoning-parser=glm45 for all GLM-4.x models.

Thanks for the review!

@QwertyJack QwertyJack closed this Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GLM-4.7 uses wrong reasoning parser (should use deepseek_r1 instead of glm45)

2 participants