{{ message }}
Repository navigation
log: report the source of the loaded context length - #18249
Open
ManoharPaturi wants to merge 1 commit into
Open
ManoharPaturi wants to merge 1 commit into
ManoharPaturi wants to merge 1 commit into
Conversation
This branch has not been deployed
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.

Fixes #18229
Summary
When a model is loaded, the runner logs the effective
num_ctxbut not where it came from, so a silent deviation from the Modelfile (e.g. a client request overriding it) goes unnoticed. This adds anum_ctx_sourceattr to the existing load/reload/unload log lines, reporting which level of the documented precedence chain supplied the value:request→modelfile→env(OLLAMA_CONTEXT_LENGTH) →default.Implementation
numCtxSource(model, requestOpts)inserver/routes.go— computed beside the existingusesAutomaticNumCtxinscheduleRunner, from the raw request/model maps (not the merged value), so a request that merely matches the Modelfile number still reportsrequest.getRunner→LlmRequest.numCtxSource→runnerRef.numCtxSource(the same path the existingnumCtxAutobool uses) and emitted byrunnerRef.LogValue()immediately after the existingnum_ctxattr.Known limits (deliberate): the auto-tier OOM reduction (only reachable when source is
default) and the small floors can lower the effective value without changing the attr — both already have their own log signals;ollama psdisplay is out of scope.Tests
server/routes_options_test.go:TestNumCtxSourcecovers all four sources plus the invariantusesAutomaticNumCtx == (source == "default").go build,go vet, and the fullgo test ./server/ -count=1pass;gofmt -lclean.