Skip to content

About

Processes for managing nodes, agents and skills to follow Shared Goals.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Thunder Forge v2

CLI for managing a self-hosted MLX inference cluster with oMLX serving and Olla routing.

Thunder Forge usage dashboard

Thunder Forge is part of the Shared Goals platform: private, self-hosted AI infrastructure for working with personal and collective goals without sending sensitive data to cloud APIs.

Start Here

Three recipes cover daily operation. Everything below is reference for when you need detail.

# Start: is the cluster alive, end to end?
make status          # nodes, models, build running on the edge
make smoke           # full path: client -> edge -> Olla -> nodes
make restart         # restart daemons after config changes
# Configure: one cluster file, one secrets file, one generated file
cp tfconfig.example.yaml tfconfig.yaml   # the only file you edit for topology/models

# .env holds secrets only: TF_USER_<NAME> per client, TF_EDGE_ADMIN_TOKEN for /usage
uv run thunder-forge generate-olla-config  # regenerate after tfconfig changes
make edge-keys EDGE_CLIENTS="alice bob"    # mint client API keys
# Monitor: dashboard, reports, alerts

# https://<edge>/usage — dashboard in a browser (paste TF_EDGE_ADMIN_TOKEN once)
make usage ARG=today        # text summary of the day
make usage-check ARG=1h     # exit 1 on failure-rate breach (cron-ready)
make usage-trim             # operator-only log retention

New host? Follow Quickstart once (SSH, bootstrap, first smoke).

Contents

Further Reading

Architecture

Client → TF edge → Olla → oMLX nodes (Apple Silicon)
  • TF edge — auth (API key → client identity), session management, proxy to Olla
  • Olla — model routing, sticky sessions, load balancing, health checks
  • oMLX — multi-model inference server for Apple Silicon (MLX native)
  • Artifacts — oMLX-native model dirs under ~/.omlx/models/<owner>/<repo>, e.g. ~/.omlx/models/mlx-community/gpt-oss-20b-MXFP4-Q8

Upstream-First Goal

Thunder Forge aims to be the thinnest possible operator layer for a homelab Mac cluster while delegating inference and routing behavior to upstream projects that already solve those concerns well:

  • oMLX as the inference runtime for Apple Silicon model serving, model lifecycle, and node-level performance behavior.
  • Olla as the router/balancer for endpoint health checks, sticky sessions, and request distribution.
  • Thunder Forge as integration and operations glue for auth boundary (TF edge), topology/model placement, bootstrap/restart/smoke workflows, and auditable usage reporting.

Design intent:

  • Minimize Thunder Forge-specific control-plane logic over time.
  • Reuse existing upstream capabilities before adding new local behavior.
  • Prefer upstream issue/PR contributions for general routing or runtime needs.
  • Keep local stopgaps small, explicit, and removable.

Shared Goals Vision

Shared Goals starts from a simple loop: people clarify motives and goals, turn them into texts and memory, then use AI agents to help convert that context into coordinated action. Thunder Forge is the local inference layer for that loop. It should let a household, workshop, lab, or small group run useful AI capacity on machines they control, with private data staying on-premise.

The current v2 direction is agent-managed operation. Instead of assuming a human runs every ssh, launchctl, artifact sync, and smoke test by hand, the cluster should be manageable by an operator agent with its own Unix account on the frontend, cache/download host, and inference nodes. That account is the execution identity for routine work: prepare artifacts, sync model caches, regenerate Olla config, restart services, run smokes, and record what happened.

Thunder Forge has three operational roles:

  • gateway: runs TF edge, Olla, routing config, auth, accounting, and external API surface.
  • cache/download: prepares model artifacts under the oMLX-native ~/.omlx/models/<owner>/<repo> layout and syncs them to inference nodes.
  • inference node: runs oMLX as the node-level inference daemon and serves the local model set.

In a compact development setup, one host such as gateway-cache-01 can hold both the gateway and cache/download roles while infer-01-infer-04 are inference nodes. In a split production setup, gateway-01 runs ingress, TF edge, and Olla, while cache-01 prepares model artifacts close to the inference fabric. The cache/download role does not need to be a daemon: it can be an operator script/CLI workflow that uses oMLX or Hugging Face tooling to download models, then syncs them over Thunderbolt fabric when available with Wi-Fi as fallback.

That model keeps the Shared Goals self-hosting principles explicit:

  • Prefer self-hosted nodes and self-hosted agents for private domains.
  • Give the agent least-privilege access to only the hosts, files, services, and model roles it needs.
  • Keep secrets in ignored local environment files or OS keychains, never in the repo.
  • Make agent activity auditable through command output, JSONL access logs, launchd state, and test/smoke results.
  • Expose OpenAI-compatible APIs through TF edge with client identity, not by exposing raw Olla or oMLX broadly.

Prerequisites

