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
feat(recipes): add deepseek-v4-pro-dpo and deepseek-v4-pro-grpo (#850) (#1297)
Nurkhan Esenbekf5edc4f4eb46
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 3e6260b6..fd3aaad1 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -123,7 +123,7 @@ src/soup_cli/experiment/ - SQLite experiment trackingeval/ - Eval platform (custom tasks, LLM judge, human eval, leaderboard)migrate/ - Config migration (LLaMA-Factory, Axolotl, Unsloth)- recipes/ - Ready-made configs for popular models (172 recipes)+ recipes/ - Ready-made configs for popular models (174 recipes)autopilot/ - Zero-config decision engine (v0.25.0)registry/ - Model Registry (hashing, store, diff, attach) (v0.26.0 + v0.33.0)cans/ - Shareable .can artifact format + run/publish orchestrator (v0.26.0 + v0.33.0)diff --git a/changelog.d/0.75.1/1297.added.md b/changelog.d/0.75.1/1297.added.mdnew file mode 100644index 00000000..a5dfcdbc--- /dev/null+++ b/changelog.d/0.75.1/1297.added.md@@ -0,0 +1 @@+- **Added ready-made `deepseek-v4-pro-dpo` and `deepseek-v4-pro-grpo` recipes for deepseek-ai/DeepSeek-V4-Pro (#850 by @kok-o in #1297).** Completes the task trio with the existing SFT sibling over the 1.6T-class flagship MoE architecture (LoRA r32/a64, 4-bit quantization, `moe_lora: true`, `moe_aux_loss_coeff: 0.01`, `gradient_checkpointing: true`). DPO uses `max_length: 4096`, `epochs: 1`, `lr: 5e-6`, and `gradient_accumulation_steps: 32`. GRPO uses `max_length: 8192`, `epochs: 3`, `lr: 1e-5`, and `gradient_accumulation_steps: 16`.diff --git a/docs/commands.md b/docs/commands.mdindex 97e8cf2c..5e1aa09c 100644--- a/docs/commands.md+++ b/docs/commands.md@@ -178,7 +178,7 @@ soup migrate --from llamafactory config.yaml Import config from LLaMA-Factorysoup migrate --from axolotl config.yml Import config from Axolotlsoup migrate --from unsloth notebook.ipynb Import config from Unsloth notebooksoup migrate --from llamafactory c.yaml --dry-run Preview without writing-soup recipes list List all 172 ready-made recipes+soup recipes list List all 174 ready-made recipessoup recipes show llama3.1-8b-sft Print recipe YAMLsoup recipes use llama3.1-8b-sft Copy recipe to soup.yamlsoup recipes search "reasoning" Search by keyword/task/sizediff --git a/docs/performance-and-quantization.md b/docs/performance-and-quantization.mdindex d2bfb14f..a50c9b3b 100644--- a/docs/performance-and-quantization.md+++ b/docs/performance-and-quantization.md@@ -1154,14 +1154,14 @@ Both reject silently-no-op combinations: setting either flag without `moe_lora=t**`moe_lora` on the remaining LoRA tasks (#1099).** #798 left it loading but unread on `ipo`, `bco`, `reward_model`, `ppo` and `embedding`, and `online_dpo` had the same gap. All six build their adapter through the same `build_lora_config` path, so they were wired to the same helper rather than refused. On `embedding` it applies only with `lora.r >= 1`; at `r: 0` that trainer full-fine-tunes and builds no adapter for the flag to select. #1151 closed the remainder: `distill` and `unlearn` build their adapter the same way and are wired to the same helper, and so is `classifier` / `reranker` / `cross_encoder` (one trainer) on its opt-in adapter path. Without `classifier_lora: true` and `lora.r > 0` that trainer full-fine-tunes and builds no adapter, so there the flag is refused at config load; `asr`, which trains only Whisper (no experts), `moe_lora_routing`, which builds no LoRA adapter, and `prm`, which fine-tunes every base parameter, refuse the flag at config load. Two paths refuse it whatever the task: `task: sft` with `modality: vision` or `audio`, whose setup builds its adapter without the MoE step, and `backend: unsloth`. On unsloth the reason depends on the task (#1264): the thirteen tasks with an unsloth setup attach its fixed attention list and never read the flag, while the rest have no unsloth setup at all, so there it is the backend that goes unapplied. Both messages point to `backend: transformers`, where the flag is read. The other `moe_lora` refusals in the same check come first, so `asr`, `prm`, `moe_lora_routing` and SFT vision/audio get one refusal whatever the backend. Every path now either reads `moe_lora` or refuses it, except `backend: mlx`, where it loads and `soup doctor --config` reports it as ignored; a source ratchet keeps a new adapter-building trainer from missing it. `train_router_only` and `moe_expert_quant` require `moe_lora: true`, so on `backend: unsloth` they now fail to load with the same message. `preference` is covered through the trainers it dispatches to, and `tts` through the SFT trainer it subclasses.-**`moe_lora` requires `lora.dropout: 0.0` on a fused-expert MoE.** transformers 5.x keeps a Qwen3-MoE's experts as fused 3-D parameters (`mlp.experts.gate_up_proj`), which peft adapts through `lora.ParamWrapper`, and that wrapper raises `lora.ParamWrapper does not work with lora_dropout != 0.` With the schema default of `0.05` the LoRA attach failed outright, so `moe_lora` did not work on any task — including `sft`. Soup now stops at the attach with a message naming the flag, instead of letting peft's reach the user, and all 31 shipped MoE recipes pin `lora.dropout: 0.0`. The check is made against the loaded model, not at config load: whether the experts are fused depends on the checkpoint and the transformers version, and a model with one module per expert takes dropout normally. A dense base is untouched — there the flag is a no-op.+**`moe_lora` requires `lora.dropout: 0.0` on a fused-expert MoE.** transformers 5.x keeps a Qwen3-MoE's experts as fused 3-D parameters (`mlp.experts.gate_up_proj`), which peft adapts through `lora.ParamWrapper`, and that wrapper raises `lora.ParamWrapper does not work with lora_dropout != 0.` With the schema default of `0.05` the LoRA attach failed outright, so `moe_lora` did not work on any task - including `sft`. Soup now stops at the attach with a message naming the flag, instead of letting peft's reach the user, and all 33 shipped MoE recipes pin `lora.dropout: 0.0`. The check is made against the loaded model, not at config load: whether the experts are fused depends on the checkpoint and the transformers version, and a model with one module per expert takes dropout normally. A dense base is untouched - there the flag is a no-op.**`moe_lora` does not reach every MoE family (measured, v0.75.0).** `get_moe_target_modules` picks module names, and whether peft turns those into adapters on the fused expert parameters depends on the architecture. On tiny stand-ins with transformers 5.16.1 / peft 0.20.0:| family | expert adapters attach | recipes ||---|---|---|| `qwen3_moe` | yes | 11 |-| `deepseek_v3` | yes | 6 |+| `deepseek_v3` | yes | 8 || `glm4_moe` | yes | 3 || `minimax` | **no — attention-only** | 2 (`minimax-m3-sft`, `minimax-m3-dpo`) || `mixtral` | **no — attention-only** | — |diff --git a/docs/serving-and-export.md b/docs/serving-and-export.mdindex ead1091b..af22afc5 100644--- a/docs/serving-and-export.md+++ b/docs/serving-and-export.md@@ -648,7 +648,7 @@ soup ui**Pages:**- **Dashboard** — view all experiment runs, loss charts, system info, multi-run comparison-- **New Training** — create configs from templates or 172 ready-made recipes, validate, start training with live SSE log streaming and progress bar+- **New Training** — create configs from templates or 174 ready-made recipes, validate, start training with live SSE log streaming and progress bar- **Data Explorer** — browse and inspect datasets (JSONL, JSON, CSV, Parquet)- **Model Chat** — chat with streaming responses, configurable temperature/top_p/max_tokens, system prompt, adapter selection, markdown rendering, chat export@@ -657,7 +657,7 @@ soup ui- **Enhanced Metrics** — 2x2 chart grid (loss, LR, grad_norm, throughput) + GPU memory chart, eval results table- **Multi-Run Compare** — overlay loss curves from up to 5 runs side-by-side- **Chat Upgrade** — SSE streaming via proxy, typing indicator, cancel button, markdown renderer (bold, italic, code blocks), chat export as JSON-- **Config Builder** — recipe dropdown (172 recipes), config schema API for dynamic form generation+- **Config Builder** — recipe dropdown (174 recipes), config schema API for dynamic form generationGradient norm is nullable: backends or steps that do not report it store andstream `null`, and the Web UI chart leaves a gap instead of drawing a falsediff --git a/src/soup_cli/recipes/catalog.py b/src/soup_cli/recipes/catalog.pyindex 9f02bd70..ffbee323 100644--- a/src/soup_cli/recipes/catalog.py+++ b/src/soup_cli/recipes/catalog.py@@ -48,7 +48,7 @@ def search_recipes(# ----------------------------------------------------------------------------# Recipe catalog (172 recipes)+# Recipe catalog (174 recipes)# ---------------------------------------------------------------------------RECIPES: Dict[str, RecipeMeta] = {@@ -4524,6 +4524,91 @@ training:moe_aux_loss_coeff: 0.01gradient_checkpointing: true+output: ./output+""",+ ),+ "deepseek-v4-pro-dpo": RecipeMeta(+ model="deepseek-ai/DeepSeek-V4-Pro",+ task="dpo",+ size="N/A",+ tags=(+ "deepseek",+ "deepseek-v4",+ "dpo",+ "alignment",+ "preference",+ "moe",+ "large",+ "multi-gpu",+ ),+ description=(+ "DeepSeek V4 Pro flagship MoE DPO alignment (MIT, 1.6T-class). "+ "Requires multi-node DeepSpeed."+ ),+ yaml_str="""\+base: deepseek-ai/DeepSeek-V4-Pro+task: dpo++data:+ train: ./data/preference_train.jsonl+ format: dpo+ max_length: 4096++training:+ epochs: 1+ lr: 5e-6+ batch_size: 1+ gradient_accumulation_steps: 32+ lora:+ dropout: 0.0 # peft's ParamWrapper refuses dropout on fused MoE experts (#798)+ r: 32+ alpha: 64+ target_modules: auto+ quantization: 4bit+ dpo_beta: 0.1+ moe_lora: true+ moe_aux_loss_coeff: 0.01+ gradient_checkpointing: true++output: ./output+""",+ ),+ "deepseek-v4-pro-grpo": RecipeMeta(+ model="deepseek-ai/DeepSeek-V4-Pro",+ task="grpo",+ size="N/A",+ tags=("deepseek", "deepseek-v4", "grpo", "reasoning", "moe", "large", "multi-gpu"),+ description=(+ "DeepSeek V4 Pro flagship MoE GRPO reasoning training (MIT, 1.6T-class). "+ "Requires multi-node DeepSpeed."+ ),+ yaml_str="""\+base: deepseek-ai/DeepSeek-V4-Pro+task: grpo++data:+ train: ./data/reasoning_train.jsonl+ format: auto+ max_length: 8192++training:+ epochs: 3+ lr: 1e-5+ batch_size: 1+ gradient_accumulation_steps: 16+ lora:+ dropout: 0.0 # peft's ParamWrapper refuses dropout on fused MoE experts (#798)+ r: 32+ alpha: 64+ target_modules: auto+ quantization: 4bit+ grpo_beta: 0.1+ num_generations: 4+ reward_fn: accuracy+ moe_lora: true+ moe_aux_loss_coeff: 0.01+ gradient_checkpointing: true+output: ./output""",),diff --git a/tests/fixtures/recipe_config_snapshots.json b/tests/fixtures/recipe_config_snapshots.jsonindex 6a617b8d..dffae9f3 100644--- a/tests/fixtures/recipe_config_snapshots.json+++ b/tests/fixtures/recipe_config_snapshots.json@@ -520,6 +520,37 @@"training.lr": 0.0001,"training.moe_lora": true},+ "deepseek-v4-pro-dpo": {+ "base": "deepseek-ai/DeepSeek-V4-Pro",+ "data.format": "dpo",+ "data.max_length": 4096,+ "data.train": "./data/preference_train.jsonl",+ "task": "dpo",+ "training.batch_size": 1,+ "training.epochs": 1,+ "training.gradient_accumulation_steps": 32,+ "training.gradient_checkpointing": true,+ "training.lora.alpha": 64,+ "training.lora.dropout": 0.0,+ "training.lora.r": 32,+ "training.lr": 5e-06,+ "training.moe_lora": true+ },+ "deepseek-v4-pro-grpo": {+ "base": "deepseek-ai/DeepSeek-V4-Pro",+ "data.format": "auto",+ "data.max_length": 8192,+ "data.train": "./data/reasoning_train.jsonl",+ "task": "grpo",+ "training.batch_size": 1,+ "training.gradient_accumulation_steps": 16,+ "training.gradient_checkpointing": true,+ "training.lora.alpha": 64,+ "training.lora.dropout": 0.0,+ "training.lora.r": 32,+ "training.lr": 1e-05,+ "training.moe_lora": true+ },"deepseek-v4-pro-sft": {"base": "deepseek-ai/DeepSeek-V4-Pro","data.format": "auto",diff --git a/tests/recipe_count.py b/tests/recipe_count.pyindex 0bcf0a76..c98e7494 100644--- a/tests/recipe_count.py+++ b/tests/recipe_count.py@@ -9,7 +9,7 @@ the catalog, in ``tests/test_recipe_count_is_synced.py``.from __future__ import annotations-EXPECTED_RECIPE_COUNT = 172+EXPECTED_RECIPE_COUNT = 174def recipe_count_hint(actual: int) -> str:diff --git a/tests/test_issue1070_moe_target_modules.py b/tests/test_issue1070_moe_target_modules.pyindex dac6f770..d3584882 100644--- a/tests/test_issue1070_moe_target_modules.py+++ b/tests/test_issue1070_moe_target_modules.py@@ -4,7 +4,7 @@returned ``None`` for everything else, delegating to peft. peft has no defaultfor any MoE ``model_type`` Soup ships a recipe for, so the attach did not fallback -- it raised ``No target_modules passed but also no target_parameters-found``, and every one of the 31 shipped MoE recipes uses ``target_modules:+found``, and every one of the 33 shipped MoE recipes uses ``target_modules:auto``.Measured on peft 0.20 / transformers 5.16.1, shrunk real models on CPU, beforediff --git a/tests/test_issue798_moe_flags_per_task.py b/tests/test_issue798_moe_flags_per_task.pyindex 6b99d39d..17fd9ebf 100644--- a/tests/test_issue798_moe_flags_per_task.py+++ b/tests/test_issue798_moe_flags_per_task.py@@ -343,7 +343,7 @@ class TestShippedConfigs:load_config_from_string(recipe.yaml_str), namedef test_the_moe_recipes_are_the_ones_this_issue_names(self):- """15, not the 8 the issue estimated: 8 dpo + 7 grpo."""+ """17: 9 dpo + 8 grpo (including deepseek-v4-pro-dpo and deepseek-v4-pro-grpo)."""import yamlfrom soup_cli.recipes.catalog import RECIPES@@ -354,7 +354,7 @@ class TestShippedConfigs:training = cfg.get("training") or {}if training.get("moe_lora") and cfg.get("task") in _MOE_TASKS:tasks.append(cfg["task"])- assert sorted(tasks) == ["dpo"] * 8 + ["grpo"] * 7, sorted(tasks)+ assert sorted(tasks) == ["dpo"] * 9 + ["grpo"] * 8, sorted(tasks)diff --git a/tests/test_recipes.py b/tests/test_recipes.pyindex b9b8379c..463fea44 100644--- a/tests/test_recipes.py+++ b/tests/test_recipes.py@@ -689,6 +689,175 @@ class TestDeepSeekV4FlashDpoRecipe:assert len({RECIPES[n].size for n in variants}) == 1+class TestDeepSeekV4ProDpoRecipe:+ """Regression coverage for the deepseek-v4-pro-dpo recipe (#850).++ DeepSeek-V4-Pro shipped SFT (v0.71.24) but no preference variant. The+ model id is pinned on ``RecipeMeta.model`` and on the YAML ``base:`` in+ two separate tests to prevent silent regressions or typos between Pro and Flash.+ """++ RECIPE = "deepseek-v4-pro-dpo"+ MODEL = "deepseek-ai/DeepSeek-V4-Pro"++ def test_recipe_meta_pins_the_model_id(self) -> None:+ """Surface 1: the catalog metadata, read without touching the YAML."""+ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None, f"{self.RECIPE} is missing from the catalog"+ assert recipe.model == self.MODEL+ assert recipe.task == "dpo"++ def test_yaml_base_pins_the_model_id(self) -> None:+ """Surface 2: the YAML body, parsed directly rather than via ``.model``."""+ import yaml++ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None+ parsed = yaml.safe_load(recipe.yaml_str)+ assert parsed["base"] == self.MODEL+ assert parsed["task"] == "dpo"++ def test_recipe_loads_with_expected_dpo_moe_shape(self) -> None:+ """The loaded config, not the source text."""+ from soup_cli.config.loader import load_config_from_string+ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None+ config = load_config_from_string(recipe.yaml_str)++ assert config.base == self.MODEL+ assert config.task == "dpo"+ assert config.data.format == "dpo"+ assert config.data.max_length == 4096+ assert config.training.lr == 5e-6+ assert config.training.batch_size == 1+ assert config.training.gradient_accumulation_steps == 32+ assert config.training.lora.r == 32+ assert config.training.lora.alpha == 64+ assert config.training.lora.dropout == 0.0+ assert config.training.moe_lora is True+ assert config.training.gradient_checkpointing is True+ # Schema default survivors+ assert config.training.dpo_beta == 0.1+ assert config.training.epochs == 1+ assert config.training.moe_aux_loss_coeff == 0.01++ def test_show_and_use_recipe(+ self,+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ ) -> None:+ """The CLI path a user actually takes, run rather than asserted about."""+ show_result = runner.invoke(app, ["recipes", "show", self.RECIPE])+ assert show_result.exit_code == 0+ assert self.MODEL in strip_ansi(show_result.output)++ monkeypatch.chdir(tmp_path)+ use_result = runner.invoke(app, ["recipes", "use", self.RECIPE, "--yes"])+ assert use_result.exit_code == 0+ written = (tmp_path / "soup.yaml").read_text(encoding="utf-8")+ assert self.MODEL in written+ assert "task: dpo" in written++ def test_v4_pro_task_variants_are_three_distinct_entries(self) -> None:+ """The unregister direction, and the shared ``size`` the family declares."""+ from soup_cli.recipes.catalog import RECIPES++ variants = {+ "deepseek-v4-pro-sft": "sft",+ self.RECIPE: "dpo",+ "deepseek-v4-pro-grpo": "grpo",+ }+ for name, task in variants.items():+ assert name in RECIPES, f"{name} is missing from the catalog"+ assert RECIPES[name].model == self.MODEL+ assert RECIPES[name].task == task+ assert len({RECIPES[n].task for n in variants}) == 3+ assert len({RECIPES[n].size for n in variants}) == 1+++class TestDeepSeekV4ProGrpoRecipe:+ """Regression coverage for the deepseek-v4-pro-grpo recipe (#850).++ DeepSeek-V4-Pro shipped SFT (v0.71.24) but no reasoning variant. The+ model id is pinned on ``RecipeMeta.model`` and on the YAML ``base:`` in+ two separate tests.+ """++ RECIPE = "deepseek-v4-pro-grpo"+ MODEL = "deepseek-ai/DeepSeek-V4-Pro"++ def test_recipe_meta_pins_the_model_id(self) -> None:+ """Surface 1: the catalog metadata, read without touching the YAML."""+ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None, f"{self.RECIPE} is missing from the catalog"+ assert recipe.model == self.MODEL+ assert recipe.task == "grpo"++ def test_yaml_base_pins_the_model_id(self) -> None:+ """Surface 2: the YAML body, parsed directly rather than via ``.model``."""+ import yaml++ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None+ parsed = yaml.safe_load(recipe.yaml_str)+ assert parsed["base"] == self.MODEL+ assert parsed["task"] == "grpo"++ def test_recipe_loads_with_expected_grpo_moe_shape(self) -> None:+ """The loaded config, not the source text."""+ from soup_cli.config.loader import load_config_from_string+ from soup_cli.recipes.catalog import get_recipe++ recipe = get_recipe(self.RECIPE)+ assert recipe is not None+ config = load_config_from_string(recipe.yaml_str)++ assert config.base == self.MODEL+ assert config.task == "grpo"+ assert config.data.max_length == 8192+ assert config.training.lr == 1e-5+ assert config.training.batch_size == 1+ assert config.training.gradient_accumulation_steps == 16+ assert config.training.lora.r == 32+ assert config.training.lora.alpha == 64+ assert config.training.lora.dropout == 0.0+ assert config.training.moe_lora is True+ assert config.training.gradient_checkpointing is True+ # Schema default survivors+ assert config.training.grpo_beta == 0.1+ assert config.training.epochs == 3+ assert config.training.num_generations == 4+ assert config.training.reward_fn == "accuracy"+ assert config.training.moe_aux_loss_coeff == 0.01++ def test_show_and_use_recipe(+ self,+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+ ) -> None:+ """The CLI path a user actually takes, run rather than asserted about."""+ show_result = runner.invoke(app, ["recipes", "show", self.RECIPE])+ assert show_result.exit_code == 0+ assert self.MODEL in strip_ansi(show_result.output)++ monkeypatch.chdir(tmp_path)+ use_result = runner.invoke(app, ["recipes", "use", self.RECIPE, "--yes"])+ assert use_result.exit_code == 0+ written = (tmp_path / "soup.yaml").read_text(encoding="utf-8")+ assert self.MODEL in written+ assert "task: grpo" in written++class TestIssue849LargeMoeDpoRecipes:"""Regression coverage for the MiniMax M3 and Mistral Large 3 DPO recipes."""@@ -1745,6 +1914,8 @@ class TestV025NewRecipes:Task-variant for #275 / #846 added 2 (qwen3.6-35b-a3b-dpo, qwen3.6-35b-a3b-grpo) -> 174.Issue #845 added 2 (qwen3.6-27b-dpo, qwen3.6-27b-grpo) -> 176.Issue #825 retires the unusable Falcon-E BitNet training recipe -> 175.+ PR #1112 removes sesame-csm-tts -> 174.+ Issue #850 added 2 (deepseek-v4-pro-dpo, deepseek-v4-pro-grpo) -> 176."""from soup_cli.recipes.catalog import RECIPESfrom tests.recipe_count import EXPECTED_RECIPE_COUNT, recipe_count_hint