Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

chore: retire text left stale by #1827; the size-limits paragraph gets its own heading (#1896)

Alpamys Makazhanfd70fd0c10f1
diff --git a/docs/backends-and-ops.md b/docs/backends-and-ops.md
index 983327a5..e372861f 100644
--- a/docs/backends-and-ops.md
+++ b/docs/backends-and-ops.md
@@ -24,6 +24,8 @@
- [Health Check](#health-check)
- [Version Info](#version-info)
- [Error Handling](#error-handling)
+- [Unknown config keys](#unknown-config-keys)
+- [Config size limits](#config-size-limits)
- [Experiment Tracking](#experiment-tracking)
- [Profiling Extras](#profiling-extras)
- [VS Code Setup (`.vscode/launch.json`)](#vs-code-setup-vscodelaunchjson)
@@ -665,7 +667,10 @@ a scripted or CI-driven sweep fails rather than reporting a grid of arms that ea
for the same reason. A sweep whose swept knob is never applied produces arms that are all
identical, so there is no partially-useful result to preserve by continuing.
-**Size limits.** A config file may be at most 1 MiB, nest mappings and lists at most 100 levels,
+
+## Config size limits
+
+A config file may be at most 1 MiB, nest mappings and lists at most 100 levels,
and expand through anchors, aliases and `<<` merge keys to at most one node per byte plus 10,000.
A file over a limit is refused with a message naming the file and the limit (`soup ship`: 4 MiB).
diff --git a/pyproject.toml b/pyproject.toml
index 624035ad..f9a95925 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -45,9 +45,10 @@ dependencies = [
# floor and its pin together; that test file refuses one without the other.
"typer>=0.15.4,<0.21.0",
# click 8.5.0 drops every positional-argument description from `--help`
- # (its Argument.__init__ overwrites the help typer sets). Imported directly by
- # commands/autopilot.py, utils/argv_redaction.py and utils/exit_codes.py, so
- # declared here. `tests/test_click_argument_help.py` pins the bound.
+ # (its Argument.__init__ overwrites the help typer sets). Imported directly at
+ # run time by commands/autopilot.py, commands/push.py, commands/ship.py and
+ # utils/exit_codes.py (utils/argv_redaction.py names click for type checking
+ # only), so declared here. `tests/test_click_argument_help.py` pins the bound.
"click>=8.0.0,<8.5",
"rich>=13.0.0",
"pydantic>=2.0.0",
diff --git a/src/soup_cli/commands/train.py b/src/soup_cli/commands/train.py
index 1a77ed77..6d0f2047 100644
--- a/src/soup_cli/commands/train.py
+++ b/src/soup_cli/commands/train.py
@@ -948,7 +948,6 @@ def train(
# An unregistered data.chat_template name raises KeyError in the trainer,
# after the model has loaded. Check it before anything is downloaded.
from soup_cli.data.chat_templates import resolve_chat_template
- from soup_cli.utils.terminal import for_terminal
try:
resolve_chat_template(cfg.data.chat_template)
diff --git a/src/soup_cli/utils/mix_proxy.py b/src/soup_cli/utils/mix_proxy.py
index f7942b01..c8f91ace 100644
--- a/src/soup_cli/utils/mix_proxy.py
+++ b/src/soup_cli/utils/mix_proxy.py
@@ -170,7 +170,8 @@ def _render_overlay_yaml(
) -> str:
"""Splice ``data.interleave`` + ``data.train`` into a base YAML.
- We round-trip via ``yaml.safe_load`` / ``yaml.safe_dump`` to defeat any
+ We round-trip via ``load_yaml_limited`` (``yaml.safe_load`` under the shared
+ size, nesting and expansion limits) and ``yaml.safe_dump`` to defeat any
accidental key collisions; weights + datasets are sanitised above so the
output cannot inject keys (the renderer emits scalars only).
diff --git a/src/soup_cli/utils/save_formats.py b/src/soup_cli/utils/save_formats.py
index e6b70fd4..b2933e50 100644
--- a/src/soup_cli/utils/save_formats.py
+++ b/src/soup_cli/utils/save_formats.py
@@ -192,7 +192,9 @@ def validate_quant_config_path(path: object) -> str:
* ``os.path.realpath`` + ``os.path.commonpath`` cwd containment
* ``os.lstat`` + ``stat.S_ISLNK`` rejection before any ``open()``
* existence + extension check (``.yaml`` / ``.yml``)
- * ``yaml.safe_load`` only.
+ * read through ``utils.yaml_limits.load_yaml_file_limited`` (``yaml.safe_load``
+ under the shared size, nesting and expansion limits), never a bare
+ ``yaml.safe_load``.
"""
if isinstance(path, bool):
raise TypeError(f"quant_config must not be bool, got {path!r}")
@@ -233,7 +235,9 @@ def load_quant_config(path: object) -> Mapping[str, Any]:
* ``os.path.realpath`` + ``os.path.commonpath`` cwd containment
* ``os.lstat + stat.S_ISLNK`` rejection (TOCTOU)
* Extension allowlist (``.yaml`` / ``.yml``)
- * ``yaml.safe_load`` only
+ * Read through ``utils.yaml_limits.load_yaml_file_limited`` (``yaml.safe_load``
+ under the shared nesting and expansion limits; the size cap below is its
+ ``max_bytes``)
* 256 KB size cap
"""
from soup_cli.utils.yaml_limits import load_yaml_file_limited
diff --git a/tests/test_click_argument_help.py b/tests/test_click_argument_help.py
index 0b4b764d..1bb7a86f 100644
--- a/tests/test_click_argument_help.py
+++ b/tests/test_click_argument_help.py
@@ -8,8 +8,8 @@ description. Option help is unaffected, which is why nothing else in the suite n
No typer release under Soup's ``<0.21`` cap compensates, and click 8.4.2 renders
correctly, so the fix is a bound on click in ``pyproject.toml``. It is declared
explicitly because Soup imports click directly (``commands/autopilot.py``,
-``utils/argv_redaction.py``, ``utils/exit_codes.py``) and typer pulls it in only
-transitively.
+``commands/push.py``, ``commands/ship.py``, ``utils/exit_codes.py``) and typer pulls
+it in only transitively.
Two tests, because they fail for different reasons: the rendering test fails on any
environment that resolved click 8.5 (whatever the cause), and the declaration test