Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ class ModelManager {
this.loadPromise = null // Track in-progress loads
}

_normalizeAddonDevice (device) {
const normalized = String(device || '').toLowerCase()
if (normalized === 'cpu') return 'cpu'
// Map common accelerator aliases to addon-supported "gpu"
if (normalized === 'gpu' || normalized === 'cuda' || normalized === 'mps') return 'gpu'
return 'gpu'
}

/**
* Generate a unique key for a model configuration
* Includes all parameters that affect model behavior
*/
_generateModelKey (modelPath, config) {
const device = config?.device || 'cpu'
const device = this._normalizeAddonDevice(config?.device || 'gpu')
const gpuLayers = config?.gpu_layers || '0'
const ctxSize = config?.ctx_size || '512'
const batchSize = config?.batch_size || '2048'
Expand Down Expand Up @@ -86,6 +94,7 @@ class ModelManager {
// Build addon config map from parameters
// Config is a map with string values: { gpu_layers: '25', ctx_size: '512', batch_size: '512' }
const addonConfig = {}
addonConfig.device = this._normalizeAddonDevice(config?.device || 'gpu')
if (config?.gpu_layers != null && config.gpu_layers !== '') {
addonConfig.gpu_layers = config.gpu_layers
} else {
Expand Down