my-homelab-configs/docs/ai-lab.md

83 lines
3.9 KiB
Markdown

# Jeannie AI lab
The AI lab builds a pinned, separate llama.cpp checkout on the Debian server.
It does not change Ollama, OmniRoute, the Jeannie model routes, or cluster
configuration. The build has CPU and Vulkan support; Vulkan detection does not
guarantee that the integrated GPU will be faster than the CPU.
After pushing this change, on Debian:
```sh
cd ~/my-homelab-configs
git pull --ff-only gitea main
./jeannie ai-lab plan
./jeannie ai-lab install
./jeannie ai-lab devices
```
Installation uses `sudo apt-get` for build and Vulkan packages, downloads the
pinned source, and compiles with two parallel jobs. The default lab directory is
`~/.local/share/homelab/ai-lab` (or `ai-lab` under `HOMELAB_STATE_DIR`); set
`JEANNIE_AI_LAB_DIR` to a writable directory to choose another location. A
previous `/data/homelab-ai-lab` workspace is not moved or deleted. If explicitly
selected, that directory must already be writable; Jeannie does not change its
ownership or permissions.
The install refuses to overwrite an existing source checkout whose origin,
commit, or tracked files do not match the expected source.
Once `ollama ps` shows no loaded models, run:
```sh
./jeannie ai-lab bench ollama
./jeannie ai-lab bench cpu
./jeannie ai-lab bench vulkan
```
The Vulkan run defaults to `Vulkan0`. If `devices` shows a different Radeon
device, set `JEANNIE_AI_LAB_VULKAN_DEVICE` to that name for the run. The lab
refuses to start if Ollama currently has a loaded model; it never stops another
model. The Ollama benchmark asks Ollama to unload the model after its own
request. Avoid concurrent AI workloads when comparing results.
Each run reads the existing `llama3.2:3b` GGUF blob; it does not copy, delete,
or modify the model. The Debian user must be able to read the path printed by
`ollama show --modelfile llama3.2:3b`. Inaccessible or non-GGUF files stop the
test. Reports and model output are saved with mode 0600 under the lab's `reports`
directory. The report labels llama.cpp's prompt and generation speeds when its
timing summary is present; a null value means timing was not recognized.
The lab captures the process's controlling terminal so its output is included
in the private log. Review the log to confirm actual GPU offload.
Each benchmark is one cold request, using the same prompt, maximum output,
context size and temperature. CLI and Ollama prompt templates, sampling options,
backend allocation and measured time boundaries can differ, so this is an
initial comparison rather than a controlled scientific benchmark. Repeat runs,
inspect answers, and compare end-to-end user experience before changing routes.
## Colibri experiment
The optional Colibri engine is pinned separately and runs on CPU. Its Qwen3
engine reads a small Qwen3-0.6B Q8_0 GGUF model. Preparation downloads about
639 MB from Qwen's Hugging Face repository and verifies its pinned SHA-256;
interrupted downloads are cleaned up and can be retried. Existing model files
with a different checksum are preserved and refused. No production model or
service is changed.
```sh
./jeannie ai-lab colibri-install
./jeannie ai-lab colibri-prepare
./jeannie ai-lab bench colibri
./jeannie ai-lab bench qwen-cpu
```
The last two commands use the exact same GGUF with Colibri and llama.cpp. The
llama.cpp build must be installed for `qwen-cpu`. Colibri checks for at least
2 GiB currently available before starting, but other workloads may use memory
while the benchmark runs. The engines may use different prompts, sampling,
context handling and timing boundaries; compare both the logs and answer
quality rather than treating the elapsed times as a conclusive ranking. These
are single-request experiments; neither backend is registered with OmniRoute.
Both Qwen runs request greedy sampling and disable thinking, so the limited
output budget is available for the answer. Check the logs to confirm that each
engine honored those settings and produced a complete answer.