Skip to content
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

add support for Ollama num_gpu #4353

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ declare global {
numThreads?: number;
useMmap?: boolean;
keepAlive?: number;
numGpu?: number;
raw?: boolean;
stream?: boolean;
prediction?: Prediction;
Expand Down
1 change: 1 addition & 0 deletions core/control-plane/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const modelDescriptionSchema = z.object({
numThreads: z.number().optional(),
useMmap: z.boolean().optional(),
keepAlive: z.number().optional(),
numGpu: z.number().optional(),
raw: z.boolean().optional(),
stream: z.boolean().optional(),
})
Expand Down
1 change: 1 addition & 0 deletions core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ export interface BaseCompletionOptions {
numThreads?: number;
useMmap?: boolean;
keepAlive?: number;
numGpu?: number;
raw?: boolean;
stream?: boolean;
prediction?: Prediction;
Expand Down
3 changes: 2 additions & 1 deletion core/llm/llms/Ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ interface OllamaModelFileParams {
top_k?: number;
top_p?: number;
min_p?: number;
num_gpu?: number;

// deprecated or not directly supported here:
num_thread?: number;
use_mmap?: boolean;
num_gqa?: number;
num_gpu?: number;
num_keep?: number;
typical_p?: number;
presence_penalty?: number;
Expand Down Expand Up @@ -264,6 +264,7 @@ class Ollama extends BaseLLM {
num_thread: options.numThreads,
use_mmap: options.useMmap,
min_p: options.minP,
num_gpu: options.numGpu,
};
}

Expand Down
1 change: 1 addition & 0 deletions docs/docs/json-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Parameters that control the behavior of text generation and completion settings.
- `maxTokens`: The maximum number of tokens to generate in a completion (default: `2048`).
- `numThreads`: The number of threads used during the generation process. Available only for Ollama as `num_thread`.
- `keepAlive`: For Ollama, this parameter sets the number of seconds to keep the model loaded after the last request, unloading it from memory if inactive (default: `1800` seconds, or 30 minutes).
- `numGpu`: For Ollama, this parameter overrides the number of gpu layers that will be used to load the model into VRAM.
- `useMmap`: For Ollama, this parameter allows the model to be mapped into memory. If disabled can enhance response time on low end devices but will slow down the stream.

Example
Expand Down
1 change: 1 addition & 0 deletions docs/docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Parameters that control the behavior of text generation and completion settings.
- `maxTokens`: The maximum number of tokens to generate in a completion (default: `2048`).
- `numThreads`: The number of threads used during the generation process. Available only for Ollama as `num_thread`.
- `keepAlive`: For Ollama, this parameter sets the number of seconds to keep the model loaded after the last request, unloading it from memory if inactive (default: `1800` seconds, or 30 minutes).
- `numGpu`: For Ollama, this parameter overrides the number of gpu layers that will be used to load the model into VRAM.
- `useMmap`: For Ollama, this parameter allows the model to be mapped into memory. If disabled can enhance response time on low end devices but will slow down the stream.

Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ Parameters that control the behavior of text generation and completion settings.
- `maxTokens`: The maximum number of tokens to generate in a completion (default: `2048`).
- `numThreads`: The number of threads used during the generation process. Available only for Ollama as `num_thread`.
- `keepAlive`: For Ollama, this parameter sets the number of seconds to keep the model loaded after the last request, unloading it from memory if inactive (default: `1800` seconds, or 30 minutes).
- `numGpu`: For Ollama, this parameter overrides the number of gpu layers that will be used to load the model into VRAM.
- `useMmap`: For Ollama, this parameter allows the model to be mapped into memory. If disabled can enhance response time on low end devices but will slow down the stream.

Example
Expand Down
5 changes: 5 additions & 0 deletions extensions/vscode/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"title": "Ollama keep_alive",
"description": "The number of seconds after no requests are made to unload the model from memory. Defaults to 60*30 = 30min",
"type": "integer"
},
"numGpu": {
"title": "Ollama num_gpu",
"description": "Override the number of gpu layers used when loading the model",
"type": "integer"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/config-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const completionOptionsSchema = z.object({
numThreads: z.number().optional(),
useMmap: z.boolean().optional(),
keepAlive: z.number().optional(),
numGpu: z.number().optional(),
raw: z.boolean().optional(),
stream: z.boolean().optional(),
});
Expand Down
Loading