Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
fix(recipes): ratchet recipe declared size against recorded base parameter counts (#1168)
Nurkhan Esenbek5ce9f8ac10c4
diff --git a/changelog.d/0.75.1/1168.fixed.md b/changelog.d/0.75.1/1168.fixed.mdnew file mode 100644index 00000000..774f3d4f--- /dev/null+++ b/changelog.d/0.75.1/1168.fixed.md@@ -0,0 +1 @@+- **Recipe size labels are the base's total parameter count, and a test now keeps them so.** Nine labels were wrong and moved: `llama4-scout-17b-sft`, `-dpo`, `-grpo` and `llama4-scout-tools` 17B -> 109B, `deepseek-v3-7b-sft` 7B -> 685B, `voxtral-sft` 3B -> 4.7B, `glm-4.6-sft` 9B -> 357B, `glm-5-sft` 9B -> 754B, `minimax-m2-sft` 9B -> 230B. `tests/test_recipe_sizes.py` compares every recipe's label with the Hub's recorded parameter count (0.70x to 1.15x) and names a recipe whose base has no count unless it is excluded with a reason (#1161 by @kok-o in #1168).diff --git a/docs/models.md b/docs/models.mdindex 058d1769..ef334019 100644--- a/docs/models.md+++ b/docs/models.md@@ -4,6 +4,8 @@> Recommended model families, the VRAM size guide, and the pip extras matrix.+> Model sizes across recipes represent the total parameter count (all resident parameters for MoE models, answering card VRAM requirements).+## Supported ModelsSoup works with **any** of the **340,000+** text-generation models on [HuggingFace Hub](https://huggingface.co/models?pipeline_tag=text-generation). If a model supports `AutoModelForCausalLM`, it works with Soup — zero config changes needed.@@ -12,7 +14,7 @@ Soup works with **any** of the **340,000+** text-generation models on [HuggingFa| Model Family | Models | Sizes | Best For ||---|---|---|---|-| **Llama 4** | Llama-4-Scout-17B, Llama-4-Maverick-17B | 17B | General, multilingual |+| **Llama 4** | Llama-4-Scout-17B, Llama-4-Maverick-17B | 109B-400B | General, multilingual || **Llama 3.x** | Llama-3.1-8B-Instruct, Llama-3.3-70B-Instruct | 1B–70B | Chat, instruction following || **Llama 3.2 Vision** | Llama-3.2-11B-Vision-Instruct, Llama-3.2-90B-Vision | 11B–90B | Image understanding || **Gemma 3** | Gemma-3-4B-IT, Gemma-3-9B-IT, Gemma-3-27B-IT | 4B–27B | Efficient, multilingual |@@ -20,7 +22,7 @@ Soup works with **any** of the **340,000+** text-generation models on [HuggingFa| **Qwen 3** | Qwen3-8B, Qwen3-14B, Qwen3-32B, Qwen3-235B-A22B | 0.6B–235B | Reasoning, code, MoE || **Qwen 2.5** | Qwen2.5-7B-Instruct, Qwen2.5-Coder-32B-Instruct, Qwen2.5-Math-7B-Instruct | 0.5B–72B | Code, math || **DeepSeek** | DeepSeek-R1-Distill-Llama-8B, DeepSeek-V3-0324, DeepSeek-V4-Flash/Pro | 1.5B–1.6T | Reasoning (GRPO), code, MoE |-| **GLM** | GLM-5, GLM-5.1 | 9B–754B | Chinese + English, MoE |+| **GLM** | GLM-4.6, GLM-5, GLM-5.1 | 357B-754B | Chinese + English, MoE || **Kimi** | Kimi-K2, Kimi-K2.5, Kimi-K2.6 | ~1T (MoE) | Long-context agentic, MoE || **MiniMax** | MiniMax-M2, MiniMax-M3 | 230B–428B | Agentic, MoE (community license) || **Phi-4** | Phi-4-14B, Phi-4-mini-reasoning | 3.8B–14B | Compact reasoning |diff --git a/scripts/record_recipe_base_architectures.py b/scripts/record_recipe_base_architectures.pyindex ccb3f6fa..2175e751 100644--- a/scripts/record_recipe_base_architectures.py+++ b/scripts/record_recipe_base_architectures.py@@ -73,6 +73,20 @@ def classify(base: str) -> dict:return {"model_type": config.get("model_type"), "routed_experts": routed_experts(config)}+def parameter_count(base: str) -> dict:+ """The Hub's safetensors total, read with no token; the reason when there is none."""+ from huggingface_hub import HfApi++ try:+ info = HfApi(token=False).model_info(base)+ except Exception as exc: # recorded in the fixture, not swallowed+ return {"parameters_unavailable": f"{type(exc).__name__}: {exc}".splitlines()[0][:160]}+ total = getattr(getattr(info, "safetensors", None), "total", None)+ if not total:+ return {"parameters_unavailable": "no safetensors metadata on the Hub"}+ return {"parameters": total}++def main() -> int:sys.path.insert(0, str(_REPO_ROOT / "src"))import yaml@@ -82,12 +96,17 @@ def main() -> int:bases = sorted({yaml.safe_load(r.yaml_str).get("base") for r in list_recipes()})record = {}for base in bases:- record[base] = classify(base)+ record[base] = {**classify(base), **parameter_count(base)}print(f"{base:55} {record[base]}", file=sys.stderr)_FIXTURE.write_text(json.dumps(record, indent=1, sort_keys=True) + "\n", encoding="utf-8")moe = sum(1 for v in record.values() if v.get("routed_experts", 0) > 1)unresolvable = sum(1 for v in record.values() if "unresolvable" in v)- print(f"{len(record)} bases, {moe} MoE, {unresolvable} unresolvable", file=sys.stderr)+ with_params = sum(1 for v in record.values() if "parameters" in v)+ summary = (+ f"{len(record)} bases, {moe} MoE, {unresolvable} unresolvable, "+ f"{with_params} with parameters"+ )+ print(summary, file=sys.stderr)return 0diff --git a/src/soup_cli/recipes/catalog.py b/src/soup_cli/recipes/catalog.pyindex fbb54846..c1e5d992 100644--- a/src/soup_cli/recipes/catalog.py+++ b/src/soup_cli/recipes/catalog.py@@ -31,7 +31,7 @@ def search_recipes(task: Optional[str] = None,size: Optional[str] = None,) -> List[RecipeMeta]:- """Search recipes by keyword, task, or model size."""+ """Search recipes by keyword, task, or model."""results = []for name, recipe in RECIPES.items():if task and recipe.task != task:@@ -917,9 +917,9 @@ output: ./output"llama4-scout-17b-sft": RecipeMeta(model="meta-llama/Llama-4-Scout-17B-16E-Instruct",task="sft",- size="17B",+ size="109B",tags=("llama", "llama4", "sft", "chat", "instruction"),- description="Llama 4 Scout 17B SFT with LoRA (4bit)",+ description="Llama 4 Scout 17B active SFT with LoRA (4bit)",yaml_str="""\base: meta-llama/Llama-4-Scout-17B-16E-Instructtask: sft@@ -945,9 +945,9 @@ output: ./output"llama4-scout-17b-dpo": RecipeMeta(model="meta-llama/Llama-4-Scout-17B-16E-Instruct",task="dpo",- size="17B",+ size="109B",tags=("llama", "llama4", "dpo", "alignment", "preference"),- description="Llama 4 Scout 17B DPO alignment",+ description="Llama 4 Scout 17B active DPO alignment",yaml_str="""\base: meta-llama/Llama-4-Scout-17B-16E-Instructtask: dpo@@ -974,9 +974,9 @@ output: ./output"llama4-scout-17b-grpo": RecipeMeta(model="meta-llama/Llama-4-Scout-17B-16E-Instruct",task="grpo",- size="17B",+ size="109B",tags=("llama", "llama4", "grpo", "reasoning"),- description="Llama 4 Scout 17B GRPO reasoning training",+ description="Llama 4 Scout 17B active GRPO reasoning training",yaml_str="""\base: meta-llama/Llama-4-Scout-17B-16E-Instructtask: grpo@@ -1153,7 +1153,7 @@ output: ./output"deepseek-v3-7b-sft": RecipeMeta(model="deepseek-ai/DeepSeek-V3-0324",task="sft",- size="7B",+ size="685B",tags=("deepseek", "sft", "moe", "mixture-of-experts"),description="DeepSeek V3 SFT with MoE LoRA",yaml_str="""\@@ -1302,9 +1302,9 @@ output: ./output"llama4-scout-tools": RecipeMeta(model="meta-llama/Llama-4-Scout-17B-16E-Instruct",task="sft",- size="17B",+ size="109B",tags=("llama", "llama4", "sft", "tool-calling", "agentic", "function-calling"),- description="Llama 4 Scout 17B tool-calling / function-calling SFT",+ description="Llama 4 Scout 17B active tool-calling / function-calling SFT",yaml_str="""\base: meta-llama/Llama-4-Scout-17B-16E-Instructtask: sft@@ -2770,9 +2770,9 @@ output: ./output"glm-4.6-sft": RecipeMeta(model="zai-org/GLM-4.6",task="sft",- size="9B",+ size="357B",tags=("glm", "zai-org", "chat", "instruction"),- description="GLM 4.6 instruction tuning with LoRA",+ description="GLM 4.6 MoE instruction tuning with LoRA",yaml_str="""\base: zai-org/GLM-4.6task: sft@@ -2798,9 +2798,9 @@ output: ./output"glm-5-sft": RecipeMeta(model="zai-org/GLM-5",task="sft",- size="9B",+ size="754B",tags=("glm", "zai-org", "chat", "next-gen"),- description="GLM 5 SFT (next-gen GLM family)",+ description="GLM 5 MoE SFT (next-gen GLM family)",yaml_str="""\base: zai-org/GLM-5task: sft@@ -2889,9 +2889,9 @@ output: ./output"minimax-m2-sft": RecipeMeta(model="MiniMaxAI/MiniMax-M2",task="sft",- size="9B",+ size="230B",tags=("minimax", "chat", "instruction"),- description="MiniMax M2 SFT instruction tuning",+ description="MiniMax M2 MoE SFT instruction tuning",yaml_str="""\base: MiniMaxAI/MiniMax-M2task: sft@@ -3305,7 +3305,7 @@ output: ./output"voxtral-sft": RecipeMeta(model="mistralai/Voxtral-Mini-3B-2507",task="sft",- size="3B",+ size="4.7B",tags=("mistral", "voxtral", "audio", "multimodal"),description="Voxtral Mini 3B audio SFT",yaml_str="""\diff --git a/tests/fixtures/recipe_base_architectures.json b/tests/fixtures/recipe_base_architectures.jsonindex bbbc8f43..d02635dd 100644--- a/tests/fixtures/recipe_base_architectures.json+++ b/tests/fixtures/recipe_base_architectures.json@@ -1,433 +1,546 @@{"BioMistral/BioMistral-7B": {"model_type": "mistral",+ "parameters_unavailable": "no safetensors metadata on the Hub","routed_experts": 0},"HKUSTAudio/Llasa-1B": {"model_type": "llama",+ "parameters": 1370048512,"routed_experts": 0},"HuggingFaceTB/SmolLM2-1.7B-Instruct": {"model_type": "llama",+ "parameters": 1711376384,"routed_experts": 0},"HuggingFaceTB/SmolLM2-135M-Instruct": {"model_type": "llama",+ "parameters": 134515008,"routed_experts": 0},"HuggingFaceTB/SmolLM2-360M-Instruct": {"model_type": "llama",+ "parameters": 361821120,"routed_experts": 0},"HuggingFaceTB/SmolLM3-3B": {"model_type": "smollm3",+ "parameters": 3075098624,"routed_experts": 0},"HuggingFaceTB/SmolVLM-256M-Instruct": {"model_type": "idefics3",+ "parameters": 256484928,"routed_experts": 0},"LiquidAI/LFM2-1.2B": {"model_type": "lfm2",+ "parameters": 1170340608,"routed_experts": 0},"MiniMaxAI/MiniMax-M2": {"model_type": "minimax_m2",+ "parameters": 228689764864,"routed_experts": 256},"MiniMaxAI/MiniMax-M3": {"model_type": "minimax_m3_vl",+ "parameters": 427040140160,"routed_experts": 128},"OpenGVLab/InternVL2_5-8B": {"model_type": "internvl_chat",+ "parameters": 8075365376,"routed_experts": 0},"OpenGVLab/InternVL3_5-8B": {"model_type": "internvl_chat",+ "parameters": 8528318464,"routed_experts": 0},"OuteAI/OuteTTS-0.3-500M": {"model_type": "qwen2",+ "parameters": 499193728,"routed_experts": 0},"PaddlePaddle/PaddleOCR-VL": {"model_type": "paddleocr_vl",+ "parameters": 958588736,"routed_experts": 0},"Qwen/QVQ-72B-Preview": {"model_type": "qwen2_vl",+ "parameters": 73405560320,"routed_experts": 0},"Qwen/QwQ-32B": {"model_type": "qwen2",+ "parameters": 32763876352,"routed_experts": 0},"Qwen/Qwen-Image": {+ "parameters": 20430401088,"unresolvable": "the repo has no config.json"},"Qwen/Qwen2-Audio-7B-Instruct": {"model_type": "qwen2_audio",+ "parameters": 8397094912,"routed_experts": 0},"Qwen/Qwen2-VL-72B-Instruct": {"model_type": "qwen2_vl",+ "parameters": 73405560320,"routed_experts": 0},"Qwen/Qwen2-VL-7B-Instruct": {"model_type": "qwen2_vl",+ "parameters": 8291375616,"routed_experts": 0},"Qwen/Qwen2.5-0.5B-Instruct": {"model_type": "qwen2",+ "parameters": 494032768,"routed_experts": 0},"Qwen/Qwen2.5-1.5B-Instruct": {"model_type": "qwen2",+ "parameters": 1543714304,"routed_experts": 0},"Qwen/Qwen2.5-3B-Instruct": {"model_type": "qwen2",+ "parameters": 3085938688,"routed_experts": 0},"Qwen/Qwen2.5-72B-Instruct": {"model_type": "qwen2",+ "parameters": 72706203648,"routed_experts": 0},"Qwen/Qwen2.5-7B": {"model_type": "qwen2",+ "parameters": 7615616512,"routed_experts": 0},"Qwen/Qwen2.5-7B-Instruct": {"model_type": "qwen2",+ "parameters": 7615616512,"routed_experts": 0},"Qwen/Qwen2.5-Coder-1.5B-Instruct": {"model_type": "qwen2",+ "parameters": 1543714304,"routed_experts": 0},"Qwen/Qwen2.5-Coder-14B-Instruct": {"model_type": "qwen2",+ "parameters": 14770033664,"routed_experts": 0},"Qwen/Qwen2.5-Coder-32B-Instruct": {"model_type": "qwen2",+ "parameters": 32763876352,"routed_experts": 0},"Qwen/Qwen2.5-Coder-7B-Instruct": {"model_type": "qwen2",+ "parameters": 7615616512,"routed_experts": 0},"Qwen/Qwen2.5-Math-1.5B-Instruct": {"model_type": "qwen2",+ "parameters": 1543714304,"routed_experts": 0},"Qwen/Qwen2.5-Math-7B-Instruct": {"model_type": "qwen2",+ "parameters": 7615616512,"routed_experts": 0},"Qwen/Qwen3-14B": {"model_type": "qwen3",+ "parameters": 14768307200,"routed_experts": 0},"Qwen/Qwen3-30B-A3B": {"model_type": "qwen3_moe",+ "parameters": 30532122624,"routed_experts": 128},"Qwen/Qwen3-32B": {"model_type": "qwen3",+ "parameters": 32762123264,"routed_experts": 0},"Qwen/Qwen3-8B": {"model_type": "qwen3",+ "parameters": 8190735360,"routed_experts": 0},"Qwen/Qwen3-Coder-30B-A3B-Instruct": {"model_type": "qwen3_moe",+ "parameters": 30532122624,"routed_experts": 128},"Qwen/Qwen3.5-0.8B": {"model_type": "qwen3_5",+ "parameters": 873438784,"routed_experts": 0},"Qwen/Qwen3.5-122B-A10B": {"model_type": "qwen3_5_moe",+ "parameters": 125086497008,"routed_experts": 256},"Qwen/Qwen3.5-27B": {"model_type": "qwen3_5",+ "parameters": 27781427952,"routed_experts": 0},"Qwen/Qwen3.5-2B": {"model_type": "qwen3_5",+ "parameters": 2274069824,"routed_experts": 0},"Qwen/Qwen3.5-35B-A3B": {"model_type": "qwen3_5_moe",+ "parameters": 35951822704,"routed_experts": 256},"Qwen/Qwen3.5-397B-A17B": {"model_type": "qwen3_5_moe",+ "parameters": 403397928944,"routed_experts": 512},"Qwen/Qwen3.5-4B": {"model_type": "qwen3_5",+ "parameters": 4659865088,"routed_experts": 0},"Qwen/Qwen3.5-4B-Base": {"model_type": "qwen3_5",+ "parameters": 4659865088,"routed_experts": 0},"Qwen/Qwen3.5-9B": {"model_type": "qwen3_5",+ "parameters": 9653104368,"routed_experts": 0},"Qwen/Qwen3.6-27B": {"model_type": "qwen3_5",+ "parameters": 27781427952,"routed_experts": 0},"Qwen/Qwen3.6-35B-A3B": {"model_type": "qwen3_5_moe",+ "parameters": 35951822704,"routed_experts": 256},"Qwen/Qwen3.8-27B": {"model_type": "qwen3_5",+ "parameters": 27781427952,"routed_experts": 0},"baichuan-inc/Baichuan2-13B-Chat": {"model_type": "baichuan",+ "parameters_unavailable": "no safetensors metadata on the Hub","routed_experts": 0},"canopylabs/orpheus-3b-0.1-ft": {+ "parameters": 3782986752,"unresolvable": "gated; set HF_TOKEN to classify"},"codellama/CodeLlama-13b-Instruct-hf": {"model_type": "llama",+ "parameters": 13016028160,"routed_experts": 0},"codellama/CodeLlama-70b-Instruct-hf": {"model_type": "llama",+ "parameters": 68976910336,"routed_experts": 0},"deepseek-ai/DeepSeek-OCR": {"model_type": "deepseek_vl_v2",+ "parameters": 3336106240,"routed_experts": 64},"deepseek-ai/DeepSeek-R1-Distill-Llama-70B": {"model_type": "llama",+ "parameters": 70553706496,"routed_experts": 0},"deepseek-ai/DeepSeek-R1-Distill-Llama-8B": {"model_type": "llama",+ "parameters": 8030261248,"routed_experts": 0},"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B": {"model_type": "qwen2",+ "parameters": 1777088000,"routed_experts": 0},"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B": {"model_type": "qwen2",+ "parameters": 14770033664,"routed_experts": 0},"deepseek-ai/DeepSeek-R1-Distill-Qwen-32B": {"model_type": "qwen2",+ "parameters": 32763876352,"routed_experts": 0},"deepseek-ai/DeepSeek-R1-Distill-Qwen-7B": {"model_type": "qwen2",+ "parameters": 7615616512,"routed_experts": 0},"deepseek-ai/DeepSeek-V3": {"model_type": "deepseek_v3",+ "parameters": 684531386000,"routed_experts": 256},"deepseek-ai/DeepSeek-V3-0324": {"model_type": "deepseek_v3",+ "parameters": 684531386000,"routed_experts": 256},"deepseek-ai/DeepSeek-V4-Flash": {"model_type": "deepseek_v4",+ "parameters": 290944616402,"routed_experts": 256},"deepseek-ai/DeepSeek-V4-Pro": {"model_type": "deepseek_v4",+ "parameters": 1598839674782,"routed_experts": 384},"epfl-llm/meditron-7b": {+ "parameters": 6738554880,"unresolvable": "gated; set HF_TOKEN to classify"},"facebook/seamless-m4t-v2-large": {"model_type": "seamless_m4t_v2",+ "parameters": 2309249669,"routed_experts": 0},"google/embeddinggemma-300m": {+ "parameters": 302863104,"unresolvable": "gated; set HF_TOKEN to classify"},"google/gemma-2-2b-it": {+ "parameters": 2614341888,"unresolvable": "gated; set HF_TOKEN to classify"},"google/gemma-3-12b-it": {+ "parameters": 12187325040,"unresolvable": "gated; set HF_TOKEN to classify"},"google/gemma-3-27b-it": {+ "parameters": 27432406640,"unresolvable": "gated; set HF_TOKEN to classify"},"google/medgemma-4b-it": {+ "parameters": 4300079472,"unresolvable": "gated; set HF_TOKEN to classify"},"ibm-granite/granite-4.0-h-tiny-base": {"model_type": "granitemoehybrid",+ "parameters": 6939037248,"routed_experts": 64},"ise-uiuc/Magicoder-S-DS-6.7B": {"model_type": "llama",+ "parameters": 6740512768,"routed_experts": 0},"llava-hf/llava-v1.6-mistral-7b-hf": {"model_type": "llava_next",+ "parameters": 7566747648,"routed_experts": 0},"meta-llama/Llama-2-13b-hf": {+ "parameters": 13015866880,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.1-70B-Instruct": {+ "parameters": 70553706496,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.1-8B": {+ "parameters": 8030261248,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.1-8B-Instruct": {+ "parameters": 8030261248,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.2-11B-Vision-Instruct": {+ "parameters": 10670220835,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.2-1B-Instruct": {+ "parameters": 1235814400,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.2-3B-Instruct": {+ "parameters": 3212749824,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-3.2-90B-Vision-Instruct": {+ "parameters": 88593355323,"unresolvable": "gated; set HF_TOKEN to classify"},"meta-llama/Llama-4-Scout-17B-16E-Instruct": {+ "parameters": 108641793536,"unresolvable": "gated; set HF_TOKEN to classify"},"microsoft/Phi-3.5-mini-instruct": {"model_type": "phi3",+ "parameters": 3821079552,"routed_experts": 0},"microsoft/phi-4": {"model_type": "phi3",+ "parameters": 14659507200,"routed_experts": 0},"mistralai/Devstral-Small-2507": {"model_type": "mistral",+ "parameters": 23572403200,"routed_experts": 0},"mistralai/Magistral-Small": {"model_type": "mistral",+ "parameters": 23572403200,"routed_experts": 0},"mistralai/Mathstral-7B-v0.1": {"model_type": "mistral",+ "parameters": 7248023552,"routed_experts": 0},"mistralai/Ministral-8B-Instruct-2410": {"model_type": "mistral",+ "parameters": 8019808256,"routed_experts": 0},"mistralai/Mistral-7B-Instruct-v0.3": {"model_type": "mistral",+ "parameters": 7248023552,"routed_experts": 0},"mistralai/Mistral-Large-3-675B-Instruct-2512": {+ "parameters_unavailable": "no safetensors metadata on the Hub","unresolvable": "the repo has no config.json"},"mistralai/Mistral-Medium-3.5-128B": {"model_type": "mistral3",+ "parameters": 127704210176,"routed_experts": 0},"mistralai/Mistral-Small-24B-Instruct-2501": {"model_type": "mistral",+ "parameters": 23572403200,"routed_experts": 0},"mistralai/Pixtral-12B-2409": {+ "parameters_unavailable": "no safetensors metadata on the Hub","unresolvable": "the repo has no config.json"},"mistralai/Voxtral-Mini-3B-2507": {"model_type": "voxtral",+ "parameters": 4676271104,"routed_experts": 0},"mlx-community/Llama-3.1-8B-Instruct-4bit": {"model_type": "llama",+ "parameters": 8030261248,"routed_experts": 0},"mlx-community/Qwen3-8B-4bit": {"model_type": "qwen3",+ "parameters": 8190735360,"routed_experts": 0},"mlx-community/gemma-3-4b-it-4bit": {"model_type": "gemma3",+ "parameters": 4971331952,"routed_experts": 0},"moonshotai/Kimi-K2-Base": {"model_type": "kimi_k2",+ "parameters": 1026470731056,"routed_experts": 384},"moonshotai/Kimi-K2-Thinking": {"model_type": "kimi_k2",+ "parameters": 1026408240256,"routed_experts": 384},"moonshotai/Kimi-K2.5": {"model_type": "kimi_k25",+ "parameters": 1026879376368,"routed_experts": 384},"moonshotai/Kimi-K2.6": {"model_type": "kimi_k25",+ "parameters": 1026879376368,"routed_experts": 384},"nvidia/Nemotron-4-340B-Instruct": {+ "parameters_unavailable": "no safetensors metadata on the Hub","unresolvable": "the repo has no config.json"},"openai/gpt-oss-120b": {"model_type": "gpt_oss",+ "parameters": 116829156672,"routed_experts": 128},"openai/gpt-oss-20b": {"model_type": "gpt_oss",+ "parameters": 20914757184,"routed_experts": 32},"openai/whisper-base": {"model_type": "whisper",+ "parameters": 72593920,"routed_experts": 0},"openai/whisper-large-v3": {"model_type": "whisper",+ "parameters": 1543490560,"routed_experts": 0},"openai/whisper-tiny": {"model_type": "whisper",+ "parameters": 37760640,"routed_experts": 0},"openbmb/MiniCPM-V-2_6": {+ "parameters": 8099175152,"unresolvable": "gated; set HF_TOKEN to classify"},"sentence-transformers/all-mpnet-base-v2": {"model_type": "mpnet",+ "parameters": 109486978,"routed_experts": 0},"zai-org/GLM-4.6": {"model_type": "glm4_moe",+ "parameters": 356785898816,"routed_experts": 160},"zai-org/GLM-5": {"model_type": "glm_moe_dsa",+ "parameters": 753864139008,"routed_experts": 256},"zai-org/GLM-5.1": {"model_type": "glm_moe_dsa",+ "parameters": 753864139008,"routed_experts": 256}}diff --git a/tests/test_issue1198_model_size_parsing.py b/tests/test_issue1198_model_size_parsing.pyindex 37095214..1290e261 100644--- a/tests/test_issue1198_model_size_parsing.py+++ b/tests/test_issue1198_model_size_parsing.py@@ -34,6 +34,7 @@ _UNRESOLVABLE_CATALOG_REASONS = {"microsoft/phi-4": "Model ID specifies release 'phi-4' without parameter count (14B).","mistralai/Devstral-Small-2507": "Uses 'Small-2507' descriptor rather than param count (24B).","mistralai/Magistral-Small": "Uses 'Small' descriptor rather than param count (24B).",+ "mistralai/Voxtral-Mini-3B-2507": "Model ID specifies '3B' but multimodal weights total 4.7B.","moonshotai/Kimi-K2-Base": "Version 'K2-Base' carries no parameter count (size N/A).","moonshotai/Kimi-K2-Thinking": "Reasoning variant of K2 with no parameter count (size N/A).","moonshotai/Kimi-K2.5": "Model ID specifies version 'K2.5' without parameter count (1T).",@@ -45,15 +46,6 @@ _UNRESOLVABLE_CATALOG_REASONS = {"zai-org/GLM-5.1": "Model ID specifies release '5.1' without parameter count (754B).",}-# Hub safetensors totals for catalog bases whose recipe label is NOT the total-# parameter count (#1161 / #1168), so the label cannot be the yardstick for them.-_KNOWN_TOTAL_B = {- "meta-llama/Llama-4-Scout-17B-16E-Instruct": 108.6, # label 17B is the active count- "deepseek-ai/DeepSeek-V3-0324": 684.5, # deepseek-v3-7b-sft, label 7B- "zai-org/GLM-5": 753.9, # label 9B- "MiniMaxAI/MiniMax-M2": 228.7, # label 9B- "zai-org/GLM-4.6": 356.8, # label 9B-}@@ -178,9 +170,9 @@ class TestIssue1198HubModelSizeParsing:assert model_size_from_name("ise-uiuc/Magicoder-S-DS-6.7B") == 6.7def test_every_allowlisted_base_is_still_used(self) -> None:- """Ensure every base in allowlist and _KNOWN_TOTAL_B is actually used in RECIPES."""+ """Ensure every base in allowlist is actually used in RECIPES."""used = {recipe.model for recipe in RECIPES.values()}- stale = sorted((set(_UNRESOLVABLE_CATALOG_REASONS) | set(_KNOWN_TOTAL_B)) - used)+ stale = sorted(set(_UNRESOLVABLE_CATALOG_REASONS) - used)assert not stale, f"allowlist names bases no recipe uses: {stale}"def test_recipe_catalog_resolution_or_allowlist(self) -> None:@@ -200,7 +192,6 @@ class TestIssue1198HubModelSizeParsing:val = float(size_match.group(1))unit = size_match.group(2)expected_b = val if unit == "B" else val / 1000.0- expected_b = _KNOWN_TOTAL_B.get(model, expected_b)rel_diff = abs(parsed - expected_b) / expected_bif rel_diff > 0.10:diff --git a/tests/test_recipe_sizes.py b/tests/test_recipe_sizes.pynew file mode 100644index 00000000..661763fe--- /dev/null+++ b/tests/test_recipe_sizes.py@@ -0,0 +1,177 @@+# Copyright 2026 Soup Authors.+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++"""Recipe declared size validation and base parameter count ratchet (#1161).++Every recipe declared in ``src/soup_cli/recipes/catalog.py`` carries a user-facing+``size`` attribute (printed by ``soup recipes`` and used to assess GPU memory fit).+For sparse MoE models, ``size`` represents total parameters (consistent with+MiniMax M3 at 428B, DeepSeek V3 at 671B, GLM-5.1 at 754B, and Qwen3.5-397B at 397B).++This suite asserts that every recipe with an anonymously resolvable base model+has a declared ``size`` that matches the parameter count recorded in+``tests/fixtures/recipe_base_architectures.json`` within a tolerance band+[0.70x .. 1.15x].+"""++from __future__ import annotations++import dataclasses+import json+import re+from pathlib import Path++import pytest+import yaml++from soup_cli.recipes.catalog import RECIPES++_FIXTURE_PATH = (+ Path(__file__).resolve().parent / "fixtures" / "recipe_base_architectures.json"+)++#: Bases that have no safetensors metadata on the Hugging Face Hub.+EXCLUDED_SIZE_BASES = {+ "BioMistral/BioMistral-7B",+ "baichuan-inc/Baichuan2-13B-Chat",+ "mistralai/Mistral-Large-3-675B-Instruct-2512",+ "mistralai/Pixtral-12B-2409",+ "nvidia/Nemotron-4-340B-Instruct",+}++#: Recipes whose size is explicitly declared as "N/A" (e.g. reasoning wrappers+#: or unreleased models). Pinned by name.+KNOWN_NA_SIZE_RECIPES = {+ "deepseek-ocr-sft",+ "deepseek-v3-reasoning",+ "deepseek-v4-flash-dpo",+ "deepseek-v4-flash-grpo",+ "deepseek-v4-flash-sft",+ "deepseek-v4-pro-dpo",+ "deepseek-v4-pro-grpo",+ "deepseek-v4-pro-sft",+ "kimi-k2-sft",+ "kimi-k2-thinking-grpo",+ "paddle-ocr-sft",+ "qwen-image-sft",+ "ra-dit-retriever",+}++#: Tolerance band for declared parameter ratio: 0.70x to 1.15x.+_MIN_SIZE_RATIO = 0.70+_MAX_SIZE_RATIO = 1.15+++def parse_size(size_str: str) -> float | None:+ """Parse human-readable size string (e.g., '8B', '300M', '1T') to parameter count."""+ if not size_str or size_str == "N/A":+ return None+ match = re.match(r"^([\d\.]+)\s*([MBT])$", size_str.strip())+ if not match:+ return None+ val, unit = float(match.group(1)), match.group(2)+ multiplier = {"M": 1e6, "B": 1e9, "T": 1e12}[unit]+ return val * multiplier+++def _load_base_architectures() -> dict[str, dict]:+ return json.loads(_FIXTURE_PATH.read_text(encoding="utf-8"))+++def size_problems(recipes, arch):+ """Every recipe whose label disagrees with its base, and how many were compared."""+ problems, checked = [], 0+ for name, meta in recipes.items():+ base = (yaml.safe_load(meta.yaml_str) or {}).get("base")+ if base in EXCLUDED_SIZE_BASES:+ continue+ if meta.size == "N/A":+ if name not in KNOWN_NA_SIZE_RECIPES:+ problems.append(f"{name}: size 'N/A' is not declared in KNOWN_NA_SIZE_RECIPES")+ continue+ declared = parse_size(meta.size)+ if declared is None:+ problems.append(f"{name}: size {meta.size!r} is not a total parameter count like '35B'")+ continue+ actual = arch.get(base, {}).get("parameters")+ if actual is None:+ problems.append(+ f"{name}: base {base} has no recorded parameter count and is not excluded"+ )+ continue+ checked += 1+ ratio = declared / actual+ if not _MIN_SIZE_RATIO <= ratio <= _MAX_SIZE_RATIO:+ problems.append(f"{name}: declared {meta.size} vs {actual:,} on {base} ({ratio:.3f}x)")+ return problems, checked+++def test_every_recipe_label_matches_its_base():+ problems, checked = size_problems(RECIPES, _load_base_architectures())+ assert problems == [], "\n".join(problems)+ excluded = sum(+ 1 for m in RECIPES.values()+ if (yaml.safe_load(m.yaml_str) or {}).get("base") in EXCLUDED_SIZE_BASES+ )+ na_count = sum(1 for m in RECIPES.values() if m.size == "N/A")+ assert checked + excluded + na_count == len(RECIPES)++[email protected](("name", "old_label"), [+ ("glm-4.6-sft", "9B"), ("glm-5-sft", "9B"), ("minimax-m2-sft", "9B"),+ ("deepseek-v3-7b-sft", "7B"), ("voxtral-sft", "3B"), ("llama4-scout-17b-sft", "17B"),+ ("qwen2.5-7b-sft", "10B"), # overstated: the upper bound has to bite too+])+def test_the_real_check_rejects_the_old_label(name, old_label):+ mutated = {**RECIPES, name: dataclasses.replace(RECIPES[name], size=old_label)}+ problems, _ = size_problems(mutated, _load_base_architectures())+ assert any(p.startswith(f"{name}:") for p in problems), problems+++def test_a_missing_count_fails_naming_the_recipe():+ arch = _load_base_architectures()+ arch["zai-org/GLM-4.6"].pop("parameters")+ problems, _ = size_problems(RECIPES, arch)+ assert any(+ p.startswith("glm-4.6-sft:") and "no recorded parameter count" in p for p in problems+ ), problems+++def test_every_exclusion_is_live_and_has_no_count():+ arch = _load_base_architectures()+ used = {(yaml.safe_load(m.yaml_str) or {}).get("base") for m in RECIPES.values()}+ assert sorted(set(EXCLUDED_SIZE_BASES) - used) == []+ assert sorted(b for b in EXCLUDED_SIZE_BASES if "parameters" in arch.get(b, {})) == []+++def test_every_known_na_entry_is_live():+ stale = [n for n in KNOWN_NA_SIZE_RECIPES if n not in RECIPES or RECIPES[n].size != "N/A"]+ assert sorted(stale) == []+++def test_the_band_is_pinned():+ assert (_MIN_SIZE_RATIO, _MAX_SIZE_RATIO) == (0.70, 1.15)+++def test_parse_size_valid_and_invalid():+ """Coverage for size parsing helper across supported units and invalid values."""+ assert parse_size("357B") == 357e9+ assert parse_size("754B") == 754e9+ assert parse_size("1.5B") == 1.5e9+ assert parse_size("300M") == 300e6+ assert parse_size("1T") == 1e12+ assert parse_size("N/A") is None+ assert parse_size("") is None+ assert parse_size("invalid") is None+ assert parse_size("12KB") is Nonediff --git a/tests/test_recipes.py b/tests/test_recipes.pyindex 463fea44..f8de608f 100644--- a/tests/test_recipes.py+++ b/tests/test_recipes.py@@ -58,13 +58,15 @@ class TestRecipeCatalog:assert len(results) > 0def test_search_by_size(self):- """search_recipes filters by model size."""- from soup_cli.recipes.catalog import search_recipes+ """search_recipes filters by matching size token against recipe name or model id (#1161)."""+ from soup_cli.recipes.catalog import RECIPES, search_recipesresults = search_recipes(size="7b")assert len(results) > 0+ names_by_recipe = {id(r): n for n, r in RECIPES.items()}for recipe in results:- assert "7b" in recipe.size.lower() or "7b" in recipe.model.lower()+ name = names_by_recipe.get(id(recipe), "")+ assert "7b" in name.lower() or "7b" in recipe.model.lower()def test_search_no_results(self):"""search_recipes returns empty list for no matches."""