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(config): refuse lora.r: 0 on task: pretrain, and LLaMA Pro on pretrain (#1813) (#1875)
Abdulwaarith Zakariyya287c186cfa89
diff --git a/changelog.d/0.76.0/1783.fixed.md b/changelog.d/0.76.0/1783.fixed.mdindex 98398cb1..fb11d0cd 100644--- a/changelog.d/0.76.0/1783.fixed.md+++ b/changelog.d/0.76.0/1783.fixed.md@@ -3,7 +3,7 @@blocks again, so only adapters on the original layers trained while theappended blocks stayed the identity. The error names `expand_layers`,`freeze_trainable_layers` and `lora.r` and points to `lora.r: 0` with- `quantization: none`; on `task: pretrain`, which has no `lora.r: 0`, it says- the recipe needs `task: sft`. The LLaMA Pro examples in+ `quantization: none`; `task: pretrain`, which has no `lora.r: 0`, gets the+ `expand_layers` scope refusal instead (#1813). The LLaMA Pro examples in`docs/peft-and-efficiency.md` and `docs/training.md` now set `lora.r: 0`, and`docs/training.md` now says the expansion runs before `get_peft_model`.diff --git a/changelog.d/0.76.0/1875.fixed.md b/changelog.d/0.76.0/1875.fixed.mdnew file mode 100644index 00000000..0c67f5b6--- /dev/null+++ b/changelog.d/0.76.0/1875.fixed.md@@ -0,0 +1,10 @@+- **`task: pretrain` with `lora.r: 0` is refused at config load, and so is `training.expand_layers` (LLaMA Pro) on `task: pretrain` (#1813 by @abdulwaarith0 in #1875).**+ The pretrain trainer always attaches a LoRA adapter, so a rank of 0 loaded+ and then failed inside peft (or unsloth) when training started, with an error+ that named neither Soup nor the field. The refusal names `lora.r` and the+ task, and points to `lora.r >= 1`, LISA or `task: sft`. LISA keeps accepting+ `lora.r: 0` on pretrain, since it attaches no adapter and trains as before.+ LLaMA Pro had no pretrain route that trained the appended blocks (a rank+ freezes them again, #1326), so the `expand_layers` scope check now refuses+ `task: pretrain` with the `task: sft` recipe. `docs/peft-and-efficiency.md`+ and `docs/training.md` say so.diff --git a/docs/peft-and-efficiency.md b/docs/peft-and-efficiency.mdindex 755463bf..8f19fd15 100644--- a/docs/peft-and-efficiency.md+++ b/docs/peft-and-efficiency.md@@ -186,7 +186,7 @@ training:**What happens at trainer start.** Soup deep-copies the last `expand_layers` decoder blocks, zero-inits each clone's residual projections (`mlp.down_proj` + `self_attn.o_proj`) so the appended block initially acts as identity, appends them to `model.model.layers`, and updates `config.num_hidden_layers`. `freeze_trainable_layers` must equal `expand_layers`: it freezes every parameter except the appended blocks, the canonical LLaMA Pro "train only new blocks" recipe. It does not select the top-N or bottom-N layers, and any other value, including `0` or a negative one, is refused at config load.-**Scope.** Works on `task: sft` with `backend: transformers`, `modality: text`, `quantization: none` and `lora.r: 0`. A LoRA rank is refused together with `expand_layers` ([#1326](https://github.com/MakazhanAlpamys/Soup/issues/1326)): the expansion runs before `get_peft_model`, which freezes every non-adapter parameter again, appended blocks included, so only adapters on the original layers would train. `task: pretrain` has no `lora.r: 0` route: a rank is refused at config load, and `lora.r: 0` loads but then fails inside peft at trainer start ([#1813](https://github.com/MakazhanAlpamys/Soup/issues/1813)), so the recipe needs `task: sft`. Other tasks, backends and modalities, and a quantized base, are refused at config load. No other trainer applies the expansion, and the appended blocks are only supported on an unquantized base. Bounds: `expand_layers ∈ [1, 64]`. Over-expansion (more new blocks than the base has layers) silently clamps to the base layer count. Non-Llama-shaped architectures (e.g. Falcon's `dense_4h_to_h`) emit a `warnings.warn` because the residual zero-init heuristic only matches the standard `down_proj` / `o_proj` names — the appended blocks are still appended + trainable, but lose the identity-init guarantee.+**Scope.** Works on `task: sft` with `backend: transformers`, `modality: text`, `quantization: none` and `lora.r: 0`. A LoRA rank is refused together with `expand_layers` ([#1326](https://github.com/MakazhanAlpamys/Soup/issues/1326)): the expansion runs before `get_peft_model`, which freezes every non-adapter parameter again, appended blocks included, so only adapters on the original layers would train. `task: pretrain` is refused at config load whatever the rank ([#1813](https://github.com/MakazhanAlpamys/Soup/issues/1813)): a rank would freeze the appended blocks again, and the pretrain trainer has no `lora.r: 0` branch, so the recipe needs `task: sft`. Other tasks, backends and modalities, and a quantized base, are refused at config load. No other trainer applies the expansion, and the appended blocks are only supported on an unquantized base. Bounds: `expand_layers ∈ [1, 64]`. Over-expansion (more new blocks than the base has layers) silently clamps to the base layer count. Non-Llama-shaped architectures (e.g. Falcon's `dense_4h_to_h`) emit a `warnings.warn` because the residual zero-init heuristic only matches the standard `down_proj` / `o_proj` names — the appended blocks are still appended + trainable, but lose the identity-init guarantee.## Optimizer & PEFT Zoodiff --git a/docs/training.md b/docs/training.mdindex 5f6ae406..696b256a 100644--- a/docs/training.md+++ b/docs/training.md@@ -309,6 +309,13 @@ decides what trains. It cannot be combined with layer streaming: streaming keepsthe decoder on the meta device and trains only the adapter, so there would benothing to full fine-tune.+`task: pretrain` refuses `lora.r: 0` at config load+([#1813](https://github.com/MakazhanAlpamys/Soup/issues/1813)): its trainer+always attaches a LoRA adapter, so a rank of 0 would only fail inside peft when+training starts. To train the base weights there, use LISA (`lisa_enabled: true`),+which trains a rotating set of whole layers without an adapter and so still+accepts `lora.r: 0`, or switch to `task: sft`.+`freeze_layers` / `freeze_ratio` **do** stay legal with `r: 0` — "traineverything above layer N" is a real technique — and the trainer respectswhatever they froze instead of silently unfreezing it. If they leave nothing@@ -2123,8 +2130,9 @@ the trained router, see `soup serve --mole` in [Serving and Export](serving-and-## Architecture Knobs — Mixture-of-Depths, LLaMA Pro, LongLoRA-Two architecture transforms that were schema-only are now live for SFT / Pretrain on-Llama / Qwen / Mistral. Both apply at trainer setup:+Two architecture transforms that were schema-only are now live on Llama / Qwen / Mistral:+Mixture-of-Depths on SFT and pretrain, LLaMA Pro on SFT only+([#1813](https://github.com/MakazhanAlpamys/Soup/issues/1813)). Both apply at trainer setup:```yamltraining:diff --git a/src/soup_cli/config/schema.py b/src/soup_cli/config/schema.pyindex a5662be0..203f021a 100644--- a/src/soup_cli/config/schema.py+++ b/src/soup_cli/config/schema.py@@ -5034,25 +5034,44 @@ class SoupConfig(BaseModel):@model_validator(mode="after")def _validate_expand_layers_scope(self) -> "SoupConfig":- """#1325 - ``training.expand_layers`` (LLaMA Pro) is wired only in the- transformers text SFT/pretrain ``_setup_transformers`` paths. Every- other task/backend/modality accepts the fields and then silently- trains the unexpanded model, so refuse at load with the actual- task/backend/modality in the message."""+ """#1325 - ``training.expand_layers`` (LLaMA Pro) trains the appended+ blocks only in the transformers text SFT ``_setup_transformers`` path+ (with ``lora.r: 0``, #1326). Every other task/backend/modality accepts+ the fields and then silently trains the unexpanded model, so refuse at+ load with the actual task/backend/modality in the message.++ #1813 - ``task: pretrain`` on transformers text runs the expansion too,+ but has no route that trains the new blocks: a LoRA rank freezes them+ again (#1326) and its trainer has no ``lora.r: 0`` branch. It is refused+ here, whatever the rank, and only there does the message name the sft+ recipe: the unsloth pretrain path never expands, and mlx or another+ modality has no such recipe."""tcfg = self.trainingif tcfg.expand_layers is None:return selfif not (- self.task in {"sft", "pretrain"}+ self.task == "sft"and self.backend == "transformers"and self.modality == "text"):+ fix = "Remove expand_layers and freeze_trainable_layers."+ if (+ self.task == "pretrain"+ and self.backend == "transformers"+ and self.modality == "text"+ ):+ fix = (+ "The pretrain trainer runs the expansion, but a LoRA rank "+ "freezes the appended blocks again and it has no lora.r: 0 "+ "branch to train them. Use task: sft with lora.r: 0 and "+ "quantization: none, or remove expand_layers and "+ "freeze_trainable_layers."+ )raise ValueError(- "training.expand_layers (LLaMA Pro) is only wired for task "- "sft/pretrain on backend transformers with modality text; got "- f"task={self.task!r}, backend={self.backend!r}, "- f"modality={self.modality!r}. Remove expand_layers and "- "freeze_trainable_layers."+ "training.expand_layers (LLaMA Pro) only trains the appended "+ "blocks on task sft with backend transformers and modality "+ f"text; got task={self.task!r}, backend={self.backend!r}, "+ f"modality={self.modality!r}. {fix}")return self@@ -5088,7 +5107,8 @@ class SoupConfig(BaseModel):identity (their zero-initialised ``o_proj``/``down_proj`` are frozen), soonly the original layers learn. Route 1 of the ruling: refuse thecombination; ``lora.r: 0`` trains the new blocks directly, and is- available on ``task: sft`` only.+ available on ``task: sft`` only. Only ``task: sft`` reaches this check:+ ``_validate_expand_layers_scope`` refuses every other task first (#1813)."""tcfg = self.trainingif tcfg.expand_layers is None or tcfg.lora.r == 0:@@ -5103,23 +5123,14 @@ class SoupConfig(BaseModel):# their own validators. Let that message speak: lora.r: 0 would not# make such a config load.return self- fields = (+ raise ValueError(f"training.expand_layers: {tcfg.expand_layers} with "f"training.freeze_trainable_layers: {tcfg.freeze_trainable_layers} "f"(LLaMA Pro) cannot be combined with LoRA (training.lora.r: "f"{tcfg.lora.r}). get_peft_model runs after the block expansion and ""freezes the appended blocks again, so only adapters on the original "- "layers would train. "- )- if self.task == "pretrain":- raise ValueError(- fields + "Training only the new blocks needs lora.r: 0, which "- "task: pretrain does not support, so this recipe needs task: sft "- "with lora.r: 0 and quantization: none."- )- raise ValueError(- fields + "To train only the new blocks, set lora.r: 0 with "- "quantization: none."+ "layers would train. To train only the new blocks, set lora.r: 0 "+ "with quantization: none.")@model_validator(mode="after")@@ -6410,9 +6421,32 @@ class SoupConfig(BaseModel):do pass the rank straight to peft keep their existing behaviour(peft's "`r` should be a positive integer value") rather than gaininga new refusal this issue never measured.++ #1813 measured ``task: pretrain``: its trainer has no ``r == 0`` branch,+ so the rank reaches ``get_peft_model`` (transformers) or unsloth's+ ``get_peft_model`` and setup fails. It is refused here. LISA is exempt:+ its pretrain path attaches no adapter and never reads the rank, so+ ``lisa_enabled`` with ``lora.r: 0`` trains today. Streaming and MLX+ refuse pretrain in their own validators, so their message wins."""tcfg = self.training- if tcfg.lora.r != 0 or self.task not in ("sft", "embedding"):+ if tcfg.lora.r != 0:+ return self+ if (+ self.task == "pretrain"+ and not tcfg.lisa_enabled+ and not tcfg.stream_layers+ and self.backend != "mlx"+ ):+ raise ValueError(+ "training.lora.r=0 (full fine-tuning) is not supported with "+ "task='pretrain': its trainer always attaches a LoRA adapter, so "+ "a rank of 0 fails inside peft (or unsloth) when training starts. "+ "Use lora.r >= 1, lisa_enabled: true (LISA trains whole layers "+ "without an adapter), or task: sft with lora.r: 0 for full "+ "fine-tuning."+ )+ if self.task not in ("sft", "embedding"):return selfif tcfg.stream_layers:# Streaming has its own, more specific refusal (the decoder livesdiff --git a/tests/test_issue1325_expand_layers_scope.py b/tests/test_issue1325_expand_layers_scope.pyindex 9ec745de..b1b4f1cb 100644--- a/tests/test_issue1325_expand_layers_scope.py+++ b/tests/test_issue1325_expand_layers_scope.py@@ -1,9 +1,11 @@"""Issue #1325: ``training.expand_layers`` must refuse unsupported routes.-LLaMA Pro block expansion is applied only by the transformers text-SFT/pretrain ``_setup_transformers`` paths. Every other task, backend or-modality accepted the fields and trained without them; these tests pin the-load-time refusal and the two accepted routes.+LLaMA Pro block expansion trains the appended blocks only on the transformers+text SFT ``_setup_transformers`` path. Every other task, backend or modality+accepted the fields and trained without them; these tests pin the load-time+refusal and the accepted route. ``task: pretrain`` was accepted until #1813: its+trainer runs the expansion but has no route that trains the new blocks, so it+is now refused with the other tasks.Every refused config is first loaded WITHOUT ``expand_layers``, so a refusalcan only come from ``expand_layers`` and not from something else wrong with@@ -20,7 +22,7 @@ import pytestfrom soup_cli.config.loader import load_config_from_stringfrom soup_cli.config.schema import SoupConfig-_SUPPORTED_TASKS = ("sft", "pretrain")+_SUPPORTED_TASKS = ("sft",)_ALL_TASKS = typing.get_args(SoupConfig.model_fields["task"].annotation)_OTHER_TASKS = tuple(task for task in _ALL_TASKS if task not in _SUPPORTED_TASKS)@@ -62,8 +64,9 @@ def _yaml(task, backend="transformers", modality=None, expand=True):def test_the_task_list_comes_from_the_schema():- assert len(_OTHER_TASKS) == len(_ALL_TASKS) - 2+ assert len(_OTHER_TASKS) == len(_ALL_TASKS) - 1assert "dpo" in _OTHER_TASKS and "sft" not in _OTHER_TASKS+ assert "pretrain" in _OTHER_TASKS # #1813@pytest.mark.parametrize("task", _OTHER_TASKS)diff --git a/tests/test_issue1326_llama_pro_lora_refused.py b/tests/test_issue1326_llama_pro_lora_refused.pyindex ce386447..33aefd1f 100644--- a/tests/test_issue1326_llama_pro_lora_refused.py+++ b/tests/test_issue1326_llama_pro_lora_refused.py@@ -4,7 +4,9 @@blocks, then ``get_peft_model`` freezes every non-adapter parameter again,appended blocks included, and puts adapters on the original layers. The ruling(route 1) refuses ``expand_layers`` together with a LoRA rank at config load and-points to ``lora.r: 0``, which ``task: pretrain`` does not have.+points to ``lora.r: 0``. ``task: pretrain`` has no ``lora.r: 0``, and since #1813 it+gets the ``expand_layers`` scope refusal before this check (see+``test_pretrain_full_finetune_refusal.py``)."""from __future__ import annotations@@ -32,7 +34,7 @@ def _config(task: str, lora: str = "") -> str:)[email protected]("task", ["sft", "pretrain"])[email protected]("task", ["sft"])@pytest.mark.parametrize(("lora", "rank"),[("", 64), (" lora:\n r: 8\n", 8)],@@ -48,10 +50,9 @@ def test_a_lora_rank_with_llama_pro_is_refused(task, lora, rank):assert "freezes the appended blocks again" in messageassert "lora.r: 0" in messageassert "quantization: none" in message- if task == "pretrain":- assert "needs task: sft" in message- else:- assert "needs task: sft" not in message+ # The pretrain advice (#1813) lives in the scope check and must not leak into this message.+ assert "needs task: sft" not in message+ assert "pretrain" not in message@pytest.mark.parametrize(diff --git a/tests/test_issue1409_freeze_equals_expand.py b/tests/test_issue1409_freeze_equals_expand.pyindex c530a66d..81068442 100644--- a/tests/test_issue1409_freeze_equals_expand.py+++ b/tests/test_issue1409_freeze_equals_expand.py@@ -27,7 +27,10 @@ def _load(task, expand, freeze):)[email protected]("task", ["sft", "pretrain"])+# #1813: task: pretrain is outside the expand_layers scope, so only sft loads. The+# #1409 check runs before the scope check, so the refusals below still name the+# freeze value on pretrain too.[email protected]("task", ["sft"])def test_freeze_equal_to_expand_loads(task):cfg = _load(task, expand=4, freeze=4)assert cfg.training.expand_layers == 4diff --git a/tests/test_pretrain_full_finetune_refusal.py b/tests/test_pretrain_full_finetune_refusal.pynew file mode 100644index 00000000..de9b3fcc--- /dev/null+++ b/tests/test_pretrain_full_finetune_refusal.py@@ -0,0 +1,189 @@+"""Issue #1813: ``task: pretrain`` with ``lora.r: 0`` is refused at config load.++``PretrainTrainerWrapper`` has no ``r == 0`` branch: the transformers path builds+a LoRA config and calls ``get_peft_model`` (peft: "`r` should be a positive+integer value"), and the unsloth path passes the rank to unsloth's+``get_peft_model``. Route (a) of the ruling refuses the config at load instead.+LISA is the exception: its pretrain path attaches no adapter and never reads the+rank, so ``lisa_enabled`` with ``lora.r: 0`` trains today and keeps loading.++The same change drops ``task: pretrain`` from the ``expand_layers`` scope: with a+rank the appended blocks are frozen again (#1326) and with ``lora.r: 0`` setup+fails, so no pretrain LLaMA Pro config trains.+"""++from __future__ import annotations++import pytest+import yaml++from soup_cli.config.loader import load_config_from_string++_RANK_ZERO_MESSAGE = "always attaches a LoRA adapter"+_EXPAND = {"expand_layers": 2, "freeze_trainable_layers": 2}+++def _yaml(task="pretrain", backend="transformers", training=None, lora=None, modality=None):+ block = {"quantization": "none", **(training or {})}+ if lora is not None:+ block["lora"] = lora+ top = {+ "base": "org/model",+ "task": task,+ "backend": backend,+ "data": {"train": "train.jsonl"},+ "training": block,+ }+ if modality is not None:+ top["modality"] = modality+ return yaml.safe_dump(top)+++def _refusal(text: str) -> str:+ with pytest.raises(ValueError) as excinfo:+ load_config_from_string(text)+ return " ".join(str(excinfo.value).split())+++ ("backend", "training"),+ [("transformers", {}), ("transformers", {"quantization": "4bit"}), ("unsloth", {})],+ ids=["transformers", "transformers_4bit", "unsloth"],+)+def test_rank_zero_on_pretrain_is_refused_at_load(backend, training):+ # The same config with a rank loads, so the refusal can only come from lora.r: 0.+ load_config_from_string(_yaml(backend=backend, training=training, lora={"r": 4}))+ message = _refusal(_yaml(backend=backend, training=training, lora={"r": 0}))+ assert "training.lora.r=0" in message+ assert "task='pretrain'" in message+ assert _RANK_ZERO_MESSAGE in message+ assert "lora.r >= 1" in message+ assert "lisa_enabled: true" in message+ assert "task: sft with lora.r: 0" in message+++def test_lisa_with_rank_zero_still_loads_on_pretrain():+ cfg = load_config_from_string(_yaml(training={"lisa_enabled": True}, lora={"r": 0}))+ assert cfg.training.lisa_enabled is True+ assert cfg.training.lora.r == 0+++ ("over", "named"),+ [+ ({"backend": "mlx"}, "MLX backend only ships SFT"),+ (+ {"training": {"stream_layers": True, "batch_size": 1}},+ "training.stream_layers supports task",+ ),+ ],+ ids=["mlx", "stream_layers"],+)+def test_routes_that_refuse_pretrain_outright_keep_their_own_message(over, named):+ message = _refusal(_yaml(lora={"r": 0}, **over))+ assert named in message+ assert _RANK_ZERO_MESSAGE not in message++[email protected]("task", ["sft", "embedding"])+def test_rank_zero_still_loads_where_it_means_full_fine_tuning(task):+ cfg = load_config_from_string(_yaml(task=task, lora={"r": 0}))+ assert cfg.training.lora.r == 0+++def test_pretrain_with_a_rank_still_loads():+ cfg = load_config_from_string(_yaml(lora={"r": 4}))+ assert cfg.training.lora.r == 4+++ ("training", "lora"),+ [({}, {"r": 0}), ({}, {"r": 8}), ({}, None), ({"lisa_enabled": True}, {"r": 0})],+ ids=["rank_zero", "explicit_rank", "default_rank", "lisa"],+)+def test_llama_pro_on_pretrain_gets_the_scope_refusal(training, lora):+ message = _refusal(_yaml(training={**_EXPAND, **training}, lora=lora))+ assert "training.expand_layers (LLaMA Pro)" in message+ assert "task='pretrain'" in message+ assert "no lora.r: 0 branch" in message+ assert "task: sft with lora.r: 0 and quantization: none" in message+ # One message per config: neither the #1326 refusal nor the rank-zero one.+ assert "cannot be combined with LoRA" not in message+ assert _RANK_ZERO_MESSAGE not in message+++def test_llama_pro_scope_refusal_on_other_tasks_does_not_mention_pretrain():+ message = _refusal(_yaml(task="dpo", training=_EXPAND, lora={"r": 0}))+ assert "task='dpo'" in message+ assert "Remove expand_layers and freeze_trainable_layers." in message+ assert "pretrain" not in message+++ ("backend", "modality"),+ [("unsloth", "text"), ("mlx", "text"), ("transformers", "vision")],+ ids=["unsloth", "mlx", "vision"],+)+def test_llama_pro_on_pretrain_elsewhere_gets_the_generic_scope_refusal(backend, modality):+ """Only pretrain on transformers text runs the expansion, so only there does the message+ describe it and name the sft recipe: the unsloth pretrain path never expands, and mlx or+ another modality has no such recipe."""+ message = _refusal(_yaml(backend=backend, training=_EXPAND, lora={"r": 0}, modality=modality))+ assert "training.expand_layers (LLaMA Pro)" in message+ assert f"backend='{backend}'" in message and f"modality='{modality}'" in message+ assert "Remove expand_layers and freeze_trainable_layers." in message+ assert "pretrain trainer runs the expansion" not in message+ assert "task: sft with lora.r: 0" not in message+++def test_lisa_with_rank_zero_trains_without_an_adapter(tmp_path, monkeypatch):+ """Through the real ``PretrainTrainerWrapper.setup()`` and one epoch on the tiny+ Llama (#341 fixture): the LISA path never reaches peft, so the rank is unused."""+ from tests.test_issue341_seed_and_fullft import _requires_train_extra, _tiny_llama_dir++ _requires_train_extra()+ import torch++ from soup_cli.trainer.pretrain import PretrainTrainerWrapper++ base = _tiny_llama_dir(tmp_path)+ monkeypatch.chdir(tmp_path)+ cfg = load_config_from_string(+ yaml.safe_dump(+ {+ "base": base,+ "task": "pretrain",+ "data": {"train": "train.jsonl", "max_length": 64},+ "training": {+ "quantization": "none",+ "epochs": 1,+ "batch_size": 1,+ "gradient_accumulation_steps": 1,+ "lr": 1e-3,+ "warmup_ratio": 0.0,+ "logging_steps": 100,+ "save_steps": 10_000,+ "lisa_enabled": True,+ "lora": {"r": 0},+ },+ "output": str(tmp_path / "out"),+ }+ )+ )+ wrapper = PretrainTrainerWrapper(cfg, device="cpu")+ wrapper.setup({"train": [{"text": "the cat sat on the mat"}] * 8})++ assert not hasattr(wrapper.model, "peft_config")+ before = {+ name: param.detach().clone()+ for name, param in wrapper.model.named_parameters()+ if param.requires_grad+ }+ assert before+ wrapper.trainer.train()+ changed = [+ name+ for name, param in wrapper.model.named_parameters()+ if name in before and not torch.equal(param.detach(), before[name])+ ]+ assert changeddiff --git a/tests/test_v0410_part_c.py b/tests/test_v0410_part_c.pyindex d8ebda6d..1d78a917 100644--- a/tests/test_v0410_part_c.py+++ b/tests/test_v0410_part_c.py@@ -212,12 +212,19 @@ class TestSchemaBlockExpansion:with pytest.raises(ValidationError, match="requires training.quantization: none"):_sft(expand_layers=2, freeze_trainable_layers=2, load_in_8bit=True)- @pytest.mark.parametrize("task", ["sft", "pretrain"])- def test_default_quantization_refused_through_the_loader(self, task):+ @pytest.mark.parametrize(+ "task,refusal",+ [+ ("sft", "requires training.quantization: none"),+ # #1813: pretrain is outside the expand_layers scope, so the scope refusal comes first.+ ("pretrain", "only trains the appended blocks on task sft"),+ ],+ )+ def test_default_quantization_refused_through_the_loader(self, task, refusal):# #1237's acceptance box: task sft AND pretrain, through the loader `soup train` uses.from soup_cli.config.loader import load_config_from_string- with pytest.raises(ValueError, match="requires training.quantization: none"):+ with pytest.raises(ValueError, match=refusal):load_config_from_string("base: org/model\n"f"task: {task}\n"@@ -229,7 +236,7 @@ class TestSchemaBlockExpansion:"task,backend", [("dpo", "transformers"), ("sft", "mlx"), ("sft", "unsloth")])def test_scope_refusal_precedes_the_quantization_refusal(self, task, backend):- with pytest.raises(ValidationError, match="only wired for task sft/pretrain"):+ with pytest.raises(ValidationError, match="only trains the appended blocks on task sft"):SoupConfig(base="fake-org/fake-model",task=task,