Skip to content

feat: support GLM DSA sharing top-k and MTP export.#1823

Merged
DongheJin merged 4 commits into
xLLM-AI:mainfrom
sanlio36:preview/glm-5.2_merge
Jul 10, 2026
Merged

feat: support GLM DSA sharing top-k and MTP export.#1823
DongheJin merged 4 commits into
xLLM-AI:mainfrom
sanlio36:preview/glm-5.2_merge

Conversation

@sanlio36

Copy link
Copy Markdown
Collaborator

Description

Related Issues

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor
  • Documentation
  • Test
  • Build or CI

Pull Request Checklist

Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.

PR Title and Commit Messages

  • The PR title and each commit message follow the xLLM commit format: <type>: <subject>.

Allowed types: feat, bugfix, docs, test, refactor, chore, style, revert, perf, model, build, release.
The subject should use clear English, start with a verb, include at least 4 words, and end with ..

Pre-commit Checks

  • I have installed pre-commit by running pip install pre-commit or an equivalent command.
  • I have installed the hooks with pre-commit install.
  • I have run pre-commit run --all-files and fixed any reported issues.

If you are unsure how to set up pre-commit, see the pre-commit documentation.

Self Review

  • I have self-reviewed the code according to .agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.
  • I have rebased this PR onto the latest main branch.

Build and Test Coverage

  • Tests have been added or updated as needed.
  • CUDA: python setup.py build test has passed on a CUDA machine.
  • NPU: python setup.py build test has passed on an NPU machine.
  • MLU: python setup.py build test has passed on an MLU machine.

Reviewer Notes

@sanlio36 sanlio36 changed the title feat: enhance support of DSA sharing_topk (GLM-5.2) and v32_layer quantize on npu devices, fix bug abdou dp-mtp-overlap and v32_layer accuracy.. feat: enhance support of DSA sharing_topk (GLM-5.2) and v32_layer quantize on npu devices, fix bugs about dp-mtp-overlap and v32_layer accuracy.. Jun 25, 2026

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

Copy link
Copy Markdown
Contributor

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 introduces support for GLM-5/5.1/5.2 models, adds W4A8 dynamic quantization preprocessing, implements sticky prefix routing in the block manager pool, and adds an MTP top-k fallback mechanism for DeepSeek V32. The review feedback highlights critical issues, including potential crashes from calling .sizes() on undefined tensors in deepseek_v32_decoder_loader.cpp. Additionally, several style guide violations were identified: C++ helper functions in deepseek_v32_decoder_loader.cpp should use snake_case instead of PascalCase, file-local Python functions in export_mtp.py must be prefixed with a leading underscore, and file-local C++ functions in hf_model_loader.cpp and mtp_worker_impl.cpp should be placed in anonymous namespaces.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread xllm/core/layers/npu/loader/deepseek_v32_decoder_loader.cpp Outdated
Comment thread xllm/core/layers/npu/loader/deepseek_v32_decoder_loader.cpp Outdated
Comment thread xllm/core/layers/npu/loader/deepseek_v32_decoder_loader.cpp Outdated
Comment thread tools/export_mtp.py Outdated
Comment thread tools/export_mtp.py Outdated
Comment thread xllm/core/framework/hf_model_loader.cpp
Comment thread xllm/core/runtime/mtp_worker_impl.cpp
@sanlio36 sanlio36 changed the title feat: enhance support of DSA sharing_topk (GLM-5.2) and v32_layer quantize on npu devices, fix bugs about dp-mtp-overlap and v32_layer accuracy.. feat: support GLM DSA sharing top-k and MTP export. Jun 25, 2026
Comment thread docs/zh/getting_started/quick_start_GLM5.md Outdated
@sanlio36 sanlio36 force-pushed the preview/glm-5.2_merge branch from a6a2503 to 6a3b860 Compare June 26, 2026 03:27
@DongheJin DongheJin merged commit 2052659 into xLLM-AI:main Jul 10, 2026
12 of 19 checks passed
return worker.execute_no_sync_on_stream(processed_input, compute_stream);
std::optional<ForwardOutput> output =
worker.execute_no_sync_on_stream(processed_input, compute_stream);
const int32_t ret = compute_stream.synchronize();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

请问这里为什么要加同步?Qwen3.5这里加了后mtp会增加空泡导致性能下降

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

image image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

v10 分支应该也有这个问题

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

猜测应该是遇到茂军老师一直反馈的一下报错,之后这么改的。但是这么改是否合理有待考量:
F20260627 17:21:22.615046 3253981 mtp_worker_impl.cpp:318] Check failed: state.token_id == token_id (539 vs. 19) MTP decode target state token mismatch, request_id=chatcmpl-2551906557222686169-xaLgCSacqP7RJtXV2rzbQv
*** Check failure stack trace: ***
@ 0x6f6310 google::LogMessage::SendToLog()
@ 0x6f2e0c google::LogMessage::Flush()
@ 0x6f68e0 google::LogMessageFatal::~LogMessageFatal()
@ 0xc770f0 xllm::MTPWorkerImpl::step_decode()
@ 0xcbd35c xllm::SpeculativeWorkerImpl::step()
@ 0xc02388 _ZZN4xllm10WorkerImpl10step_asyncERKNS_12ForwardInputEENUlvE_clEv
@ 0x31e3720 xllm::ThreadPool::internal_loop()
@ 0x31e4410 _ZNSt6thread11_State_implINS_8_InvokerISt5tupleIJZN4xllm10ThreadPoolC4EmN5folly8FunctionIFvvEEEbRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEUlvE_EEEEE6_M_runEv
@ 0xffff878c9da4 (unknown)
@ 0xffff7825fbb4 (unknown)
@ 0xffff782c7f4c (unknown)
@ (nil) (unknown)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

当前改动为规避dp+mtp的精度bug,可在非dp场景下不走这个同步,或进一步定位乱序的问题根因。

return topk_indices.index_select(/*dim=*/0, index);
}

std::optional<ForwardOutput> run_llm_no_sync_impl(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里函数名是no_sync,里面却加了sync,需要看一下是修改函数名还是把sync去掉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants