-
Notifications
You must be signed in to change notification settings - Fork 382
Add GLM 5 MTP #1513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Add GLM 5 MTP #1513
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
ad61684
wip: port MTP architecture
SamuelOliveirads b75f70e
Refactors `server_slot` to support generic speculative decoding (MTP …
SamuelOliveirads f9c4f6c
core: enable hybrid outputs (logits + embeddings) for MTP support
SamuelOliveirads b61daeb
fix(mtp): correct KV-cache slot finding for updates
SamuelOliveirads c03ae51
fix(mtp): persist hidden states to prevent context corruption during …
SamuelOliveirads ab6f4bb
refactor(mtp): clean unused code
SamuelOliveirads ec2d1a0
fix(mtp): update server to new functions name
SamuelOliveirads 9317463
fix(mtp): fix graph and save hidden state
SamuelOliveirads d3465f1
mtp: refactor integration, context params and kv cache search
SamuelOliveirads 2539f4f
mtp: fix hidden state extraction and speculative acceptance flow
SamuelOliveirads 07e4936
server: fix MTP warmup for long prompts and reset token buffer
SamuelOliveirads d088faa
llama: refactor MTP operation state to context parameters
SamuelOliveirads 97ec50e
server: fix n_past calculation in MTP acceptance
SamuelOliveirads 573170e
llama: fix mtp enable flags
SamuelOliveirads 5260bf2
Merge branch 'main' into feat-glm-mtp
SamuelOliveirads b4a2c88
speculative: refactor MTP to use common_speculative interface
SamuelOliveirads b8f27f3
context: remove unused signatures
SamuelOliveirads dd684fb
clip: fix deprecated enum-enum conversion warning
SamuelOliveirads 0bcee4e
common: fix format string crash in help message
SamuelOliveirads 1d5b287
context: fix mtp activation logic
SamuelOliveirads 1da0758
llamat: always use the extracted embedding
SamuelOliveirads 4d774d0
llama: get all embeddings to kv cache
SamuelOliveirads dc5ee27
Merge branch 'main' into fix-mtp-embedding
SamuelOliveirads 1ab6327
llama: revert logit to not run mtp for not supported arch
SamuelOliveirads 5eec0d3
llama: allocate all the n_outputs for MTP
SamuelOliveirads 301f3db
wip
SamuelOliveirads 6236fb3
server-context: get only the last embedding for hidden state
SamuelOliveirads f548ac1
ggml-backend: fix array of bounds in debug build
SamuelOliveirads d53dfc7
server-context: run mt kv update to each prompt batch
SamuelOliveirads 94c8184
revert segmentation fault fixes
SamuelOliveirads 8a47d51
Merge branch 'main' into fix-mtp-embedding
SamuelOliveirads c81d493
glm-mtp(feat): optimize graph embedding and recursive drafting
SamuelOliveirads 4e4fd95
glm5-mtp(feat): add glm 5 mtp logic
SamuelOliveirads f978268
Merge branch 'main' into feat/glm5-mtp
SamuelOliveirads 1c8af93
Merge branch 'main' into feat/glm5-mtp
SamuelOliveirads deb13ea
wip
SamuelOliveirads 767ebca
glm-mtp: standardize the MTP graph
SamuelOliveirads 0ead56d
glm 5 mtp: apply post-layer cvec
SamuelOliveirads 284d754
Merge branch 'main' into feat/glm5-mtp
SamuelOliveirads b3a3be0
glm 5 mtp: mark head as mandatory
SamuelOliveirads 9edded3
Merge remote-tracking branch 'origin/main' into feat/glm5-mtp
SamuelOliveirads ee51a7a
get normed embeddings for glm 5
SamuelOliveirads 4646800
Merge branch 'main' into feat/glm5-mtp
ikawrakow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the above construction of the MTP input, is this function just a copy of
build_deepseek2for one layer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, mtp is a typical one-layer decoder after the inputs.
I reviewed it, and the architecture matches SGLang, there was just a small fix missing in the post-layer. I also checked the embeddings just to be sure, and they match. I reran the benchmark along with a new rebase, and the performance remains consistent with what I highlighted in my last test. I also tested with --draft-max 3, yielding 8.1 ± 1.2 t/s overall and 45.8% ± 12.6% accept.