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.

fix(notebook): make proof-4gb reproducible (#1545)

Pernav Jainef44c0c0af75
diff --git a/changelog.d/0.75.1/1545.fixed.md b/changelog.d/0.75.1/1545.fixed.md
new file mode 100644
index 00000000..41ba588f
--- /dev/null
+++ b/changelog.d/0.75.1/1545.fixed.md
@@ -0,0 +1 @@
+- `notebooks/proof-4gb.ipynb` runs again on a hosted multi-GPU runtime with a current `huggingface-hub`: the install cell caps `huggingface-hub<1.32.0` (soup-cli 0.75.0 refuses the shared blob store introduced in 1.32, #1509) and the notebook sets `CUDA_VISIBLE_DEVICES` to one card before torch is imported, because layer streaming cannot run under `nn.DataParallel` (#1543 by @here-2007 in #1545).
diff --git a/notebooks/proof-4gb.ipynb b/notebooks/proof-4gb.ipynb
index 4891320c..c0631021 100644
--- a/notebooks/proof-4gb.ipynb
+++ b/notebooks/proof-4gb.ipynb
@@ -115,10 +115,18 @@
],
"source": [
"%pip uninstall -q -y torchao\n",
+ "\n",
+ "import os\n",
+ "\n",
+ "# Layer streaming cannot run under nn.DataParallel; default to GPU 0 if unset,\n",
+ "# but preserve a caller-selected single card (e.g. CUDA_VISIBLE_DEVICES=1).\n",
+ "os.environ.setdefault(\"CUDA_VISIBLE_DEVICES\", \"0\")\n",
+ "\n",
"import sys\n",
"\n",
"_extra_flag = \"--ignore-requires-python\" if sys.version_info >= (3, 13) else \"\"\n",
- "%pip install -q \"soup-cli[train]==0.75.0\" {_extra_flag}\n",
+ "# huggingface-hub>=1.32 keeps blobs in a cache-wide store that soup-cli 0.75.0 refuses (#1509); drop this cap when the notebook re-pins to a release that carries the fix.\n",
+ "%pip install -q \"huggingface-hub<1.32.0\" \"soup-cli[train]==0.75.0\" {_extra_flag}\n",
"\n",
"import importlib.util\n",
"\n",
@@ -6471,4 +6479,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
-}
\ No newline at end of file
+}
diff --git a/tests/test_issue844_notebook_pin_guard.py b/tests/test_issue844_notebook_pin_guard.py
index d2ae3b7f..d5fc091a 100644
--- a/tests/test_issue844_notebook_pin_guard.py
+++ b/tests/test_issue844_notebook_pin_guard.py
@@ -176,3 +176,29 @@ class TestEveryImportInTheNotebookStillResolves:
"notebook (or the pinned version) before merging:\n"
+ "\n".join(failures)
)
+
+
+class TestTheNotebookRunsOnAModernHostedRuntime:
+ """#1543: a fresh 2-GPU runtime with a current huggingface-hub broke two cells."""
+
+ def test_one_gpu_is_selected_before_torch_is_imported(self):
+ env_idx = torch_idx = None
+ for idx, src in enumerate(_code_cell_sources()):
+ if env_idx is None and "CUDA_VISIBLE_DEVICES" in src:
+ env_idx = idx
+ if torch_idx is None and re.search(r"^\s*(import torch|from torch)\b", src, re.M):
+ torch_idx = idx
+ assert env_idx is not None, (
+ "no cell sets CUDA_VISIBLE_DEVICES: on a 2-GPU runtime layer streaming "
+ "refuses to start (it cannot run under nn.DataParallel)"
+ )
+ assert torch_idx is not None and env_idx <= torch_idx, (
+ "CUDA_VISIBLE_DEVICES is only read when CUDA initialises, so it must be "
+ "set in a cell at or before the first cell that imports torch"
+ )
+
+ def test_the_install_cell_caps_huggingface_hub_below_the_shared_blob_store(self):
+ # huggingface_hub >= 1.32 keeps Xet blobs in a cache-wide store that
+ # soup-cli 0.75.0 treats as an escape (#1509). Drop this assertion together
+ # with the pin when the notebook moves to a release that carries the fix.
+ assert re.search(r"huggingface-hub\s*<\s*1\.32", _install_cell_source())