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(bench): resolve the #361 harness's source SHA from soup_cli's tree, not the checkout's HEAD (#1327) (#1382)
Y.B.dccc868094ed
diff --git a/benchmarks/harness/issue361_nf4_throughput.py b/benchmarks/harness/issue361_nf4_throughput.pyindex c1c339e3..7d9d6376 100644--- a/benchmarks/harness/issue361_nf4_throughput.py+++ b/benchmarks/harness/issue361_nf4_throughput.py@@ -50,7 +50,9 @@ from __future__ import annotationsimport argparseimport json+import reimport statistics+import subprocessimport sysimport threadingimport time@@ -101,25 +103,54 @@ def _source_sha() -> str:``soup-cli`` reports a release version that does not move between commits,so without this a row cannot name its own tree — and this harness measures a- path that three post-#361-base commits changed (#989 above all).+ path that three post-#361-base commits changed (#989 above all). Resolved+ from the ``soup_cli`` package's own location (not this harness file's), so a+ shadow install elsewhere on ``sys.path`` is not misreported as the checkout+ that produced the row, and marked ``-dirty`` when that tree has uncommitted+ changes (#1085's ``variant2_gate._source_sha`` first added both checks)."""- import shutil- import subprocess+ import soup_cli- tool = shutil.which("git")- if tool is None:+ package_file = getattr(soup_cli, "__file__", None)+ if package_file is None:return "unknown"try:- out = subprocess.run(- [tool, "rev-parse", "HEAD"],- cwd=Path(__file__).resolve().parents[2],+ package_dir = Path(package_file).resolve().parent+ root = subprocess.run(+ ["git", "rev-parse", "--show-toplevel"],+ cwd=package_dir,+ check=True,capture_output=True,text=True,- timeout=10,+ timeout=5,+ ).stdout.strip()+ if not root:+ return "unknown"+ commit = (+ subprocess.run(+ ["git", "rev-parse", "HEAD"],+ cwd=Path(root),+ check=True,+ capture_output=True,+ text=True,+ timeout=5,+ )+ .stdout.strip()+ .lower())- except Exception:+ dirty = subprocess.run(+ ["git", "status", "--porcelain", "--untracked-files=normal"],+ cwd=Path(root),+ check=True,+ capture_output=True,+ text=True,+ timeout=5,+ ).stdout+ except (OSError, subprocess.SubprocessError):+ return "unknown"+ if not re.fullmatch(r"[0-9a-f]{40}", commit):return "unknown"- return out.stdout.strip() or "unknown"+ return f"{commit}-dirty" if dirty else commitdef _versions() -> dict:diff --git a/tests/test_issue361_nf4_throughput.py b/tests/test_issue361_nf4_throughput.pyindex 63c664c7..ef6212b7 100644--- a/tests/test_issue361_nf4_throughput.py+++ b/tests/test_issue361_nf4_throughput.py@@ -21,8 +21,11 @@ import astimport importlib.utilimport jsonimport re+import subprocessimport sysfrom pathlib import Path+from types import SimpleNamespace+from typing import Anyimport pytest@@ -172,7 +175,7 @@ class TestTheRowNamesItsTree:def test_source_sha_is_a_commit_or_an_honest_unknown(self) -> None:sha = _harness._source_sha()- assert sha == "unknown" or re.fullmatch(r"[0-9a-f]{40}", sha)+ assert sha == "unknown" or re.fullmatch(r"[0-9a-f]{40}(-dirty)?", sha)def test_the_versions_blob_carries_it(self) -> None:assert _harness._versions()["commit"] == _harness._source_sha()@@ -182,6 +185,36 @@ class TestTheRowNamesItsTree:assert "source commit:" in textassert '"versions": versions' in text+ @pytest.mark.parametrize("status", ["", " M src/soup_cli/changed.py\n"])+ def test_source_sha_uses_imported_package_tree_and_marks_dirty(+ self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, status: str+ ) -> None:+ import soup_cli++ package_file = soup_cli.__file__+ assert package_file is not None+ package_dir = Path(package_file).resolve().parent+ expected_sha = "a" * 40+ calls: list[tuple[list[str], Path]] = []++ def fake_run(command: list[str], *, cwd: Path, **kwargs: object) -> Any:+ calls.append((command, cwd))+ if command == ["git", "rev-parse", "--show-toplevel"]:+ return SimpleNamespace(stdout=f"{tmp_path}\n")+ if command == ["git", "rev-parse", "HEAD"]:+ return SimpleNamespace(stdout=f"{expected_sha}\n")+ return SimpleNamespace(stdout=status)++ monkeypatch.chdir(tmp_path)+ monkeypatch.setattr(subprocess, "run", fake_run)++ assert _harness._source_sha() == expected_sha + ("-dirty" if status else "")+ assert calls == [+ (["git", "rev-parse", "--show-toplevel"], package_dir),+ (["git", "rev-parse", "HEAD"], tmp_path),+ (["git", "status", "--porcelain", "--untracked-files=normal"], tmp_path),+ ]+class TestNumeratorConvention:def test_tied_head_is_not_double_counted(self, tmp_path: Path) -> None: