|
| 1 | +# fit |
| 2 | + |
| 3 | +**Does this model fit on your GPUs — and at what shape?** |
| 4 | + |
| 5 | +`fit` is a stateless planner for vLLM deployments. Give it a HuggingFace model |
| 6 | +ID, your GPU inventory, and your workload (concurrency, context length, SLOs), |
| 7 | +and it returns a ranked list of valid `(quantization, KV dtype, parallelism, |
| 8 | +placement)` configurations that fit in memory and meet the SLO — along with |
| 9 | +the rejected ones and **why** they were rejected. |
| 10 | + |
| 11 | +It is a pure planning engine. It does not schedule, deploy, or talk to a |
| 12 | +cluster. Hand the top-ranked config to your orchestrator and let it act. |
| 13 | + |
| 14 | +The full design spec lives in [SPEC.md](./SPEC.md). |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## What's in the box |
| 19 | + |
| 20 | +- **Go HTTP server** (`cmd/fit`) — single static binary. Embeds the React UI, |
| 21 | + exposes the planning API at `/api/v1/*`. |
| 22 | +- **React UI** (`web/`) — model + workload + inventory editor with live |
| 23 | + re-planning on every edit. Built into the binary; no separate web server. |
| 24 | +- **Planner core** (`internal/{estimator,solver,model,gpu,hf}`) — memory and |
| 25 | + throughput math (roofline model), combinatorial config search, HuggingFace |
| 26 | + introspection, GPU SKU catalog, and per-architecture family handlers (dense, |
| 27 | + MoE, MLA-MoE, hybrid SSM, multimodal vision/audio). |
| 28 | +- **Calibration tooling** (`cmd/calibrate`) — skeleton for empirical |
| 29 | + calibration against real vLLM runs. |
| 30 | +- **vLLM architecture generator** (`cmd/gen-vllm-archs`) — scrapes upstream |
| 31 | + vLLM's model registry and emits Go bindings. |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Quick start |
| 36 | + |
| 37 | +```bash |
| 38 | +# 1. Configure your HuggingFace token (only required for gated/private models) |
| 39 | +cp .env.example .env |
| 40 | +echo 'HF_TOKEN=hf_xxx' >> .env |
| 41 | + |
| 42 | +# 2. Build the React UI (output is embedded into the Go binary) |
| 43 | +npm --prefix web ci |
| 44 | +npm --prefix web run build |
| 45 | + |
| 46 | +# 3. Build the binary |
| 47 | +go build -o fit ./cmd/fit |
| 48 | + |
| 49 | +# 4. Run |
| 50 | +./fit |
| 51 | +# → http://localhost:8080 (UI + API on the same port) |
| 52 | +``` |
| 53 | + |
| 54 | +The binary serves the SPA at `/` and the JSON API at `/api/v1/*`. |
| 55 | + |
| 56 | +### Frontend dev loop |
| 57 | + |
| 58 | +For live frontend reloads, run Vite separately and let it proxy to the Go |
| 59 | +backend: |
| 60 | + |
| 61 | +```bash |
| 62 | +go run ./cmd/fit # terminal 1 — backend on :8080 |
| 63 | +npm --prefix web run dev # terminal 2 — Vite on :5173 proxying /api → :8080 |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Configuration |
| 69 | + |
| 70 | +All configuration is via environment variables. `fit` loads `.env` on startup |
| 71 | +(via [godotenv](https://github.com/joho/godotenv)); real env vars always win. |
| 72 | +See [`.env.example`](./.env.example) for the complete list. |
| 73 | + |
| 74 | +| Var | Default | Purpose | |
| 75 | +|----------------------|-----------------------------|----------------------------------------------------| |
| 76 | +| `HF_TOKEN` | _(none)_ | Server-side default HF token. Per-request tokens override. | |
| 77 | +| `HF_API_BASE` | `https://huggingface.co` | Override for HF Hub mirror. | |
| 78 | +| `PORT` | `8080` | HTTP port. | |
| 79 | +| `LOG_LEVEL` | `info` | One of `debug`, `info`, `warn`, `error`. | |
| 80 | +| `REQUEST_TIMEOUT_MS` | `5000` | Per-request timeout. | |
| 81 | +| `CACHE_MAX_ENTRIES` | `10000` | In-memory HF metadata cache size. | |
| 82 | +| `CONSTANTS_PATH` | _(built-in)_ | Path to a custom estimator constants JSON file. | |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## API |
| 87 | + |
| 88 | +| Method | Path | Purpose | |
| 89 | +|--------|-------------------------------------------|--------------------------------------| |
| 90 | +| GET | `/api/v1/healthz` | Liveness probe. | |
| 91 | +| GET | `/api/v1/readyz` | Readiness (constants + HF reachable). | |
| 92 | +| GET | `/api/v1/gpus` | Built-in GPU SKU catalog. | |
| 93 | +| GET | `/api/v1/models/{owner}/{repo}/profile` | Model introspection (no planning). | |
| 94 | +| POST | `/api/v1/plan` | Main endpoint. Returns ranked configs. | |
| 95 | + |
| 96 | +Request/response schemas are documented in [SPEC.md §2](./SPEC.md). |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Docker |
| 101 | + |
| 102 | +```bash |
| 103 | +docker build -t fit . |
| 104 | +docker run --rm -p 8080:8080 --env-file .env fit |
| 105 | +``` |
| 106 | + |
| 107 | +The Dockerfile is a multi-stage build: Node stage builds the React UI into |
| 108 | +`internal/webui/dist/`, Go stage compiles the binary (which embeds the dist), |
| 109 | +final stage runs distroless static. |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Repository layout |
| 114 | + |
| 115 | +``` |
| 116 | +cmd/ |
| 117 | + fit/ # HTTP server entrypoint |
| 118 | + calibrate/ # empirical calibration CLI (skeleton) |
| 119 | + gen-vllm-archs/ # generator for internal/model/vllm_archs.go |
| 120 | +internal/ |
| 121 | + api/ # request/response wire types + validation |
| 122 | + estimator/ # memory + throughput math, calibration constants |
| 123 | + gpu/ # built-in GPU SKU catalog + inventory resolution |
| 124 | + hf/ # HuggingFace Hub client + in-memory cache |
| 125 | + model/ # per-family handlers (dense, MoE, MLA, hybrid SSM, multimodal) |
| 126 | + server/ # chi routes, middleware, handlers |
| 127 | + solver/ # combinatorial config search + ranking |
| 128 | + webui/ # //go:embed of the built React SPA + static handler |
| 129 | +pkg/ |
| 130 | + planner/ # public planner type re-exports |
| 131 | +web/ # React 19 + Vite TypeScript SPA |
| 132 | +testdata/ # golden files + sample configs |
| 133 | +``` |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +## License |
| 138 | + |
| 139 | +[MIT](./LICENSE) |
0 commit comments