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

@ -160,7 +160,26 @@ def run_env(cfg, hw=None, include_key=True):
return env
def exec_server(cfg, args):
"""Replace this process with `vllm serve` (so the service manager tracks vLLM directly)."""
def run_server(cfg, entry, choice, args):
"""Start the proxy on api_port, then `vllm serve` as a child on api_port+1 (args).
vLLM keeps its own API key, so the inner port isn't open to anyone else on the box;
the proxy checks the client's key and sends ours on."""
from .. import hfcache, plan
from . import proxy
port = cfg["api_port"]
inner = port + 1
stats = proxy.Stats()
stats.ready = True # vLLM's own /health is only OK once the model is loaded
controls = hfcache.template_controls(choice["repo"])
key = paths.api_key()
srv = proxy.listen(port, proxy.make_handler(
inner, entry["name"], choice.get("est_context", entry["context"]), key, stats,
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls),
upstream_model=entry["name"], upstream_key=key,
effort_levels=plan.effort_levels(entry, controls)))
proxy.kill_stale(inner, VENV, "vllm")
exe = str(VENV / "bin/vllm")
os.execve(exe, [exe, "serve", *args], run_env(cfg))
# vLLM's output goes straight to ours (the service log); nothing in it needs reading.
child = subprocess.Popen([exe, "serve", *args], env=run_env(cfg))
# vLLM shuts its engine processes down on SIGTERM; give that time before killing.
proxy.supervise(srv, child, "vllm", port, inner, stop_timeout=45)