#!/bin/bash set -e echo "=== Ternary-Bonsai startup ===" # FIX: Remove old incorrect usage if env still points to drafter if [ -f "/models/Ternary-Bonsai-27B-dspark-Q4_1.gguf" ]; then echo "Found drafter file (will keep for optional speculative decoding, but NOT as main model)" ls -lh /models/ fi # Download CORRECT main model if missing - 7.17GB if [ ! -f "/models/Ternary-Bonsai-27B-Q2_0.gguf" ]; then echo "Downloading main model Ternary-Bonsai-27B-Q2_0.gguf (7.2GB)... this takes a few minutes on first run" python3 -c 'from huggingface_hub import hf_hub_download; hf_hub_download(repo_id="prism-ml/Ternary-Bonsai-27B-gguf", filename="Ternary-Bonsai-27B-Q2_0.gguf", local_dir="/models")' else echo "Found main model: /models/Ternary-Bonsai-27B-Q2_0.gguf" ls -lh /models/Ternary-Bonsai-27B-Q2_0.gguf fi echo "Starting llama-server on 0.0.0.0:7860 with CORRECT model..." # For HF Spaces CPU: no -ngl, no draft-model (draft only helps on CUDA and slows CPU) # If you have CUDA, add: --draft-model /models/Ternary-Bonsai-27B-dspark-Q4_1.gguf -ngl 99 exec llama-server \ -m /models/Ternary-Bonsai-27B-Q2_0.gguf \ --host 0.0.0.0 \ --port 7860 \ -c 8192 \ -n 4096 \ -t 8 \ --cache-type-k f16 \ --cache-type-v f16