Skip to content

fix(engine): floor memory fit-check against a real weights+KV-cache estimate - #2

Merged
jsaigou merged 2 commits into
mainfrom
fix/kv-cache-memory-fit-check
Sep 7, 2026
Merged

fix(engine): floor memory fit-check against a real weights+KV-cache estimate#2
jsaigou merged 2 commits into
mainfrom
fix/kv-cache-memory-fit-check

Conversation

@jsaigou

@jsaigou jsaigou commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • A model's memory fit check previously fell back to a curated (hand-entered)
    or bare-file-size estimate with no context-dependent term for any
    non-profiled config, so a large-context config could be admitted well
    under its real memory need.
  • Extends the GGUF metadata reader (layer count, head counts, key/value
    dimensions, sliding-window pattern, and hybrid SSM/attention signals) and
    adds a KV-cache byte estimator ported from llama.cpp's own hparams/KV-cache
    sizing logic, so a curated or file-size figure can never undercut the
    computed weights+KV floor.
  • Architectures the formula can't model (hybrid SSM/attention designs) are
    detected and left on the existing curated-or-refuse path rather than
    guessed at — no regression for those.

Test plan

  • go build/go vet/go test ./... (incl. -race) clean
  • New unit tests cover a plain dense/GQA model, an interleaved
    sliding-window-attention model (full formula match against a
    hand-calculated expected value), the embedding/head-count fallback,
    and hybrid-architecture abstention
  • Regression test reproducing the incident shape at the fit-check level
    (curated figure below the real need) — now correctly refuses
  • Live-verified against real GGUF files on the production host

jsaigou added 2 commits September 6, 2026 22:21
…ce icons

STT server swapped from Nemotron ASR to Qwen3-ASR-0.6B for improved accuracy
and cleaner output (no leaked language-tag tokens, no truncated sentences).

Fixed-service vendor icons (STT/Embedding/Aligner/TTS) moved from a
compiled-in Go map to a store-backed setting (infra.service_icons) with a
live GET/PUT API — changing one no longer requires a rebuild or restart.

Claude-Session: https://claude.ai/code/session_01C8p4KLqr9S2MJzQET8dZSc
…stimate

A real production incident: a config's curated memory estimate (weight-
adjacent, no KV-cache term) let the fit check admit a model load that
actually needed far more memory once its large-context, full-SWA KV cache
materialized, while another already-loaded model's real footprint left
little genuinely free headroom. The host OOM-killed several unrelated
services before self-healing.

The fit check's need-estimate had no context-dependent term on any
non-profiled path (profile -> curated catalog figure -> bare weight-file
size), so any large-context, unprofiled config was exposed the same way.

Extends the GGUF parser (block_count, head_count[_kv], key/value_length
[+_swa variants], sliding_window[_pattern], and ssm./indexer hybrid
signals) and adds a KV-cache byte estimator ported directly from
llama.cpp's own hparams/KV-cache sizing logic (verified against source).
A curated or file-size figure can no longer undercut the computed
weights+KV floor. Architectures the formula can't model (hybrid
SSM/attention designs) are detected and left on the existing
curated-or-refuse path rather than guessed at.
@jsaigou
jsaigou merged commit bcb8069 into main Sep 7, 2026
2 checks passed
@jsaigou
jsaigou deleted the fix/kv-cache-memory-fit-check branch September 7, 2026 14:40
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.

1 participant