You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extends #119 (which added n_layer/n_head_kv/n_embd_k_gqa/n_embd_v_gqa/cache_type_{k,v} to /v1/modelsmeta). Those let a client compute KV/token assuming all layers scale with context — correct for dense models, but a 2–8× over-estimate for SWA-hybrid models (gemma-4 12B/31B, gemma-4-12b-256k@gem), where most layers cap KV at a small sliding window and only a few full-attention layers scale with ctx.
heierchat’s VRAM panel currently uses the all-layers value as a safe upper bound (errs toward over-VRAM, never under-predicts an OOM) labeled ≈. To make gemma-4 exact the FE needs the SWA split, which llama.cpp already knows.
Proposed additive meta fields (per loaded model, same path as #119)
field
source
example (gemma-4-12b)
n_swa
llama_model_n_swa(model) (already public)
1024
n_swa_layers
new accessor llama_model_n_swa_layers(model) = count of il where hparams.is_swa(il)
e.g. 40
swa_type
hparams.swa_type as string (none/standard/chunked)
standard
n_full_layers = n_layer − n_swa_layers is derived on the FE.
src/llama-model.cpp + include/llama.h: add LLAMA_API int32_t llama_model_n_swa_layers(const llama_model * model) next to the existing llama_model_n_swa — loop il in [0, n_layer) counting hparams.is_swa(il). (n_swa, is_swa, is_swa_any already exist in src/llama-hparams.h.)
tools/server/server-context.h: add int32_t model_n_swa; int32_t model_n_swa_layers; std::string swa_type; to server_context_meta.
None until rolled; purely additive meta. Makes the gemma-4 VRAM verdict exact instead of a safe upper bound. Related: #119, #122. FE side queued by heierchat ("Exact KV for SWA-hybrid models in the VRAM panel").
Extends #119 (which added
n_layer/n_head_kv/n_embd_k_gqa/n_embd_v_gqa/cache_type_{k,v}to/v1/modelsmeta). Those let a client compute KV/token assuming all layers scale with context — correct for dense models, but a 2–8× over-estimate for SWA-hybrid models (gemma-4 12B/31B, gemma-4-12b-256k@gem), where most layers cap KV at a small sliding window and only a few full-attention layers scale withctx.heierchat’s VRAM panel currently uses the all-layers value as a safe upper bound (errs toward over-VRAM, never under-predicts an OOM) labeled
≈. To make gemma-4 exact the FE needs the SWA split, which llama.cpp already knows.Proposed additive
metafields (per loaded model, same path as #119)n_swallama_model_n_swa(model)(already public)1024n_swa_layersllama_model_n_swa_layers(model)= count ofilwherehparams.is_swa(il)40swa_typehparams.swa_typeas string (none/standard/chunked)standardn_full_layers = n_layer − n_swa_layersis derived on the FE.Exact KV/token the FE will then compute
i.e. full layers scale with
ctx; SWA layers saturate atmin(ctx, n_swa).Implementation sketch (our fork — clean, mirrors #119)
src/llama-model.cpp+include/llama.h: addLLAMA_API int32_t llama_model_n_swa_layers(const llama_model * model)next to the existingllama_model_n_swa— loopil in [0, n_layer)countinghparams.is_swa(il). (n_swa,is_swa,is_swa_anyalready exist insrc/llama-hparams.h.)tools/server/server-context.h: addint32_t model_n_swa; int32_t model_n_swa_layers; std::string swa_type;toserver_context_meta.tools/server/server-context.cpp: populate them where feat(server): expose KV-cache geometry + quant in /v1/models meta #119 populatedn_layeretc.; emitn_swa,n_swa_layers,swa_typein the/v1/modelsmetaJSON.Downstream (tracked separately, snoop-kube’s lane)
meta.llamaswap(mirror the dims/KV passthrough from omniswap [Frontend] Add lora-adapter toggler / selection list for selected model #13).Impact
None until rolled; purely additive meta. Makes the gemma-4 VRAM verdict exact instead of a safe upper bound. Related: #119, #122. FE side queued by heierchat ("Exact KV for SWA-hybrid models in the VRAM panel").