llm-tuner 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es.md +187 -64
- package/README.md +190 -67
- package/package.json +1 -1
- package/src/cli/index.js +78 -23
- package/src/cli/profile.js +14 -1
- package/src/core/engines/lmstudio.js +2 -1
- package/src/core/engines/ollama.js +2 -1
- package/src/core/index.js +2 -0
- package/src/core/telemetry.js +73 -0
- package/src/core/tuner.js +113 -78
- package/src/i18n/en.js +7 -2
- package/src/i18n/es.js +7 -2
- package/src/web/public/app.js +78 -0
- package/src/web/public/index.html +20 -0
- package/src/web/public/style.css +16 -0
package/README.es.md
CHANGED
|
@@ -2,122 +2,245 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) · **Español**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/llm-tuner)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
Carga un LLM local con la mejor configuración para el contexto que necesitas, en LM Studio u Ollama, en Windows, macOS y Linux. Tú eliges qué significa «mejor» mediante perfiles de carga deterministas: velocidad, equilibrio o máxima calidad de respuestas.
|
|
10
|
+
|
|
11
|
+
Ningún LLM decide la configuración. LLM Tuner lee la topología de tu hardware y los metadatos GGUF del modelo, calcula matemáticamente qué cabe en la VRAM, mide empíricamente las mejores configuraciones candidatas en hardware real y guarda la ganadora como un **preset** persistente. La próxima vez que cargues ese modelo con ese contexto y perfil, el preset se aplica directamente (en ~20 s) sin volver a medir.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Tabla de contenidos
|
|
16
|
+
|
|
17
|
+
- [Características](#características)
|
|
18
|
+
- [Cómo funciona](#cómo-funciona)
|
|
19
|
+
- [Perfiles de carga](#perfiles-de-carga)
|
|
20
|
+
- [Instalación](#instalación)
|
|
21
|
+
- [Uso](#uso)
|
|
22
|
+
- [Asistente interactivo](#asistente-interactivo)
|
|
23
|
+
- [Aplicación de escritorio](#aplicación-de-escritorio)
|
|
24
|
+
- [Modo CLI no interactivo](#modo-cli-no-interactivo)
|
|
25
|
+
- [Referencia de opciones CLI](#referencia-de-opciones-cli)
|
|
26
|
+
- [Qué se prueba](#qué-se-prueba)
|
|
27
|
+
- [Dónde se guardan los presets](#dónde-se-guardan-los-presets)
|
|
28
|
+
- [Estado por plataforma](#estado-por-plataforma)
|
|
29
|
+
- [Arquitectura del proyecto](#arquitectura-del-proyecto)
|
|
30
|
+
- [Desarrollo y pruebas](#desarrollo-y-pruebas)
|
|
31
|
+
- [Notas y solución de problemas](#notas-y-solución-de-problemas)
|
|
32
|
+
- [Licencia](#licencia)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Características
|
|
37
|
+
|
|
38
|
+
- **Optimización determinista**: Basada en metadatos reales de tensores GGUF, ancho de banda PCIe y pruebas empíricas de velocidad de generación, sin que ninguna IA adivine parámetros.
|
|
39
|
+
- **Detección multitarjeta y topología**: Reparte capas inteligentemente priorizando la GPU con mayor enlace PCIe y sin monitor conectado.
|
|
40
|
+
- **Perfiles de carga a medida**: Optimiza para velocidad pura (`speed`), equilibrio ponderado por calidad (`balanced`) o retención íntegra en GPU sin pérdidas (`quality`).
|
|
41
|
+
- **Soporte de motores locales**: Compatibilidad directa con LM Studio (a través de `llama-server`) y Ollama (instancias privadas aisladas).
|
|
42
|
+
- **Presets persistentes**: Mide una única vez por combinación de hardware, modelo, contexto y perfil. Invalida presets automáticamente si el hardware o el archivo del modelo cambian.
|
|
43
|
+
- **Doble interfaz**: Asistente en consola (`llm-tuner`) y aplicación gráfica de escritorio (`llm-tuner-desktop`).
|
|
44
|
+
- **Bilingüe**: Localización completa en español e inglés tanto en terminal como en entorno gráfico.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Cómo funciona
|
|
49
|
+
|
|
50
|
+
1. **Motor**: Eliges LM Studio u Ollama. Si no está instalado, la app ofrece planes de instalación oficiales.
|
|
51
|
+
2. **Modelo y contexto**: Eliges uno de tus modelos descargados y defines el tamaño de contexto deseado (p. ej. 16.384 tokens).
|
|
52
|
+
3. **Perfil de carga**: Eliges qué optimizar: `speed`, `balanced` (predeterminado) o `quality`. La app resalta una recomendación según la VRAM libre.
|
|
14
53
|
4. **Cargar**:
|
|
15
|
-
- Si
|
|
16
|
-
-
|
|
54
|
+
- **Preset existente**: Si ya existe un preset para ese modelo, contexto, perfil y hardware, se aplica de inmediato y se carga el modelo (~20 s).
|
|
55
|
+
- **Sin preset**: Descarga modelos previos para liberar VRAM, prueba las configuraciones más prometedoras (2–3 min), guarda la mejor como preset y carga el modelo.
|
|
17
56
|
|
|
18
|
-
Solo se vuelve a medir cuando cambias el contexto o el perfil, cambia el hardware (GPU, VRAM,
|
|
57
|
+
Solo se vuelve a medir cuando cambias el contexto o el perfil, cambia el hardware (GPU, VRAM, PCIe), cambia el archivo del modelo o se modifican las variantes descargadas (en `speed` y `quality`). También puedes forzar una nueva medición con `--force`.
|
|
58
|
+
|
|
59
|
+
---
|
|
19
60
|
|
|
20
61
|
## Perfiles de carga
|
|
21
62
|
|
|
22
|
-
Más tokens por segundo no significa mejores respuestas. El perfil decide cuánta calidad de
|
|
63
|
+
Más tokens por segundo no siempre significa mejores respuestas. El perfil decide cuánta calidad de respuestas se puede ceder a cambio de velocidad o memoria:
|
|
23
64
|
|
|
24
|
-
| Perfil | Qué optimiza |
|
|
65
|
+
| Perfil | Qué optimiza | Comportamiento y compensaciones |
|
|
25
66
|
|---|---|---|
|
|
26
|
-
| `speed` (Velocidad) |
|
|
27
|
-
| `balanced` (Equilibrado) |
|
|
28
|
-
| `quality` (Calidad) |
|
|
67
|
+
| `speed` (Velocidad) | Tokens por segundo al máximo. | Usa la variante descargada más ligera y cualquier tipo de caché KV (incluyendo `q4_0`). |
|
|
68
|
+
| `balanced` (Equilibrado) | Velocidad ponderada por calidad de caché KV. *(Predeterminado)* | Término medio: usa la variante seleccionada y pondera la velocidad según la precisión de la caché. |
|
|
69
|
+
| `quality` (Calidad) | Mínima pérdida que aún se ejecuta por completo en GPU. | Elige la variante descargada más pesada que quepa en VRAM con caché KV precisa (`f16` o `q8_0`). Si nada cabe completo en GPU, recurre a la regla de `balanced`. |
|
|
29
70
|
|
|
30
|
-
Las optimizaciones
|
|
71
|
+
Las optimizaciones sin pérdida (reparto de capas entre GPUs, orden de tarjetas, hilos de CPU) se aplican siempre en todos los perfiles.
|
|
31
72
|
|
|
32
|
-
|
|
73
|
+
### Selección de variantes
|
|
33
74
|
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
36
|
-
- **Si la vista previa es conservadora**: se calcula con la VRAM que está libre en ese momento, así que la app te avisa cuando la VRAM está en uso. Al cargar, primero se descargan de la memoria los modelos del motor y después se hace la elección real.
|
|
75
|
+
- **Ollama**: La app puede elegir automáticamente la variante (etiqueta) óptima para el perfil y cargarla entre las etiquetas que reconozca como el mismo modelo.
|
|
76
|
+
- **LM Studio**: Dado que LM Studio no permite seleccionar variantes por API externa, la app optimiza la variante activa y te avisa cuando otra variante se ajusta mejor al perfil seleccionado.
|
|
37
77
|
|
|
38
|
-
|
|
78
|
+
---
|
|
39
79
|
|
|
40
80
|
## Instalación
|
|
41
81
|
|
|
82
|
+
Instalación global vía npm:
|
|
83
|
+
|
|
42
84
|
```bash
|
|
43
85
|
npm install -g llm-tuner
|
|
44
|
-
llm-tuner # asistente en la terminal
|
|
45
|
-
llm-tuner-desktop # app de escritorio
|
|
46
86
|
```
|
|
47
87
|
|
|
48
|
-
|
|
88
|
+
Requisitos previos:
|
|
89
|
+
- **Node.js**: versión 22 o posterior (`node >= 22`).
|
|
90
|
+
- **Motor local**: LM Studio (0.4.25+) u Ollama instalado (o instalarlo mediante las opciones del asistente).
|
|
91
|
+
|
|
92
|
+
---
|
|
49
93
|
|
|
50
94
|
## Uso
|
|
51
95
|
|
|
52
|
-
|
|
96
|
+
### Asistente interactivo
|
|
97
|
+
|
|
98
|
+
Ejecuta el asistente en la terminal:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
llm-tuner
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Te guiará paso a paso en la selección de motor, modelo, contexto, perfil recomendado y carga afinada.
|
|
105
|
+
|
|
106
|
+
### Aplicación de escritorio
|
|
107
|
+
|
|
108
|
+
Ejecuta la interfaz de escritorio:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
llm-tuner-desktop
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> **Nota**: El entorno de ejecución de Electron se descarga la primera vez que ejecutas `llm-tuner-desktop`. Se requiere conexión a internet en esa primera ejecución.
|
|
115
|
+
|
|
116
|
+
### Modo CLI no interactivo
|
|
117
|
+
|
|
118
|
+
Útil para automatizaciones, scripts y entornos desatendidos:
|
|
53
119
|
|
|
54
120
|
```bash
|
|
121
|
+
# Ejecución básica con perfil balanced
|
|
55
122
|
llm-tuner --engine lmstudio --model qwen/qwen2.5-coder-32b --ctx 16384 --yes
|
|
123
|
+
|
|
124
|
+
# Especificando perfil de carga
|
|
56
125
|
llm-tuner --engine lmstudio --model qwen/qwen2.5-coder-32b --ctx 16384 --profile quality --yes
|
|
57
|
-
llm-tuner --presets # lista los presets guardados
|
|
58
|
-
llm-tuner --help
|
|
59
|
-
llm-tuner --lang <en|es> # idioma de la interfaz; se guarda para la próxima vez
|
|
60
|
-
```
|
|
61
126
|
|
|
62
|
-
|
|
127
|
+
# Listar presets guardados
|
|
128
|
+
llm-tuner --presets
|
|
63
129
|
|
|
64
|
-
|
|
130
|
+
# Configurar idioma o tema
|
|
131
|
+
llm-tuner /settings
|
|
132
|
+
```
|
|
65
133
|
|
|
66
|
-
|
|
134
|
+
### Referencia de opciones CLI
|
|
67
135
|
|
|
68
|
-
|
|
136
|
+
| Opción | Descripción | Valor predeterminado |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `--engine <lmstudio\|ollama>` | Motor local objetivo. | Preguntado interactivamente |
|
|
139
|
+
| `--model <key>` | Clave del modelo (LM Studio) o nombre/etiqueta (Ollama). | Preguntado interactivamente |
|
|
140
|
+
| `--ctx <tokens>` | Tamaño de contexto en tokens (ej. `16384`). | Preguntado interactivamente |
|
|
141
|
+
| `--profile <speed\|balanced\|quality>` | Perfil de carga a optimizar. | `balanced` |
|
|
142
|
+
| `--force` | Forzar nueva medición aunque exista un preset. | `false` |
|
|
143
|
+
| `--candidates <n>` | Número de configuraciones candidatas a medir. | `3` |
|
|
144
|
+
| `--yes` | Ejecutar sin pedir confirmación. | `false` |
|
|
145
|
+
| `--dry-run` | Medir sin aplicar cambios ni guardar presets. | `false` |
|
|
146
|
+
| `--presets` | Listar presets guardados. | — |
|
|
147
|
+
| `--json` | Salida en formato JSON. | `false` |
|
|
148
|
+
| `--lang <en\|es>` | Establece y guarda el idioma de la interfaz. | Sistema / `en` |
|
|
149
|
+
| `--theme <system\|light\|dark>` | Establece y guarda el tema de la interfaz. | `system` |
|
|
150
|
+
| `/settings` | Menú interactivo de configuración. | — |
|
|
151
|
+
| `--help` | Muestra la ayuda de comandos. | — |
|
|
152
|
+
|
|
153
|
+
---
|
|
69
154
|
|
|
70
|
-
|
|
71
|
-
- **Caché de contexto** según capas con atención, cabezas KV, dimensión y ventana deslizante (SWA).
|
|
72
|
-
- **Reparto de capas entre GPUs**, con prioridad a la GPU con el enlace PCIe más ancho y sin monitor, y el margen libre igualado entre tarjetas.
|
|
73
|
-
- **En modelos MoE que no caben**, cuántas capas de expertos pueden quedarse en la RAM (`--n-cpu-moe`).
|
|
74
|
-
- **Velocidad esperada**, según el ancho de banda de memoria.
|
|
155
|
+
## Qué se prueba
|
|
75
156
|
|
|
76
|
-
|
|
157
|
+
Para cada tipo de caché KV admitido por el perfil (`f16`, `q8_0`, `q4_0`):
|
|
77
158
|
|
|
78
|
-
|
|
79
|
-
|
|
159
|
+
1. **Inspección de tensores GGUF**: Lectura directa de tensores para conocer el peso exacto por capa.
|
|
160
|
+
2. **Modelado de memoria de contexto**: Cálculo de la caché KV según atención, cabezas, dimensiones y ventana deslizante (SWA).
|
|
161
|
+
3. **Reparto en múltiples GPUs**: Distribución proporcional al margen libre de VRAM, priorizando enlaces PCIe más anchos y excluyendo monitores.
|
|
162
|
+
4. **Descarga en modelos MoE**: En modelos con Mixture of Experts que exceden la VRAM, determina cuántos expertos pueden operar en RAM (`--n-cpu-moe`).
|
|
163
|
+
5. **Medición empírica**: Pruebas con un prompt corto y otro que ocupa ~50% del contexto.
|
|
164
|
+
6. **Aplicación de configuración**:
|
|
165
|
+
- **LM Studio**: Escribe la configuración por modelo en `~/.lmstudio/.internal/user-concrete-model-default-config/` y actualiza `hardware-config.json`.
|
|
166
|
+
- **Ollama**: Genera un Modelfile específico (`<modelo>-tuned-<ctx>`) y ajusta las variables de entorno del servidor. Siempre se crea una copia de respaldo `*.bak-llm-tuner-*` antes de modificar archivos.
|
|
80
167
|
|
|
81
|
-
|
|
168
|
+
---
|
|
82
169
|
|
|
83
170
|
## Dónde se guardan los presets
|
|
84
171
|
|
|
85
|
-
|
|
172
|
+
Existe un preset por cada combinación de motor, modelo, contexto y perfil:
|
|
86
173
|
|
|
87
|
-
- Linux
|
|
88
|
-
- macOS
|
|
89
|
-
- Windows
|
|
174
|
+
- **Linux**: `~/.config/llm-tuner/presets/`
|
|
175
|
+
- **macOS**: `~/Library/Application Support/llm-tuner/presets/`
|
|
176
|
+
- **Windows**: `%APPDATA%\llm-tuner\presets\`
|
|
177
|
+
|
|
178
|
+
---
|
|
90
179
|
|
|
91
180
|
## Estado por plataforma
|
|
92
181
|
|
|
93
|
-
| |
|
|
182
|
+
| Plataforma y Motor | Estado | Notas |
|
|
94
183
|
|---|---|---|
|
|
95
|
-
| Linux + NVIDIA + LM Studio | ✅ 2× RTX 5070, Ryzen 7 5800X |
|
|
96
|
-
| Linux + Ollama |
|
|
97
|
-
| Windows / macOS |
|
|
98
|
-
| AMD
|
|
184
|
+
| **Linux + NVIDIA + LM Studio** | ✅ Verificado | Calibrado con mediciones reales (2× RTX 5070, Ryzen 7 5800X). |
|
|
185
|
+
| **Linux + Ollama** | ✅ Verificado | Comprobado mediante instancias privadas y suite de pruebas unitarias. |
|
|
186
|
+
| **Windows / macOS** | 🧪 Soportado | Rutas oficiales, comandos del sistema y detección implementados. |
|
|
187
|
+
| **AMD ROCm / Apple Silicon / Intel Arc** | 🧪 Soportado | Detección de VRAM activa; ancho de banda estimado por tabla de especificaciones. |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Arquitectura del proyecto
|
|
99
192
|
|
|
100
|
-
|
|
193
|
+
```
|
|
194
|
+
llmtuner/
|
|
195
|
+
├── src/
|
|
196
|
+
│ ├── core/ # Núcleo del afinador, estimador, detección de hardware, presets y perfiles
|
|
197
|
+
│ │ ├── engines/ # Controladores de LM Studio y Ollama
|
|
198
|
+
│ │ ├── estimator.js# Modelado matemático de memoria y VRAM
|
|
199
|
+
│ │ ├── gguf.js # Parser de tensores GGUF
|
|
200
|
+
│ │ ├── hardware.js # Detección de GPU, enlaces PCIe y estado de VRAM
|
|
201
|
+
│ │ ├── presets.js # Lógica de guardado e invalidación de presets
|
|
202
|
+
│ │ └── profiles.js # Reglas de perfiles speed, balanced y quality
|
|
203
|
+
│ ├── cli/ # Asistente interactivo y análisis de argumentos CLI
|
|
204
|
+
│ ├── i18n/ # Catálogos de internacionalización en español e inglés
|
|
205
|
+
│ └── web/ # Servidor HTTP/SSE embebido que alimenta la interfaz gráfica
|
|
206
|
+
├── electron/ # Lanzador y proceso principal de Electron
|
|
207
|
+
├── test/ # Suite de pruebas unitarias de Node.js
|
|
208
|
+
└── docs/ # Especificaciones técnicas, mediciones reales y notas
|
|
209
|
+
```
|
|
101
210
|
|
|
102
|
-
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Desarrollo y pruebas
|
|
214
|
+
|
|
215
|
+
Clonar y preparar el repositorio local:
|
|
103
216
|
|
|
104
217
|
```bash
|
|
105
218
|
git clone https://github.com/ronald32acunadev/llmtuner.git
|
|
106
219
|
cd llmtuner
|
|
107
220
|
npm install
|
|
108
|
-
npm start # asistente en la terminal
|
|
109
|
-
npm run desktop # app de escritorio
|
|
110
|
-
```
|
|
111
221
|
|
|
112
|
-
|
|
222
|
+
# Iniciar asistente CLI
|
|
223
|
+
npm start
|
|
113
224
|
|
|
114
|
-
|
|
225
|
+
# Iniciar aplicación de escritorio
|
|
226
|
+
npm run desktop
|
|
227
|
+
|
|
228
|
+
# Ejecutar suite de pruebas
|
|
115
229
|
npm test
|
|
116
230
|
```
|
|
117
231
|
|
|
118
|
-
|
|
232
|
+
La suite incluye pruebas de regresión que verifican los resultados reales de doble RTX 5070 con Qwen2.5-Coder-32B.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Notas y solución de problemas
|
|
237
|
+
|
|
238
|
+
- **Descarga inicial de Electron**: Electron se descarga al ejecutar por primera vez `llm-tuner-desktop`. En entornos cerrados sin conexión, extrae `electron-v*.zip` en la carpeta `dist/` del paquete instalado de `electron` y crea `path.txt` con el texto `electron`.
|
|
239
|
+
- **Instalaciones con sudo / permisos**: Evita instalar con permisos de superusuario desalineados (`sudo npm install -g`), ya que Electron podría no poder descomprimir sus binarios en la carpeta del usuario.
|
|
240
|
+
- **Compatibilidad con LM Studio**: Verificado y calibrado con LM Studio 0.4.25+.
|
|
241
|
+
|
|
242
|
+
---
|
|
119
243
|
|
|
120
|
-
##
|
|
244
|
+
## Licencia
|
|
121
245
|
|
|
122
|
-
|
|
123
|
-
- Los archivos internos de LM Studio no son una API pública. Esta versión está verificada con LM Studio 0.4.25.
|
|
246
|
+
[MIT](LICENSE) © Ronald Daniel Acuña Arias
|
package/README.md
CHANGED
|
@@ -2,122 +2,245 @@
|
|
|
2
2
|
|
|
3
3
|
**English** · [Español](README.es.md)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/llm-tuner)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
Load a local LLM with the best configuration for the context you need, on LM Studio or Ollama, on Windows, macOS, and Linux. You choose what "best" means through deterministic load profiles: speed, a balanced trade-off, or maximum answer quality.
|
|
10
|
+
|
|
11
|
+
No LLM decides the configuration. LLM Tuner reads your hardware topology and model GGUF metadata, mathematically calculates what fits into VRAM, benchmarks the top candidate configurations on real hardware, and saves the winner as a persistent **preset**. The next time you load that model with the same context and profile, the preset is applied instantly (in ~20s) without re-measuring.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [Features](#features)
|
|
18
|
+
- [How It Works](#how-it-works)
|
|
19
|
+
- [Load Profiles](#load-profiles)
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [Interactive Wizard](#interactive-wizard)
|
|
23
|
+
- [Desktop App](#desktop-app)
|
|
24
|
+
- [Non-Interactive CLI](#non-interactive-cli)
|
|
25
|
+
- [CLI Options Reference](#cli-options-reference)
|
|
26
|
+
- [Tuning Pipeline](#tuning-pipeline)
|
|
27
|
+
- [Preset Storage](#preset-storage)
|
|
28
|
+
- [Platform Support](#platform-support)
|
|
29
|
+
- [Project Architecture](#project-architecture)
|
|
30
|
+
- [Development & Testing](#development--testing)
|
|
31
|
+
- [Notes & Troubleshooting](#notes--troubleshooting)
|
|
32
|
+
- [License](#license)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Deterministic Optimization**: Uses GGUF tensor-level metadata, PCIe bandwidth measurements, and real token-generation benchmarks—never an AI guessing parameters.
|
|
39
|
+
- **Multi-GPU & Topology Aware**: Splits layers intelligently, prioritizing the GPU with the widest PCIe link and no display server attached.
|
|
40
|
+
- **Tailored Load Profiles**: Optimize for raw tokens/second (`speed`), quality-weighted speed (`balanced`), or zero-loss GPU retention (`quality`).
|
|
41
|
+
- **Engine Support**: First-class support for both LM Studio (direct `llama-server` management) and Ollama (isolated private benchmarks).
|
|
42
|
+
- **Persistent Presets**: Measures once per hardware, model, context, and profile. Automatically invalidates presets if hardware or model weights change.
|
|
43
|
+
- **Dual Interfaces**: Interactive terminal wizard (`llm-tuner`) and cross-platform desktop UI (`llm-tuner-desktop`).
|
|
44
|
+
- **Bilingual**: Full English and Spanish localization for both terminal and desktop interfaces.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## How It Works
|
|
49
|
+
|
|
50
|
+
1. **Engine Selection**: Select LM Studio or Ollama. If not installed, LLM Tuner provides official installer commands.
|
|
51
|
+
2. **Model & Context**: Pick any locally downloaded model and set the desired context window (e.g. 16,384 tokens).
|
|
52
|
+
3. **Load Profile**: Choose between `speed`, `balanced` (default), or `quality`. The system highlights a recommended profile based on free VRAM.
|
|
14
53
|
4. **Load**:
|
|
15
|
-
- If
|
|
16
|
-
-
|
|
54
|
+
- **Preset Hit**: If a preset exists for that exact model, context, profile, and hardware, it applies immediately and loads the model (~20s).
|
|
55
|
+
- **Preset Miss**: Unloads existing models to free VRAM, evaluates top candidate configurations (2–3 min), benchmarks actual generation speeds, saves the best preset, and loads the model.
|
|
17
56
|
|
|
18
|
-
|
|
57
|
+
Benchmarks run again only if the context or profile changes, the hardware changes (GPU, VRAM, PCIe link), the model file changes, or downloaded variants change (for `speed` and `quality`). You can also force a benchmark run with `--force`.
|
|
19
58
|
|
|
20
|
-
|
|
59
|
+
---
|
|
21
60
|
|
|
22
|
-
|
|
61
|
+
## Load Profiles
|
|
23
62
|
|
|
24
|
-
|
|
63
|
+
More tokens per second does not always equal better answers. Profiles let you decide when answer quality can be traded for speed or memory efficiency:
|
|
64
|
+
|
|
65
|
+
| Profile | Optimization Goal | Trade-offs & Behaviour |
|
|
25
66
|
|---|---|---|
|
|
26
|
-
| `speed` |
|
|
27
|
-
| `balanced` | Speed weighted by
|
|
28
|
-
| `quality` |
|
|
67
|
+
| `speed` | Maximum tokens per second. | Uses the lightest downloaded quantization variant and any KV cache type (including `q4_0`). |
|
|
68
|
+
| `balanced` | Speed weighted by KV cache quality. *(Default)* | Balanced trade-off; runs with the selected variant and weighs speed by KV precision. |
|
|
69
|
+
| `quality` | Zero degradation that still fits fully on GPU. | Keeps the heaviest downloaded variant that fits entirely into VRAM, using precise KV cache (`f16` or `q8_0`). Falls back to `balanced` if no full offload is possible. |
|
|
70
|
+
|
|
71
|
+
Lossless optimizations (layer distribution across GPUs, thread count, GPU selection order) are applied across all profiles.
|
|
29
72
|
|
|
30
|
-
|
|
73
|
+
### Variant Switching
|
|
31
74
|
|
|
32
|
-
|
|
75
|
+
- **Ollama**: Automatically selects and loads the best tag variant for the active profile among tags identified as the same model.
|
|
76
|
+
- **LM Studio**: Since LM Studio cannot switch variants programmatically, LLM Tuner optimizes the active variant and advises you when another variant better suits your chosen profile.
|
|
33
77
|
|
|
34
|
-
|
|
35
|
-
- **Whether a heavier variant would fit**: for example, that Q8_0 is not downloaded and would fit fully on your GPUs. The size is an estimate, and the app never downloads anything.
|
|
36
|
-
- **Whether the preview is conservative**: it is computed with the VRAM that is free at that moment, so the app warns you when VRAM is in use. Loading unloads the engine's models first and then makes the real choice.
|
|
78
|
+
---
|
|
37
79
|
|
|
38
|
-
|
|
80
|
+
## Installation
|
|
39
81
|
|
|
40
|
-
|
|
82
|
+
Install globally via npm:
|
|
41
83
|
|
|
42
84
|
```bash
|
|
43
85
|
npm install -g llm-tuner
|
|
44
|
-
llm-tuner # terminal wizard
|
|
45
|
-
llm-tuner-desktop # desktop app
|
|
46
86
|
```
|
|
47
87
|
|
|
48
|
-
|
|
88
|
+
Prerequisites:
|
|
89
|
+
- **Node.js**: version 22 or higher (`node >= 22`).
|
|
90
|
+
- **Local Engine**: LM Studio (0.4.25+) or Ollama installed (or let the wizard guide installation).
|
|
91
|
+
|
|
92
|
+
---
|
|
49
93
|
|
|
50
94
|
## Usage
|
|
51
95
|
|
|
52
|
-
|
|
96
|
+
### Interactive Wizard
|
|
97
|
+
|
|
98
|
+
Launch the terminal wizard:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
llm-tuner
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Guides you interactively through engine selection, model selection, context length, profile recommendation, and automatic tuning.
|
|
105
|
+
|
|
106
|
+
### Desktop App
|
|
107
|
+
|
|
108
|
+
Launch the desktop interface:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
llm-tuner-desktop
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> **Note**: Electron downloads automatically during the first launch of `llm-tuner-desktop`. A working network connection is required for that initial launch.
|
|
115
|
+
|
|
116
|
+
### Non-Interactive CLI
|
|
117
|
+
|
|
118
|
+
Run directly in headless, scripted, or CI environments:
|
|
53
119
|
|
|
54
120
|
```bash
|
|
121
|
+
# Basic run with balanced profile
|
|
55
122
|
llm-tuner --engine lmstudio --model qwen/qwen2.5-coder-32b --ctx 16384 --yes
|
|
123
|
+
|
|
124
|
+
# Specify load profile
|
|
56
125
|
llm-tuner --engine lmstudio --model qwen/qwen2.5-coder-32b --ctx 16384 --profile quality --yes
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
llm-tuner --
|
|
126
|
+
|
|
127
|
+
# List saved presets
|
|
128
|
+
llm-tuner --presets
|
|
129
|
+
|
|
130
|
+
# Configure language and theme
|
|
131
|
+
llm-tuner /settings
|
|
60
132
|
```
|
|
61
133
|
|
|
62
|
-
|
|
134
|
+
### CLI Options Reference
|
|
63
135
|
|
|
64
|
-
|
|
136
|
+
| Flag | Description | Default |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `--engine <lmstudio\|ollama>` | Target engine. | Interactive prompt |
|
|
139
|
+
| `--model <key>` | Model key or Ollama tag. | Interactive prompt |
|
|
140
|
+
| `--ctx <tokens>` | Context length in tokens (e.g. `16384`). | Interactive prompt |
|
|
141
|
+
| `--profile <speed\|balanced\|quality>` | Load profile to optimize for. | `balanced` |
|
|
142
|
+
| `--force` | Force re-measurement even if a valid preset exists. | `false` |
|
|
143
|
+
| `--candidates <n>` | Number of top candidate configurations to benchmark. | `3` |
|
|
144
|
+
| `--yes` | Run non-interactively without confirmation prompts. | `false` |
|
|
145
|
+
| `--dry-run` | Measure without saving presets or modifying engine configurations. | `false` |
|
|
146
|
+
| `--presets` | List all saved presets. | — |
|
|
147
|
+
| `--json` | Output results as JSON. | `false` |
|
|
148
|
+
| `--lang <en\|es>` | Set and persist interface language. | System / `en` |
|
|
149
|
+
| `--theme <system\|light\|dark>` | Set and persist interface theme. | `system` |
|
|
150
|
+
| `/settings` | Open interactive settings menu. | — |
|
|
151
|
+
| `--help` | Show usage instructions. | — |
|
|
65
152
|
|
|
66
|
-
|
|
153
|
+
---
|
|
67
154
|
|
|
68
|
-
|
|
155
|
+
## Tuning Pipeline
|
|
69
156
|
|
|
70
|
-
|
|
71
|
-
- **Context cache** based on layers with attention, KV heads, dimension and sliding window (SWA).
|
|
72
|
-
- **Layer split across GPUs**, prioritizing the GPU with the widest PCIe link and no monitor attached, with free headroom balanced evenly across cards.
|
|
73
|
-
- **For MoE models that don't fit**, how many expert layers can stay in RAM (`--n-cpu-moe`).
|
|
74
|
-
- **Expected speed**, based on memory bandwidth.
|
|
157
|
+
For each KV cache type allowed by the selected profile (`f16`, `q8_0`, `q4_0`):
|
|
75
158
|
|
|
76
|
-
|
|
159
|
+
1. **GGUF Tensor Inspection**: Parses GGUF tensors to obtain actual byte sizes per layer.
|
|
160
|
+
2. **Context Memory Modeling**: Models KV cache size taking into account attention heads, dimensions, and sliding window attention (SWA).
|
|
161
|
+
3. **Multi-GPU Split**: Allocates layers proportionally to VRAM headroom, ordering GPUs by PCIe bandwidth and avoiding active display adapters.
|
|
162
|
+
4. **MoE Offloading**: For Mixture of Experts (MoE) architectures that exceed VRAM, calculates the exact expert count that can reside in system RAM (`--n-cpu-moe`).
|
|
163
|
+
5. **Empirical Benchmarks**: Benchmarks candidates using both a short prompt and a deep prompt filling ~50% of the context.
|
|
164
|
+
6. **Configuration Application**:
|
|
165
|
+
- **LM Studio**: Updates per-model config in `~/.lmstudio/.internal/user-concrete-model-default-config/` and updates `hardware-config.json`.
|
|
166
|
+
- **Ollama**: Creates an optimized Modelfile (`<model>-tuned-<ctx>`) and sets system server environment variables. A backup (`*.bak-llm-tuner-*`) is created before changing files.
|
|
77
167
|
|
|
78
|
-
|
|
79
|
-
- **Ollama**: each option is measured on a private `ollama serve` on another port, because the KV type and Flash Attention are global. The model `<model>-tuned-16k` is created with `num_ctx`, `num_gpu` and `num_thread`, and the server variables are configured (systemd on Linux, `setx` on Windows, `launchctl` on macOS).
|
|
168
|
+
---
|
|
80
169
|
|
|
81
|
-
|
|
170
|
+
## Preset Storage
|
|
82
171
|
|
|
83
|
-
|
|
172
|
+
Presets are stored deterministically per engine, model, context, and profile:
|
|
84
173
|
|
|
85
|
-
|
|
174
|
+
- **Linux**: `~/.config/llm-tuner/presets/`
|
|
175
|
+
- **macOS**: `~/Library/Application Support/llm-tuner/presets/`
|
|
176
|
+
- **Windows**: `%APPDATA%\llm-tuner\presets\`
|
|
86
177
|
|
|
87
|
-
|
|
88
|
-
- macOS: `~/Library/Application Support/llm-tuner/presets/`
|
|
89
|
-
- Windows: `%APPDATA%\llm-tuner\presets\`
|
|
178
|
+
---
|
|
90
179
|
|
|
91
|
-
## Platform
|
|
180
|
+
## Platform Support
|
|
92
181
|
|
|
93
|
-
| |
|
|
182
|
+
| Platform & Engine | Status | Notes |
|
|
94
183
|
|---|---|---|
|
|
95
|
-
| Linux + NVIDIA + LM Studio | ✅ 2× RTX 5070, Ryzen 7 5800X |
|
|
96
|
-
| Linux + Ollama |
|
|
97
|
-
| Windows / macOS |
|
|
98
|
-
| AMD
|
|
184
|
+
| **Linux + NVIDIA + LM Studio** | ✅ Verified | Calibrated with real measurements (2× RTX 5070, Ryzen 7 5800X). |
|
|
185
|
+
| **Linux + Ollama** | ✅ Verified | Tested via private instance harnesses and unit test suite. |
|
|
186
|
+
| **Windows / macOS** | 🧪 Supported | Official paths, system commands, and detection logic implemented. |
|
|
187
|
+
| **AMD ROCm / Apple Silicon / Intel Arc** | 🧪 Supported | Hardware VRAM detection enabled; memory bandwidth sourced from lookup tables. |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Project Architecture
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
llmtuner/
|
|
195
|
+
├── src/
|
|
196
|
+
│ ├── core/ # Core tuning engine, estimator, hardware detection, presets, profiles
|
|
197
|
+
│ │ ├── engines/ # LM Studio and Ollama driver adapters
|
|
198
|
+
│ │ ├── estimator.js# Mathematical memory and VRAM modeling
|
|
199
|
+
│ │ ├── gguf.js # GGUF tensor parser
|
|
200
|
+
│ │ ├── hardware.js # GPU detection, PCIe links, VRAM monitoring
|
|
201
|
+
│ │ ├── presets.js # Preset persistence and invalidation logic
|
|
202
|
+
│ │ └── profiles.js # Speed, balanced, and quality profile rules
|
|
203
|
+
│ ├── cli/ # Interactive wizard and CLI argument parsing
|
|
204
|
+
│ ├── i18n/ # English and Spanish localization catalogs
|
|
205
|
+
│ └── web/ # Embedded HTTP/SSE server powering the desktop GUI
|
|
206
|
+
├── electron/ # Desktop launcher and main process wrapper
|
|
207
|
+
├── test/ # Node.js native test suite
|
|
208
|
+
└── docs/ # Technical specs, real benchmark measurements, and notes
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
99
212
|
|
|
100
|
-
|
|
213
|
+
## Development & Testing
|
|
101
214
|
|
|
102
|
-
|
|
215
|
+
Clone and set up locally:
|
|
103
216
|
|
|
104
217
|
```bash
|
|
105
218
|
git clone https://github.com/ronald32acunadev/llmtuner.git
|
|
106
219
|
cd llmtuner
|
|
107
220
|
npm install
|
|
108
|
-
npm start # terminal wizard
|
|
109
|
-
npm run desktop # desktop app
|
|
110
|
-
```
|
|
111
221
|
|
|
112
|
-
|
|
222
|
+
# Start CLI wizard
|
|
223
|
+
npm start
|
|
113
224
|
|
|
114
|
-
|
|
225
|
+
# Start Desktop app
|
|
226
|
+
npm run desktop
|
|
227
|
+
|
|
228
|
+
# Run test suite
|
|
115
229
|
npm test
|
|
116
230
|
```
|
|
117
231
|
|
|
118
|
-
|
|
232
|
+
The test suite includes regression tests verifying real dual-RTX 5070 measurements with Qwen2.5-Coder-32B.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Notes & Troubleshooting
|
|
237
|
+
|
|
238
|
+
- **Desktop Runtime Download**: The Electron runtime is downloaded on the first execution of `llm-tuner-desktop`. If downloading in a restricted offline environment, extract `electron-v*.zip` into the `dist/` directory of the installed `electron` package and create `path.txt` with the content `electron`.
|
|
239
|
+
- **Root / Sudo Installs**: Avoid running `npm install -g --unsafe-perm` under root without proper directory ownership, as Electron may fail to unpack its binary into user space.
|
|
240
|
+
- **LM Studio Compatibility**: Internal config paths are calibrated and tested against LM Studio 0.4.25+.
|
|
241
|
+
|
|
242
|
+
---
|
|
119
243
|
|
|
120
|
-
##
|
|
244
|
+
## License
|
|
121
245
|
|
|
122
|
-
|
|
123
|
-
- LM Studio's internal files are not a public API. This version is verified with LM Studio 0.4.25.
|
|
246
|
+
[MIT](LICENSE) © Ronald Daniel Acuña Arias
|