Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(vllm): recognize the weights layout the Qwen3.8 prepare step writes (#4716)
[._.]/ Adam Eivyc5da8db904fb
diff --git a/docs/features/qwen38-rtx3090.md b/docs/features/qwen38-rtx3090.mdindex 698bb3cbc5..9c517ee2b3 100644--- a/docs/features/qwen38-rtx3090.md+++ b/docs/features/qwen38-rtx3090.md@@ -53,23 +53,36 @@ would.### 1. Prepare the stack (operator, on the 3090 host)-This step is yours, in a terminal. PortOS does not clone the project, pull the+This step is yours, in a terminal. PortOS does not clone the project, build the~9.5 GB image, or download the ~20 GB of weights — those are decisions with abandwidth and disk cost, and a button that started them by surprise would be thewrong default.On Windows you need WSL2 with Docker and the NVIDIA Container Toolkit (driver-≥ 580 / CUDA 13); on Linux, the same toolkit natively.+≥ 580 / CUDA 13); on Linux, the same toolkit natively. Run the commands below+*inside the WSL2 distro*, not in PowerShell — the compose project and its+20 GB of weights belong on the Linux filesystem.```bashgit clone https://github.com/syv-ai/qwen38-27b-rtx3090 ~/qwen-servingcd ~/qwen-servingecho "VLLM_API_KEY=$(openssl rand -hex 24)" > .envprintf 'SPEC=dflash2\nPREFIX_CACHE=1\n' >> .env+docker compose build # ~9.5 GB image, built here — there is no registry to pull from+docker compose run --rm prepare # ~20 GB download + CPU requantization, idempotent, resumabledocker compose --profile single up -d```-If startup dies on memory, upstream's escape hatches are `GPU_UTIL=0.93` and+`docker compose --profile single up -d` on its own does all three — `prepare` is+a `depends_on` of the server. Running them separately is worth it anyway: it is+the long, unattended part, and PortOS's Start button deliberately refuses until+`prepare` has actually landed weights on disk (see below).++**The card must be otherwise empty.** vLLM's startup gate compares free VRAM+against `GPU_UTIL`, so another model server holding a few GB — LM Studio, Ollama,+a local image/video job — makes the container exit rather than start small. Stop+those first. If startup still dies on memory, upstream's escape hatches are+`GPU_UTIL=0.93` (the documented WSL2 fallback) and`PYTORCH_CUDA_ALLOC_CONF=expandable_segments:False` in `.env`. Capping boardpower with `nvidia-smi -pl 250` is worth doing on a 3090.@@ -83,6 +96,20 @@ On Windows, confirm the same URL answers from the PortOS side too — DockerDesktop / WSL2 localhost forwarding is what makes a container in the VMreachable at `127.0.0.1` on the host.+### 1b. Point PortOS at the project (Windows only)++A native-Win32 PortOS resolves the default `~/qwen-serving` to a *Windows* home+directory, where the project is not. Set `VLLM_QWEN_PROJECT_DIR` to the distro's+UNC path so the readiness checklist can see the project and its `models/`:++```+VLLM_QWEN_PROJECT_DIR=\\wsl.localhost\<distro>\home\<user>\qwen-serving+```++Node reads that path, and `docker compose` accepts it as a working directory, so+both the checklist and the Start button work from it. On Linux the default is+already correct.+**`DFLASH_TOKENS=15` is deliberately not a default.** It is the setting behindthe headline throughput number, but it costs KV cache: 56k context across 4slots is too tight for CoS agent prompts, which carry a repo's worth of files.@@ -103,10 +130,14 @@ workload that fits.The provider card's requirements checklist probes `:18020` directly. Its**Start** button runs `docker compose --profile single up -d` — but only when itcan see a prepared project (a compose file in `~/qwen-serving`, or wherever-`VLLM_QWEN_PROJECT_DIR` points) **and** confirm the weights are already cached.-It never pulls. If your HuggingFace cache lives in a docker named volume PortOS-cannot see — the normal case on Windows — the button says so and asks you to-start compose yourself, or to point `VLLM_QWEN_WEIGHTS_DIR` at the cache.+`VLLM_QWEN_PROJECT_DIR` points) **and** confirm the weights are already on disk.+It never builds and never downloads. `prepare` writes them into the project's own+`models/` directory (compose bind-mounts `${MODELS_DIR:-./models}`), which is+what PortOS looks at; the `qwen-cache` docker volume alongside it holds only the+torch.compile / Triton / FlashInfer JIT caches. If PortOS cannot read that+directory at all — the normal case on Windows before `VLLM_QWEN_PROJECT_DIR` is+set to the UNC path above — the button says so, and `VLLM_QWEN_WEIGHTS_DIR` is+the escape hatch for weights kept somewhere else entirely.## What the numbers mean@@ -123,8 +154,8 @@ one-shot completion.| Variable | Default | Purpose ||---|---|---|-| `VLLM_QWEN_PROJECT_DIR` | `~/qwen-serving` | Where the compose project was cloned. |-| `VLLM_QWEN_WEIGHTS_DIR` | *(unset)* | HuggingFace hub cache holding the weights, when PortOS cannot find it — e.g. a docker named volume bind-mounted elsewhere. |+| `VLLM_QWEN_PROJECT_DIR` | `~/qwen-serving` | Where the compose project was cloned. Required on Windows, as the `\\wsl.localhost\…` UNC path. |+| `VLLM_QWEN_WEIGHTS_DIR` | *(unset)* | The directory holding the model weights, when it is not the project's own `models/` — e.g. a `MODELS_DIR` pointed elsewhere, or a HuggingFace hub cache shared with another stack. |## Relateddiff --git a/server/lib/vllmQwenProject.js b/server/lib/vllmQwenProject.jsindex 6ed2ac4a8b..81281609d9 100644--- a/server/lib/vllmQwenProject.js+++ b/server/lib/vllmQwenProject.js@@ -14,17 +14,20 @@* directory entries — it never runs docker, contacts a registry, or reads a* weight file.*- * **Sentinels matter here.** `hasWeights` is a tri-state: `true` (an HF hub cache- * entry for a Qwen repo was found), `false` (every candidate root was readable- * and none held one), `null` (no candidate root could be read at all). The start+ * **Sentinels matter here.** `hasWeights` is a tri-state: `true` (a Qwen model+ * directory was found), `false` (every candidate root was readable and none held+ * one), `null` (no candidate root could be read at all). The start* path treats anything other than `true` as "not verified" and refuses — but the* three cases get different copy, because "your cache is empty" and "I cannot see* your cache" send the operator to different fixes. The common `null` case is a- * real deployment shape, not a bug: the compose stack can keep its HuggingFace- * cache in a docker named volume, which on Windows/WSL lives inside the VM and is- * invisible to a native-Win32 PortOS. `VLLM_QWEN_WEIGHTS_DIR` is the escape hatch- * for that setup; otherwise the operator simply runs compose themselves, which is- * the documented path anyway.+ * real deployment shape, not a bug: on Windows the compose project is cloned+ * inside a WSL2 distro, so a native-Win32 PortOS reaches neither it nor its+ * `models/` at the Windows `~/qwen-serving` this module defaults to. Pointing+ * `VLLM_QWEN_PROJECT_DIR` at the UNC path (`\\wsl.localhost\<distro>\home\…`)+ * resolves it — Node reads that path, and `docker compose` accepts it as a+ * working directory. `VLLM_QWEN_WEIGHTS_DIR` covers the rarer case of a cache+ * kept somewhere else entirely; otherwise the operator simply runs compose+ * themselves, which is the documented path anyway.*/import { readdir, stat } from 'fs/promises';@@ -62,6 +65,25 @@ const COMPOSE_FILENAMES = ['docker-compose.yml', 'docker-compose.yaml', 'compose*/const QWEN_CACHE_ENTRY = /^models--.*qwen/i;+/**+ * The hub layout is not what upstream's `prepare` service actually produces.+ * `docker/prepare.sh` runs `hf download <repo> --local-dir /app/models/<model>`,+ * and compose bind-mounts `${MODELS_DIR:-./models}` there — so a prepared 3090+ * holds a plainly-named `models/Qwen3.8-27B-W4A16-AutoRound/` (plus `-fast` and+ * the DFlash2 drafter), never a `models--…` directory. Matching only the hub+ * shape reported every correctly-prepared machine as "no weights cached yet"+ * and refused to start a container that was ready to run.+ */+const QWEN_LOCAL_ENTRY = /qwen/i;++/**+ * What makes a `qwen`-named directory *weights* rather than a notes folder that+ * happens to share the name. These are the same files upstream's own readiness+ * check keys on: a sharded download writes the index, a single-file one (the+ * DFlash2 drafter) writes the tensor file itself.+ */+const LOCAL_WEIGHT_MARKERS = ['model.safetensors.index.json', 'model.safetensors'];+const isDirectory = (path) => stat(path).then((s) => s.isDirectory(), () => false);const isFile = (path) => stat(path).then((s) => s.isFile(), () => false);@@ -90,6 +112,25 @@ function weightsCandidateRoots(projectDir, env = process.env) {];}+/**+ * Whether one cache root holds Qwen weights, in either layout: a HuggingFace hub+ * entry, or the `--local-dir` model directory upstream's prepare step writes.+ *+ * @param {string} root+ * @param {string[]} entries+ * @returns {Promise<boolean>}+ */+async function rootHoldsQwenWeights(root, entries) {+ if (entries.some((name) => QWEN_CACHE_ENTRY.test(name))) return true;+ for (const name of entries.filter((entry) => QWEN_LOCAL_ENTRY.test(entry))) {+ for (const marker of LOCAL_WEIGHT_MARKERS) {+ // eslint-disable-next-line no-await-in-loop -- two stats on a short, ordered candidate list+ if (await isFile(join(root, name, marker))) return true;+ }+ }+ return false;+}+/*** Inspect the operator's vLLM project without touching docker.*@@ -116,7 +157,8 @@ export async function inspectVllmQwenProject(env = process.env) {const entries = await readdir(root).catch(() => null);if (entries === null) continue; // absent or unreadable — says nothing either wayreadAnyRoot = true;- if (entries.some((name) => QWEN_CACHE_ENTRY.test(name))) { weightsRoot = root; break; }+ // eslint-disable-next-line no-await-in-loop -- short, ordered, first-match-wins+ if (await rootHoldsQwenWeights(root, entries)) { weightsRoot = root; break; }}return {@@ -148,7 +190,7 @@ export function vllmStartBlockedReason(project) {return `the project is cloned but no Qwen weights are cached yet. Run its prepare step in a terminal — starting compose now would pull roughly 20 GB, which PortOS will not do for you.`;}if (project.hasWeights === null) {- return `PortOS cannot see a HuggingFace cache for this project, so it cannot confirm the weights are already downloaded (a cache kept in a docker volume is invisible from here). Start it yourself with \`docker compose --profile single up -d\` in ${project.dir}, or set ${VLLM_WEIGHTS_DIR_ENV} to the cache directory once the weights are on disk.`;+ return `PortOS cannot read a models directory for this project, so it cannot confirm the weights are already downloaded. On Windows the project usually lives inside WSL2 — point ${VLLM_PROJECT_DIR_ENV} at its UNC path (\\\\wsl.localhost\\<distro>\\home\\<user>\\qwen-serving). Otherwise set ${VLLM_WEIGHTS_DIR_ENV} to the directory holding the weights, or start it yourself with \`docker compose --profile single up -d\` in ${project.dir}.`;}return null;}diff --git a/server/lib/vllmQwenProject.test.js b/server/lib/vllmQwenProject.test.jsindex 259824a52a..acbf20ad5d 100644--- a/server/lib/vllmQwenProject.test.js+++ b/server/lib/vllmQwenProject.test.js@@ -69,7 +69,7 @@ describe('inspectVllmQwenProject', () => {// `null`, not `false` — nothing was READ, which is a different fix than an// empty cache. The distinction is the point of the sentinel.expect(project.hasWeights).toBeNull();- expect(vllmStartBlockedReason(project)).toContain('cannot see a HuggingFace cache');+ expect(vllmStartBlockedReason(project)).toContain('cannot read a models directory');});it('distinguishes a readable-but-empty cache from an unreadable one', async () => {@@ -93,6 +93,42 @@ describe('inspectVllmQwenProject', () => {expect(vllmStartBlockedReason(project)).toBeNull();});+ it('clears the block for the local-dir layout upstream prepare actually writes', async () => {+ // `docker/prepare.sh` runs `hf download … --local-dir models/<model>`, so a+ // prepared machine has no `models--…` hub entry at all.+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ const model = join(projectDir(), 'models', 'Qwen3.8-27B-W4A16-AutoRound');+ mkdirSync(model, { recursive: true });+ writeFileSync(join(model, 'model.safetensors.index.json'), '{"weight_map":{}}\n');++ const project = await inspectVllmQwenProject(env());+ expect(project.hasWeights).toBe(true);+ expect(project.weightsRoot).toBe(join(projectDir(), 'models'));+ expect(vllmStartBlockedReason(project)).toBeNull();+ });++ it('accepts a single-file model directory (the DFlash2 drafter shape)', async () => {+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ const model = join(projectDir(), 'models', 'Qwen3.8-27B-DFlash2-W4A16');+ mkdirSync(model, { recursive: true });+ writeFileSync(join(model, 'model.safetensors'), 'tensors\n');++ expect((await inspectVllmQwenProject(env())).hasWeights).toBe(true);+ });++ it('does not count a qwen-named directory that holds no weight file', async () => {+ // Name matching alone would report a notes folder as a prepared model.+ mkdirSync(projectDir(), { recursive: true });+ writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');+ const notes = join(projectDir(), 'models', 'qwen-notes');+ mkdirSync(notes, { recursive: true });+ writeFileSync(join(notes, 'README.md'), 'not weights\n');++ expect((await inspectVllmQwenProject(env())).hasWeights).toBe(false);+ });+it('ignores a cache holding only unrelated models', async () => {mkdirSync(projectDir(), { recursive: true });writeFileSync(join(projectDir(), 'docker-compose.yml'), 'services: {}\n');