File size: 3,213 Bytes
727757f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Qwen SpeedLab β€” Common configuration
# RTX 3090 24GB VRAM optimized
#
# Two inference engines available:
#   1. BeeLlama.cpp (Anbeeld) β†’ DFlash + TurboQuant
#   2. TurboQ-MTP (Indras-Mirror) β†’ TBQ4 fused FA + RotorQuant + MTP + tensor sharing
#
# Two model variants:
#   1. batiai (standard GGUF, no MTP heads) β†’ baseline, DFlash
#   2. ManniX (MTP-enabled GGUF, blk.64.nextn.* preserved) β†’ MTP self-spec

set -euo pipefail

# ─── Engine paths ──────────────────────────────────────────
BEELLAMA_DIR="/workspace/beellama.cpp"
TURBOQ_DIR="/workspace/llama.cpp-turboq-mtp"

# Default to TurboQ-MTP (more features: RotorQuant, tensor sharing, TBQ4 fused FA)
ENGINE="${ENGINE:-turboq}"
if [ "${ENGINE}" = "beellama" ]; then
    LLAMA_SERVER="${BEELLAMA_DIR}/build/bin/llama-server"
    LLAMA_CLI="${BEELLAMA_DIR}/build/bin/llama-cli"
    LLAMA_BENCH="${BEELLAMA_DIR}/build/bin/llama-bench"
else
    LLAMA_SERVER="${TURBOQ_DIR}/build/bin/llama-server"
    LLAMA_CLI="${TURBOQ_DIR}/build/bin/llama-cli"
    LLAMA_BENCH="${TURBOQ_DIR}/build/bin/llama-bench"
fi

# ─── Model files ───────────────────────────────────────────
MODELS_DIR="/workspace/models"

# Standard GGUF (no MTP heads) β€” for baseline & DFlash
TARGET_MODEL="${MODELS_DIR}/batiai-qwen36-27b/Qwen-Qwen3.6-27B-Q4_K_M.gguf"

# MTP-enabled GGUF (blk.64.nextn.* preserved at Q8_0) β€” for self-spec
MTP_MODEL="${MODELS_DIR}/mannix-mtp-qwen36-27b/Qwen3.6-27B-Omnimerge-v4-Q4_K_M.gguf"

# DFlash draft model (block diffusion spec decode)
DFLASH_DRAFT="${MODELS_DIR}/dflash/Qwen3.6-27B-DFlash-Q4_K_M.gguf"

# Multimodal projector (optional)
MMPROJ="${MODELS_DIR}/batiai-qwen36-27b/mmproj-Qwen-Qwen3.6-27B-BF16.gguf"

# ─── GPU Configuration ─────────────────────────────────────
GPU_LAYERS=99
BATCH_SIZE=2048
UBATCH_SIZE=512

# ─── KV Cache ──────────────────────────────────────────────
CTX_SIZE=102400

# ─── Server ────────────────────────────────────────────────
HOST="0.0.0.0"
PORT=8082
N_PARALLEL=1

# ─── Logging ───────────────────────────────────────────────
LOG_DIR="/workspace/logs"
mkdir -p "${LOG_DIR}"

log() {
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "${LOG_DIR}/qwen-speedlab.log"
}

wait_for_server() {
    local port=${1:-$PORT}
    local max_wait=${2:-60}
    local waited=0
    log "Waiting for server on port ${port}..."
    while ! curl -s "http://localhost:${port}/health" > /dev/null 2>&1; do
        sleep 1
        waited=$((waited + 1))
        if [ $waited -ge $max_wait ]; then
            log "ERROR: Server did not start within ${max_wait}s"
            return 1
        fi
    done
    log "Server is ready! (took ${waited}s)"
}