Commit ·
1c87b42
1
Parent(s): 75089a0
chore: install llama-cpp from prebuilt Space wheel
Browse files- README.md +5 -3
- pyproject.toml +0 -1
- requirements.txt +8 -7
- uv.lock +0 -24
README.md
CHANGED
|
@@ -200,7 +200,7 @@ The **Actor Engine** selector supports:
|
|
| 200 |
- **Local OpenBMB:** the existing experimental local OpenBMB Transformers actor backend.
|
| 201 |
- **Hugging Face API:** the existing remote actor backend using Hugging Face Inference Providers.
|
| 202 |
|
| 203 |
-
The
|
| 204 |
|
| 205 |
Local model defaults are set for demo reliability: LoRA uses `ACTOR_LORA_DEVICE=auto`, GGUF uses `ACTOR_GGUF_N_GPU_LAYERS=-1`, and both local actor backends default to a 120 second generation timeout.
|
| 206 |
|
|
@@ -220,6 +220,8 @@ ACTOR_MODEL_BACKEND=local_gguf \
|
|
| 220 |
uv run python app.py
|
| 221 |
```
|
| 222 |
|
|
|
|
|
|
|
| 223 |
To force a local file instead of downloading from the Hugging Face GGUF repo:
|
| 224 |
|
| 225 |
```bash
|
|
@@ -240,7 +242,7 @@ uv run python app.py
|
|
| 240 |
Limitations:
|
| 241 |
|
| 242 |
- Local LoRA needs enough GPU or CPU memory for `openbmb/MiniCPM5-1B` plus the adapter.
|
| 243 |
-
- Local GGUF needs enough CPU/GPU memory for the quantized file; by default it downloads the configured GGUF from Hugging Face Hub, or uses `ACTOR_GGUF_MODEL_PATH` when set. The GGUF file is not committed to git.
|
| 244 |
- Hosted Spaces may use fallback unless a model backend is explicitly configured.
|
| 245 |
- GGUF is prompted with ChatML, matching the best eval format used for the Q4_K_M actor model.
|
| 246 |
|
|
@@ -281,7 +283,7 @@ USE_ZEROGPU=true
|
|
| 281 |
|
| 282 |
`USE_ZEROGPU` defaults to `false`, so the app still starts locally and on regular CPU Spaces without requesting ZeroGPU. When enabled and the `spaces` package is available, local OpenBMB generation runs through a `@spaces.GPU(duration=30)` function. The app does not load local models at startup.
|
| 283 |
|
| 284 |
-
The Space requirements are resolved for Python 3.10 compatibility because ZeroGPU builds may use a Python 3.10 base image. The local project also supports Python 3.11. The runtime pins `torch==2.8.0`, which is the preferred ZeroGPU-compatible Torch version for this Space. If Hugging Face reports a different supported Torch version for ZeroGPU, update `pyproject.toml`, regenerate `requirements.txt`, and refresh `uv.lock`.
|
| 285 |
|
| 286 |
If ZeroGPU is not enabled, `spaces` is unavailable, local model loading fails, CUDA is unavailable inside the GPU function, or model output is invalid, the show falls back gracefully. The Hugging Face API backend remains selectable and is the recommended fallback when you have `HF_TOKEN`; deterministic mode remains the no-token safety path.
|
| 287 |
|
|
|
|
| 200 |
- **Local OpenBMB:** the existing experimental local OpenBMB Transformers actor backend.
|
| 201 |
- **Hugging Face API:** the existing remote actor backend using Hugging Face Inference Providers.
|
| 202 |
|
| 203 |
+
The LoRA runtime libraries are included in the app runtime dependencies. The Space `requirements.txt` also includes `llama-cpp-python` through the upstream prebuilt CUDA wheel index so the GGUF backend can use GPU offload when the Space image has a compatible wheel. Model weights are still loaded lazily: the first selected LoRA or GGUF beat downloads/loads the model and keeps the loaded backend object in memory for the app lifecycle. If a selected backend fails, times out, errors, or returns invalid JSON, runtime output goes through first-JSON extraction, Actor JSON sanitization, validation, and then falls back to the deterministic actor generator.
|
| 204 |
|
| 205 |
Local model defaults are set for demo reliability: LoRA uses `ACTOR_LORA_DEVICE=auto`, GGUF uses `ACTOR_GGUF_N_GPU_LAYERS=-1`, and both local actor backends default to a 120 second generation timeout.
|
| 206 |
|
|
|
|
| 220 |
uv run python app.py
|
| 221 |
```
|
| 222 |
|
| 223 |
+
`requirements.txt` uses the upstream prebuilt CUDA 12.1 wheel index for `llama-cpp-python` to avoid source builds where possible on the current GPU Space. If the Space CUDA/runtime image changes, replace `/cu121` with the matching CUDA wheel index from the `llama-cpp-python` docs, such as `/cu124`, `/cu125`, `/cu130`, or `/cu132`. For a CPU Space, replace `/cu121` with `/cpu` and set `ACTOR_GGUF_N_GPU_LAYERS=0`. If no compatible prebuilt wheel exists for the Space image, pip may still fall back to a slow native build.
|
| 224 |
+
|
| 225 |
To force a local file instead of downloading from the Hugging Face GGUF repo:
|
| 226 |
|
| 227 |
```bash
|
|
|
|
| 242 |
Limitations:
|
| 243 |
|
| 244 |
- Local LoRA needs enough GPU or CPU memory for `openbmb/MiniCPM5-1B` plus the adapter.
|
| 245 |
+
- Local GGUF needs `llama-cpp-python` and enough CPU/GPU memory for the quantized file; by default it downloads the configured GGUF from Hugging Face Hub, or uses `ACTOR_GGUF_MODEL_PATH` when set. The GGUF file is not committed to git.
|
| 246 |
- Hosted Spaces may use fallback unless a model backend is explicitly configured.
|
| 247 |
- GGUF is prompted with ChatML, matching the best eval format used for the Q4_K_M actor model.
|
| 248 |
|
|
|
|
| 283 |
|
| 284 |
`USE_ZEROGPU` defaults to `false`, so the app still starts locally and on regular CPU Spaces without requesting ZeroGPU. When enabled and the `spaces` package is available, local OpenBMB generation runs through a `@spaces.GPU(duration=30)` function. The app does not load local models at startup.
|
| 285 |
|
| 286 |
+
The Space requirements are resolved for Python 3.10 compatibility because ZeroGPU builds may use a Python 3.10 base image. The local project also supports Python 3.11. The runtime pins `torch==2.8.0`, which is the preferred ZeroGPU-compatible Torch version for this Space. `llama-cpp-python` is included in `requirements.txt` through its prebuilt CUDA wheel index for GGUF support on the current GPU Space; for CPU Space hardware, switch that index to `/cpu` and set `ACTOR_GGUF_N_GPU_LAYERS=0`. If the Space image cannot use the selected wheel, pip may fall back to a slow source build. If Hugging Face reports a different supported Torch version for ZeroGPU, update `pyproject.toml`, regenerate `requirements.txt`, and refresh `uv.lock`.
|
| 287 |
|
| 288 |
If ZeroGPU is not enabled, `spaces` is unavailable, local model loading fails, CUDA is unavailable inside the GPU function, or model output is invalid, the show falls back gracefully. The Hugging Face API backend remains selectable and is the recommended fallback when you have `HF_TOKEN`; deterministic mode remains the no-token safety path.
|
| 289 |
|
pyproject.toml
CHANGED
|
@@ -9,7 +9,6 @@ dependencies = [
|
|
| 9 |
"edge-tts",
|
| 10 |
"gradio==6.5.1",
|
| 11 |
"huggingface-hub==1.18.0",
|
| 12 |
-
"llama-cpp-python==0.3.28",
|
| 13 |
"peft==0.19.1",
|
| 14 |
"pydantic<=2.12.5",
|
| 15 |
"spaces==0.50.4",
|
|
|
|
| 9 |
"edge-tts",
|
| 10 |
"gradio==6.5.1",
|
| 11 |
"huggingface-hub==1.18.0",
|
|
|
|
| 12 |
"peft==0.19.1",
|
| 13 |
"pydantic<=2.12.5",
|
| 14 |
"spaces==0.50.4",
|
requirements.txt
CHANGED
|
@@ -1,5 +1,13 @@
|
|
| 1 |
# This file was autogenerated by uv via the following command:
|
| 2 |
# uv pip compile pyproject.toml -o requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
accelerate==1.13.0
|
| 4 |
# via
|
| 5 |
# ai-puppet-theater (pyproject.toml)
|
|
@@ -40,8 +48,6 @@ click==8.4.1
|
|
| 40 |
# huggingface-hub
|
| 41 |
# typer
|
| 42 |
# uvicorn
|
| 43 |
-
diskcache==5.6.3
|
| 44 |
-
# via llama-cpp-python
|
| 45 |
edge-tts==7.2.8
|
| 46 |
# via ai-puppet-theater (pyproject.toml)
|
| 47 |
fastapi==0.136.3
|
|
@@ -102,10 +108,7 @@ idna==3.18
|
|
| 102 |
jinja2==3.1.6
|
| 103 |
# via
|
| 104 |
# gradio
|
| 105 |
-
# llama-cpp-python
|
| 106 |
# torch
|
| 107 |
-
llama-cpp-python==0.3.28
|
| 108 |
-
# via ai-puppet-theater (pyproject.toml)
|
| 109 |
markdown-it-py==4.2.0
|
| 110 |
# via rich
|
| 111 |
markupsafe==3.0.3
|
|
@@ -126,7 +129,6 @@ numpy==2.2.6
|
|
| 126 |
# via
|
| 127 |
# accelerate
|
| 128 |
# gradio
|
| 129 |
-
# llama-cpp-python
|
| 130 |
# pandas
|
| 131 |
# peft
|
| 132 |
# transformers
|
|
@@ -244,7 +246,6 @@ typing-extensions==4.15.0
|
|
| 244 |
# gradio
|
| 245 |
# gradio-client
|
| 246 |
# huggingface-hub
|
| 247 |
-
# llama-cpp-python
|
| 248 |
# pydantic
|
| 249 |
# pydantic-core
|
| 250 |
# spaces
|
|
|
|
| 1 |
# This file was autogenerated by uv via the following command:
|
| 2 |
# uv pip compile pyproject.toml -o requirements.txt
|
| 3 |
+
#
|
| 4 |
+
# Manual Space runtime addition:
|
| 5 |
+
# Use llama-cpp-python's prebuilt CUDA wheel index so the Local GGUF Actor model
|
| 6 |
+
# can use GPU offload on the current GPU Space without forcing a source build
|
| 7 |
+
# when a compatible wheel is available. For CPU Spaces, change /cu121 to /cpu
|
| 8 |
+
# and set ACTOR_GGUF_N_GPU_LAYERS=0.
|
| 9 |
+
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121
|
| 10 |
+
llama-cpp-python==0.3.28
|
| 11 |
accelerate==1.13.0
|
| 12 |
# via
|
| 13 |
# ai-puppet-theater (pyproject.toml)
|
|
|
|
| 48 |
# huggingface-hub
|
| 49 |
# typer
|
| 50 |
# uvicorn
|
|
|
|
|
|
|
| 51 |
edge-tts==7.2.8
|
| 52 |
# via ai-puppet-theater (pyproject.toml)
|
| 53 |
fastapi==0.136.3
|
|
|
|
| 108 |
jinja2==3.1.6
|
| 109 |
# via
|
| 110 |
# gradio
|
|
|
|
| 111 |
# torch
|
|
|
|
|
|
|
| 112 |
markdown-it-py==4.2.0
|
| 113 |
# via rich
|
| 114 |
markupsafe==3.0.3
|
|
|
|
| 129 |
# via
|
| 130 |
# accelerate
|
| 131 |
# gradio
|
|
|
|
| 132 |
# pandas
|
| 133 |
# peft
|
| 134 |
# transformers
|
|
|
|
| 246 |
# gradio
|
| 247 |
# gradio-client
|
| 248 |
# huggingface-hub
|
|
|
|
| 249 |
# pydantic
|
| 250 |
# pydantic-core
|
| 251 |
# spaces
|
uv.lock
CHANGED
|
@@ -36,7 +36,6 @@ dependencies = [
|
|
| 36 |
{ name = "edge-tts" },
|
| 37 |
{ name = "gradio" },
|
| 38 |
{ name = "huggingface-hub" },
|
| 39 |
-
{ name = "llama-cpp-python" },
|
| 40 |
{ name = "peft" },
|
| 41 |
{ name = "pydantic" },
|
| 42 |
{ name = "spaces" },
|
|
@@ -56,7 +55,6 @@ requires-dist = [
|
|
| 56 |
{ name = "edge-tts" },
|
| 57 |
{ name = "gradio", specifier = "==6.5.1" },
|
| 58 |
{ name = "huggingface-hub", specifier = "==1.18.0" },
|
| 59 |
-
{ name = "llama-cpp-python", specifier = "==0.3.28" },
|
| 60 |
{ name = "peft", specifier = "==0.19.1" },
|
| 61 |
{ name = "pydantic", specifier = "<=2.12.5" },
|
| 62 |
{ name = "spaces", specifier = "==0.50.4" },
|
|
@@ -305,15 +303,6 @@ wheels = [
|
|
| 305 |
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
| 306 |
]
|
| 307 |
|
| 308 |
-
[[package]]
|
| 309 |
-
name = "diskcache"
|
| 310 |
-
version = "5.6.3"
|
| 311 |
-
source = { registry = "https://pypi.org/simple" }
|
| 312 |
-
sdist = { url = "https://files.pythonhosted.org/packages/3f/21/1c1ffc1a039ddcc459db43cc108658f32c57d271d7289a2794e401d0fdb6/diskcache-5.6.3.tar.gz", hash = "sha256:2c3a3fa2743d8535d832ec61c2054a1641f41775aa7c556758a109941e33e4fc", size = 67916, upload-time = "2023-08-31T06:12:00.316Z" }
|
| 313 |
-
wheels = [
|
| 314 |
-
{ url = "https://files.pythonhosted.org/packages/3f/27/4570e78fc0bf5ea0ca45eb1de3818a23787af9b390c0b0a0033a1b8236f9/diskcache-5.6.3-py3-none-any.whl", hash = "sha256:5e31b2d5fbad117cc363ebaf6b689474db18a1f6438bc82358b024abd4c2ca19", size = 45550, upload-time = "2023-08-31T06:11:58.822Z" },
|
| 315 |
-
]
|
| 316 |
-
|
| 317 |
[[package]]
|
| 318 |
name = "edge-tts"
|
| 319 |
version = "7.2.8"
|
|
@@ -595,19 +584,6 @@ wheels = [
|
|
| 595 |
{ url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" },
|
| 596 |
]
|
| 597 |
|
| 598 |
-
[[package]]
|
| 599 |
-
name = "llama-cpp-python"
|
| 600 |
-
version = "0.3.28"
|
| 601 |
-
source = { registry = "https://pypi.org/simple" }
|
| 602 |
-
dependencies = [
|
| 603 |
-
{ name = "diskcache" },
|
| 604 |
-
{ name = "jinja2" },
|
| 605 |
-
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
| 606 |
-
{ name = "numpy", version = "2.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },
|
| 607 |
-
{ name = "typing-extensions" },
|
| 608 |
-
]
|
| 609 |
-
sdist = { url = "https://files.pythonhosted.org/packages/83/c1/ac90e90d28f405009a89f08a5727d3f0dac49309575fb2d1a5ff1d265826/llama_cpp_python-0.3.28.tar.gz", hash = "sha256:958227b394f413425d6039952096daa0b8b98328c6b99d652862aec775f1672d", size = 68296944, upload-time = "2026-06-07T23:54:28.292Z" }
|
| 610 |
-
|
| 611 |
[[package]]
|
| 612 |
name = "markdown-it-py"
|
| 613 |
version = "4.2.0"
|
|
|
|
| 36 |
{ name = "edge-tts" },
|
| 37 |
{ name = "gradio" },
|
| 38 |
{ name = "huggingface-hub" },
|
|
|
|
| 39 |
{ name = "peft" },
|
| 40 |
{ name = "pydantic" },
|
| 41 |
{ name = "spaces" },
|
|
|
|
| 55 |
{ name = "edge-tts" },
|
| 56 |
{ name = "gradio", specifier = "==6.5.1" },
|
| 57 |
{ name = "huggingface-hub", specifier = "==1.18.0" },
|
|
|
|
| 58 |
{ name = "peft", specifier = "==0.19.1" },
|
| 59 |
{ name = "pydantic", specifier = "<=2.12.5" },
|
| 60 |
{ name = "spaces", specifier = "==0.50.4" },
|
|
|
|
| 303 |
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" },
|
| 304 |
]
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
[[package]]
|
| 307 |
name = "edge-tts"
|
| 308 |
version = "7.2.8"
|
|
|
|
| 584 |
{ url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" },
|
| 585 |
]
|
| 586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
[[package]]
|
| 588 |
name = "markdown-it-py"
|
| 589 |
version = "4.2.0"
|