Skip to content

Dual-model serving: 1.7B default + 0.6B, backward-compatible - #3

Merged
marzoukbaig14 merged 1 commit into
mainfrom
serving/dual-model
Jul 1, 2026
Merged

Dual-model serving: 1.7B default + 0.6B, backward-compatible#3
marzoukbaig14 merged 1 commit into
mainfrom
serving/dual-model

Conversation

@marzoukbaig14

Copy link
Copy Markdown
Owner

What

Extends the serving layer to serve both fine-tunes (1.7B + 0.6B) from one process, selectable per request, without changing the existing default path.

  • src/committed/serving/api.py — model registry (1.7bcommitted-gguf, 0.6bcommitted-gguf-0.6b) as the source of truth. POST /generate gains an optional model field defaulting to "1.7b", so a request with no model is byte-for-byte the v1 behavior (backward compatibility is a hard requirement — the live portfolio sends no model). Unknown model → 400, not a crash. /health extended with models_loaded/models_available, keeping the existing model_loaded field the portfolio reads.
  • Load strategy: default (1.7B) loads eagerly at startup (v1 cold-start behavior preserved); 0.6B loads lazily on first request and is cached — cold start never pays for both.
  • Thread fix carried: every generator instance is built with n_threads=2, n_threads_batch=2 (the v1 CPU-Space fix). The default is constructed via the engine resolver, so the COMMITTED_MODEL_* Space Variables still override it.
  • app/app.py (Gradio) — model dropdown wired to the same shared registry/factory; default eager warm-up, 0.6B lazy; thread fix + NotADiffError guard carried.

Verification (local, no model download)

TestClient + a fake generator exercised every path:

  • no-model → 200 served by 1.7b (backward-compat) ✅
  • model: "0.6b" → 200, and /health models_loaded grew ['1.7b']['1.7b','0.6b'] (lazy load) ✅
  • unknown model → 400 ✅ · empty diff → 400

Deploy notes (Phase 2 — after merge)

The Spaces install committed from @main in a cached layer, so merge alone does nothing — each Space must be factory-rebuilt to pull new code. Two prerequisites before the 0.6B path works live:

  • The committed-gguf-0.6b repo is currently PRIVATE — must be made public (or a token added to the Space) or the runtime pull 401s.
  • Pin caveat: llama-cpp-python==0.3.30 — couldn't verify the CPU wheel exists at the abetlen index from CI (network-restricted); if it's missing the first rebuild falls back to a (slower, cached-after) source compile. Pin intentionally not loosened.

Does not touch the portfolio front-end or any eval/training/grammar/prompt code.

🤖 Generated with Claude Code


Generated by Claude Code

Extend the serving layer to serve both fine-tunes from one process, selectable
per request, without changing the default path.

- api.py: model registry (1.7b -> committed-gguf, 0.6b -> committed-gguf-0.6b)
  as the source of truth; optional `model` field on /generate (defaults to
  "1.7b" so a no-model request is byte-for-byte v1 behavior); unknown model ->
  400, not a crash; /health extended with models_loaded/models_available while
  keeping the model_loaded field the portfolio reads. Default loads eagerly at
  startup; 0.6b loads lazily on first request and is cached. Every instance gets
  n_threads=2/n_threads_batch=2 (the v1 CPU-Space thread fix). The default is
  built via the engine resolver so the COMMITTED_MODEL_* Space Variables still
  override it.
- app.py (Gradio): model dropdown wired to the same shared registry/factory;
  default eager warm-up, 0.6b lazy; thread fix and NotADiffError guard carried.

Verified with a TestClient + fake generator (no model download): backward-compat
no-model->1.7b, explicit 0.6b lazy-loads, unknown->400, empty->400, health
reports both. The 0.6b GGUF repo is still PRIVATE on the Hub — must be made
public (or given a Space token) before the live deploy can pull it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CyxW8LpuJuQRCzdnfYp8Xo
@marzoukbaig14
marzoukbaig14 merged commit 54c3d05 into main Jul 1, 2026
1 check passed
@marzoukbaig14
marzoukbaig14 deleted the serving/dual-model branch July 1, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants