cvpfus Codex commited on
Commit ·
f158a05
1
Parent(s): 8a826e8
Use prebuilt llama.cpp Modal image
Browse filesCo-authored-by: Codex <codex@openai.com>
- DEPLOY_SPACES.md +2 -0
- README.md +1 -1
- modal_workers/reader_brain.py +1 -11
- scripts/verify.py +3 -2
DEPLOY_SPACES.md
CHANGED
|
@@ -115,6 +115,8 @@ llama-server \
|
|
| 115 |
|
| 116 |
Modal scales the worker down when idle. The first request after scale-to-zero can be slow while the container and model start.
|
| 117 |
|
|
|
|
|
|
|
| 118 |
---
|
| 119 |
|
| 120 |
## Step 4 - Optional Live Image Generation
|
|
|
|
| 115 |
|
| 116 |
Modal scales the worker down when idle. The first request after scale-to-zero can be slow while the container and model start.
|
| 117 |
|
| 118 |
+
The worker uses the prebuilt `ghcr.io/ggml-org/llama.cpp:server-cuda12` image, so Modal should pull a CUDA server image instead of compiling llama.cpp from source during deployment.
|
| 119 |
+
|
| 120 |
---
|
| 121 |
|
| 122 |
## Step 4 - Optional Live Image Generation
|
README.md
CHANGED
|
@@ -77,7 +77,7 @@ LLAMA_CPP_MODEL=narrator-brain
|
|
| 77 |
LLAMA_CPP_TOKEN=your-random-token
|
| 78 |
```
|
| 79 |
|
| 80 |
-
The Modal worker starts Nemotron with `--ctx-size 0`, `--reasoning off`, full GPU offload, and `--api-key` when `LLAMA_CPP_TOKEN` is configured. It scales down when idle, so the first request after a cold start can be slower.
|
| 81 |
|
| 82 |
## Modal Klein Image Generation
|
| 83 |
|
|
|
|
| 77 |
LLAMA_CPP_TOKEN=your-random-token
|
| 78 |
```
|
| 79 |
|
| 80 |
+
The Modal worker starts Nemotron with `--ctx-size 0`, `--reasoning off`, full GPU offload, and `--api-key` when `LLAMA_CPP_TOKEN` is configured. It uses the prebuilt `ghcr.io/ggml-org/llama.cpp:server-cuda12` image instead of compiling llama.cpp during deploy. It scales down when idle, so the first request after a cold start can be slower.
|
| 81 |
|
| 82 |
## Modal Klein Image Generation
|
| 83 |
|
modal_workers/reader_brain.py
CHANGED
|
@@ -33,19 +33,9 @@ def _secret_names() -> list[modal.Secret]:
|
|
| 33 |
|
| 34 |
reader_brain_image = (
|
| 35 |
modal.Image.from_registry(
|
| 36 |
-
"
|
| 37 |
add_python="3.12",
|
| 38 |
)
|
| 39 |
-
.apt_install("git", "cmake", "build-essential", "curl", "ca-certificates")
|
| 40 |
-
.run_commands(
|
| 41 |
-
"git clone --depth 1 https://github.com/ggml-org/llama.cpp.git /tmp/llama.cpp",
|
| 42 |
-
"cmake -S /tmp/llama.cpp -B /tmp/llama.cpp/build "
|
| 43 |
-
"-DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release",
|
| 44 |
-
"cmake --build /tmp/llama.cpp/build --target llama-server -j$(nproc)",
|
| 45 |
-
"cp /tmp/llama.cpp/build/bin/llama-server /usr/local/bin/llama-server",
|
| 46 |
-
"chmod +x /usr/local/bin/llama-server",
|
| 47 |
-
"rm -rf /tmp/llama.cpp",
|
| 48 |
-
)
|
| 49 |
.env(
|
| 50 |
{
|
| 51 |
"HF_HOME": f"{CACHE_DIR}/huggingface",
|
|
|
|
| 33 |
|
| 34 |
reader_brain_image = (
|
| 35 |
modal.Image.from_registry(
|
| 36 |
+
"ghcr.io/ggml-org/llama.cpp:server-cuda12",
|
| 37 |
add_python="3.12",
|
| 38 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
.env(
|
| 40 |
{
|
| 41 |
"HF_HOME": f"{CACHE_DIR}/huggingface",
|
scripts/verify.py
CHANGED
|
@@ -476,8 +476,9 @@ def verify_modal_klein_integration() -> None:
|
|
| 476 |
assert_true(reader_worker_path.exists(), "Modal reader-brain worker file should exist")
|
| 477 |
reader_worker_source = reader_worker_path.read_text(encoding="utf-8")
|
| 478 |
assert_true("modal.web_server" in reader_worker_source, "Reader-brain worker should expose llama-server through Modal web_server")
|
| 479 |
-
assert_true("
|
| 480 |
-
assert_true("GGML_CUDA=ON" in reader_worker_source, "Reader-brain worker should compile llama.cpp
|
|
|
|
| 481 |
assert_true("NVIDIA-Nemotron-3-Nano-4B-GGUF:Q4_K_M" in reader_worker_source, "Reader-brain worker should serve the Nemotron GGUF")
|
| 482 |
assert_true('"--reasoning"' in reader_worker_source and '"off"' in reader_worker_source, "Reader-brain worker should disable reasoning mode")
|
| 483 |
assert_true('"--ctx-size"' in reader_worker_source and '"0"' in reader_worker_source, "Reader-brain worker should use model context size")
|
|
|
|
| 476 |
assert_true(reader_worker_path.exists(), "Modal reader-brain worker file should exist")
|
| 477 |
reader_worker_source = reader_worker_path.read_text(encoding="utf-8")
|
| 478 |
assert_true("modal.web_server" in reader_worker_source, "Reader-brain worker should expose llama-server through Modal web_server")
|
| 479 |
+
assert_true("ghcr.io/ggml-org/llama.cpp:server-cuda12" in reader_worker_source, "Reader-brain worker should use the prebuilt llama.cpp CUDA server image")
|
| 480 |
+
assert_true("GGML_CUDA=ON" not in reader_worker_source, "Reader-brain worker should not compile llama.cpp during Modal builds")
|
| 481 |
+
assert_true("cmake --build" not in reader_worker_source, "Reader-brain worker should avoid slow CMake builds on Modal")
|
| 482 |
assert_true("NVIDIA-Nemotron-3-Nano-4B-GGUF:Q4_K_M" in reader_worker_source, "Reader-brain worker should serve the Nemotron GGUF")
|
| 483 |
assert_true('"--reasoning"' in reader_worker_source and '"off"' in reader_worker_source, "Reader-brain worker should disable reasoning mode")
|
| 484 |
assert_true('"--ctx-size"' in reader_worker_source and '"0"' in reader_worker_source, "Reader-brain worker should use model context size")
|