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)
| 233 | |
| 234 | |
| 235 | def _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 | |
| 259 | def _resolve_sliding_window( |
no test coverage detected