From 3b0354735c783831ea4dfb7a07cd8ec943451c15 Mon Sep 17 00:00:00 2001 From: Jon Wingender Date: Thu, 30 Jul 2026 11:43:17 -0500 Subject: [PATCH] fix(deps): make torch/ML stack opt-in instead of a mandatory install requirements-amd.txt/requirements-nvidia.txt were pulling a multi-GB torch wheel by default even though nothing in synapse/ imports torch, transformers, accelerate, bitsandbytes, or PySide6 - dead weight that made the pip batch fragile (one failed download could take unrelated base deps down with it on a slow connection). Split the unused ML/GUI stack out of requirements-base.txt into a new opt-in requirements-ml.txt, and dropped the torch lines from the AMD/NVIDIA overlays and generator. Also: recreate the venv if it exists but pip is missing, instead of silently reusing a half-built one (ensurepip can fail during venv creation and leave an interpreter with no pip). Co-Authored-By: Claude Sonnet 5 --- bin/gen-nvidia-reqs.py | 7 +++---- bin/sync.py | 10 ++++++++++ requirements-amd.txt | 7 +++---- requirements-base.txt | 11 +---------- requirements-ml.txt | 20 ++++++++++++++++++++ requirements-nvidia.txt | 7 +++---- 6 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 requirements-ml.txt diff --git a/bin/gen-nvidia-reqs.py b/bin/gen-nvidia-reqs.py index 8e1a4df..2bad8a0 100644 --- a/bin/gen-nvidia-reqs.py +++ b/bin/gen-nvidia-reqs.py @@ -53,10 +53,9 @@ def main(): -r requirements-base.txt -# GPU Compute Stack -torch -torchaudio -torchvision +# Torch itself is opt-in — see requirements-ml.txt. The --index-url above is +# what makes `pip install -r requirements-nvidia.txt -r requirements-ml.txt` +# resolve torch as the matching CUDA build instead of CPU-only. """, newline="\n") print(f"\nWritten: {NVIDIA_REQS}") diff --git a/bin/sync.py b/bin/sync.py index 4438433..65afe28 100644 --- a/bin/sync.py +++ b/bin/sync.py @@ -61,6 +61,16 @@ def venv_python() -> Path: """Path to the Promethean interpreter, creating the venv if it's missing.""" venv = ROOT / "Promethean" py = venv / ("Scripts/python.exe" if os.name == "nt" else "bin/python") + if py.exists() and subprocess.run( + [str(py), "-m", "pip", "--version"], capture_output=True).returncode: + # venv creation can partially succeed: the interpreter gets built but + # ensurepip's bootstrap fails (e.g. the matching pythonX.Y-venv package + # wasn't installed yet), leaving pip missing. Existence of `py` alone + # can't tell a venv like that apart from a good one, so a prior failed + # run would otherwise be reused forever instead of getting rebuilt now + # that whatever broke ensurepip is fixed. + print("Existing venv has no pip - recreating it...") + shutil.rmtree(venv) if not py.exists(): result = subprocess.run([sys.executable, "-m", "venv", str(venv)]) if result.returncode: diff --git a/requirements-amd.txt b/requirements-amd.txt index 7abce69..5407ea7 100644 --- a/requirements-amd.txt +++ b/requirements-amd.txt @@ -4,7 +4,6 @@ -r requirements-base.txt -# GPU Compute Stack -torch -torchaudio -torchvision +# Torch itself is opt-in — see requirements-ml.txt. The --index-url above is +# what makes `pip install -r requirements-amd.txt -r requirements-ml.txt` +# resolve torch as the ROCm build instead of CPU-only. diff --git a/requirements-base.txt b/requirements-base.txt index 017cf19..523686f 100644 --- a/requirements-base.txt +++ b/requirements-base.txt @@ -1,11 +1,6 @@ # --- Shared Base (GPU-agnostic) --- -# AI Stack -transformers -accelerate -bitsandbytes -safetensors -sentencepiece +# AI Stack (tokenizers/huggingface-hub: faster-whisper deps, not transformers) tokenizers huggingface-hub @@ -28,10 +23,6 @@ numpy scipy pandas psutil -PySide6 -PySide6_Addons -PySide6_Essentials -shiboken6 tqdm rich python-dotenv diff --git a/requirements-ml.txt b/requirements-ml.txt new file mode 100644 index 0000000..2d3fef2 --- /dev/null +++ b/requirements-ml.txt @@ -0,0 +1,20 @@ +# --- Optional: local ML inference stack --- +# Nothing in synapse/ imports any of this — Ollama handles all inference over +# HTTP. Only install this if you're doing local model work outside Ollama +# (fine-tuning, direct transformers inference, etc). Skipping it is what keeps +# the default install light and out of a multi-GB torch download. +# +# This file has no --index-url of its own, so torch resolves as CPU-only +# unless you combine it with the GPU overlay that sets one: +# pip install -r requirements-amd.txt -r requirements-ml.txt # ROCm +# pip install -r requirements-nvidia.txt -r requirements-ml.txt # CUDA +# pip install -r requirements-ml.txt # CPU only + +transformers +accelerate +bitsandbytes +safetensors +sentencepiece +torch +torchaudio +torchvision diff --git a/requirements-nvidia.txt b/requirements-nvidia.txt index 66d62fd..5acc628 100644 --- a/requirements-nvidia.txt +++ b/requirements-nvidia.txt @@ -4,7 +4,6 @@ -r requirements-base.txt -# GPU Compute Stack -torch -torchaudio -torchvision +# Torch itself is opt-in — see requirements-ml.txt. The --index-url above is +# what makes `pip install -r requirements-nvidia.txt -r requirements-ml.txt` +# resolve torch as the matching CUDA build instead of CPU-only.