Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .compass.org
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ listen address is the =--listen= flag, else =#+serve_listen:= of the local
settings, else this table's. =agent_server= is where the compass agent's
=llama-server= listens, which the =--agent= flag overrides, and
=agent_model= the model file the agent tells the developer to start it
with: Qwen2.5-7B-Instruct at Q4_K_M, as the product owner signed off on
2026-11-30.
with: Qwen3.5-9B at Q6_K, as the product owner asked on 2026-12-02.

| setting | value |
|--------------+---------------------------------------------------------------|
| listen | 127.0.0.1:8080 |
| agent_server | 127.0.0.1:8081 |
| agent_model | ~/.local/share/compass/models/Qwen2.5-7B-Instruct-Q4_K_M.gguf |
| agent_model | ~/.local/share/compass/models/Qwen3.5-9B-Q6_K.gguf |

* Views

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ its own documentation screens in its favour.
|---------------+----------------------------------------|
| State | STARTED |
| Parent sprint | [[id:850C1BC8-FE02-4EE0-A5D6-6085DC34CE27][Sprint 1]] |
| Now | Captured with its tasks. Rename, the OpenAPI document and the inventory are done. Prototype the shell and the document view (#234), Prototype the link graph in WebGL (#236), Prototype the agent panel on llama.cpp (#237) and Prototype the sprint and testing views (#239) are signed off. Stand up compass.web on the ores.web stack (#241) is signed off: compass serve serves compass.web. Search the documents in the browser (#242) is signed off with decision 10's ranking. Read a document in the browser (#243) is signed off and merged. Retire the HTML document route (#244) is signed off and merged. Show the sprint board, its stories and its tasks (#246) is signed off and merged. Draw the sprint charts (#247) is signed off and merged. Run test scenarios with screenshots in the browser (#248) is signed off and merged. Draw the link graph in WebGL (#249) is signed off and merged. Talk to the compass agent in the browser (#252) is signed off and merged. Serve compass behind ORE Studio's gateway (#254) is signed off and merged. Open compass.web from ores.web (#256) is signed off and merged. Publish the developer link (#257) merged the packaging and install work; the team address remains the product owner's. Suggest searches and offer an AI mode (#259) is STARTED: the landing page keeps its box centered while typing, lists the closest documents in a combo box, and hands the typed query to the agent from AI mode. The agent's retrieval dropped compass itself; the fix is in review. |
| Now | Captured with its tasks. Rename, the OpenAPI document and the inventory are done. Prototype the shell and the document view (#234), Prototype the link graph in WebGL (#236), Prototype the agent panel on llama.cpp (#237) and Prototype the sprint and testing views (#239) are signed off. Stand up compass.web on the ores.web stack (#241) is signed off: compass serve serves compass.web. Search the documents in the browser (#242) is signed off with decision 10's ranking. Read a document in the browser (#243) is signed off and merged. Retire the HTML document route (#244) is signed off and merged. Show the sprint board, its stories and its tasks (#246) is signed off and merged. Draw the sprint charts (#247) is signed off and merged. Run test scenarios with screenshots in the browser (#248) is signed off and merged. Draw the link graph in WebGL (#249) is signed off and merged. Talk to the compass agent in the browser (#252) is signed off and merged. Serve compass behind ORE Studio's gateway (#254) is signed off and merged. Open compass.web from ores.web (#256) is signed off and merged. Publish the developer link (#257) merged the packaging and install work; the team address remains the product owner's. Suggest searches and offer an AI mode (#259) is STARTED: the landing page keeps its box centered while typing, lists the closest documents in a combo box, and hands the typed query to the agent from AI mode. The agent's retrieval dropped compass itself; the fix is in review. The agent's model server runs as a tracked systemd user unit on the GPU with Qwen3.5-9B; verified, waiting on the product owner's sign-off. |
| Waiting on | The product owner's team address for compass.web. |
| Next | Publish the developer link once the address is decided. |
| Last touched | 2026-12-01 |
Expand Down Expand Up @@ -107,7 +107,7 @@ its own documentation screens in its favour.
| [[id:55AACEE0-4551-43E8-8985-A79CE53666C2][Run test scenarios with screenshots in the browser]] | DONE | 2026-11-30 | 2026-12-01 | Add the testing pages: what needs testing in the sprint, a step-by-step scenario runner that records results, notes and pasted screenshots through the service's run routes, and the screenshots shown back. |
| [[id:D730E00C-E6DF-4ED8-8B38-ECD40C335EF4][Draw the link graph in WebGL]] | DONE | 2026-11-30 | 2026-12-01 | Serve the environment's ID-link graph from a new compass route and draw it in compass.web with sigma.js and graphology, with search, local graph, colouring by type and the Zettelkasten overlays. |
| [[id:A4FFB55D-43E3-4E2E-AA22-2503F0A49090][Talk to the compass agent in the browser]] | DONE | 2026-11-30 | 2026-12-01 | Add the compass agent: a chat panel in compass.web over a compass route that runs the signed-off loop against a local llama-server, retrieves through the query layer, streams over SSE and cites documents that open in compass.web. |
| [[id:AF19ABDD-FCB6-4241-ACA3-9A50388BB245][Answer questions about compass itself]] | STARTED | 2026-12-01 | | Search the agent's question for compass itself: the stop-word list dropped the product name, so what is compass searched for nothing. Keep compass and compass's as terms, with a test. |
| [[id:AF19ABDD-FCB6-4241-ACA3-9A50388BB245][Answer questions about compass itself]] | STARTED | 2026-12-01 | | Search the agent's question for compass itself: the stop-word list dropped the product name, so what is compass searched for nothing. Keep compass and compass's as terms, with a test. [[id:78C7C6CA-F9A1-43E5-89D8-E0D4BD8BDC69][Run the agent's model server as a user service on the GPU]] | STARTED | 2026-12-02 | | Build llama.cpp with CUDA, run Qwen3.5-9B at Q6_K wholly on the GPU with a 65536-token context, and track a systemd user unit following ORE Studio's pattern, so the agent answers from the GPU and the service survives crashes. |
| [[id:D6F014EB-CB9F-44D6-B14A-9544B2691943][Serve compass behind ORE Studio's gateway]] | DONE | 2026-12-01 | 2026-12-01 | Run compass.http behind ores.http as its gateway and compass.web inside ores.web on ores.web's session, while compass on its own keeps running with no sign-in, and hand ORE Studio the forwarder and view mapping its side needs. |
| [[id:44146C3F-FE10-4832-9311-7C2A87D17CDC][Open compass.web from ores.web]] | DONE | 2026-12-01 | 2026-12-01 | Make compass.web reachable from ores.web: first an external menu entry, then compass.web's pages as a package ores.web adds as a dependency and mounts, reading compass through ores.http, so ORE Studio can decommission its own documentation screens. |
| [[id:131CF0B6-CF93-40A0-A6AC-4635F4A3CE8A][Publish the developer link]] | STARTED | 2026-12-01 | | Run compass.web for the team at a stable address, link it from compass's developer pages, and ship its built files with compass's releases. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
:PROPERTIES:
:ID: 78C7C6CA-F9A1-43E5-89D8-E0D4BD8BDC69
:END:
#+title: Task: Run the agent's model server as a user service on the GPU
#+description: Build llama.cpp v1.1.0 with CUDA for the 2080 Ti, run Qwen3.5-9B at Q6_K wholly on the GPU with a 65536-token context, and track a systemd user unit in the project that follows ORE Studio's unit pattern.
#+type: task
#+level: s1
#+filetags: :build_the_compass_web_front_end:sprint_01:v0:
#+owner: marco
#+branch: feature/llama-gpu-systemd
#+pr: 261
#+blocked_on:
#+blocked_since:
#+created: 2026-12-02
#+updated: 2026-12-02
#+environment:
#+todo: DISCOVERED BACKLOG STARTED BLOCKED | DONE ABANDONED

This page documents a [[id:31C868B9-306E-4282-BA8C-07E647021B34][task]] in the [[id:D8019709-7EF9-43E0-AC64-85DB34A078BE][Build the compass web front end]] story. It captures the goal, current status, acceptance, and any notes or results.

* Goal

The compass agent's model server runs on the GPU as a user service: the
current Qwen model, a 64k context, and a service that restarts and cannot
take the machine down. The unit lives in this project, as ORE Studio's do.

* Status

| Field | Value |
|--------------+----------------------------------------|
| State | STARTED |
| Parent story | [[id:D8019709-7EF9-43E0-AC64-85DB34A078BE][Build the compass web front end]] |
| Now | Verified on 2026-12-02: the unit is active and enabled, the model is 8,020 MiB on the GPU with a 65,536-token context, the agent's first token is 750 ms, and 114 tokens generate at 56.7 a second. |
| Waiting on | The product owner's sign-off. |
| Next | The product owner's sign-off. |
| Last touched | 2026-12-02 |

* Acceptance

- llama.cpp v1.1.0 is built with CUDA for compute capability 7.5 and runs
on the RTX 2080 Ti.
- Qwen3.5-9B at Q6_K is downloaded, checked against its SHA-256 and
loaded wholly on the GPU with a 65536-token context and a quantised KV
cache.
- =systemd/units/llama-server.service= is tracked in this project,
enabled as a user unit, restarts on failure, caps the host memory and
waits for =/health= before it is up.
- =.compass.org= names the new model, and the compass agent answers
through the service.
- The measurements: the VRAM used, the first-token time and the tokens a
second.

* Plan

1. Build llama.cpp v1.1.0 from source with CUDA enabled and the compute
capability of the RTX 2080 Ti, so the model runs on the GPU rather than
the CPU.
2. Download Qwen3.5-9B at Q6_K and check it against its SHA-256, recorded in
=systemd/README.org= with the build and download commands.
3. Write =systemd/units/llama-server.service= following ORE Studio's unit
pattern: tracked in this project, =Restart=always=, a =MemoryMax= and
=MemorySwapMax=, and an =ExecStartPost= that waits for =/health=.
4. Point =.compass.org= at the new model and address, link the unit with
=systemctl --user link=, enable it, and allow it to start at boot with
linger.
5. Verify the unit is active and enabled, measure the VRAM, the first-token
time and the generation rate, and ask the agent a question through the
service.

* Measurements

Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an =evidence/= file beside the
task and name that file in the Command column.

| What | Value | Command | Commit |
|------+-------+---------+--------|
| Model resident on the GPU | 8,020 MiB | =nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv= | e7e7bfd4 |
| Context | 65,536 tokens | =curl -s http://127.0.0.1:8081/props= | e7e7bfd4 |
| Prompt processing | 250.8 tokens/s | =curl -s http://127.0.0.1:8081/v1/chat/completions= | e7e7bfd4 |
| Generation, short completion | 56.0 tokens/s | =curl -s http://127.0.0.1:8081/v1/chat/completions= | e7e7bfd4 |
| Agent first token | 750 ms | =curl -sN 'http://127.0.0.1:8080/v1/compass/agent?q=what%20is%20compass'= | e7e7bfd4 |
| Agent generation | 114 tokens at 56.7 tokens/s, 2.74 s | =curl -sN 'http://127.0.0.1:8080/v1/compass/agent?q=what%20is%20compass'= | e7e7bfd4 |
| Host memory of the unit | 423 MB, capped at 12G | =systemctl --user status llama-server.service= | e7e7bfd4 |

* Notes

The model is Qwen3.5-9B at Q6_K, SHA-256
=91898433cf5ce0a8f45516a4cc3e9343b6e01d052d01f684309098c66a326c59=,
7,458,301,152 bytes, from
=https://huggingface.co/unsloth/Qwen3.5-9B-GGUF=. The Qwen3.8 family's open
model is 27B and does not fit the 11 GiB card without offloading layers to
the CPU, which costs the speed the GPU is for; the 9B is the largest current
model that fits wholly. Its hybrid attention keeps the KV cache small, which
is what makes the 64k context fit beside the Q6 weights.

The server is llama.cpp v1.1.0, built with CUDA 13.5 for compute capability
7.5, at =~/.local/opt/llama.cpp/v1.1.0=. The unit and its install, check and
prerequisite commands are in =systemd/README.org=. It follows ORE Studio's
unit pattern: tracked in the project, =Restart=always=, =MemoryMax= and
=MemorySwapMax= from ORE's systemd resource plan, and an =ExecStartPost=
that waits for the health endpoint.

* Test Scenarios

Manual QA scenarios (scaffolded via =compass add test_scenario=)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.

| Scenario | State | Notes |
|----------+-------+-------|
| | | |

* PRs

| PR | Title |
|----+-------|
| [[https://github.com/MASD-Project/compass/pull/261][#261]] | [systemd] Run the agent's llama-server as a GPU user service |

* Review

| # | Comment summary | File | Decision | Notes |
|---+-----------------+------+----------+-------|
| | | | | |

* Result

The unit is installed, enabled and running: llama.cpp v1.1.0 with CUDA on
the RTX 2080 Ti, Qwen3.5-9B at Q6_K wholly on the card, a 65,536-token
context, quantised KV, flash attention and reasoning off. The model takes
8,020 MiB of the 10,830 MiB free. The agent answers through the unit: its
first token is 750 ms and 114 tokens generate at 56.7 a second, citing
passages 1 to 4, where the CPU build took 18 to 33 seconds to its first
token. The unit's host memory is 423 MB under a 12G cap.
91 changes: 91 additions & 0 deletions systemd/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
:PROPERTIES:
:ID: 5A7C2E4B-9D31-4F86-B2A0-7E5C1D3A9F42
:END:
#+title: systemd user units
#+description: The systemd user units compass's development services run under, how to install them, and why they follow ORE Studio's unit pattern.
#+type: reference
#+level: cross
#+filetags: :systemd:infrastructure:reference:
#+created: 2026-12-02
#+updated: 2026-12-02

These units run compass's development services under the user's systemd
manager. They are tracked here so the same unit is installed on every
machine, and they follow ORE Studio's pattern, described in its
=systemd-resource-management-plan.org=.

* llama-server.service

The compass agent's model server. llama.cpp v1.1.0 built with CUDA runs
Qwen3.5-9B at Q6_K wholly on the GPU, with a 65536-token context, a
quantised KV cache, flash attention and reasoning off. Qwen3.5's chat
template thinks by default; the agent's answers are short and grounded, so
the service spends the token budget on the answer instead. The unit restarts on failure,
caps the process's host memory, and waits for =/health= before it is
considered up.

** Prerequisites

Build llama.cpp with CUDA 13.5 for the GPU's compute capability (7.5 on
the RTX 2080 Ti):

#+begin_src sh
git clone --depth 1 --branch v1.1.0 https://github.com/ggml-org/llama.cpp.git ~/.local/opt/llama.cpp/v1.1.0
cd ~/.local/opt/llama.cpp/v1.1.0
CUDACXX=/usr/local/cuda/bin/nvcc cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=75 -DGGML_CURL=OFF \
-DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_USE_PREBUILT_UI=OFF
cmake --build build --config Release -j8 --target llama-server llama-cli
#+end_src

Download the model and check its SHA-256:

#+begin_src sh
curl -fL -o ~/.local/share/compass/models/Qwen3.5-9B-Q6_K.gguf \
https://huggingface.co/unsloth/Qwen3.5-9B-GGUF/resolve/main/Qwen3.5-9B-Q6_K.gguf
echo "91898433cf5ce0a8f45516a4cc3e9343b6e01d052d01f684309098c66a326c59 $HOME/.local/share/compass/models/Qwen3.5-9B-Q6_K.gguf" \
| sha256sum -c -
#+end_src

The model is Qwen3.5-9B at Q6_K. The Qwen3.8 family's open model is 27B
and does not fit the 11 GiB card without offloading layers to the CPU,
which costs the speed this service exists to get. The 9B leaves room for
the 64k context.

** Install

#+begin_src sh
systemctl --user link "$PWD/systemd/units/llama-server.service"
systemctl --user daemon-reload
systemctl --user enable --now llama-server.service
loginctl enable-linger "$USER"
#+end_src

The link keeps the unit pointing at the checkout, so an edit is picked up
after =daemon-reload=. The linger makes the service start at boot, without
a login session.

** Check

#+begin_src sh
systemctl --user status llama-server.service
curl -s http://127.0.0.1:8081/health
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv
journalctl --user -u llama-server.service -f
#+end_src

=health= answers ={"status":"ok"}= once the model is resident. The
=nvidia-smi= line names =llama-server= and its VRAM. The compass agent
uses this server at =127.0.0.1:8081=, as =.compass.org= and the local
settings say.

** Why this shape

The unit is tracked in the project rather than edited in
=~/.config/systemd/user=, as ORE Studio tracks its units. =Restart=always=
keeps a crashed model server from staying down. =MemoryMax= and
=MemorySwapMax= bound the host memory, because the model's file-backed
pages and the compute buffers are charged to the unit; the GPU memory is
not cgroup-managed. =ExecStartPost= waits for the health endpoint, so a
unit that is active really answers. The flags put every layer on the
card; the quantised KV and flash attention make the larger context fit.
36 changes: 36 additions & 0 deletions systemd/units/llama-server.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# The compass agent's model server, as a systemd user unit.
#
# It follows ORE Studio's unit pattern: the unit is tracked in the project,
# it always restarts, a MemoryMax keeps a bad model from taking the host down
# (the 2026-07-31 lockup that produced systemd-resource-management-plan.org),
# and an ExecStartPost waits for the server to answer before the unit is up.
#
# Install from the repository root:
# systemctl --user link "$PWD/systemd/units/llama-server.service"
# systemctl --user daemon-reload
# systemctl --user enable --now llama-server.service
# loginctl enable-linger "$USER"
#
# The model and the CUDA build are described in systemd/README.org.

[Unit]
Description=llama.cpp server for the compass agent (Qwen3.5-9B, CUDA)
Documentation=https://github.com/ggml-org/llama.cpp
After=network.target
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Type=simple
Environment=CUDA_VISIBLE_DEVICES=0
Environment=LLAMA_CACHE=%h/.cache/llama.cpp
ExecStart=%h/.local/opt/llama.cpp/v1.1.0/build/bin/llama-server --model %h/.local/share/compass/models/Qwen3.5-9B-Q6_K.gguf --alias qwen3.5-9b --host 127.0.0.1 --port 8081 --ctx-size 65536 --parallel 1 --n-gpu-layers 99 --flash-attn on --cache-type-k q8_0 --cache-type-v q8_0 --batch-size 2048 --ubatch-size 512 --threads 8 --threads-batch 8 --reasoning auto --jinja --no-ui
ExecStartPost=/bin/sh -c 'for i in $(seq 1 600); do curl -fsS http://127.0.0.1:8081/health | grep -q ok && exit 0; sleep 0.5; done; echo "llama-server did not become ready within 300s" >&2; exit 1'
Restart=always
RestartSec=5
TimeoutStartSec=300
MemoryMax=12G
MemorySwapMax=2G

[Install]
WantedBy=default.target
Loading