Executor-Tyrant-Framework commited on
Commit
490fa67
Β·
verified Β·
1 Parent(s): 4a1690a

Sync from GitHub: dcdbd755536453bb053dd732d7d25cb3ad5a51c2

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -9
Dockerfile CHANGED
@@ -41,6 +41,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
41
  build-essential \
42
  ca-certificates \
43
  curl \
 
 
 
44
  && rm -rf /var/lib/apt/lists/*
45
 
46
  # HF Spaces convention: non-root user with UID 1000
@@ -57,27 +60,42 @@ ENV HOME=/home/user \
57
  WORKDIR /home/user/bitnet
58
  RUN git clone --recursive https://github.com/microsoft/BitNet.git /home/user/bitnet
59
 
60
- # Install BitNet's Python build/utility deps
 
 
61
  RUN pip install --no-cache-dir --user -r /home/user/bitnet/requirements.txt
62
 
63
- # Build + download BitNet 2B4T (i2_s = ternary quant scheme specific to
64
- # BitNet's kernels). This single call: downloads the GGUF weights,
65
- # preprocesses them, configures cmake, and compiles llama-cli.
 
 
66
  RUN cd /home/user/bitnet \
67
- && python setup_env.py --hf-repo microsoft/BitNet-b1.58-2B-4T -q i2_s
 
 
 
 
 
 
 
68
 
69
- # Download Falcon3-10B-Instruct 1.58bit GGUF (already ternary-quantized
70
- # by tiiuae; we just need the weights). Filename inside the repo gets
71
- # resolved at runtime by globbing for "*.gguf" in the dir.
 
72
  RUN python -c "\
73
  from huggingface_hub import snapshot_download; \
 
 
 
74
  snapshot_download('tiiuae/Falcon3-10B-Instruct-1.58bit-GGUF', \
75
  local_dir='/home/user/models/falcon3-10b-gguf', \
76
  allow_patterns=['*.gguf'])"
77
 
78
  # Paths exposed to app.py via env vars
79
  ENV BITNET_CPP_BINARY=/home/user/bitnet/build/bin/llama-cli
80
- ENV BITNET_CHAT_GGUF_DIR=/home/user/bitnet/models
81
  ENV FALCON_EXTRACTOR_GGUF_DIR=/home/user/models/falcon3-10b-gguf
82
 
83
  # ── Python app deps + repo ──────────────────────────────────────────
 
41
  build-essential \
42
  ca-certificates \
43
  curl \
44
+ pkg-config \
45
+ libcurl4-openssl-dev \
46
+ libssl-dev \
47
  && rm -rf /var/lib/apt/lists/*
48
 
49
  # HF Spaces convention: non-root user with UID 1000
 
60
  WORKDIR /home/user/bitnet
61
  RUN git clone --recursive https://github.com/microsoft/BitNet.git /home/user/bitnet
62
 
63
+ # Install BitNet's Python build/utility deps (gguf, huggingface_hub,
64
+ # numpy, torch-cpu, etc. β€” used by their conversion + download scripts,
65
+ # which we're about to bypass for the compile, but keep for ggml tools).
66
  RUN pip install --no-cache-dir --user -r /home/user/bitnet/requirements.txt
67
 
68
+ # Compile llama-cli directly via cmake. Bypasses setup_env.py (which
69
+ # swallows cmake errors into logs/compile.log with no way to see them
70
+ # on build failure). -j 2 limits parallel compile jobs so LLVM kernel
71
+ # compilation doesn't OOM the build runner. On compile failure, dump
72
+ # all cmake + compile logs so next-iteration debugging has signal.
73
  RUN cd /home/user/bitnet \
74
+ && cmake -B build \
75
+ -DCMAKE_BUILD_TYPE=Release \
76
+ -DBITNET_X86_TL2=ON \
77
+ && (cmake --build build -j 2 --target llama-cli || \
78
+ (echo "==================== BUILD FAILED ====================" && \
79
+ find /home/user/bitnet -name "CMakeError.log" -o -name "CMakeOutput.log" -o -name "compile.log" 2>/dev/null | \
80
+ while read f; do echo "=== $f ===" && cat "$f" || true; done ; \
81
+ exit 1))
82
 
83
+ # Download GGUF weights directly via huggingface_hub (decoupled from
84
+ # the BitNet repo's preprocess scripts since those assume a specific
85
+ # directory layout). Both models' GGUF files land in known dirs that
86
+ # BitnetCppClient.resolve_gguf finds at runtime.
87
  RUN python -c "\
88
  from huggingface_hub import snapshot_download; \
89
+ snapshot_download('microsoft/bitnet-b1.58-2B-4T-gguf', \
90
+ local_dir='/home/user/models/bitnet-2b-gguf', \
91
+ allow_patterns=['*.gguf']); \
92
  snapshot_download('tiiuae/Falcon3-10B-Instruct-1.58bit-GGUF', \
93
  local_dir='/home/user/models/falcon3-10b-gguf', \
94
  allow_patterns=['*.gguf'])"
95
 
96
  # Paths exposed to app.py via env vars
97
  ENV BITNET_CPP_BINARY=/home/user/bitnet/build/bin/llama-cli
98
+ ENV BITNET_CHAT_GGUF_DIR=/home/user/models/bitnet-2b-gguf
99
  ENV FALCON_EXTRACTOR_GGUF_DIR=/home/user/models/falcon3-10b-gguf
100
 
101
  # ── Python app deps + repo ──────────────────────────────────────────