ggml : reuse compute buffers for MTP (#27282) - #27489
Open
mushang0 wants to merge 1 commit into
Open
Conversation
|
Hi @mushang0, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Author
|
I verified the implementation, design, testing, and PR description per guidelines. AI was used solely for exploration, debugging, and testing. |
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.
Overview
Fixes #27282
Native MTP creates a target context and an MTP context, each requiring independent scheduler state. Both currently reserve separate GPU compute backing storage, though in the validated native MTP path they never use the compute workspace concurrently. Near the VRAM limit this duplicate reservation causes OOM on the second allocation.
This PR keeps schedulers and allocation plans independent but shares the physical compute buffers via reference counting. A scheduler detaches and allocates independently if it later needs a larger reservation. Automatic enablement is restricted to the validated single-sequence, single-CUDA-device native MTP path; all other cases fall back to independent buffers.
A narrow scheduler-level API is added because no existing interface can express shared backing storage with independent scheduler state.
Additional information
Tested on: RTX 4090 · Qwen3.8-27B · native MTP
Memory
OOM regression
With 1,024 MiB external GPU pressure:
/healthreturns HTTP 200Correctness / Performance
512/2048 token runs: output hash and accepted/generated counts identical between master and patch. No meaningful performance regression observed (512 tok: 74.63 → 75.28 t/s; 2048 tok: 73.27 → 73.49 t/s).
Tests
test-alloc— PASStest-backend-ops— 13,348/13,348 PASSllama-bench,llama-perplexity— PASSDefault CUDA local CI is blocked by a pre-existing
-Werror=stringop-overflowin unmodifiedggml-cuda.cu; reproduces identically on clean master.Requirements