Skip to content

feat(configuration): improve configuration to support settings using GPU #15

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

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
31 changes: 23 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
"default": false,
"description": "Enable experimental chat feature."
},
"firecoder.experimental.chat.useGpu": {
"type": "boolean",
"default": false,
"description": "Enable experimental chat feature."
},
"firecoder.completion.autoMode": {
"type": "string",
"default": "base-small",
Expand All @@ -117,25 +122,35 @@
"base-large"
],
"enumDescriptions": [
"Use if you have only CPU.",
"Use if you have standard GPU.",
"Use if you have enterprise GPU."
"Use if you have only CPU. (RAM OR VRAM required 4 GB)",
"Use if you have standard GPU. (RAM OR VRAM required 10 GB)",
"Use if you have enterprise GPU. (RAM OR VRAM required 38 GB)"
]
},
"firecoder.completion.manuallyMode": {
"firecoder.completion.autoMode.useGpu": {
"type": "boolean",
"default": false,
"description": "Enable experimental chat feature."
},
"firecoder.completion.manualMode": {
"type": "string",
"default": "base-small",
"markdownDescription": "Select a model for the manually mode based on your system specifications.",
"markdownDescription": "Select a model for the manual mode based on your system specifications.",
"enum": [
"base-small",
"base-medium",
"base-large"
],
"enumDescriptions": [
"Use if you have only CPU.",
"Use if you have standard GPU.",
"Use if you have enterprise GPU."
"Use if you have only CPU. (RAM OR VRAM required 4 GB)",
"Use if you have standard GPU. (RAM OR VRAM required 10 GB)",
"Use if you have enterprise GPU. (RAM OR VRAM required 38 GB)"
]
},
"firecoder.completion.manualMode.useGpu": {
"type": "boolean",
"default": false,
"description": "Enable experimental chat feature."
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/completion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const getInlineCompletionProvider = (

const modelType = triggerAuto
? configuration.get("completion.autoMode")
: configuration.get("completion.manuallyMode");
: configuration.get("completion.manualMode");
const prompt = await getPromptCompletion(
document,
position,
Expand Down
24 changes: 19 additions & 5 deletions src/common/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,30 @@ class Server {
component: "server",
sendTelemetry: true,
});
const isChatModel = this.typeModel in modelsChat;
const isBaseModel = this.typeModel in modelsBase;

const useGPU =
const gpuEnabled =
configuration.get("experimental.useGpu.linux.nvidia") ||
configuration.get("experimental.useGpu.osx.metal") ||
configuration.get("experimental.useGpu.windows.nvidia");

const port = models[this.typeModel].port;
const useGPUChat =
configuration.get("experimental.chat.useGpu") && isChatModel;

const isChatModel = this.typeModel in modelsChat;
const isBaseModel = this.typeModel in modelsBase;
const useGPUCompletionAuto =
configuration.get("completion.autoMode.useGpu") &&
this.typeModel === configuration.get("completion.autoMode");

const useGPUCompletionManual =
configuration.get("completion.manualMode.useGpu") &&
this.typeModel === configuration.get("completion.manualMode");

const useGpu =
gpuEnabled &&
(useGPUCompletionAuto || useGPUCompletionManual || useGPUChat);

const port = models[this.typeModel].port;

this.serverProcess = spawn(
serverPath,
Expand All @@ -126,7 +140,7 @@ class Server {
...(isChatModel ? ["--ctx-size", "16384"] : ["--ctx-size", "4096"]),
...(isBaseModel ? ["--parallel", "4"] : []),
...(isMacArm64 ? ["--nobrowser"] : []),
...(useGPU ? ["--n-gpu-layers", "100"] : []),
...(useGpu ? ["--n-gpu-layers", "100"] : []),
"--cont-batching",
"--embedding",
"--log-disable",
Expand Down
22 changes: 20 additions & 2 deletions src/common/utils/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@ const ConfigurationProperties = {
"experimental.chat": {
default: false,
},
"experimental.chat.useGpu": {
default: false,
},
"completion.autoMode": {
default: "base-small",
},
"completion.manuallyMode": {
"completion.autoMode.useGpu": {
default: false,
},
"completion.manualMode": {
default: "base-small",
},
"completion.manualMode.useGpu": {
default: false,
},
} as const;

interface ConfigurationPropertiesType
Expand All @@ -36,12 +45,21 @@ interface ConfigurationPropertiesType
"experimental.chat": {
possibleValues: boolean;
};
"experimental.chat.useGpu": {
possibleValues: boolean;
};
"completion.autoMode": {
possibleValues: TypeModelsBase;
};
"completion.manuallyMode": {
"completion.autoMode.useGpu": {
possibleValues: boolean;
};
"completion.manualMode": {
possibleValues: TypeModelsBase;
};
"completion.manualMode.useGpu": {
possibleValues: boolean;
};
}

class Configuration {
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function activate(context: vscode.ExtensionContext) {
[
...new Set([
configuration.get("completion.autoMode"),
configuration.get("completion.manuallyMode"),
configuration.get("completion.manualMode"),
...(isChatEnabled ? ["chat-medium" as const] : []),
]),
].map((serverType) => servers[serverType].startServer())
Expand Down