fix(context): draft model fit vs load inconsistency#25056
Open
wadealexc wants to merge 2 commits into
Open
Conversation
…d context load - moves speculative init to speculative.cpp - changes server_context_impl model_dft and ctx_dft to use raw pointers
fedef14 to
e985236
Compare
Author
|
Rebased. I was thinking about changing |
Member
|
No problem - I'll probably review this in about a week, so feel free to make changes until then. |
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
This PR fixes an inconsistency between draft model fit and load. On master, draft models are fit to VRAM using
params_dft.n_outputs_max = params_base.n_parallel. However, when we actually load the draft model, we don't do this, leadingn_outputs_maxto inherit the much larger value calculated byserver_n_outputs_max. This leads to a slight over-allocation for the draft model.Note: this PR could be a one-line fix, but after reviewing the code, I felt the root cause of the oversight was that draft/mtp fit calculations and model/context load are spread across the
load_modelmethod, leading to several inconsistencies. To fully address the underlying issue, this PR has 2 commits:I split these into 2 commits for ease of review. If you want me to remove the second commit, let me know - but I think the refactor makes
load_modelmuch cleaner 😄Additional information
The second commit unifies draft/mtp param initialization, and model and context loading.
Draft/MTP model/context are now initialized almost identically to the main model - a constructor that uses a pimpl and exposes model/context via accessor methods.
server_context_implhas been changed so thatmodel_dftandctx_dftare raw pointers, like the main model.I also added a helper for
common_paramsinitialization that captures the behavior spread across a few different places inload_modeland provides a single method that should handle all initialization cases correctly. (seecommon_base_params_to_speculative). This single method also setsn_outputs_max, so all locations receive the corrected value.One more tweak: when
common_speculative_initfails, we now reset the model as well as the context (master only resets the context).Requirements
n_outputs_maxdiscrepancy.