interplane.Get Omega
Read in your language

MojoLlama

Archived Mojo/MAX quantizer and serving research repository (read-only history)

Brought by drakestapleton

branch main Branches Tags History

MojoLlama / src / mojollama / docker-compose.yml

168 lines · 5458 bytes Raw Blame History
1# ============================================================
2# MojoLlama Docker Compose
3# ============================================================
4# Start: docker compose up -d
5# Build: docker compose build
6# Tail: docker compose logs -f
7#
8# Environment variables (all optional — set in .env or shell):
9#
10# === Model & Server ===
11# MODEL GGUF model path (default: /models/tl-Q4_0.gguf)
12# PORT API server port (default: 8080)
13# HOST Bind address (default: 0.0.0.0)
14#
15# === Performance ===
16# OMP_NUM_THREADS OpenMP threads (default: auto-tuned, fallback: nproc)
17# CPU_LIMIT Docker CPU limit (default: host CPU count)
18# MEM_LIMIT Docker memory limit (default: 128G)
19# MOJOLLAMA_DEVICE Device override: cpu | cuda | auto (default: auto)
20#
21# === Tuning ===
22# AUTO_TUNE Run autotune on container start: true|false (default: true)
23# TUNE_QUICK Fast tuning mode: true|false (default: true)
24#
25# === Storage ===
26# MODELS_VOLUME Path to models directory (default: ./models)
27# CONFIG_VOLUME Path to config directory (default: ./config)
28# CACHE_VOLUME Path to HF cache (default: ./cache/huggingface)
29# HF_TOKEN HuggingFace token for gated models
30#
31# === Advanced ===
32# LLAMA_CPP_DIR llama.cpp build path (default: /tmp/llama.cpp)
33# MOJOLLAMA_DEBUG Enable debug output: true|false
34# ============================================================
35
36version: "3.9"
37
38x-common: &common
39 image: ghcr.io/a730/mojollama:latest
40 pull_policy: always
41 environment:
42 # ── Model ──
43 MODEL_PATH: "${MODEL:-/models/tl-Q4_0.gguf}"
44 PORT: "${PORT:-8080}"
45 HOST: "${HOST:-0.0.0.0}"
46
47 # ── Performance ──
48 OMP_NUM_THREADS: "${OMP_NUM_THREADS:-}"
49 MOJOLLAMA_DEVICE: "${MOJOLLAMA_DEVICE:-auto}"
50
51 # ── Debugging ──
52 MOJOLLAMA_DEBUG: "${MOJOLLAMA_DEBUG:-false}"
53
54 # ── HuggingFace ──
55 HF_TOKEN: "${HF_TOKEN:-}"
56 HUGGINGFACE_TOKEN: "${HF_TOKEN:-}"
57 HF_REPO: "${HF_REPO:-}"
58 HF_FILE: "${HF_FILE:-}"
59 HF_HOME: "${HF_HOME:-/cache/huggingface}"
60 HUGGINGFACE_HUB_CACHE: "${HUGGINGFACE_HUB_CACHE:-/cache/huggingface/hub}"
61
62 # ── Advanced ──
63 LLAMA_CPP_DIR: "${LLAMA_CPP_DIR:-/tmp/llama.cpp}"
64 MOJOLLAMA_EXPERIMENTS_DB: "${MOJOLLAMA_EXPERIMENTS_DB:-/data/experiments.db}"
65
66 volumes:
67 - "${MODELS_VOLUME:-./models}:/models:ro"
68 - "${CONFIG_VOLUME:-./config}:/root/.mojollama"
69 - "${CACHE_VOLUME:-./cache}:/cache"
70 - "${DATA_VOLUME:-./data}:/data"
71 restart: unless-stopped
72 healthcheck:
73 test: ["CMD", "curl", "-sf", "http://localhost:${PORT:-8080}/health"]
74 interval: 30s
75 timeout: 10s
76 retries: 3
77 start_period: 20s
78
79services:
80 # ── Main: API Server ──
81 mojollama:
82 <<: *common
83 build:
84 context: .
85 dockerfile: Dockerfile
86 ports:
87 - "${PORT:-8080}:${PORT:-8080}"
88 command: ["serve", "-m", "${MODEL:-/models/tl-Q4_0.gguf}", "-p", "${PORT:-8080}", "--host", "${HOST:-0.0.0.0}"]
89 profiles: [""] # default profile
90
91 # ── Interactive Chat ──
92 chat:
93 <<: *common
94 ports:
95 - "${CHAT_PORT:-8081}:8081"
96 command: ["chat", "-m", "${MODEL:-/models/tl-Q4_0.gguf}", "--web", "-p", "8081"]
97 profiles: [chat]
98
99 # ─── Batch inference ──
100 bench:
101 <<: *common
102 command: ["bench", "-m", "${MODEL:-/models/tl-Q4_0.gguf}", "-n", "${BENCH_TOKENS:-100}", "-t", "${OMP_NUM_THREADS:-32}"]
103 profiles: [bench]
104 restart: "no"
105 healthcheck: disable
106
107 # ─── One-shot query ──
108 query:
109 <<: *common
110 command: ["chat", "-q", "${QUERY:-Hello, who are you?}", "-m", "${MODEL:-/models/tl-Q4_0.gguf}"]
111 profiles: [query]
112 restart: "no"
113 healthcheck: disable
114
115 # ─── Quantization worker ──
116 quantize:
117 <<: *common
118 volumes:
119 - "${MODELS_VOLUME:-./models}:/models:rw" # need write for output
120 - "${CONFIG_VOLUME:-./config}:/root/.mojollama"
121 - "${CACHE_VOLUME:-./cache}:/cache"
122 command: ["quantize", "${MODEL:-/models/tl-Q4_0.gguf}", "-t", "${QUANT_TYPE:-Q4_K_M}", "-o", "${QUANT_OUTPUT:-/models/quantized.gguf}"]
123 profiles: [quantize]
124 restart: "no"
125 healthcheck: disable
126
127 # ─── Auto-tuner ──
128 autotune:
129 <<: *common
130 command: ["autotune", "-m", "${MODEL:-/models/tl-Q4_0.gguf}", "--quick", "--mojollama"]
131 profiles: [autotune]
132 restart: "no"
133 healthcheck: disable
134
135 # ─── Information / diagnostics ──
136 info:
137 <<: *common
138 command: ["info"]
139 profiles: [info]
140 restart: "no"
141 healthcheck: disable
142
143 # ─── llama.cpp fallback server ──
144 llama-cpp:
145 <<: *common
146 ports:
147 - "${LLAMA_PORT:-8082}:8080"
148 entrypoint: ["llama-server"]
149 command: ["-m", "${MODEL:-/models/tl-Q4_0.gguf}", "--port", "8080", "--host", "0.0.0.0",
150 "-t", "${OMP_NUM_THREADS:-32}", "-b", "${BATCH:-4096}", "-ub", "${UBATCH:-1024}",
151 "-np", "${N_PARALLEL:-4}", "--mlock", "--cont-batching"]
152 profiles: [fallback]
153
154 # ─── MAX engine server (GPU) ──
155 max:
156 <<: *common
157 ports:
158 - "${MAX_PORT:-8083}:8080"
159 entrypoint: ["mojo_engine"]
160 command: ["--model", "${MODEL:-/models/tl-Q4_0.gguf}", "--port", "8080", "--threads", "${OMP_NUM_THREADS:-32}"]
161 profiles: [max]
162 deploy:
163 resources:
164 reservations:
165 devices:
166 - driver: nvidia
167 count: 1
168 capabilities: [gpu]