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

Function _resolve_sliding_window

src/whichllm/models/fetcher.py:259–287  ·  view source on GitHub ↗

Resolve (sliding_window, global_ratio) for honored SWA architectures. Returns (None, None) for every model outside the allowlist so the KV estimate stays at full context (conservative).

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

Source from the content-addressed store, hash-verified

257
258
259def _resolve_sliding_window(
260 config: dict, model_id: str, gguf_arch: str | None = None
261) -> tuple[int | None, float | None]:
262 """Resolve (sliding_window, global_ratio) for honored SWA architectures.
263
264 Returns (None, None) for every model outside the allowlist so the KV
265 estimate stays at full context (conservative).
266 """
267 # Respect an explicit opt-out before doing any work.
268 if config.get("use_sliding_window") is False:
269 return None, None
270
271 key = _swa_arch_key(config, model_id, gguf_arch)
272 if key is None:
273 return None, None
274
275 default_window, default_ratio = _SWA_ARCH_DEFAULTS[key]
276
277 window = config.get("sliding_window")
278 if not isinstance(window, int) or window <= 0:
279 window = default_window
280
281 pattern = config.get("sliding_window_pattern")
282 if isinstance(pattern, int) and pattern > 0:
283 global_ratio = 1.0 / pattern
284 else:
285 global_ratio = default_ratio
286
287 return window, global_ratio
288
289
290def _normalize_param_count(

Callers 1

_parse_modelFunction · 0.85

Calls 1

_swa_arch_keyFunction · 0.85

Tested by

no test coverage detected