MCPcopy
hub / github.com/Andyyyy64/whichllm / _swa_arch_key

Function _swa_arch_key

src/whichllm/models/fetcher.py:235–256  ·  view source on GitHub ↗

Identify the SWA architecture key for a model, or None if not honored. Relies on authoritative metadata only — the raw HF config ``model_type``/ ``architectures`` (not the normalized architecture string, which collapses gemma2 and gemma3 into "gemma") and the GGUF metadata architecture.

(config: dict, model_id: str, gguf_arch: str | None)

Source from the content-addressed store, hash-verified

233
234
235def _swa_arch_key(config: dict, model_id: str, gguf_arch: str | None) -> str | None:
236 """Identify the SWA architecture key for a model, or None if not honored.
237
238 Relies on authoritative metadata only — the raw HF config ``model_type``/
239 ``architectures`` (not the normalized architecture string, which collapses
240 gemma2 and gemma3 into "gemma") and the GGUF metadata architecture. When
241 none of these are present the model is left unhonored (full-context
242 estimate) rather than guessed at from the model id, since a false positive
243 would under-count VRAM.
244 """
245 model_type = config.get("model_type")
246 key = _swa_key_from_arch(model_type if isinstance(model_type, str) else None)
247 if key:
248 return key
249
250 arch_list = config.get("architectures") or []
251 if arch_list and isinstance(arch_list[0], str):
252 key = _swa_key_from_arch(arch_list[0])
253 if key:
254 return key
255
256 return _swa_key_from_arch(gguf_arch)
257
258
259def _resolve_sliding_window(

Callers 1

_resolve_sliding_windowFunction · 0.85

Calls 1

_swa_key_from_archFunction · 0.85

Tested by

no test coverage detected