Proxy in front of vLLM too; dashboard reset/clear; opencode effort variants

- Move the MLX proxy into backends/proxy.py and run it on both backends:
  public port 1134 is the proxy, the model server listens on 127.0.0.1:1135.
  On vLLM this brings the reasoning chooser, the "default" alias and the
  per-request table. Effort levels the model lacks map to the nearest it has
  (high -> xhigh on qwen3.8); vLLM's own key is sent upstream; streamed runs
  are counted from the usage chunk (MTP packs several tokens per chunk).
- Dashboard: restore METRIC_RE (vLLM page stuck on "loading"); Statistics
  header with Reset, Requests header with Clear; drop the TTFT chart; rename
  token columns; Peak KV shows "-" when no samples cover a run.
- opencode: config snippet's model points at <provider>/default, and
  reasoning models get variants built from the levels the template accepts.
- README: proxy on both platforms; NVIDIA checklist split into verified / open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-03 13:03:52 -08:00
parent 1121c3f908
commit 8879db44a0
12 changed files with 886 additions and 493 deletions

View file

@ -118,13 +118,19 @@ def catalog_entry(catalog, name):
# ---------- backend command lines ----------
def vllm_args(entry, choice, port, tp):
"""Arguments after `vllm serve`."""
"""Arguments after `vllm serve` (bound to localhost; the proxy faces the network and
owns the model's other names, so vLLM only needs the one it's addressed by)."""
v = entry.get("vllm", {})
args = [choice["repo"], "--served-model-name", entry["name"], SERVED_ALIAS,
"--host", "0.0.0.0", "--port", str(port),
args = [choice["repo"], "--served-model-name", entry["name"],
"--host", "127.0.0.1", "--port", str(port),
"--max-model-len", "-1", # let vLLM fit the context to free memory (capped at native)
"--gpu-memory-utilization", f"{choice['util']:.2f}",
"--enable-prefix-caching"]
"--enable-prefix-caching",
# usage.prompt_tokens_details.cached_tokens, so a run's prompt count is the part
# actually processed -- what mlx_lm reports too
"--enable-prompt-tokens-details",
# every request now comes from the proxy, which logs the real client itself
"--disable-uvicorn-access-log"]
if tp > 1:
args += ["--tensor-parallel-size", str(tp)]
if entry.get("hybrid"):
@ -165,8 +171,8 @@ def mlx_args(entry, choice, port):
# A second name the API answers to, besides the model's own. opencode (and any client
# with a saved default) points at this instead of a specific model, so the choice keeps
# working after `llmhost switch` -- only one model is loaded at a time, so naming one in
# a client config only ever goes stale. vLLM takes it as a second --served-model-name and
# still reports the real slug, being the first; the MLX proxy accepts it as an alias.
# a client config only ever goes stale. The proxy in front of either backend accepts it
# and /v1/models lists only the real slug.
SERVED_ALIAS = "default"
@ -204,3 +210,26 @@ def reasoning_kwargs(value, entry, controls):
if controls.get("effort") and value in levels:
return {"reasoning_effort": value}
return {}
# Effort levels in order, for mapping a level a model lacks onto the nearest it has.
EFFORT_SCALE = ["none", "minimal", "low", "medium", "high", "xhigh", "max"]
def effort_levels(entry, controls):
"""The effort levels this model's template accepts, or () if it takes none."""
levels = (entry.get("effort") or {}).get("levels") or []
return tuple(levels) if entry.get("reasoning") and controls.get("effort") else ()
def nearest_effort(value, levels):
"""The level in `levels` closest to `value` on EFFORT_SCALE; on a tie, the higher one
(asking for "high" between medium and xhigh means wanting more, not less). None when
either is off the scale."""
if value not in EFFORT_SCALE:
return None
want = EFFORT_SCALE.index(value)
known = [l for l in levels if l in EFFORT_SCALE]
if not known:
return None
return min(known, key=lambda l: (abs(EFFORT_SCALE.index(l) - want), -EFFORT_SCALE.index(l)))