Files
gpu-rent/docs/llm.md
T
Leonid Pershin 7ed6a99df2 Enhance LLM and SwarmUI integration with improved configuration options
- Updated `env.example` and `gpu-rent.vars.example` to include new variables for LLM runtime and SwarmUI options.
- Refactored CLI commands to support interactive selection of LLM runtime and workload type (SwarmUI, LLM, or both).
- Improved access link generation to handle cases where SwarmUI is disabled, providing clearer user feedback.
- Enhanced provisioning logic to conditionally bootstrap SwarmUI based on user configuration, allowing for LLM-only setups.
- Updated documentation across multiple files to reflect changes in LLM integration, CLI usage, and configuration management.
2026-08-21 06:44:50 +03:00

158 lines
5.1 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 или llama.cpp — отдельно (помощь с промптами и т.п.).
Интерактивные вопросы — **нумерованные меню** (Enter = вариант со ←). Ключ словом (`recommended`, `keep`) тоже принимается.
Три стека на GPU:
| # | стек | смысл |
| --- | --- | --- |
| 1 | SwarmUI | только генерация картинок |
| 2 | SwarmUI + LLM | UI + Ollama/llama.cpp на той же карте |
| 3 | только LLM | **без** SwarmUI — Ollama или llama.cpp |
Флаги: `up --yes --llm-only --llamacpp` / `--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 llamacpp
gpu-rent up --yes --llm-only --llamacpp # без SwarmUI
```
С `--yes` пресеты не спрашивает (берёт существующий yaml / example).
### C — vars вручную
```env
LLM_RUNTIME=ollama
```
Потом `gpu-rent up --yes`.
Выключить: `LLM_RUNTIME=none` (на `up` старые unit’ы `gpu-rent-ollama` / `gpu-rent-llamacpp` останавливаются).
Голый `gpu-rent` без args — **help**. Двойной клик: `GPU_RENT_DEFAULT_ARGS=up --yes`. Полный doctor на up: `up -v`.
---
## Порты (loopback + туннель)
| Сервис | На VM | На ноутбуке |
| --- | --- | --- |
| SwarmUI | 7801 | **17801** |
| Ollama | 11434 | **17811** |
| llama.cpp | 8080 | **17812** |
```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` по списку. Точные теги: уже есть `foo:7b` ≠ skip для `foo:3b`. Лишнее на диске не удаляет.
### Пресеты (меню)
| # | ключ | tag / смысл |
| --- | --- | --- |
| 1 | **recommended** | `huihui_ai/qwen2.5-abliterate:7b` — RU/EN, ~5 GB |
| 2 | light | `qwen2.5:3b` |
| 3 | stock | `qwen2.5:7b` |
| 4 | alt | другой abliterate 7B |
| 5 | empty | только runtime |
| — | keep | не трогать yaml (если уже спросили повторно) |
`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`.
---
## llama.cpp
| Файл | Роль |
| --- | --- |
| `llamacpp-models.example.yaml` | шаблон |
| `llamacpp-models.yaml` | HTTPS URL на `.gguf` (gitignore) |
На `up`: скачать GGUF → `/mnt/swarm_data/llamacpp/models``llama-server` + systemd. Уже скачанные крупные файлы не трогает.
### Пресеты (меню)
| # | ключ | что |
| --- | --- | --- |
| 1 | **recommended** | Qwen2.5 7B abliterate Q4_K_M (~4.7 GB) |
| 2 | light | Qwen2.5 3B Instruct Q4_K_M |
| 3 | stock | официальный 7B Instruct Q4_K_M |
| 4 | empty | только runtime |
| — | keep | не трогать yaml |
`-ngl` / `-c` — по GPU probe. Опционально `HF_TOKEN` для gated HF. Вручную: положи GGUF в models и `systemctl restart gpu-rent-llamacpp`.
---
## Idle-killer и LLM
Busy (не гасить GPU):
- `ollama pull` (маркер младше ~45 мин; старше сбрасывается);
- загруженная модель в Ollama;
- llama.cpp: слоты заняты.
Ошибка установки LLM на `up`**fail** (не тихий лог).
---
## Supply-chain (опциональный pin)
По умолчанию install тянет upstream без pin (`WARN` в логе). Жёстче:
```bash
OLLAMA_VERSION=0.6.5
OLLAMA_SHA256=<sha256 of ollama-linux-amd64.tgz>
LLAMACPP_TAG=b4690
# или LLAMACPP_ASSET_URL=... + LLAMACPP_SHA256=...
```