server : reset fit_params_target to baseline on model (re)load - #24498
Closed
liminfei-amd wants to merge 1 commit into
Closed
server : reset fit_params_target to baseline on model (re)load#24498liminfei-amd wants to merge 1 commit into
liminfei-amd wants to merge 1 commit into
Conversation
|
Hi @liminfei-amd, 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. |
Fixes ggml-org#24475. Signed-off-by: liminfei-amd <91481003+liminfei-amd@users.noreply.github.com>
liminfei-amd
force-pushed
the
amd-rocm/24475-fit-params-target-reset
branch
from
June 29, 2026 03:18
aa0b4f6 to
65ab5b3
Compare
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
llama-serverwith--mmproj(and/or a draft/MTP model) inflates its free-memorytarget every time it resumes from sleep. With
--sleep-idle-seconds, each wake addsthe mmproj/draft size again, so
fit_params_targetgrows without bound.Root cause:
handle_sleeping_state(false)re-callsload_model(params_base), andload_model()adds the mmproj size (fit_params_target[i] += size) and the draft/MTPsize (
fit_params_target[i] += bytes) toparams_base.fit_params_target. That targetis never reset to its first-load baseline, so the additions compound across wakes.
Fix: snapshot the per-device
fit_params_targeton the first load and restore it beforethe mmproj/draft sizes are added, so the first load and every resume accumulate from the
same clean baseline.
Fixes #24475.
Additional information
The same
+=pattern applies to the draft/MTP branch, so this also covers the draft casethe reporter suspected.
Validation (host-side server logic, hardware-independent):
cmake --build ... --target llama-server, recompilesserver-context.cpp).load_modeltarget lifecycle reproduces the bug and the fix:with the reporter's ~1290 MiB mmproj + a 500 MiB draft, the stock target grows
2814 -> 4604 -> 6394 -> 8184 MiB across three wakes, while the patched target stays at
2814 MiB on every wake.
I currently have two other open PRs (#24237 HIP runtime, #24450 Vulkan build tooling); this one
touches a different area (
server). Happy to serialize and wait if you'd prefer I keep fewer open at once.Requirements
relevant code paths and drafting wording). I authored and reviewed the change, understand
it fully, and can explain every line; the root-cause analysis and validation are mine. No
AI-written code was submitted without manual review.