Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

fix(packaging)!: keep PyTorch extras out of all (#4067)

lorenzozanea8905214d949
diff --git a/.github/workflows/eval.yml b/.github/workflows/eval.yml
index ef0731d8c..08ad840c8 100644
--- a/.github/workflows/eval.yml
+++ b/.github/workflows/eval.yml
@@ -49,7 +49,7 @@ jobs:
- name: Install dependencies (builds Rust extension via maturin)
run: |
- pip install -e ".[all]"
+ pip install -e ".[all,evals]"
python -c "from headroom._core import SmartCrusher; print('headroom._core OK:', SmartCrusher)"
- name: Run CCR round-trip (zero cost)
@@ -119,7 +119,7 @@ jobs:
- name: Install dependencies (builds Rust extension via maturin)
run: |
- pip install -e ".[all]"
+ pip install -e ".[all,evals,ml]"
python -c "from headroom._core import SmartCrusher; print('headroom._core OK')"
- name: Run Tier 1 evaluation suite
run: |
@@ -157,7 +157,7 @@ jobs:
# Real-dataset recall on the prose path (HotpotQA): does the ground-truth
# answer survive compressing the supporting context? Uses the production
# routing path, so prose flows through Kompress (ModernBERT) — allowed here
- # because the weekly job installs [all]. Non-blocking and defensive: a
+ # because the weekly job explicitly installs [ml]. Non-blocking and defensive: a
# dataset download or model failure warns rather than fails the job.
- name: Dataset recall report — HotpotQA (model-allowed, non-blocking)
run: |
diff --git a/README.md b/README.md
index a5b042732..4616271ad 100644
--- a/README.md
+++ b/README.md
@@ -481,14 +481,18 @@ orchestration stays focused on lifecycle, sequencing and policy:
```bash
uv tool install --python 3.13 "headroom-ai[all]" # CLI, isolated app env
-pip install "headroom-ai[all]" # Python, everything — includes the CLI
+pip install "headroom-ai[all]" # CLI/proxy feature set
npm install headroom-ai # TypeScript SDK (library only)
docker pull ghcr.io/headroomlabs-ai/headroom:latest
```
+`[all]` includes the CLI/proxy feature set, including image support, without PyTorch-backed dependencies.
+Add `[ml]`, `[memory]`, `[evals]`, or `[voice]` separately for those features;
+their PyTorch dependency can install CUDA runtime packages on Linux.
+
Granular extras: `[proxy]`, `[mcp]`, `[ml]` (Kompress-v2-base), `[code]`,
-`[memory]`, `[vector]` (optional HNSW backend — needs a C++ toolchain, not in
-`[all]`), `[relevance]`, `[image]`, `[agno]`, `[langchain]`, `[evals]`,
+`[memory]`, `[vector]` (optional HNSW backend — needs a C++ toolchain),
+`[relevance]`, `[image]`, `[lean]` (torch-free proxy dependency profile; `[sandbox]` is a deprecated alias), `[agno]`, `[langchain]`, `[evals]`, `[voice]`, and
`[pytorch-mps]` (Apple-GPU memory-embedder offload — set
`HEADROOM_EMBEDDER_RUNTIME=pytorch_mps`). Requires **Python 3.11+**.
diff --git a/docs/content/docs/installation.mdx b/docs/content/docs/installation.mdx
index 299d32ebb..8cec26a8b 100644
--- a/docs/content/docs/installation.mdx
+++ b/docs/content/docs/installation.mdx
@@ -87,7 +87,7 @@ The core package includes the `compress()` function, SmartCrusher, CacheAligner,
### Extras
-Install only what you need, or grab everything with `[all]`:
+Install only what you need, or use `[all]` for the default CLI/proxy feature set:
```bash
pip install "headroom-ai[all]"
@@ -97,16 +97,16 @@ pip install "headroom-ai[all]"
|---|---|---|
| `proxy` | Proxy server, HTTP API, MCP runtime, local ONNX Kompress path | `pip install "headroom-ai[proxy]"` |
| `proxy-prod` | `proxy` plus gunicorn on Unix production hosts | `pip install "headroom-ai[proxy,proxy-prod]"` |
-| `ml` | PyTorch/Hugging Face Kompress backend and model tooling | `pip install "headroom-ai[ml]"` |
+| `ml` | PyTorch/Hugging Face Kompress backend and model tooling; opt-in, not in `[all]` | `pip install "headroom-ai[ml]"` |
| `code` | CodeCompressor (tree-sitter AST parsing) | `pip install "headroom-ai[code]"` |
-| `memory` | Persistent memory (sqlite-vec, sentence-transformers) — pure-Python default backend, no compiler | `pip install "headroom-ai[memory]"` |
+| `memory` | Persistent memory (sqlite-vec, sentence-transformers); opt-in, not in `[all]` | `pip install "headroom-ai[memory]"` |
| `vector` | Optional HNSW vector backend (hnswlib) — needs a C++ toolchain; **not in `[all]`** | `pip install "headroom-ai[vector]"` |
| `memory-stack` | Optional Qdrant + Neo4j memory backend helpers; **not in `[all]`**. Headroom turns off Mem0's PostHog telemetry by default; set `MEM0_TELEMETRY=True` to allow it | `pip install "headroom-ai[memory-stack]"` |
| `relevance` | fastembed-based relevance scoring (BAAI/bge-small-en-v1.5, ONNX) | `pip install "headroom-ai[relevance]"` |
| `image` | Image compression (Pillow, ONNX runtime, OCR) | `pip install "headroom-ai[image]"` |
| `reports` | HTML/Markdown report generation (Jinja2) | `pip install "headroom-ai[reports]"` |
| `otel` | OpenTelemetry exporter (OTLP) | `pip install "headroom-ai[otel]"` |
-| `voice` | Voice/audio support | `pip install "headroom-ai[voice]"` |
+| `voice` | Voice/audio support; opt-in, not in `[all]` | `pip install "headroom-ai[voice]"` |
| `voice-train` | Voice training dependencies; **not in `[all]`** | `pip install "headroom-ai[voice-train]"` |
| `mcp` | MCP server tools (`headroom_compress`, `headroom_retrieve`, `headroom_stats`) | `pip install "headroom-ai[mcp]"` |
| `langchain` | LangChain `HeadroomChatModel` wrapper; **not in `[all]`** | `pip install "headroom-ai[langchain]"` |
@@ -117,15 +117,16 @@ pip install "headroom-ai[all]"
| `anyllm` | any-llm multi-provider backend (Python 3.11+); **not in `[all]`** | `pip install "headroom-ai[anyllm]"` |
| `bedrock` | Native AWS Bedrock credentials/backend support; **not in `[all]`** | `pip install "headroom-ai[bedrock]"` |
| `redis` | Redis client for state shared across replicas (`HEADROOM_CCR_BACKEND=redis`, `HEADROOM_COMPRESS_SESSION_STORE`); **not in `[all]`**, included in every Docker image | `pip install "headroom-ai[redis]"` |
-| `evals` | Evaluation framework (GSM8K, SQuAD, BFCL benchmarks) | `pip install "headroom-ai[evals]"` |
+| `evals` | Evaluation framework (GSM8K, SQuAD, BFCL benchmarks); opt-in, not in `[all]` | `pip install "headroom-ai[evals]"` |
| `pytorch-mps` | Apple-GPU (MPS) memory-embedder offload — **macOS only**, not in `[all]` (torch + sentence-transformers); opt in with `HEADROOM_EMBEDDER_RUNTIME=pytorch_mps` | `pip install "headroom-ai[pytorch-mps]"` |
| `html` | HTML main-content extraction with trafilatura | `pip install "headroom-ai[html]"` |
| `spreadsheet` | `.xlsx` / `.xls` ingestion with openpyxl and xlrd | `pip install "headroom-ai[spreadsheet]"` |
| `lean` | Torch-free proxy bundle for constrained environments (a dependency profile; it provides no isolation). `sandbox` is a deprecated alias | `pip install "headroom-ai[lean]"` |
-| `all` | Runtime bundle: `proxy,code,ml,memory,relevance,image,reports,otel,evals,voice,html,mcp,spreadsheet` | `pip install "headroom-ai[all]"` |
+| `all` | CLI/proxy feature set without PyTorch-backed dependencies | `pip install "headroom-ai[all]"` |
-`[all]` is the full built-in runtime bundle, not every integration or optional
-backend. The rows marked “not in `[all]`” must be requested explicitly.
+`[all]` is the built-in CLI/proxy feature set, not every integration or
+PyTorch-backed feature. The rows marked “not in `[all]`” must be requested
+explicitly. PyPI's Linux PyTorch wheels can include CUDA runtime packages.
You can combine extras:
diff --git a/headroom/evals/README.md b/headroom/evals/README.md
index 1fd60cf42..b26a5dbd9 100644
--- a/headroom/evals/README.md
+++ b/headroom/evals/README.md
@@ -25,7 +25,7 @@ Model: `gpt-4o-mini` | Suite cost: ~$3 | Duration: ~15 min
## Installation
```bash
-pip install "headroom-ai[all]" # Everything including evals (recommended)
+pip install "headroom-ai[all,evals]" # CLI/proxy feature set plus evaluation dependencies
pip install "headroom-ai[evals]" # Evaluation framework only
```
@@ -234,7 +234,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.11" }
- - run: pip install -e ".[all]"
+ - run: pip install -e ".[all,evals]"
- name: CCR Round-trip (zero cost)
run: |
python -c "
diff --git a/llms.txt b/llms.txt
index 407c036a1..df0afc558 100644
--- a/llms.txt
+++ b/llms.txt
@@ -17,7 +17,7 @@ The canonical, always-current documentation index lives at the docs site below.
## Install (copy-paste-runnable)
-- Python: `pip install headroom-ai` is enough for `compress()`; add `[proxy]` for the HTTP proxy and `headroom wrap`, `[all]` for every optional extra
+- Python: `pip install headroom-ai` is enough for `compress()`; add `[proxy]` for the HTTP proxy and `headroom wrap`, `[all]` for the CLI/proxy feature set. PyTorch-backed `[ml]`, `[memory]`, `[evals]`, and `[voice]` are separate opt-ins.
- TypeScript / Node: `npm install headroom-ai` (or `pnpm add headroom-ai`, `bun add headroom-ai`)
- Docker local: `docker run --rm -p 127.0.0.1:8787:8787 ghcr.io/headroomlabs-ai/headroom:latest --host 0.0.0.0`
- Run the proxy: `headroom proxy --port 8787` then point any client at `http://127.0.0.1:8787`
diff --git a/pyproject.toml b/pyproject.toml
index 00d9f21b3..985035193 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -361,7 +361,9 @@ dev = [
"cryptography>=50.0.0",
"respx>=0.20.0", # HTTP mock transport for passthrough handler tests
]
-# All optional dependencies (everything you need).
+# All optional dependencies for the default CLI/proxy feature set.
+# PyTorch-backed features stay opt-in because Linux PyPI wheels include CUDA
+# runtime packages and dependency metadata cannot detect installed hardware.
#
# The EleutherAI lm-evaluation-harness is intentionally not exposed as a
# project extra. Headroom invokes it as an external subprocess
@@ -371,7 +373,7 @@ dev = [
# who need standard accuracy benchmarks can install `lm-eval[api]` in their
# benchmark environment separately.
all = [
- "headroom-ai[proxy,code,ml,memory,relevance,image,reports,otel,evals,voice,html,mcp,spreadsheet]",
+ "headroom-ai[proxy,code,relevance,image,reports,otel,html,mcp,spreadsheet]",
]
# Lean: a proxy with ALL torch-free capability — for running Headroom in a
# constrained or low-resource environment and offloading heavy ML elsewhere.
diff --git a/tests/test_onnx_dependency_contract.py b/tests/test_onnx_dependency_contract.py
index 359e6debf..55f4ac2c1 100644
--- a/tests/test_onnx_dependency_contract.py
+++ b/tests/test_onnx_dependency_contract.py
@@ -76,15 +76,21 @@ def test_intel_macos_python314_omits_ort_dependent_optional_backends() -> None:
assert not selected & ort_backends, (extra, selected & ort_backends)
-def test_all_extra_includes_proxy_and_voice() -> None:
+def test_all_extra_includes_proxy_without_torch_dependency_extras() -> None:
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
- all_requirements = project["optional-dependencies"]["all"]
+ optional = project["optional-dependencies"]
+ all_requirements = optional["all"]
- assert any(
- requirement.name == "headroom-ai" and {"proxy", "voice"} <= set(requirement.extras)
+ included_extras = {
+ extra
for raw_requirement in all_requirements
- if (requirement := Requirement(raw_requirement))
- )
+ if (requirement := Requirement(raw_requirement)) and requirement.name == "headroom-ai"
+ for extra in requirement.extras
+ }
+
+ assert {"proxy", "image"} <= included_extras
+ assert not {"ml", "memory", "evals", "voice"} & included_extras
+ assert {"ml", "memory", "evals", "voice", "sandbox"} <= optional.keys()
@pytest.mark.proxy_dependency_gate
diff --git a/tests/test_optional_dependencies.py b/tests/test_optional_dependencies.py
index 8060d8b09..3b532e922 100644
--- a/tests/test_optional_dependencies.py
+++ b/tests/test_optional_dependencies.py
@@ -105,8 +105,14 @@ def test_all_extra_does_not_require_torch_on_macos_x86_64() -> None:
}
)
- assert "ml" in optional_deps[ALL_EXTRA][0]
- assert "voice" in optional_deps[ALL_EXTRA][0]
+ all_requirements = [Requirement(dep) for dep in optional_deps[ALL_EXTRA]]
+ all_nested_extras = {
+ extra
+ for requirement in all_requirements
+ if requirement.name == HEADROOM_PACKAGE_NAME
+ for extra in requirement.extras
+ }
+ assert not {"ml", "memory", "evals", "voice"} & all_nested_extras
torch_deps = [
dep
@@ -131,6 +137,20 @@ def test_all_extra_does_not_require_torch_on_macos_x86_64() -> None:
assert TORCH_PACKAGE_NAME not in selected_all_dependency_names
assert selected_all_dependency_names.isdisjoint(locked_torch_transitive_dependency_names)
+ # Explicit opt-ins still honor the Intel macOS wheel guard independently
+ # of whether the default installation profile requests them.
+ for extra_name in ("ml", "voice"):
+ selected = _selected_dependency_names_for_extra(
+ optional_deps, extra_name, macos_x86_64_environment
+ )
+ assert TORCH_PACKAGE_NAME not in selected
+ assert selected.isdisjoint(locked_torch_transitive_dependency_names)
+
+ linux_environment = dict(macos_x86_64_environment, sys_platform="linux")
+ assert TORCH_PACKAGE_NAME in _selected_dependency_names_for_extra(
+ optional_deps, extra_name, linux_environment
+ )
+
def test_proxy_extra_includes_orjson_for_litellm_backends() -> None:
"""`headroom-ai[all]` must ship orjson for LiteLLM provider backends (GH #2056)."""
diff --git a/uv.lock b/uv.lock
index ff9c6094a..a00074f61 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1441,12 +1441,9 @@ agno = [
{ name = "agno" },
]
all = [
- { name = "anthropic" },
- { name = "datasets" },
{ name = "fastapi" },
{ name = "fastembed", marker = "python_full_version < '3.14' or platform_machine != 'x86_64' or sys_platform != 'darwin'" },
{ name = "httpx", extra = ["http2"] },
- { name = "huggingface-hub" },
{ name = "jinja2" },
{ name = "magika", marker = "python_full_version < '3.14' or platform_machine != 'x86_64' or sys_platform != 'darwin'" },
{ name = "mcp" },
@@ -1462,12 +1459,9 @@ all = [
{ name = "python-socks" },
{ name = "rapidocr", marker = "(python_full_version >= '3.13' and platform_machine != 'x86_64') or (python_full_version == '3.13.*' and platform_machine == 'x86_64' and sys_platform == 'darwin') or (python_full_version >= '3.13' and sys_platform != 'darwin')" },
{ name = "rapidocr-onnxruntime", marker = "python_full_version < '3.13'" },
- { name = "scikit-learn" },
- { name = "sentence-transformers", marker = "platform_machine != 'x86_64' or sys_platform != 'darwin'" },
{ name = "sentencepiece" },
{ name = "sqlite-vec" },
{ name = "starlette" },
- { name = "torch", marker = "platform_machine != 'x86_64' or sys_platform != 'darwin'" },
{ name = "trafilatura" },
{ name = "transformers" },
{ name = "tree-sitter" },
@@ -1726,7 +1720,7 @@ requires-dist = [
{ name = "gunicorn", marker = "sys_platform != 'win32' and extra == 'proxy-prod'", specifier = ">=21.0.0" },
{ name = "headroom-ai", extras = ["lean"], marker = "extra == 'sandbox'" },
{ name = "headroom-ai", extras = ["proxy"], marker = "extra == 'proxy-prod'" },
- { name = "headroom-ai", extras = ["proxy", "code", "ml", "memory", "relevance", "image", "reports", "otel", "evals", "voice", "html", "mcp", "spreadsheet"], marker = "extra == 'all'" },
+ { name = "headroom-ai", extras = ["proxy", "code", "relevance", "image", "reports", "otel", "html", "mcp", "spreadsheet"], marker = "extra == 'all'" },
{ name = "headroom-ai", extras = ["proxy", "code", "relevance", "reports", "otel", "html", "mcp", "spreadsheet"], marker = "extra == 'lean'" },
{ name = "headroom-ai", extras = ["voice"], marker = "extra == 'voice-train'" },
{ name = "hf-xet", marker = "platform_machine == 'AMD64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'", specifier = ">=1.6.0" },