This repository was archived by the owner on Sep 7, 2026. It is now read-only.
Repository navigation
Omlx docker support - #1
Closed
geekaholic wants to merge 42 commits into
Closed
geekaholic wants to merge 42 commits into
geekaholic wants to merge 42 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Add `omni launch <tool>` subcommand to the omni CLI, mirroring `omlx launch` but connecting to the docker proxy instead of the native MLX server; supports claude, codex, copilot, opencode, openclaw, hermes, pi, and `list` - Add OpenAI Responses API adapter (`/v1/responses`) to the proxy so Codex CLI (which exclusively uses the Responses API) can connect to any OpenAI-compatible backend via the proxy - Add `wire_api = "responses"` to the codex config.toml provider block - Fix hermes.py top-level `import yaml` breaking `omni launch list` in --no-deps installs; import moved inside the methods that need it - Enrich `/v1/models` response with `context_window` / `max_context_window` from backend `max_model_len` and admin settings so Codex can use the correct context window for auto-compaction - Fix proxy admin `cli_prefix` from `"omlx proxy"` to `"omni"` so the dashboard command cards show `omni launch <tool>` - Fix README install instructions: clarify package name vs CLI name, add `rehash` to uv workflow, remove hardcoded Linux paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Introduces llama.cpp as a second managed sidecar backend alongside vLLM, with a shared HuggingFace cache mount so model downloads are never duplicated when switching backends. Backend-portable settings (model, context length, parallelism, ports, HF cache, network proxy) are renamed from VLLM_* to OMNI_* — a clean break with no aliases. Backend-specific knobs keep their VLLM_*/LLAMACPP_* prefixes. New files: - omlx/proxy/sidecar_compose.py: shared CommonSidecarSettings base, SidecarBackendSpec registry, render_proxy_service(), and all shared helpers - omlx/proxy/llamacpp_compose.py: LlamacppComposeSettings, renderer, and BACKEND_SPECS registration; supports -hf owner/repo[:tag] and local *.gguf - docker/docker-compose.llamacpp.template.yml: generated template - tests/test_llamacpp_compose.py, tests/test_sidecar_compose.py: new test suites Updated: - vllm_compose.py now subclasses CommonSidecarSettings - omni_cli.py: --context-length/--max-parallel portable flags, llamacpp-specific flags, mode tracking (managed vs proxy), generalized serve/control paths - admin.py: sidecar-agnostic endpoints (GET/POST sidecar-compose), keyed off OMLX_SIDECAR_BACKEND - Frontend: dashboard.js + _settings.html use proxy.sidecar.* with backend-conditional x-show sections for vLLM vs llama.cpp settings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… via Docker API - Drop `ollama` as a distinct backend type; alias it to `openai-compatible` everywhere (admin API, omni_cli, serve-state migration). Ollama native-metric probes in metrics.py are unchanged. - Backend URL auto-populates per type (BACKEND_URL_DEFAULTS in config.py); sidecar URLs (vllm / llama.cpp) are readonly in the UI and enforced server-side. - Per-backend profile persistence: URL, API key, model, and served-model-name stash/restore in `backend_profiles` (proxy-state.json) when the type changes; shared settings (context length, max parallel, sampling) remain unprofiled. - Sidecar-only settings (image, extra args, port) are hidden in openai-compatible router mode. - "Restart Backend" button in Settings restarts the managed sidecar container via Docker Engine API over the mounted /var/run/docker.sock (docker_control.py, httpx over UDS). Sidecar startup script re-sources the generated env file so a plain restart applies saved settings without a host-side compose recreate. - Button is disabled with an explanatory hint when docker.sock is not mounted (server reports docker_socket_available in the GET payload). - "Restart server" (native oMLX button) is hidden in proxy mode; JS also treats HTTP 501 the same as 503 (amber "unsupported" instead of generic error). - Router-mode Backend URL hint now mentions http://host.docker.internal:11434/v1 for Docker users reaching a backend on the host. - Delete translated READMEs (fr/ja/ko/zh); update English README and LINUX_PROXY_REMAINING_WORK.md. - 98 tests added/updated across test_proxy.py, test_docker_control.py, test_omni_cli.py, test_sidecar_compose.py. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Brings in the upstream redesigned admin dashboard (Serving Stats, Average Speed, Active Models, Runtime Cache Observability, API Endpoints panels), reworked admin routes, and updated MLX dep pins. Conflict resolution: kept fork's oMNI branding, README set, proxy modules and omni CLI; combined both new CLI subcommand branches; kept fork's getAuthHeaders() in chat.html while adopting upstream's integration-settings fetch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reuse upstream's MLX-free ServerMetrics for session/all-time/per-model serving stats in proxy mode. Usage and timing are captured on all four request paths: Anthropic messages (streaming + non-streaming, recording unscaled backend tokens), the Responses adapter, and the raw chat/completions passthrough, which now injects stream_options.include_usage when the client didn't ask (stripping the trailing usage-only chunk from the relayed stream, with a one-shot retry without injection if the backend rejects it). TTFT approximates prefill duration; first-token-to-close the generation duration; llama.cpp `timings` are honored for non-streaming responses. /admin/api/stats now returns real snapshots with model/scope filters, and the clear endpoints split into session vs all-time. All-time stats persist to OMLX_PROXY_STATS_PATH (default: next to the proxy state file). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Ollama backends list loaded models from /api/ps with real memory size and TTL countdown; vLLM/llama.cpp backends attribute Prometheus running/waiting request counts to the served model. Backend metric collection now goes through a 5s per-backend cache so dashboard polling doesn't hammer the backend, and the per-model unload button is hidden in proxy mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…xy mode select_prometheus_metrics now recognizes vLLM prefix-cache counters (v1 hits/queries plus the legacy v0 hit-rate gauge) and llama.cpp --metrics families (kv_cache_usage_ratio, kv_cache_tokens, prompt/ predicted tok/s, requests_processing/deferred), and the summary computes a prefix hit rate percentage. The llama.cpp sidecar now launches with --metrics. In proxy mode the Runtime Cache Observability panel becomes "Backend KV / Prefix Cache", showing whichever metrics the backend exposes and a clear note for backends (e.g. Ollama) that expose none; the MLX SSD/hot-cache internals stay native-mode only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The panel iterates MLX engine version entries; behind a remote backend the proxy's engines dict has no such shape and the Proxy Backend Status panel already covers backend identity. API Endpoints and Claude Code panels work in proxy mode as-is (host/port/cli_prefix/claude_code all served by the proxy). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Record the v0.4.4rc1 dashboard merge, proxy-side serving stats, Active Models and backend cache observability as completed; document the deferred external-caching decision (LMCache etc.) and the streaming usage caveat; fold llama.cpp sidecar and UI-cleanup items into done. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Continuation context for a Claude Code session on the DGX Spark: branch state, settled design decisions, implementation map, the real-backend verification checklist, and Linux-specific gotchas. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The upstream dashboard's memory-pressure bar was hidden in proxy mode because memory_pressure was hardcoded to disabled/zero. Populate it: - current: per-process GPU memory from nvidia-smi run inside the managed sidecar via the Docker exec API (on unified-memory machines like DGX Spark, CUDA allocations appear neither in the container cgroup nor process RSS, so this is the only real signal); Ollama uses the /api/ps model sizes already collected. - soft limit: vLLM's gpu_memory_utilization share of host memory. - hard limit: host MemTotal from /proc/meminfo (the unified pool). The single sidecar model row now shows its real footprint instead of "remote", and the JS label renders "X / Y" when there is no distinct soft limit. GPU probe results are cached for 10s on top of the 5s backend-metrics TTL. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Current llama.cpp server images (b9570+) no longer emit llamacpp:kv_cache_usage_ratio / kv_cache_tokens, which left the proxy-mode "Backend KV / Prefix Cache" panel showing "not exposed" despite usable throughput data. Select llamacpp:n_tokens_max as a context high-water mark, count throughput/peak metrics toward panel availability, and add a Peak Context Tokens tile (i18n'd). Verified against the live ghcr.io/ggml-org/llama.cpp:server-cuda sidecar on DGX Spark. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Prometheus name drift: 2026 vLLM images emit
vllm:prefix_cache_{hits,queries}_total (no gpu_ prefix) and
vllm:kv_cache_usage_perc. Extend the candidate tuples, keeping the
vllm:-prefixed names first so suffix matching never picks up the
*external_prefix_cache* families (verified live: 63% hit rate on
repeated prompts now reaches the dashboard panel).
- Stale persisted backend routing: launching a different sidecar stack
(omni serve --backend vllm after a llama.cpp session) left the proxy
pointed at the dead llamacpp hostname because the saved
proxy_backend_url override beat the env. OMLX_SIDECAR_BACKEND is now
authoritative at startup, mirroring the admin UI's type-switch flow
(profiles archived for switching back).
- vLLM only reports usage.prompt_tokens_details.cached_tokens with
--enable-prompt-tokens-details; pass it in the generated compose so
proxy-side cached-token stats work (template + synced copy).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The reverse of the sidecar-launch reconciliation: switching from a managed sidecar session to `omni serve --backend openai` left the proxy routing to the dead compose hostname because the persisted sidecar backend type/URL overrode the env. Without OMLX_SIDECAR_BACKEND a persisted sidecar type is always stale — archive its profile, fall back to openai-compatible, and let the env-provided backend URL win. Verified live on the Spark: vLLM session -> omni serve --backend openai (host Ollama) now routes correctly; Active Models shows real size + TTL. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
docs/SPARK_RUNBOOK.md covers the verified quick starts (vLLM and llama.cpp sidecars, external Ollama through host-gateway, external OpenAI-compatible endpoints), operations, and troubleshooting for every incident hit during verification (broken container DNS sandbox, stale generated env files, port conflicts between stacks, GB10 unified-memory quirks). Worklog marks Task 1 (real-backend testing) and Task 2 (runbook) done with the full verification log. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A configured sampling default of max_tokens >= the backend context made vLLM reject every chat request (prompt + max_tokens > max_model_len); the admin UI even pre-filled Max Tokens with the context size, making the footgun one click away. Defense in depth: - New backend_context_limit() probe (vLLM /v1/models max_model_len, llama.cpp /props n_ctx, cached per backend; sidecar stacks fall back to the launch context length). - apply_proxy_request_defaults skips injecting a max_tokens default that reaches the limit, treats 0/empty as "no cap configured", and reports injection so the passthrough can retry once without the cap on a backend 400 (prompt may consume the remaining room). - Out-of-box default changed from a hardcoded 32768 to unset — the backend's own limit applies unless the operator opts in. - Settings UI no longer pre-fills Max Tokens with the context size; it shows the live backend context window, flags unsafe values inline, and offers a one-click "Use recommended (ctx/2)" fix. The chat per-model modal shows the model's context window and warns likewise. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
omni serve --scan-models [--model-dir DIR] mounts the host model caches read-only into the proxy (HF cache at /models-scan/hf, plus the llama.cpp cache on that stack) and enables a Models-tab section listing everything already downloaded: safetensors repos tagged for vLLM, GGUF repos/files tagged for llama.cpp, with type, size, and context length. - omlx/proxy/local_models.py: layout-aware scanner (HF hub caches, plain model dirs, loose GGUFs) reusing the MLX-free helpers from omlx.model_discovery; skips aborted downloads (refs without snapshots) and dedupes repos reachable via multiple mounts. - GET /admin/api/proxy/local-models (cached, ?refresh=1 rescans); disabled without the flag so the UI section stays hidden. - "Use with sidecar" posts the existing global-settings flow (omni_model -> regenerated env) and chains into the existing backend-restart confirm dialog. Rows gated on backend compatibility. - Compose templates carry OMLX_MODEL_SCAN/OMLX_MODEL_SCAN_DIR and the :ro scan mounts (inert while the feature is off); env keys survive regeneration. i18n'd across all locales. Verified against the real Spark caches: 14 models classified correctly (VLM/embedding types, GGUF tagging, aborted MiniMax download skipped). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live verification caught it: switching the vLLM sidecar to Qwen/Qwen3-1.7B kept the previous --max-model-len 65000 and vLLM refused to start (model max is 40960). The scan rows already carry each model's config.json context length — "Use with sidecar" now lowers omni_context_length to the model's limit when the configured value exceeds it. Runbook + worklog document the feature. Verified end-to-end on the Spark: scan listed 12 HF repos, switch to Qwen3-1.7B (ctx capped to 40960) restarted cleanly and chat works. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ed-name sync DGX Spark / unified-memory hardening for the vLLM and llama.cpp sidecars: - Pre-flight memory-fit guard (omlx/proxy/memory_fit.py): refuses launches predicted to exhaust the unified pool and hard-lock the host. CLI exits non-zero (--force-memory to override); admin returns 409 with a "Launch anyway" dialog. Replaces the blind 0.80 gpu-memory-utilization default with a host-reserve-aware value. - Demand-aware gpu-memory-utilization: size the KV pool to the workload (weights + max_parallel x context x headroom), capped by the safety ceiling, so a small model no longer preallocates ~100 GiB of KV. Reads KV geometry from config.json; OMLX_KV_HEADROOM tunes the slack. - HF offline mode (OMNI_HF_OFFLINE -> HF_HUB_OFFLINE/TRANSFORMERS_OFFLINE): auto-on when the model is cached so a broken DNS sandbox or an offline box can't crash vLLM startup; --offline/--online override. - Served-name resync: changing --model (or the admin model) re-derives the served name unless one is set explicitly, so the new model isn't exposed under the previous session's name. Threaded through sidecar_compose settings + both compose templates; admin recommended-util hint and model-switch are demand/offline aware. Adds tests (test_memory_fit.py + proxy/cli/compose suites) and updates the Spark runbook and worklog. Removes the obsolete SPARK_HANDOFF.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ig.toml omlx launch codex permanently rewrote ~/.codex/config.toml (flipping model_provider to omlx and adding a provider block with env_key = "OMLX_API_KEY"). That persisted past the session, so later plain codex runs failed demanding OMLX_API_KEY. Mirror the env-only pattern used by Claude Code/Copilot: pass the whole oMLX provider through Codex's `-c key=value` inline overrides, which layer on top of the user's existing config for that one run only. Nothing is written to disk, and the user's upstream default provider/model/trust levels are preserved. Delete the file-mutating configure() path and switch the integration type to env_var. Tests now drive launch() and assert the override argv plus that no config file is written. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Logs tab only showed the proxy's in-memory buffer, missing the container stdout/stderr that `omni logs -f` surfaces (proxy startup and the entire vLLM/llama.cpp sidecar). Add Docker Engine API container logs as selectable sources in the existing tab. - docker_control: add container_logs() over the unix-socket httpx client (no docker CLI); generalize _demux_docker_stream to keep stdout+stderr, exec keeps stdout-only via streams=(1,). - admin /api/logs: advertise "<service> (container)" sources (proxy + backend) when /var/run/docker.sock is mounted, and tail them per poll. Missing socket -> 501, daemon error -> 502; server.log path unchanged. - Frontend is data-driven (available_files + ?file=), so no JS changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Selecting a large model (e.g. gemma-4-26B) via "Use with sidecar" wrote
gpu-memory-utilization ~0.45, whose vLLM budget barely cleared the resident
weights and left the KV pool negative ("No available memory for the cache
blocks"). Root cause: the safety ceiling subtracted the weights a second time
as a "load transient" — but that copy is reclaimable page cache, not pinned
memory, so it double-counted the weights (already inside vLLM's budget) and
dragged the ceiling below what vLLM needs for weights + runtime overhead + KV.
- memory_fit: recommended_utilization ceiling is now (total-reserve)/total;
the genuine load-time double-weight peak stays guarded by the intrinsic
2*weights+reserve<=total block, and the redundant per-util transient block
in evaluate_fit is removed.
- memory_fit: ACTIVATION_HEADROOM_GB 2.0 -> 8.0 (covers the non-weight runtime
peak, inflated for VLMs by multimodal-encoder profiling) and auto_utilization
floors the result so the chosen budget always clears weights + overhead +
a minimal KV pool, capped by the ceiling.
- admin: on a model switch, reset model-specific vLLM knobs (dtype,
quantization, kv_cache_dtype, tokenizer/revision/load_format, chunked_prefill,
prefix_caching, max_num_batched_tokens, cpu_offload/swap) to auto. Preserves
enforce_eager (GB10-required), tool/reasoning parser, generation config,
image, max_parallel, and any value set in the same save.
- admin/dashboard.js: "Use with sidecar" sends reset_optimal so optimal
defaults are re-applied even when re-selecting the already-current model
(heals a stuck config without a switch-away-and-back).
- Update SPARK_RUNBOOK to match; add memory_fit + proxy tests.
Net effect for gemma-4-26B on a ~121 GiB pool: util 0.45 -> ~0.79, available
KV -3.3 -> ~38 GiB; the pre-flight guard still blocks genuinely unsafe utils.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Make `omni launch codex` against vLLM-served models (especially gemma-4) work out of the box, end to end. Tool calling (vLLM): - New omlx/proxy/tool_config.py: per-model registry maps a model family to the correct vLLM --tool-call-parser (+ --reasoning-parser / --chat-template), so gemma-4 auto-selects the native gemma4 parser. Tools on by default; an explicit --tool-call-parser still wins; unknown families start cleanly (the launch guard only enables tools when a concrete parser is present). Parser re-derives on model switch. Codex Responses adapter: - Fix the tool-call loop: _input_to_messages now translates Responses function_call / function_call_output items into assistant tool_calls + tool messages, so the model sees tool results instead of re-requesting forever. - Strip stray gemma-4 reasoning-channel markers (<|channel>thought...<channel|>) that vLLM's parser leaves in content (new omlx/proxy/protocol_markers.py; streaming + non-streaming). - Pass model_context_window / model_max_output_tokens to Codex so it compacts and stops overflowing the window (fixes mid-stream 400 disconnects). Context window / Max Tokens (single source of truth): - /v1/models advertises the backend's real max_model_len (no separate cap). - Max Tokens defaults to Auto (backend caps to remaining context); the dashboard shows context window + Max Tokens read-only in proxy mode and drops the confusing "exceeds context" warning. The serving Context Length is the one editable place; add `omni serve --max-output-tokens` for power users. Tests: tool_config, vllm_compose, responses_adapter, protocol_markers, enrich_models, integrations, omni_cli (425 passing). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vLLM's gemma4 parser needs a clean <tool_call|> terminator and its fallback
truncates brace-heavy arguments at the first '}', so a heredoc writing JS (or
any tool call with braces in its args, ending without the terminator) leaks
into content and never executes.
Add Gemma4StreamProcessor (omlx/proxy/protocol_markers.py): one streaming pass
that strips reasoning-channel markers AND reassembles leaked tool calls. It
detects call:name{...}, tracks balanced braces across deltas (so '}' inside the
arguments is handled), and parses the span with omlx's balanced-brace fallback
(_parse_gemma4_tool_call_fallback) — no terminator required. Recovery is
Gemma-4 only (enable_tool_recovery) so other models' prose isn't misread.
- responses_adapter.stream_responses_events: dispatch processor events to text
or a synthesized function_call item; recovered calls join structured ones in
response.completed.
- Non-streaming: recover_tool_calls() used in non_streaming_responses_response
and backend.openai_response_to_internal (covers /v1/messages + chat).
Tests: processor (brace-heavy heredoc with no terminator, split across deltas,
partial-start hold, truncated-call drop, recall: non-misfire, recovery-off) and
streaming/non-streaming integration. 437 proxy-suite tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The context length was a fixed default (8192), so out of the box every model served a tiny window and coding agents overran it. Compute it from the model + host instead — no per-model database, all read from config.json + weights + host memory, extending the existing demand-aware memory-fit machinery. - memory_fit.recommended_context_length(): largest context that safely fits (inverse of demand_utilization — weights + KV for context*parallel + activation must fit the host budget), clamped to the model's native max_position_embeddings and a 256K cap (OMLX_MAX_AUTO_CONTEXT), floored to a 4096 multiple. Returns None when geometry is unknown so the caller keeps a conservative fallback. - Fix kv_bytes_per_token to read nested text_config (multimodal models like Gemma-4 kept the LM geometry there, so KV sizing silently fell back to the safety ceiling — this also improves the existing auto-util). - Default max_parallel 4 -> 2: a single coding agent rarely needs more, and low concurrency lets the auto context be much larger (KV split across max_parallel). - Wire into the two existing auto-sites (omni serve preflight + admin model-switch): when --context-length isn't set, auto-size it before the util calc. Explicit --context-length still wins. On the DGX Spark, gemma-4 now auto-sizes to ~64K (was 8192/manual 32768), qwen3 to its own value, etc. Combined with the shipped auto parser + Auto max-tokens, serving "just works" with no manual tuning. 459 proxy-suite tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Gemma-4 tool-call recovery worked on whole/chunked input but leaked under real token streaming (vLLM delivers ~1 char per delta): the buffer only held a tool-call start once the full `call:` keyword was present, so streamed one char at a time the keyword never formed — `c`,`a`,`l`,`l`,`:` each flushed as text before the start could be detected, and the call leaked verbatim. Hold trailing *prefixes* of the `call:` keyword (`c`/`ca`/`cal`/`call`) at a word boundary so it accretes across deltas, then the existing brace-balanced recovery fires. Word-boundary check keeps surrounding prose (e.g. "recall") intact. Tests: recover a tool call fed one character at a time; surrounding text with "recall" preserved. 461 proxy-suite tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.