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

13.0 KB
Raw Blame

SGLang Qwen3.8-27B cookbook vs PortOS local-agent serving

Date: 2026-08-21

Read against the SGLang Qwen3.8-27B cookbook at the documented H200 / FP8 / single-node / no-speculation / low-latency / float32-SSM operating point (hw=h200&variant=default&quant=fp8&nodes=single&spec=none&tier=low-latency&ssmDtype=float32), then against how PortOS actually runs Qwen3.8-class models for CoS agents today.

Verdict

Do not replace the RTX 3090 vLLM stack, and do not add SGLang on Apple Silicon. The cookbook is a verified Hopper / Blackwell recipe for a dense hybrid GDN vision-language model that PortOS currently cannot serve. The improvement is a third CUDA path, complementary to qwen38-rtx3090 (Ampere 24 GB, frozen vLLM + DFlash 2) and to MTPLX / DSpark (Apple Silicon).

The linked cell is the right CoS default on a card that can hold it: no extra draft weights, low-latency radix strategy, official lmsysorg/sglang:qwen38-27b image, tool-call and reasoning parsers already on the launch line. Two cookbook facts change the harness choice vs vLLM:

  1. SGLang registers an Anthropic /v1/messages endpoint on every server — Claude Code talks to it with no LiteLLM. vLLM is OpenAI-only, which is why PortOS fronts the 3090 stack with OpenCode instead.
  2. Claude Code must set CLAUDE_CODE_ATTRIBUTION_HEADER=0 or the radix prefix cache is defeated every turn. That is the 24× TTFT collapse measured on the 3090 bring-up, lost.

--mamba-full-memory-ratio is the one sizing flag the cookbook says actually matters on hybrid GDN models. The default 0.9 over-provisions the KV pool and silently clamps concurrency. CoS agent prompts are long (the 3090 bring-up used a 17k-token prefix); the ratio has to be derived from that length, not left at the default.

Issues filed from this note:

  • #4776 — SGLang local runtime
  • #4777 — Claude-SGLang providers
  • #4778 — Qwen parser registry

They are claimable; this file is the point-in-time record, not a living guide.

What PortOS runs today

Host class Runtime How CoS talks to it Speculative path
Apple Silicon MTPLX (:8000) OpenCode wrappers native MTP
Apple Silicon llama-server (:5568) OpenCode wrappers DSpark (stock), DFlash 2 (unmerged llama.cpp)
Apple Silicon Ollama / LM Studio Claude Ollama (Anthropic Messages) none PortOS controls
RTX 3090 24 GB (Ampere) vLLM Docker (:18020) OpenCode wrappers DFlash 2, frozen in syv-ai/qwen38-27b-rtx3090

There is no SGLang runtime, no sglangBacked provider flag, and no Hopper / Blackwell recipe. server/lib/localModelTuning.js explicitly has no vLLM knobs because PortOS does not own that container's launch line. The same hole would apply to a new SGLang container unless the launch flags live in PortOS.

Related open work that this note does not duplicate:

  • #4765 — vLLM generation controls silently dropped (THINKING_STYLE has no vllm key).
  • #4766 — media jobs do not notice the vLLM container holding the GPU.
  • #4767 — guided clone / build / prepare for the 3090 vLLM stack.

A new SGLang path must include generation controls and GPU-exclusive refusals on day one, so those two bugs are not copied.

What the linked cookbook cell actually launches

H200, Qwen/Qwen3.8-27B-FP8, single GPU, no speculation, low-latency, fp32 SSM. Base flags from the verified cell, plus the default overlays:

sglang serve \
  --trust-remote-code \
  --model-path Qwen/Qwen3.8-27B-FP8 \
  --kv-cache-dtype fp8_e4m3 \
  --mem-fraction-static 0.85 \
  --attention-backend flashinfer \
  --chunked-prefill-size 32768 \
  --max-prefill-tokens 32768 \
  --reasoning-parser qwen3 \
  --tool-call-parser qwen3_coder \
  --mamba-radix-cache-strategy extra_buffer \
  --mamba-ssm-dtype float32 \
  --host 0.0.0.0 \
  --port 30000