The operator user (e.g. shag) must have passwordless SSH access to every node in the cluster before running any Thunder Forge setup or management commands:

# Verify access to each node
ssh infer-01 true && echo ok

If key auth is not yet configured:

ssh-copy-id infer-01   # or ssh-copy-id user@host

Thunder Forge always SSHes as the operator user. Privilege escalation (via su or sudo) is performed on the remote node — the operator user is never required to SSH as the admin user directly.

Cache-host and Thunderbolt-fabric setup: docs/operations/node-setup.md.

Quickstart

git clone https://github.com/shared-goals/thunder-forge.git
cd thunder-forge
uv sync

# Create local config/env files
cp tfconfig.example.yaml tfconfig.yaml

# edit tfconfig.yaml for your cluster

# Generate Olla config from the TF cluster config
uv run thunder-forge generate-olla-config

# One-time bootstrap: install gateway (Olla + Edge), cache oMLX tooling + hub, and node (oMLX) LaunchDaemons

# Operator user must have passwordless SSH to all nodes first (see Prerequisites)
make bootstrap           # gateway + cache + inference nodes
make bootstrap gateway-cache-01    # combined gateway/cache host only
make bootstrap infer-01            # inference node only

# Restart daemons after config changes (passwordless via installed sudoers)
make restart

# Smoke-test the cluster
make smoke

# Check node runtime status
make status

Service Management

The Makefile is a thin dispatcher for cluster-level CLI commands:

  • make bootstrap [node] -> uv run thunder-forge cluster prepare [node] --apply
  • make restart [node] -> uv run thunder-forge cluster restart [node] --apply
  • make smoke [node] -> uv run thunder-forge cluster smoke [node] ...
  • make status [node] -> uv run thunder-forge cluster status [node]
  • make sync [node] -> uv run thunder-forge cluster sync [node] --apply, syncing configured models and following operations.sync.restart_runtime for the post-sync oMLX restart.

service restart remains the lower-level per-service path for managed Thunder Forge daemons:

  • uv run thunder-forge service restart --service olla --apply installs or updates the local gateway LaunchAgent and restarts Olla as the current user. This is the default path for a macOS gateway/cache host such as gateway-cache-01, so the operator user can restart Olla without sudo.
  • uv run thunder-forge service restart --service edge --apply installs or updates the local frontend TF edge LaunchAgent and restarts it as the current user.
  • uv run thunder-forge service restart --service omlx --node <node> --manager daemon --apply delegates to the existing node LaunchDaemon workflow after one-time setup.
  • Use --dry-run first to print the generated plist and shell commands without changing the host.

Node and service setup in depth (bootstrap escalation, GPU memory ceiling, daemon managers, VS Code terminal note): docs/operations/node-setup.md.

Local Config

Thunder Forge keeps secrets and operational config separate:

  • .env is ignored and secrets-only. Keep HF_TOKEN, TF_USER_<CLIENT>, and similar credentials there.
  • tfconfig.yaml is ignored and is the local source of truth for services, operator defaults, model registry, and node placement.
  • tfconfig.example.yaml is tracked as the schema/example mirror.
  • config/olla-config.yaml is generated output managed by Thunder Forge.
  • Config node roles are gateway, cache, and inference. Use roles: [gateway, cache] for multi-role hosts such as gateway-cache-01; use roles: [inference] for oMLX-serving nodes such as infer-01.

Create a local config with cp tfconfig.example.yaml tfconfig.yaml, then edit the local file for this host.

Config

cp tfconfig.example.yaml tfconfig.yaml   # local source of truth, ignored by git
uv run thunder-forge config lint          # validate before generating router config

Port table, operator defaults, and where every parameter comes from: docs/operations/configuration.md.

Edge Users

TF edge API keys are local secrets in ignored .env lines named TF_USER_<CLIENT> (TF_USER_OPENCODE authenticates as opencode). Mint them instead of hand-editing:

make edge-keys EDGE_CLIENTS="opencode hindsight"

edge serve loads those entries plus TF_EDGE_ADMIN_TOKEN (browser dashboard anonymous, data paths bearer-only; a ?token= query is rejected). Full auth model, build provenance, and the anonymous-vs-bearer /status split: docs/operations/edge.md.

Daily Usage Reporting

File-backed workflow: request events in logs/tf-edge-access.jsonl, node snapshots in logs/tf-node-metrics.jsonl, rollups via make usage or the /usage dashboard.

make usage-check 15m    # alert on failure rate (cron-ready, see Start Here)
make usage-trim         # operator-only retention; nothing schedules it for you

Field tables, failure semantics, coverage and partial flags, and what the summary deliberately cannot answer: docs/operations/usage.md. Exact output contract: docs/operations/daily-summary-contract.md.

Information Sources To Inspect

The following sources are the first places to look when debugging routing or building better metrics:

