Skip to content

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

feat: pin llama-server to one slot and add a Q2_K DFlash 2 drafter

Adam Eivy4d30bc42ed26
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index 268e4c1c11..96aa75d94b 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -55,7 +55,7 @@ const specWeightEntries = (preset) => [preset?.model, preset?.draftModel].filter
// Keep the launcher default aligned with server/lib/ports.js. 8080 is a common
// IPFS / Tomcat / local-dashboard port and is not a safe default for a managed
// daemon.
-const LLAMA_NUMBER_DEFAULTS = { port: 5568, ctxSize: 32768, nGpuLayers: 99 };
+const LLAMA_NUMBER_DEFAULTS = { port: 5568, ctxSize: 32768, nGpuLayers: 99, parallel: 1 };
// Optional llama.cpp tuning flags — unlike the fields above these have NO
// PortOS default: an untouched one is stripped from the launch payload so
// llama.cpp applies its own. Mirrors `server/lib/localModelTuning.js`.
@@ -372,6 +372,9 @@ export function LocalLlmTab() {
ctxSize: 32768,
nGpuLayers: 99,
alias: 'dflash',
+ // Always sent — llama-server's own default is often 4 slots, which divides
+ // the context window and spends VRAM a TUI agent never uses.
+ parallel: 1,
// Performance tuning (`server/lib/localModelTuning.js`). Empty = NOT SET:
// the flag is left off the launch line entirely so llama.cpp applies its own
// default. A number here would silently pin a value the user never chose and
@@ -1311,6 +1314,22 @@ export function LocalLlmTab() {
className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
/>
</div>
+ <div className="col-span-2">
+ <label htmlFor="llama-parallel" className="text-[11px] text-gray-400 block mb-1">Parallel slots</label>
+ <input
+ id="llama-parallel"
+ aria-label="Parallel slots"
+ type="number"
+ min={1}
+ max={16}
+ value={llamaForm.parallel}
+ onChange={(e) => setLlamaNumber('parallel', e.target.value)}
+ className="w-full bg-port-card border border-port-border rounded px-2 py-1 text-xs text-white"
+ />
+ <p className="text-[11px] text-gray-500 mt-1">
+ llama.cpp divides context across this many request slots. 1 is right for a TUI agent.
+ </p>
+ </div>
<div className="col-span-2 sm:col-span-4">
<label htmlFor="llama-spec-type" className="text-[11px] text-gray-400 block mb-1">Spec Type</label>
<input
@@ -1440,7 +1459,7 @@ export function LocalLlmTab() {
className="text-[11px] text-gray-500 hover:text-gray-300 flex items-center gap-1"
>
{showLlamaAdvanced ? <ChevronUp size={12} /> : <ChevronDown size={12} />}
- {showLlamaAdvanced ? 'Hide options' : 'Advanced options (port, ctx, GPU layers, model id, spec type, performance tuning)'}
+ {showLlamaAdvanced ? 'Hide options' : 'Advanced options (port, ctx, GPU layers, parallel slots, model id, spec type, performance tuning)'}
</button>
<div className="flex items-center gap-2">
{llamaStartBlocked && (
diff --git a/client/src/components/settings/LocalLlmTab.test.jsx b/client/src/components/settings/LocalLlmTab.test.jsx
index 14973bfd54..6a42760a15 100644
--- a/client/src/components/settings/LocalLlmTab.test.jsx
+++ b/client/src/components/settings/LocalLlmTab.test.jsx
@@ -493,6 +493,23 @@ describe('LocalLlmTab llama-server management', () => {
});
});
+ it('sends --parallel 1 by default and honours an edited slot count', async () => {
+ const { getLlamaServerStatus, startLlamaServer } = await import('../../services/api');
+ getLlamaServerStatus.mockResolvedValue(llamaReady());
+ startLlamaServer.mockResolvedValueOnce({ success: true, pid: 99 });
+
+ await renderTab();
+ await screen.findByText(/Launch Speculative Decoding Server/);
+ await waitFor(() => expect(screen.queryByText(/Enter a Target Base Model path to enable Start/)).toBeNull());
+
+ fireEvent.click(screen.getByRole('button', { name: /Advanced options/ }));
+ fireEvent.change(screen.getByLabelText('Parallel slots'), { target: { value: '2' } });
+ fireEvent.click(screen.getByRole('button', { name: /Start Speculative Server/ }));
+
+ await waitFor(() => expect(startLlamaServer).toHaveBeenCalled());
+ expect(startLlamaServer.mock.calls[0][0].parallel).toBe(2);
+ });
+
// An untouched tuning field means "llama.cpp's default", which is not a value
// PortOS can name. Sending `''` (which the server coerces to 0) or a made-up
// number would pin a setting the user never chose and make two "default"
@@ -544,6 +561,7 @@ describe('LocalLlmTab llama-server management', () => {
model: 'models/Qwen3.8-27B-Instruct-Q4_K_M.gguf',
draftModel: 'models/Qwen3.8-27B-DSpark-bf16.gguf',
specType: 'draft-dspark',
+ parallel: 1,
}));
});
});
diff --git a/docs/features/dflash2.md b/docs/features/dflash2.md
index bb6d480717..7c9f64ddc4 100644
--- a/docs/features/dflash2.md
+++ b/docs/features/dflash2.md
@@ -60,7 +60,10 @@ the target can be any quant.
DFlash 2 pairs (require a source build of llama.cpp [#27342](https://github.com/ggml-org/llama.cpp/pull/27342)):
-- **Qwen 3.8 27B Draft Pair**:
+- **Qwen 3.8 27B Draft Pair (Q2_K — preferred for TUI agents)**:
+ - Base: `ggml-org/Qwen3.8-27B-GGUF` (e.g. `Qwen3.8-27B-Q4_K_M.gguf`)
+ - Drafter: `analogalok/Qwen3.8-27B-DFlash2-Q2_K-GGUF` (`Qwen3.8-27B-DFlash2-Q2_K.gguf`, ~700 MB). Measured identical ~93.7% draft acceptance vs the official Q4_K_M drafter at ~1.1 GB — the ~450 MB saved goes to KV cache. Works with any Qwen3.8-27B target quant, including Unsloth UD-Q4_K_XL.
+- **Qwen 3.8 27B Draft Pair (official Q4_K_M)**:
- Base: `ggml-org/Qwen3.8-27B-GGUF` (e.g. `Qwen3.8-27B-Q4_K_M.gguf`)
- Drafter: `incoai/Qwen3.8-27B-DFlash2-GGUF` (e.g. `Qwen3.8-27B-DFlash2-Q4_K_M.gguf`)
- **Muse-Glimmer 30B Draft Pair**:
@@ -82,10 +85,47 @@ llama-server \
--host 127.0.0.1 \
--alias dflash \
--ctx-size 32768 \
- --n-gpu-layers 99
+ --n-gpu-layers 99 \
+ --parallel 1
```
-### 2b. Drafter-free speculation (n-gram spec types)
+`--parallel 1` is a PortOS pin, not llama.cpp's default. `llama-server` often
+starts with 4 request slots and **divides `--ctx-size` across them**, so a 32k
+window becomes 8k per in-flight request and the unused slots sit on VRAM a
+single TUI agent never uses. PortOS's launcher always passes `--parallel 1`
+unless you raise it under Advanced options. Raise it only if you actually run
+several concurrent requests against the same server — each extra slot shrinks
+the context the OpenCode llama TUI agent sees.
+
+### 2b. 24 GB card, max TUI-agent context (DFlash 2)
+
+On a single 24 GB GPU (RTX 4090 / 3090) the Q2_K DFlash 2 drafter plus
+`--parallel 1` is what unlocks a quarter-million-token window. Measured on
+Qwen3.8-27B UD-Q4_K_XL with llama.cpp PR #27342 at `--spec-draft-n-max 3`
+(the engine default):
+
+| KV cache | Context | Decode | Notes |
+| --- | --- | --- | --- |
+| Q4_0 (`--cache-type-k/v q4_0`) | 250,000 | ~74 t/s | deepest "repo swallower" |
+| Q8_0 | 150,000 | ~75 t/s | higher-precision SWE |
+| FP16 (engine default) | 90,000 | ~81 t/s | unquantized attention |
+
+```bash
+llama-server \
+ -m models/Qwen3.8-27B-Q4_K_M.gguf \
+ --model-draft models/Qwen3.8-27B-DFlash2-Q2_K.gguf \
+ --spec-type draft-dflash \
+ --port 5568 --host 127.0.0.1 --alias dflash \
+ --ctx-size 250000 -ngl 99 --parallel 1 \
+ --cache-type-k q4_0 --cache-type-v q4_0
+```
+
+Do **not** ship 250k as PortOS's default `--ctx-size` — that OOMs every
+machine that is not a 24 GB NVIDIA card. Set Context Size and KV cache type
+under Advanced options on the machine that has the VRAM. The Q2_K preset and
+`--parallel 1` are the parts that apply everywhere.
+
+### 2c. Drafter-free speculation (n-gram spec types)
`--spec-type` is a **comma-separated list**, and only its `draft-*` entries need a
drafter GGUF. The `ngram-*` implementations draft by pattern-matching the tokens
@@ -107,7 +147,7 @@ llama-server \
-m models/Qwen3.8-27B-Q4_K_M.gguf \
--model-draft models/Qwen3.8-27B-DSpark-BF16.gguf \
--spec-type draft-dspark,ngram-map-k \
- --port 5568 --host 127.0.0.1 --alias dflash
+ --port 5568 --host 127.0.0.1 --alias dflash --parallel 1
```
In PortOS, set this in **Settings → Local LLMs → Speculative Decoding →
diff --git a/server/lib/README.md b/server/lib/README.md
index b989d9ee86..3ad51d12ef 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -315,7 +315,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `ollamaContext.js` | Ollama runtime context-window reasoning. `resolveOllamaContextLength(provider, env)` → the window PortOS should hold the daemon at (`provider.numCtx`, then `OLLAMA_CONTEXT_LENGTH`, then `null` = leave Ollama's VRAM-based auto-pick alone); `withOllamaContextEnv(env, n)` builds the `ollama serve` child env; `parseOllamaContextOverflow(text)` recognizes the `exceed_context_size_error` rejection and pulls `{ promptTokens, contextLength }` out of either the JSON body or the human message; `describeOllamaContextOverflow` / `describeOllamaContextTooSmall` render the actionable one-liners; `isSameOllamaDaemon(providerBase, managedBase)` compares host+port so a provider pointed at a *remote* Ollama never triggers a local-daemon reload; `OLLAMA_AGENT_MIN_CONTEXT` is the window below which an agent harness is warned. Pure — the daemon side lives in `services/ollamaManager.js` (`ensureContextWindow`), the pre-spawn enforcement in `services/ollamaAgentContext.js`. |
| `localModelHeuristics.js` | Capability heuristics for untyped local (Ollama/LM Studio) models. `isEmbeddingModel`/`isGenerationModel` (so a generation/fallback run never picks an embedding model like `nomic-embed-text`); `isVisionModel(model)` (string id or model card — prefers explicit `type:'vlm'`/`capabilities:['vision']` metadata, falls back to id regex; used by the LoRA captioner); `recommendEditorialModel(models, { measured })` ranks installed models for editorial review/editing, dropping any a fresh measurement proved cannot run here. Pure. Mirror `isEmbeddingModel`/`isVisionModel` in `client/src/utils/providers.js`. |
| `localModelAssessment.js` | Scoring for MEASURED local-model assessments (recorded by `services/localModelAssessments.js`): `classifyFitVerdict` (`fits`/`does-not-fit`/`incompatible`/`unknown`), `summarizePerformance` (mean/peak chars-per-second AND tokens-per-second, prefill rate, TTFT, max working context, cross-context degradation), `scoreAssessment` + `scoreForIntent` + `rankByIntent` for the balanced/smartest/fastest/lightweight pickers, `explainAssessment`, `compareEnvironments`/`describeStaleness` (is a stored reading still valid for THIS machine?), `buildThroughputReport` (every measurement as one tokens/s table, fastest first, per-context readings intact), `selectSweepTargets`/`summarizeSweepScopes`/`SWEEP_SCOPES` (which measurements a "measure everything" run covers, and how many), and `measuredFitVerdict`/`reconcileFit` (fold a measurement into the catalog's size-estimate fit badge, keeping the disagreement). Pure. `null` strictly means NOT MEASURED — never 0, never "failed". |
-| `localModelTuning.js` | Launch/runtime tuning knobs for the measurable local runtimes — ONLY knobs PortOS can actually apply. A knob is defined by its transport, and `applies` + the user-facing `note` are DERIVED from it: `config` (llama.cpp's `-b`/`-ub`/`-t`/`--flash-attn`/`--cache-type-k\|v`/`--draft-max`, via `launchConfig`), `env` (Ollama's `OLLAMA_CONTEXT_LENGTH`/`_FLASH_ATTENTION`/`_KV_CACHE_TYPE`/`_NUM_PARALLEL`, via `launchEnv`), `cli` (LM Studio's `lms load --context-length`/`--gpu`/`--parallel`, via `launchArgs`), or `wire` (a request-body field, via `requestBody` — currently no members). MTPLX/vLLM declare none: PortOS has no launch path into them. Also `normalizeTuning` (coerce + clamp + drop unknown keys), `tuningSignature` (stable identity — `''` for backend defaults, so pre-tuning store keys keep resolving), `describeTuning`, `launchTuning`, and `compareTunings` (which tuning won per model, labelled from each record's persisted `tuningLabel`, with a `deltaPercent` against the winner). Pure. |
+| `localModelTuning.js` | Launch/runtime tuning knobs for the measurable local runtimes — ONLY knobs PortOS can actually apply. A knob is defined by its transport, and `applies` + the user-facing `note` are DERIVED from it: `config` (llama.cpp's `-b`/`-ub`/`-t`/`--parallel`/`--flash-attn`/`--cache-type-k\|v`/`--draft-max`, via `launchConfig`), `env` (Ollama's `OLLAMA_CONTEXT_LENGTH`/`_FLASH_ATTENTION`/`_KV_CACHE_TYPE`/`_NUM_PARALLEL`, via `launchEnv`), `cli` (LM Studio's `lms load --context-length`/`--gpu`/`--parallel`, via `launchArgs`), or `wire` (a request-body field, via `requestBody` — currently no members). MTPLX/vLLM declare none: PortOS has no launch path into them. Also `normalizeTuning` (coerce + clamp + drop unknown keys), `tuningSignature` (stable identity — `''` for backend defaults, so pre-tuning store keys keep resolving), `describeTuning`, `launchTuning`, and `compareTunings` (which tuning won per model, labelled from each record's persisted `tuningLabel`, with a `deltaPercent` against the winner). Pure. |
| `loraDataset.js` | Pure helpers for character LoRA training datasets (`data/lora-datasets/`): `sanitizeLoraDataset` (collectionStore sanitizer), `deriveTriggerWord` (name → single-token slug with collision suffix), `prefixCaption` (idempotent trigger-word prefixing), `buildVariationMatrix` (deterministic view/pose/expression/outfit tuples for batch generation), `computeDatasetReadiness` (trainable gate: ≥`MIN_TRAINING_IMAGES` ready+captioned images, plus an advisory `recommended`/`quality` tier via `datasetQualityTier` nudging toward `RECOMMENDED_TRAINING_IMAGES`), `analyzeCaptionInvariants` (flags identity fragments repeated across ≥`INVARIANT_SHARE_THRESHOLD` of captions — those bind to the caption phrases instead of the trigger token, issue #1320) + `stripSharedFragments` (rewrite one caption with those fragments removed, trigger preserved). Prompt building + I/O live in `services/loraDatasetGenerate.js` / `services/loraDatasets.js`. |
| `loraTriggers.js` | Pure trigger-word weaving for renders that load a LoRA (#4665): `weaveLoraTriggers(prompt, triggerWordLists)` → `{ prompt, added }` appends each selected LoRA's FIRST activation token to the prompt when it is not already there, in selection order, as a trailing comma clause so the user's own phrasing keeps its position and weight. `promptHasTriggerWord` is the whole-token, case-insensitive presence test (`aria_tok` does not match inside `aria_token`); `firstTriggerWord` picks the canonical token out of a Civitai `trainedWords` list. Idempotent, so a re-render of an already-woven prompt is a no-op. Consumed by `services/imageGen/local.js` and `services/videoGen/local.js` (paired with `services/loras.js#readTriggerWordsByFilename` for the sidecar reads). The comic pipeline shares it rather than opting out — its own "<Name> (<trigger>)" clause uses the same token, so the weave adds nothing there except for the characters that clause drops. |
| `issueLength.js` | Per-issue size targets fed into text stages. |
diff --git a/server/lib/localModelTuning.js b/server/lib/localModelTuning.js
index f0b188519a..78810febf4 100644
--- a/server/lib/localModelTuning.js
+++ b/server/lib/localModelTuning.js
@@ -104,6 +104,7 @@ const RAW_SPECS = {
llama: [
{ id: 'ctxSize', label: 'Context size', type: 'number', config: true, min: 512, max: 1048576, unit: 'tokens', hint: 'KV cache is allocated for the whole window up front — a larger one costs memory even when prompts are short.' },
{ id: 'nGpuLayers', label: 'GPU layers', type: 'number', config: true, min: 0, max: 999, hint: 'Layers offloaded to the GPU. Fewer layers frees VRAM for a bigger context at the cost of throughput.' },
+ { id: 'parallel', label: 'Parallel slots', type: 'number', config: true, min: 1, max: 16, hint: 'Request slots llama-server reserves VRAM for. It divides the context window across them — 1 is right for a TUI agent (one long session). Raising it shrinks per-request context.' },
{ id: 'batchSize', label: 'Batch size', type: 'number', config: true, min: 1, max: 8192, hint: 'Logical prompt batch (-b). Raising it speeds up prefill on long prompts and raises peak memory.' },
{ id: 'ubatchSize', label: 'Micro-batch size', type: 'number', config: true, min: 1, max: 8192, hint: 'Physical micro-batch (-ub). The single knob that most often moves long-context throughput.' },
{ id: 'threads', label: 'CPU threads', type: 'number', config: true, min: 1, max: 256, hint: 'Threads for the CPU-resident layers. More is not always faster once you pass the physical core count.' },
diff --git a/server/lib/localModelTuning.test.js b/server/lib/localModelTuning.test.js
index 53656051f8..58ff49a830 100644
--- a/server/lib/localModelTuning.test.js
+++ b/server/lib/localModelTuning.test.js
@@ -156,6 +156,12 @@ describe('launchTuning / launchConfig / launchEnv / launchArgs / requestBody', (
.toEqual({ ubatchSize: 512, cacheTypeK: 'q8_0' });
});
+ it('carries llama.cpp --parallel so a TUI-agent slot count can be measured', () => {
+ expect(launchConfig('llama', { parallel: 1 })).toEqual({ parallel: 1 });
+ expect(normalizeTuning('llama', { parallel: 0 })).toEqual({ parallel: 1 });
+ expect(normalizeTuning('llama', { parallel: 99 })).toEqual({ parallel: 16 });
+ });
+
// A key no spec declares must never reach a launch line, whichever renderer
// it is handed to.
it('drops an undeclared key from every launch renderer', () => {
diff --git a/server/lib/mediaValidation.js b/server/lib/mediaValidation.js
index 5a09dbcea1..845f20c714 100644
--- a/server/lib/mediaValidation.js
+++ b/server/lib/mediaValidation.js
@@ -196,6 +196,10 @@ export const localLlmLlamaServerStartSchema = z.object({
ctxSize: z.coerce.number().int().min(512).max(1048576).optional().default(32768),
nGpuLayers: z.coerce.number().int().min(0).max(999).optional().default(99),
alias: z.string().trim().max(100).optional().default('dflash'),
+ // PortOS-opinionated, unlike the tuning flags below: llama-server's own
+ // default is often 4 slots, which divides `--ctx-size` and spends VRAM on
+ // unused batch buffers. A TUI agent is one long session, so 1 is the pin.
+ parallel: z.coerce.number().int().min(1).max(16).optional().default(1),
// Tuning flags. Every one defaults to null = NOT SET, so the flag is left off
// the launch line and llama.cpp applies its own default — a numeric default
// here would silently pin a value the user never chose. Ranges mirror
diff --git a/server/lib/specDecodePresets.js b/server/lib/specDecodePresets.js
index 9b6e4c3e2b..c2a12ddf70 100644
--- a/server/lib/specDecodePresets.js
+++ b/server/lib/specDecodePresets.js
@@ -55,9 +55,30 @@ export const SPEC_DECODE_PRESETS = Object.freeze([
path: 'models/dspark_qwen3_8b_block7-bf16.gguf',
},
},
+ {
+ // analogalok's Q2_K DFlash 2 drafter (~700 MB) matches official Q4_K_M
+ // acceptance (~93.7%) and returns ~450 MB of VRAM to the KV cache — the
+ // difference between a 170k and a 250k window on a 24 GB card once
+ // llama-server is also pinned to `--parallel 1`. Pairs with any Qwen3.8-27B
+ // target quant, including Unsloth UD-Q4_K_XL.
+ // https://huggingface.co/analogalok/Qwen3.8-27B-DFlash2-Q2_K-GGUF
+ id: 'qwen3.8-27b-dflash2-q2k',
+ label: 'Qwen 3.8 27B + DFlash 2 Q2_K Drafter (max context — needs llama.cpp PR #27342)',
+ specType: 'draft-dflash',
+ model: {
+ path: 'models/Qwen3.8-27B-Q4_K_M.gguf',
+ repo: 'ggml-org/Qwen3.8-27B-GGUF',
+ quant: 'Q4_K_M',
+ },
+ draftModel: {
+ path: 'models/Qwen3.8-27B-DFlash2-Q2_K.gguf',
+ repo: 'analogalok/Qwen3.8-27B-DFlash2-Q2_K-GGUF',
+ quant: 'Q2_K',
+ },
+ },
{
id: 'qwen3.8-27b',
- label: 'Qwen 3.8 27B + DFlash 2 Drafter (needs llama.cpp PR #27342 build)',
+ label: 'Qwen 3.8 27B + DFlash 2 Q4_K_M Drafter (needs llama.cpp PR #27342 build)',
specType: 'draft-dflash',
model: {
path: 'models/Qwen3.8-27B-Q4_K_M.gguf',
diff --git a/server/services/llamaServerManager.js b/server/services/llamaServerManager.js
index 67b38d4ff3..eff4b4a93a 100644
--- a/server/services/llamaServerManager.js
+++ b/server/services/llamaServerManager.js
@@ -91,6 +91,11 @@ function parseConfigFromArgs(args) {
const ctxSize = getArg('--ctx-size') ? Number(getArg('--ctx-size')) : 32768;
const nGpuLayers = getArg('-ngl') !== null ? Number(getArg('-ngl')) : 99;
const alias = getArg('--alias') || 'dflash';
+ // Absent is not 1: an older launch line with no `--parallel` is running
+ // llama.cpp's own default (often 4 slots), which is distinct from a value
+ // PortOS chose. A relaunch still pins 1 — see startLlamaServer.
+ const parallelRaw = getArg('--parallel') ?? getArg('-np');
+ const parallel = parallelRaw !== null ? Number(parallelRaw) : null;
return {
model,
@@ -101,6 +106,7 @@ function parseConfigFromArgs(args) {
ctxSize,
nGpuLayers,
alias,
+ parallel,
// Tuning flags. `null` means the flag was NOT on the launch line, so
// llama.cpp's own default applied — distinct from a value we chose. A
// caller re-launching with this config must leave a null off the line
@@ -212,6 +218,7 @@ export async function startLlamaServer(options = {}) {
ctxSize = 32768,
nGpuLayers = 99,
alias = 'dflash',
+ parallel = 1,
// Tuning knobs (`lib/localModelTuning.js`). Every one defaults to `null` =
// NOT SET: the flag is left off the launch line entirely so llama.cpp
// applies its own default. Substituting a number here would silently pin a
@@ -282,6 +289,11 @@ export async function startLlamaServer(options = {}) {
if (host) args.push('--host', host);
if (ctxSize) args.push('--ctx-size', String(ctxSize));
if (nGpuLayers !== undefined && nGpuLayers !== null) args.push('-ngl', String(nGpuLayers));
+ // Always on the line — leaving it off reverts to llama.cpp's multi-slot
+ // default, which is the VRAM tax this pin exists to avoid. `null` from a
+ // recovered pre-flag launch still means 1, not "daemon default".
+ const parallelSlots = Number.isFinite(parallel) && parallel >= 1 ? parallel : 1;
+ args.push('--parallel', String(parallelSlots));
if (Number.isFinite(batchSize)) args.push('-b', String(batchSize));
if (Number.isFinite(ubatchSize)) args.push('-ub', String(ubatchSize));
if (Number.isFinite(threads)) args.push('-t', String(threads));
@@ -318,6 +330,7 @@ export async function startLlamaServer(options = {}) {
ctxSize,
nGpuLayers,
alias,
+ parallel: parallelSlots,
batchSize,
ubatchSize,
threads,
diff --git a/server/services/llamaServerManager.test.js b/server/services/llamaServerManager.test.js
index f55c99f821..0a4caf3d7a 100644
--- a/server/services/llamaServerManager.test.js
+++ b/server/services/llamaServerManager.test.js
@@ -176,6 +176,7 @@ describe('llamaServerManager', () => {
'--host', '127.0.0.1',
'--ctx-size', '32768',
'-ngl', '99',
+ '--parallel', '1',
'--alias', 'dflash',
]);
@@ -183,6 +184,7 @@ describe('llamaServerManager', () => {
expect(status.running).toBe(true);
expect(status.managed).toBe(true);
expect(status.pid).toBe(12345);
+ expect(status.config.parallel).toBe(1);
});
it('starts an ngram spec type with no drafter model at all', async () => {
@@ -254,6 +256,16 @@ describe('llamaServerManager', () => {
expect(startCall).not.toContain('--spec-type');
});
+ it('honours an explicit parallel slot count', async () => {
+ vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue('/usr/local/bin/llama-server');
+
+ await startLlamaServer({ model: modelPath, parallel: 4 });
+
+ const startCall = execPm2Calls.find((c) => c[0] === 'start');
+ expect(startCall.slice(startCall.indexOf('--parallel'), startCall.indexOf('--parallel') + 2))
+ .toEqual(['--parallel', '4']);
+ });
+
it('uses PortOS\'s extension port when no port is supplied', async () => {
vi.spyOn(processEnv, 'findCommandOnPath').mockReturnValue('/usr/local/bin/llama-server');
@@ -321,7 +333,7 @@ describe('llamaServerManager', () => {
name: LLAMA_APP,
status: 'online',
pid: 98765,
- args: ['-m', modelPath, '--model-draft', draftPath, '--port', '8090', '--host', '127.0.0.1'],
+ args: ['-m', modelPath, '--model-draft', draftPath, '--port', '8090', '--host', '127.0.0.1', '--parallel', '4'],
};
const status = await getLlamaServerStatus();
@@ -331,6 +343,7 @@ describe('llamaServerManager', () => {
expect(status.endpoint).toBe('http://127.0.0.1:8090/v1');
expect(status.config?.model).toBe(modelPath);
expect(status.config?.draftModel).toBe(draftPath);
+ expect(status.config?.parallel).toBe(4);
});
it('surfaces unknown/degraded state when PM2 read fails', async () => {
diff --git a/server/services/specDecodeModels.test.js b/server/services/specDecodeModels.test.js
index 9423807942..23fe12f4b5 100644
--- a/server/services/specDecodeModels.test.js
+++ b/server/services/specDecodeModels.test.js
@@ -112,6 +112,11 @@ describe('getSpecDecodePresetStatus', () => {
expect(recommended.model.exists).toBe(false);
expect(recommended.model.downloadable).toBe(true);
expect(recommended.model.repoUrl).toContain('huggingface.co');
+ const q2k = presets.find((p) => p.id === 'qwen3.8-27b-dflash2-q2k');
+ expect(q2k.specType).toBe('draft-dflash');
+ expect(q2k.draftModel.path).toMatch(/DFlash2-Q2_K\.gguf$/);
+ expect(q2k.draftModel.repo).toBe('analogalok/Qwen3.8-27B-DFlash2-Q2_K-GGUF');
+ expect(q2k.draftModel.downloadable).toBe(true);
// `custom` carries no paths, so it has no weights rows to render.
expect(presets.find((p) => p.id === 'custom').model).toBeNull();
expect(fetchSpy).not.toHaveBeenCalled();