Spaces:
Running
Running
perf(build): skip heavy compile+GGUF on HF (A11OY_REQUIRE_LOCAL_LLM!=1); byte-identical to GitHub fa3e0b2e
Browse files- Dockerfile +17 -15
Dockerfile
CHANGED
|
@@ -480,22 +480,17 @@ COPY szl_alloy_models.py ./szl_alloy_models.py
|
|
| 480 |
# HF Space reliably bootable. No fabricated data either way.
|
| 481 |
ARG A11OY_REQUIRE_LOCAL_LLM=0
|
| 482 |
RUN set -eux; \
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
if CMAKE_ARGS="-DGGML_NATIVE=OFF" pip install --no-cache-dir --no-binary llama-cpp-python "llama-cpp-python==0.3.19" \
|
| 486 |
-
&& python3 -c "import llama_cpp, os, glob; base=os.path.dirname(llama_cpp.__file__); so=glob.glob(os.path.join(base,'**','libllama.so'), recursive=True); assert so, 'libllama.so not found under '+base; d=open(so[0],'rb').read(); assert b'libc.so.6' in d and b'libc.musl-x86_64.so.1' not in d, 'libllama.so is not glibc-linked: '+so[0]; print('[a11oy] llama_cpp built from source OK (glibc):', so[0], getattr(llama_cpp,'__version__','?'))"; then \
|
| 487 |
-
echo '[a11oy] local llama.cpp demo tier: BUILT (real on-CPU output available)'; \
|
| 488 |
else \
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
apt-get autoremove -y; \
|
| 498 |
-
rm -rf /var/lib/apt/lists/*
|
| 499 |
# GGUF weight — RELIABLY PRESENT (pinned revision + retry + integrity verify), NOT best-effort.
|
| 500 |
# Previously a single best-effort `hf_hub_download(...) || echo` step: a transient download
|
| 501 |
# failure silently shipped an image with NO model, so the alloy demo tier always degraded to
|
|
@@ -516,6 +511,13 @@ RUN python3 <<'GGUFPY'
|
|
| 516 |
import hashlib, os, sys, time
|
| 517 |
from huggingface_hub import hf_hub_download
|
| 518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
repo = os.environ["A11OY_ALLOY_GGUF_REPO"]
|
| 520 |
fname = os.environ["A11OY_ALLOY_GGUF_FILE"]
|
| 521 |
rev = os.environ["A11OY_ALLOY_GGUF_REV"]
|
|
|
|
| 480 |
# HF Space reliably bootable. No fabricated data either way.
|
| 481 |
ARG A11OY_REQUIRE_LOCAL_LLM=0
|
| 482 |
RUN set -eux; \
|
| 483 |
+
if [ "${A11OY_REQUIRE_LOCAL_LLM}" != "1" ]; then \
|
| 484 |
+
echo '[a11oy] A11OY_REQUIRE_LOCAL_LLM!=1 (constrained builder, e.g. HF cpu-basic): SKIPPING the heavy from-source llama.cpp compile to keep this build fast + reliable. The demo tier serves the HONEST tower-side label (szl_alloy_models.py, served_locally=False, never fake output). The strict GHCR-published image sets =1 and DOES compile + boot-verify real local output.'; \
|
|
|
|
|
|
|
|
|
|
| 485 |
else \
|
| 486 |
+
apt-get update; \
|
| 487 |
+
apt-get install -y --no-install-recommends build-essential cmake ninja-build git libgomp1 libstdc++6; \
|
| 488 |
+
CMAKE_ARGS="-DGGML_NATIVE=OFF" pip install --no-cache-dir --no-binary llama-cpp-python "llama-cpp-python==0.3.19"; \
|
| 489 |
+
python3 -c "import llama_cpp, os, glob; base=os.path.dirname(llama_cpp.__file__); so=glob.glob(os.path.join(base,'**','libllama.so'), recursive=True); assert so, 'libllama.so not found under '+base; d=open(so[0],'rb').read(); assert b'libc.so.6' in d and b'libc.musl-x86_64.so.1' not in d, 'libllama.so is not glibc-linked: '+so[0]; print('[a11oy] llama_cpp built from source OK (glibc):', so[0], getattr(llama_cpp,'__version__','?'))"; \
|
| 490 |
+
apt-get purge -y build-essential cmake ninja-build git; \
|
| 491 |
+
apt-get autoremove -y; \
|
| 492 |
+
rm -rf /var/lib/apt/lists/*; \
|
| 493 |
+
fi
|
|
|
|
|
|
|
| 494 |
# GGUF weight — RELIABLY PRESENT (pinned revision + retry + integrity verify), NOT best-effort.
|
| 495 |
# Previously a single best-effort `hf_hub_download(...) || echo` step: a transient download
|
| 496 |
# failure silently shipped an image with NO model, so the alloy demo tier always degraded to
|
|
|
|
| 511 |
import hashlib, os, sys, time
|
| 512 |
from huggingface_hub import hf_hub_download
|
| 513 |
|
| 514 |
+
# RESILIENCE: on a constrained builder (A11OY_REQUIRE_LOCAL_LLM!=1, e.g. HF cpu-basic)
|
| 515 |
+
# the llama.cpp compile was skipped, so the 491MB GGUF is dead weight + slows the build.
|
| 516 |
+
# Skip the download too; the demo tier serves the HONEST tower-side label. The strict
|
| 517 |
+
# GHCR image sets =1 and DOES fetch + sha/size-verify the weight (boot-tested in CI).
|
| 518 |
+
if os.environ.get("A11OY_REQUIRE_LOCAL_LLM") != "1":
|
| 519 |
+
print("[a11oy] A11OY_REQUIRE_LOCAL_LLM!=1: skipping GGUF weight fetch (demo tier = honest tower-side label). App boots normally.", flush=True)
|
| 520 |
+
sys.exit(0)
|
| 521 |
repo = os.environ["A11OY_ALLOY_GGUF_REPO"]
|
| 522 |
fname = os.environ["A11OY_ALLOY_GGUF_FILE"]
|
| 523 |
rev = os.environ["A11OY_ALLOY_GGUF_REV"]
|