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(card): keep newest evaluation score per benchmark (#1459)
Krishna85518b19e754
diff --git a/changelog.d/0.75.1/1459.fixed.md b/changelog.d/0.75.1/1459.fixed.mdnew file mode 100644index 00000000..877dff04--- /dev/null+++ b/changelog.d/0.75.1/1459.fixed.md@@ -0,0 +1 @@+- `soup card` now shows the newest score of a benchmark that was evaluated more than once, not the oldest: the scorecard walked the tracker's newest-first rows and kept the last one, and rows with an identical timestamp now resolve to the later insert. It uses the same newest-row helper as `soup registry diff` and `soup eval compare` (#1315 by @Ru0k3 in #1459).diff --git a/src/soup_cli/commands/card.py b/src/soup_cli/commands/card.pyindex ae759f0f..9febcd96 100644--- a/src/soup_cli/commands/card.py+++ b/src/soup_cli/commands/card.py@@ -34,6 +34,7 @@ from soup_cli.commands.push import (_render_training_section,_safe_md_cell,)+from soup_cli.eval.results import newest_eval_rowsfrom soup_cli.registry.store import AmbiguousRefError, RegistryStorefrom soup_cli.utils.paths import atomic_write_text@@ -132,14 +133,12 @@ def build_model_card(# Row caps: bound the card regardless of how many rows the registry holds.artifacts = list(artifacts or [])[:_MAX_ROWS]ancestors = list(ancestors or [])[:_MAX_ROWS]- eval_results = list(eval_results or [])[:_MAX_ROWS]-- scorecard: dict[str, Any] = {}- for row in eval_results or []:- bench = row.get("benchmark")- score = row.get("score")- if bench is not None and score is not None:- scorecard[str(bench)] = score+ eval_results = list(eval_results or [])++ scorecard = {+ str(row["benchmark"]): row["score"]+ for row in newest_eval_rows(eval_results)[:_MAX_ROWS]+ }is_adapter = _is_adapter(artifacts, config)diff --git a/tests/test_v07135.py b/tests/test_v07135.pyindex 91a620c1..d8c24b68 100644--- a/tests/test_v07135.py+++ b/tests/test_v07135.py@@ -672,7 +672,7 @@ class TestBuildModelCardEdges:assert "mmlu" in mdassert "gsm8k" not in md- def test_scorecard_duplicate_benchmark_last_wins(self):+ def test_scorecard_duplicate_benchmark_newest_row_wins(self):from soup_cli.commands.card import build_model_cardentry = {@@ -680,11 +680,88 @@ class TestBuildModelCardEdges:"created_at": "t", "notes": None, "config_hash": "", "data_hash": "","run_id": "run1", "tags": [], "config_json": "{}",}- evals = [{"benchmark": "mmlu", "score": 0.1}, {"benchmark": "mmlu", "score": 0.9}]+ # ExperimentTracker returns rows newest first; card must not let the+ # older row overwrite the newest score.+ evals = [+ {"benchmark": "mmlu", "score": 0.9, "created_at": "2026-01-02", "id": 2},+ {"benchmark": "mmlu", "score": 0.1, "created_at": "2026-01-01", "id": 1},+ ]md = build_model_card(entry, [], evals, [])assert "0.900" in mdassert "0.100" not in md+ @pytest.mark.parametrize("newest_first", [True, False])+ def test_scorecard_tie_uses_later_insert_in_either_input_order(self, newest_first):+ from soup_cli.commands.card import build_model_card++ entry = {+ "id": "r", "name": "m", "base_model": "b", "task": "sft",+ "created_at": "t", "notes": None, "config_hash": "", "data_hash": "",+ "run_id": "run1", "tags": [], "config_json": "{}",+ }+ evals = [+ {"benchmark": "mmlu", "score": 0.9, "created_at": "2026-01-01", "id": 2},+ {"benchmark": "mmlu", "score": 0.1, "created_at": "2026-01-01", "id": 1},+ ]+ if not newest_first:+ evals.reverse()+ md = build_model_card(entry, [], evals, [])+ assert "| mmlu | 0.900 |" in md+ assert "0.100" not in md++ def test_scorecard_cap_is_applied_after_picking_the_newest_row(self):+ """300 newer rows of one benchmark must not push an older benchmark off the card."""+ from soup_cli.commands.card import _MAX_ROWS, build_model_card++ entry = {+ "id": "r", "name": "m", "base_model": "b", "task": "sft",+ "created_at": "t", "notes": None, "config_hash": "", "data_hash": "",+ "run_id": "run1", "tags": [], "config_json": "{}",+ }+ noise = [+ {"benchmark": "noise", "score": 0.5, "created_at": "2026-02-01", "id": 1000 - i}+ for i in range(_MAX_ROWS + 100)+ ]+ older = {"benchmark": "mmlu", "score": 0.7, "created_at": "2026-01-01", "id": 1}+ md = build_model_card(entry, [], noise + [older], [])+ assert "| mmlu | 0.700 |" in md++ def test_scorecard_is_capped_at_max_rows_benchmarks_newest_first(self):+ from soup_cli.commands.card import _MAX_ROWS, build_model_card++ entry = {+ "id": "r", "name": "m", "base_model": "b", "task": "sft",+ "created_at": "t", "notes": None, "config_hash": "", "data_hash": "",+ "run_id": "run1", "tags": [], "config_json": "{}",+ }+ evals = [+ {"benchmark": f"bench{index:04d}", "score": 0.5,+ "created_at": "2026-01-01", "id": 10_000 - index}+ for index in range(_MAX_ROWS + 50)+ ]+ md = build_model_card(entry, [], evals, [])+ assert "| bench0000 |" in md+ assert f"| bench{_MAX_ROWS - 1:04d} |" in md+ assert f"| bench{_MAX_ROWS:04d} |" not in md++ def test_card_shows_newest_score_from_real_tracker_rows(self, tmp_path):+ from soup_cli.commands.card import build_model_card+ from soup_cli.experiment.tracker import ExperimentTracker++ entry = {+ "id": "r", "name": "m", "base_model": "b", "task": "sft",+ "created_at": "t", "notes": None, "config_hash": "", "data_hash": "",+ "run_id": "run1", "tags": [], "config_json": "{}",+ }+ tracker = ExperimentTracker(db_path=tmp_path / "exp.db")+ tracker.save_eval_result("model", "mmlu", 0.30, {}, run_id="run1")+ tracker.save_eval_result("model", "mmlu", 0.45, {}, run_id="run1")+ evals = tracker.get_eval_results("run1")+ assert [row["score"] for row in evals] == [0.45, 0.30]+ md = build_model_card(entry, [], evals, [])+ assert "| mmlu | 0.450 |" in md+ assert "0.300" not in md+def test_malformed_config_json_does_not_crash(self):from soup_cli.commands.card import build_model_card