Source What it tells us How to query it
logs/tf-edge-access.jsonl Per-request client, model, node, and latency timing Read JSONL directly or summarize with make usage
logs/tf-node-metrics.jsonl Node health, hot-loaded model sets, active/waiting requests, and per-model memory footprint Read JSONL directly, collect via usage collect-node-metrics, or fetch GET /usage/report from the edge
GET /usage on TF edge Browser dashboard: requests by node/hour, latency percentiles, peak parallel requests, cold cache share with warm p50, node load, model memory (Chart.js served by the edge, no CDN) Open https://<edge>/usage and paste TF_EDGE_ADMIN_TOKEN once
GET /usage/report on TF edge Same aggregates as usage report --json over HTTP, optional ?user=<client> filter; users.known lists configured identities curl -H 'Authorization: Bearer <token>' '<edge>/usage/report?period=today&user=hermes'
GET /usage/events on TF edge Raw log lines for one period: source=access (default) or source=node-metrics curl -OJ -H 'Authorization: Bearer <token>' '<edge>/usage/events?period=2026-06-02&source=node-metrics'
GET /status on TF edge Running build (version, commit, dirty) plus the cluster snapshot: gateway/inference health, oMLX versions, hot-loaded models, readiness curl '<edge>/status'
logs/olla-40115.stdout.log Olla startup config, discovered endpoints, model filters, sticky-session settings, and routed request decisions Read the log directly if available; it is a useful operational trace
GET /internal/health Olla liveness/ready status Probe Olla directly
GET /internal/status/endpoints Which endpoints are healthy/routable Probe Olla directly
GET /internal/status/models Model catalog by endpoint Probe Olla directly
GET /internal/stats/sticky Sticky-session statistics Probe Olla directly
GET /health on oMLX Node-level runtime health Probe each oMLX node directly
GET /v1/models on oMLX Models visible on the node Probe each oMLX node directly
GET /v1/models/status on oMLX Model load state and runtime status Probe each oMLX node directly
X-Olla-Endpoint response header Which backend actually handled a request Inspect routed responses
X-Olla-Session-ID request/response header Caller-provided session identity for stickiness Send an explicit sticky-session id
X-Olla-Sticky-Session response header Sticky-session outcome (hit, miss, repin, disabled) Inspect routed responses

Olla log observations from the local stdout trace support the same model: startup loads config/olla-config.yaml, registers endpoints, applies model filters, enables sticky-session affinity, and logs each routed request with the selected endpoint and completion latency. That makes logs/olla-40115.stdout.log a useful complement to the JSONL summaries when diagnosing routing decisions.

Data-source decision:

  • Use Olla/oMLX endpoints and TF JSONL logs as the primary harvest path for metrics.
  • Use logs/olla-40115.stdout.log as a diagnostic/fallback trace, not as the primary metrics source.

Reuse Plan and Roadmap

Upstream-first, in order: reuse as-is -> wire existing capability -> contribute upstream -> only then a minimal local stopgap. Landscape survey, phases, and the deletion-oriented success metric (net reduction of Thunder Forge-specific code): docs/roadmap.md.

Client Providers

Generate editor and agent configs from tfconfig.yaml:

make opencode shag   # OpenCode provider JSONC, printed and copied
make hermes shag     # Hermes custom_providers YAML snippet
make vscode shag     # VS Code chatLanguageModels.json entry

Full renderer reference (placeholders vs injected keys, clipboard behavior): docs/operations/clients.md.

Model Strategy

The serving layout is deliberately simple and stays version-agnostic:

  • One large, popular, freshly quantized open-weight model serves every LLM workload — interactive agent runs, coding sessions, and Hindsight memory operations. Every LLM alias points at the same runtime model id, so each node keeps exactly one hot weight set, the node-local prefix cache stays warm across roles, and least-busy routing balances sessions instead of swapping weights. Today that is a Qwen3-family A3B MoE with MTP; when the state of the art moves, the family changes and the layout does not.
  • Light retrieval models serve Hindsight's recall path: one embedding model and one reranker, a few GB each, resident beside the large model on every node. Today both come from the BAAI bge family.
  • On a 128 GB node the budget arithmetic is: one ~95 GB quantized weight set plus a few GB of retrieval models, leaving headroom for KV cache, transient prefill, and the OS under the GPU wired ceiling; the memory guard throttles prefill before allocation can fail hard.

When the family is revisited: pick a popular, fresh MLX-community quant of a strong open family, confirm it fits the budget above (weights + retrieval models + KV + OS under the ceiling), smoke chat and embeddings through the edge, and switch every node to the same runtime id so the layout stays uniform. Concrete model ids live only in tfconfig.yaml — that file, not this page, is the source of truth for what currently runs.

Testing

uv run pytest --tb=short -q
uv run ruff check .

About

Processes for managing nodes, agents and skills to follow Shared Goals.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages