Files
gpu-rent/docs/llm.md
T
Leonid Pershin 5832c5cf75 Enhance Ollama model management and performance tuning
- Updated the `provision_llm` function to utilize the `/api/tags` endpoint for verifying available models, improving accuracy in model management.
- Introduced a new `already_have_ollama_tag` function to ensure exact tag matching, preventing mismatches during model checks.
- Enhanced the `pull_stream` function to require a successful status from the API before proceeding, ensuring reliable model downloads.
- Added logic to handle unwritten blob files, improving the robustness of the model pulling process.
- Updated documentation and tests to reflect these changes, ensuring clarity and reliability in Ollama model operations.
2026-08-21 14:20:06 +03:00

135 lines
4.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LLM рядом со SwarmUI (opt-in)
По умолчанию поднимается **только SwarmUI**. Ollama — отдельно (помощь с промптами и т.п.).
Интерактивные вопросы — **нумерованные меню** (Enter = вариант со ←). Ключ словом (`recommended`, `keep`) тоже принимается.
Три стека на GPU:
| # | стек | смысл |
| --- | --- | --- |
| 1 | SwarmUI | только генерация картинок |
| 2 | SwarmUI + LLM | UI + Ollama на той же карте |
| 3 | только LLM | **без** SwarmUI — только Ollama |
Флаги: `up --yes --llm-only --ollama` / `--no-swarm --ollama`. Vars: `ENABLE_SWARMUI=false` или `WORKLOAD=llm`.
---
## Быстрый путь
### A — wizard
```text
gpu-rent setup
```
Меню: runtime → пресет моделей → опционально local-watchdog. Пишет `LLM_RUNTIME` в `gpu-rent.vars`.
### B — флаг на `up`
```text
gpu-rent up --yes --ollama
gpu-rent up --yes --llm ollama
gpu-rent up --yes --llm-only --ollama # без SwarmUI
```
С `--yes` пресеты не спрашивает (берёт существующий yaml / example).
### C — vars вручную
```env
LLM_RUNTIME=ollama
```
Потом `gpu-rent up --yes`.
Выключить: `LLM_RUNTIME=none` (на `up` старые LLM unit’ы на VM останавливаются).
Голый `gpu-rent` без args — **help**. Двойной клик: `GPU_RENT_DEFAULT_ARGS=up --yes`. Полный doctor на up: `up -v`.
---
## Порты (loopback + туннель)
| Сервис | На VM | На ноутбуке |
| --- | --- | --- |
| SwarmUI | 7801 | **17801** |
| Ollama | 11434 | **17811** |
```text
gpu-rent tunnel
gpu-rent open --llm
```
```powershell
$env:OLLAMA_HOST = "http://127.0.0.1:17811"
```
После `up`/`tunnel` — access-card с URL и MCP-сниппетом.
---
## Ollama
| Файл | Роль |
| --- | --- |
| `ollama-models.example.yaml` | шаблон в git |
| `ollama-models.yaml` | список тегов (gitignore); лаунчер копирует example при отсутствии |
На `up``ollama pull` по списку, сверка с **`/api/tags`**. Слой 100% без `status=success` не считается успехом (кэш ≠ модель в Assistent). Если тега всё ещё нет — warning, **GPU не гасим**. Лишнее на диске не удаляет.
### Пресеты (меню)
| # | ключ | tag / смысл |
| --- | --- | --- |
| 1 | **recommended** | `huihui_ai/qwen2.5-vl-abliterated:7b` — RU + vision, ~6GB |
| 2 | light | `…:3b` — то же, мало VRAM (~3GB) |
| 3 | text | `huihui_ai/qwen2.5-abliterate:7b` — RU, без vision (~5GB) |
| 4 | big | `huihui_ai/qwen2.5-vl-abliterated:32b` — RU + vision (~21GB) |
| 5 | empty | только runtime |
| — | keep | не трогать yaml |
Все пресеты (кроме `empty`) — **abliterated** Qwen2.5 с нормальным русским. Официальные censored-теги (`qwen2.5vl:…`) в меню нет.
`default: true` в yaml — preferred в логе; pull идёт по всему списку.
---
## Автотюнинг Ollama
Unit `gpu-rent-ollama` читает `/mnt/swarm_data/.gpu-rent-gpu.json`:
| Tier (VRAM) | Flash Attn | KEEP_ALIVE | KV cache | GPU_OVERHEAD |
| --- | --- | --- | --- | --- |
| low (<16GiB) | off | 2m | q4_0 | 6GiB |
| mid (1623) | on* | 5m | q8_0 | 10GiB |
| high (2447) | on* | 15m | q8_0 | 14GiB |
| ultra (≥48) | on* | 30m | q8_0 | 20GiB |
\*Flash на Ampere+ (compute ≥ 8.0). `NUM_PARALLEL=1`, `MAX_LOADED_MODELS=1`. Env: `/mnt/swarm_data/.gpu-rent-ollama.env`.
---
## Idle-killer и LLM
Busy (не гасить GPU):
- `ollama pull` (маркер младше ~45 мин; старше сбрасывается);
- загруженная модель в Ollama.
Ошибка установки LLM на `up`**fail** (не тихий лог).
---
## Supply-chain (опциональный pin)
По умолчанию install тянет upstream без pin (`WARN` в логе). Жёстче:
```bash
OLLAMA_VERSION=0.6.5
OLLAMA_SHA256=<sha256 of ollama-linux-amd64.tgz>
```
Готовые кейсы — в `gpu-rent.vars.example`.