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

8.3 KiB

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:

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:

./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.

./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.

The Colibri report extracts weight load time, RSS after loading weights, and lookup decoder tokens, forwards and draft acceptance when those log lines are present. The lookup token count describes tokens fed to the decoder, not necessarily the visible output count. Its derived tokens/second includes the whole command startup and is not directly comparable to llama.cpp's generation-only rate. RSS after model loading is not peak process memory. Fields are null when the log does not contain the corresponding measurement.

Doctor model comparison

On the Debian server, install the existing lab engines first. The doctor model preparation downloads an approximately 18 GB GGUF to the AI lab workspace and verifies its SHA-256 before importing it for Colibri:

./jeannie ai-lab install
./jeannie ai-lab colibri-install
./jeannie ai-lab doctor-prepare
./jeannie ai-lab doctor-suite

The suite runs ten synthetic diagnostic cases twice per backend, including contrasting known and unknown intent for the runner, stopped services, and a maintenance window. Sandbox intent is tested as unknown. Pass a repeat count from 1 to 5 to doctor-suite to change that. It uses the existing qwen2.5-coder:7b Ollama model on CPU for Ollama and llama.cpp, and Qwen3-Coder-30B-A3B Q4_K_M on CPU for Colibri. The 30B model is the largest candidate in Colibri's pinned catalog with an 8 GB minimum, not a guarantee that this particular GGUF and context will fit. Keep at least 22 GiB free in the lab workspace for the download and at least 9 GiB of host MemAvailable before each backend starts. The suite requires a functioning systemd user manager and cgroup v2 memory controller. It refuses to load a model unless an 8 GiB memory limit and zero swap are verified; a low-memory watchdog stops its own scope. This limit can terminate a model and cannot eliminate host pressure.

The report includes each response, citation and command validation, timing, and available memory measurements. It and server logs are private files under the lab reports directory. A valid response is not proof of factual accuracy: review the cases and responses manually. The lab accepts one complete outer JSON code fence before applying the same validator and preserves raw answers; it does not change production Doctor parsing. Different model sizes and output constraints also mean Colibri quality results do not isolate engine performance. This experiment does not change the production doctor model or stop services. Ollama must be idle before the test; stop or unload models deliberately first.

Repeated comparison suite

After the llama.cpp and Colibri installation and model preparation above:

./jeannie ai-lab suite

The default is three repetitions of six prompts per available backend; pass an integer from 1 to 10 to change it, for example ./jeannie ai-lab suite 5. It rotates backend order and runs Ollama, llama.cpp CPU, llama.cpp Vulkan when the selected Vulkan device is detected, and Colibri CPU. Unavailable engines are listed as skipped. Each run uses the same verified Qwen3 0.6B Q8 GGUF, 4096-token context and 128-token output limit, requesting no thinking and temperature zero. Ollama chooses its own CPU/GPU placement; Vulkan layer offload is only confirmed when its log reports it. No backend is selected as a winner automatically.

The first run registers a persistent Ollama model named jeannie-ai-lab-qwen3-q8:latest from the verified local GGUF. A pre-existing alias pointing elsewhere is never replaced. This does not change production routes or models. The suite checks Ollama is idle rather than stopping loaded models, requests unload after its own Ollama inference, and requires at least 2 GiB available RAM before each run. Other host workloads can still start concurrently and affect or interrupt a benchmark.

The summary includes median end-to-end time per backend and per prompt, simple exact-match checks for arithmetic, JSON, extraction and a recovery signal, plus manual-review Kubernetes and untrusted-log prompts. Those checks are examples, not a comprehensive measurement of model quality. The process or server request starts cold, but filesystem and accelerator caches may be warm; startup boundaries and chat templates can vary. The report includes each run, errors, skipped engines, available throughput metrics and private per-run logs in a new mode-0700 report directory. A nonzero exit means at least one attempted run failed; inspect report.json and the corresponding log before drawing conclusions.