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(data): reject unsupported pre-tokenized combinations (#1363)
Samarth Mukhija42c76ca2b997
diff --git a/changelog.d/0.75.1/1363.fixed.md b/changelog.d/0.75.1/1363.fixed.mdnew file mode 100644index 00000000..0256bbda--- /dev/null+++ b/changelog.d/0.75.1/1363.fixed.md@@ -0,0 +1 @@+- **Refuse incompatible pre-tokenized data transformations.** Soup data preprocessing does not apply non-text modality transforms (vision/audio/audio_out), `data.add_new_tokens`, `data.new_special_tokens`, or `data.prompt_strategy` to cached ids, so those combinations are refused at config load (#1273 by @Samearth17 in #1363)diff --git a/docs/data.md b/docs/data.mdindex b584a69e..23a6e281 100644--- a/docs/data.md+++ b/docs/data.md@@ -894,7 +894,6 @@ reports them as ignored.**AOT preprocessing:**-```bash# Tokenize once, reuse the cache across runs.soup data preprocess soup.yaml --output ./.soup-tokenized@@ -905,6 +904,12 @@ soup data preprocess soup.yaml --output ./.soup-tokenized# tokenized_path: ./.soup-tokenized/<16-char-cache-key>```+Pre-tokenized caches contain the ids produced by soup data preprocessing.+Because preprocessing does not apply a non-text modality (`vision`, `audio`,+or `audio_out`), `data.add_new_tokens`, `data.new_special_tokens`, or+`data.prompt_strategy`, those combinations are refused at config load instead+of being silently skipped.+**Document ingestion (PDF / DOCX / MD / TXT → JSONL):**```bashdiff --git a/src/soup_cli/config/schema.py b/src/soup_cli/config/schema.pyindex 0cb8f45a..1042b137 100644--- a/src/soup_cli/config/schema.py+++ b/src/soup_cli/config/schema.py@@ -982,11 +982,26 @@ class DataConfig(BaseModel):# tokenized_path is meaningful regardless of format (Axolotl `empty`# type expects the cache to be the source of truth). But the# pre_tokenized format implies the path must be set.- if self.format == "pre_tokenized" and not self.tokenized_path:- raise ValueError(- "format='pre_tokenized' requires data.tokenized_path to point "- "at a cache directory produced by `soup data preprocess`."- )+ if self.format == "pre_tokenized":+ if not self.tokenized_path:+ raise ValueError(+ "format='pre_tokenized' requires data.tokenized_path to point "+ "at a cache directory produced by `soup data preprocess`."+ )+ conflicts = []+ if self.add_new_tokens:+ conflicts.append("data.add_new_tokens")+ if self.new_special_tokens:+ conflicts.append("data.new_special_tokens")+ if self.prompt_strategy:+ conflicts.append("data.prompt_strategy")+ if conflicts:+ raise ValueError(+ "format='pre_tokenized' cannot be combined with "+ + ", ".join(conflicts)+ + "; soup data preprocess never applies it, so the cached ids "+ "do not contain it. Remove it, or train from the source format."+ )return self@field_validator("remove_unused_columns", mode="after")@@ -4963,6 +4978,16 @@ class SoupConfig(BaseModel):)return self+ @model_validator(mode="after")+ def _validate_v042_pre_tokenized_modality(self) -> "SoupConfig":+ if self.data.format == "pre_tokenized" and self.modality != "text":+ raise ValueError(+ "data.format='pre_tokenized' cannot be combined with "+ f"modality={self.modality!r}; soup data preprocessing does not "+ "apply modality transforms to cached ids"+ )+ return self+@model_validator(mode="after")def _validate_quest_first_slice(self) -> "SoupConfig":"""Keep #674 on the one route supported by the measured prototype."""diff --git a/src/soup_cli/utils/data_pipeline.py b/src/soup_cli/utils/data_pipeline.pyindex c3943cf1..bc217215 100644--- a/src/soup_cli/utils/data_pipeline.py+++ b/src/soup_cli/utils/data_pipeline.py@@ -263,14 +263,12 @@ NOT_PREPROCESS_KEY_FIELDS: Mapping[str, str] = types.MappingProxyType({"video_fps": "no runtime code reads it (staged, #808)","video_maxlen": "no runtime code reads it (staged, #808)","add_new_tokens": (- "preprocess tokenizes with the base tokenizer and never adds these "- "tokens (the live path does, in apply_vocab_expansion), so the cached ids "- "do not depend on it"+ "pre_tokenized mode rejects this combination: preprocessing tokenizes "+ "with the base tokenizer and never applies live vocabulary expansion"),"new_special_tokens": (- "preprocess tokenizes with the base tokenizer and never adds these "- "tokens (the live path does, in apply_vocab_expansion), so the cached ids "- "do not depend on it"+ "pre_tokenized mode rejects this combination for the same reason: cached "+ "ids cannot include live special-token expansion"),"resize_vocab": "no runtime code reads it","extend_conversation": "no runtime code reads it",@@ -280,8 +278,8 @@ NOT_PREPROCESS_KEY_FIELDS: Mapping[str, str] = types.MappingProxyType({"False (#759)"),"prompt_strategy": (- "applied by the live SFT formatter only; preprocess renders messages "- "directly and never calls it"+ "pre_tokenized mode rejects this combination because preprocessing "+ "never applies the live prompt formatter"),"forget_set": "read by task: unlearn only, which never loads a preprocess cache","retain_set": "read by task: unlearn only, which never loads a preprocess cache",diff --git a/tests/test_v0420.py b/tests/test_v0420.pyindex 2789ee5a..a8a42965 100644--- a/tests/test_v0420.py+++ b/tests/test_v0420.py@@ -153,6 +153,44 @@ class TestPartANewFormats:with pytest.raises(Exception, match="tokenized_path"):DataConfig(train="data.jsonl", format="pre_tokenized")+ @pytest.mark.parametrize(+ ("field", "value"),+ [+ ("add_new_tokens", ["<x>"]),+ ("new_special_tokens", ["<x>"]),+ ("prompt_strategy", "pkg:fn"),+ ],+ )+ def test_pre_tokenized_rejects_live_text_transform(self, field, value):+ with pytest.raises(+ Exception,+ match=fr"pre_tokenized.*data\.{field}.*cached ids do not contain it",+ ):+ DataConfig(+ train="data.jsonl",+ format="pre_tokenized",+ tokenized_path="./cache",+ **{field: value},+ )++ @pytest.mark.parametrize("modality", ["vision", "audio", "audio_out"])+ def test_pre_tokenized_rejects_non_text_modality(self, modality):+ with pytest.raises(+ Exception,+ match=fr"pre_tokenized.*modality='{modality}'",+ ):+ load_config_from_string(+ f"""+base: x/y+task: sft+modality: {modality}+data:+ train: ./data.jsonl+ format: pre_tokenized+ tokenized_path: ./cache+"""+ )+# ---------------------------------------------------------------------------# Part B — Remote loading allowlist + streaming + sharding