--mamba-full-memory-ratio is then pinned from the calculator (see below), not left at 0.9.

Docker: docker pull lmsysorg/sglang:qwen38-27b. Unlike the 3090 vLLM image, this one exists on a registry — no local 9.5 GB build.

The cookbook's supported cards for this model are H200, RTX PRO 6000 (96 GB), RTX 5090 (32 GB), DGX Spark, and GB300. RTX 3090 is not a cell. Ampere 24 GB stays on the vLLM container.

Architecture that drives the flags

Qwen3.8-27B is a dense hybrid Gated DeltaNet vision-language model (64 layers: 48 GDN + 16 full-attention GQA), served through the Qwen3-VL path. The checkpoint ships an in-checkpoint MTP head. Native context is 262,144 tokens (extensible to 1,000,000). Serving-relevant layout matches Qwen3.6-27B, so a recipe table for this model is reusable for that sibling.

Thinking is on by default and disabled per request via enable_thinking / chat_template_kwargs. reasoning_effort and preserve_thinking exist. CoS coding should keep thinking off — same call as #4716 / the 3090 bring-up (enable_thinking: false is how tool-call format stays reliable).

Speculative overlays (do not make DFLASH2 the default)

Overlay Extra weights Fits official qwen38-27b tag? CoS default?
none (linked cell) no yes yes — zero extra download, verified
EAGLE / MTP (--speculative-algorithm EAGLE, 3/1/4) no (in-checkpoint head) yes optional later, when VRAM allows
DSPARK (RadixArk/Qwen3.8-27B-DSpark) yes yes no — extra sidecar, not needed for first ship
DFLASH2 (incoai/Qwen3.8-27B-DFlash2) yes no — needs SGLang 1cf2b8c (PR #35496) or newer no

This is the opposite of the 3090 path, where DFlash 2 is the frozen container's reason to exist. On SGLang, DFLASH2 is newer than the pinned image and unmeasured on H200. Do not copy SPEC=dflash2 across.

On H200, --attention-backend fa3 is a documented alternative to FlashInfer, measured slightly faster at bs=1. Leave FlashInfer as the default (the verified cell); fa3 is a tuning knob, not a recipe change.

--mamba-full-memory-ratio

Hybrid GDN models split post-weight memory into a reserved GDN state pool (the concurrency ceiling) and a paged attention KV pool. The cookbook formula:

ratio = (S + D) × state_bytes / (L × kv_bytes_per_token)
  • S — state slots per running request: extra_buffer = 5 (low-latency), extra_buffer_lazy = 4 (high-throughput), radix off = 1.
  • D — speculative verify intermediates (0 with spec off; 4 for MTP 3/1/4; 8 for DFLASH2 / DSPARK's default block).
  • state_bytes — 153.9 MB at fp32, 78.4 MB at bf16 (this model's geometry).
  • kv_bytes_per_token — 32.8 KB at fp8 KV, 65.5 KB at bf16.
  • L — average total request length (input + output).

--max-mamba-cache-size = target_concurrency × S is the equivalent explicit pin. After boot, the server log's max_running_requests line must not be capped below the intended concurrency.

CoS decision: size for concurrency 1–2 and L ≈ 16k–25k (the 3090 bring-up's 17k-token agent prefix is the measured data point), low-latency extra_buffer, spec off so D = 0. High-throughput extra_buffer_lazy is the wrong default for a TUI tool-loop: TTFT on a warm prefix is the number that matters, and the 3090 measurements already showed a 24× collapse when prefix cache actually hits.

Do not disable radix cache on the agent recipe.

Tool / reasoning parsers — runtime-specific, silent if wrong

The 3090 vLLM stack needs --tool-call-parser qwen3_xml. SGLang's verified cells all ship --tool-call-parser qwen3_coder and --reasoning-parser qwen3. The failure mode is identical across engines: the server starts, answers, and returns raw markup with no structured tool_calls / tool_use blocks, so the agent never edits a file. SGLang's own Anthropic tutorial says the same thing in so many words.

This mapping must live in one table PortOS owns, not in three feature docs. vLLM's EXTRA_ARGS is currently only a documented .env line; #4767 will write it during guided install. SGLang must bake both parsers into the launch line so they cannot be omitted.

Anthropic API and Claude Code

SGLang Anthropic-compatible API:

  • /v1/messages is on by default. No extra serve flag.
  • Anthropic SDK base_url is the server root (no /v1 suffix). OpenAI clients keep /v1.
  • Tool-call parser required for structured tool_use blocks.
  • CLAUDE_CODE_ATTRIBUTION_HEADER=0 is required. Claude Code otherwise prepends a per-request hash to the system prompt, which is the first token to differ between turns, so the radix cache re-prefills the whole history every turn. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC does not remove that header.
  • Claude Code needs a non-empty ANTHROPIC_AUTH_TOKEN; SGLang accepts any value unless --api-key is set.

This is why a Claude-SGLang provider pair is worth seeding (mirroring Claude Ollama), and why it is a separate issue from the OpenCode wrappers: the env-var contract is load-bearing and easy to miss.

PortOS loopback convention: bind 127.0.0.1, not the cookbook's 0.0.0.0. Suggested port: 18021 (adjacent to vLLM's 18020, outside 5553–5569). Document in docs/PORTS.md when the runtime ships.

Hardware gate

getCudaCapability() / getCudaComputeCaps() already exist (server/lib/cudaCapability.js). Use them:

Detected card Path
Ampere 24 GB (RTX 3090) existing vLLM container — not SGLang
SM90 Hopper (H200 / H100) SGLang H200 cell (32k prefill chunks, FlashInfer, FP8 or BF16)
Blackwell 32 GB (RTX 5090) SGLang 5090 cell: NVFP4, --max-running-requests 1, GDN state pool is the limit
Blackwell 96 GB (RTX PRO 6000) SGLang rtx6000 cell
darwin MTPLX / DSpark — refuse SGLang the way vLLM already refuses
probe unknown do not claim "no GPU"; say the probe failed

H200 has no FP4 tensor cores; the NVFP4 cell is correctly greyed out there. Do not offer NVFP4 on SM90.

What we are not doing

  • Vendoring SGLang or an engine patch. Same bar as the DFlash 2 note: point at the official image and a launch line. DFLASH2 stays off the default until lmsysorg/sglang:qwen38-27b includes PR #35496.
  • SGLang on Apple Silicon. The Metal backend exists upstream; the cookbook cells are NVIDIA. Adding a fourth local backend on Mac was already declined for mlx-dspark.
  • Replacing vLLM on the 3090. That stack is measured and the CoS tool-loop works. SGLang has no 3090 cell.
  • Auto-starting on boot. Same exclusive-GPU rule as vLLM. The container holds the card; local image/video cannot share it.
  • Vision-agent / Qwen3-VL request bodies through the coding harness. The model is a VLM, but CoS file-editing does not send images today. Out of scope until serving + tool-calling work.
  • PD disaggregation, HiCache, HiSparse, multi-node. Cookbook playground knobs for datacenter serving, not a single-user CoS box.

What to ship

Three claimable issues, decisions already made in the bodies:

  1. #4776 SGLang Qwen3.8-27B local runtime — official Docker image, verified H200-FP8-low-latency-no-spec launch line, OpenCode CLI/TUI presets, sglangBacked, hardware gate, --mamba-full-memory-ratio derived for CoS L, parsers baked in, never auto-start, generation controls from day one.
  2. #4777 Claude-SGLang provider pair — Anthropic /v1/messages + CLAUDE_CODE_ATTRIBUTION_HEADER=0. Blocked on #4776.
  3. #4778 Qwen-family tool/reasoning parser registry — one table so vLLM (qwen3_xml), SGLang (qwen3_coder), and a future llama.cpp path cannot silently ship the wrong parser.

Sources