pashak commited on
Commit
df28248
Β·
1 Parent(s): f813944

add ternary + mcp

Browse files
.gitattributes CHANGED
@@ -34,4 +34,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  bin/*.so.* filter=lfs diff=lfs merge=lfs -text
 
37
  bin/llama-* filter=lfs diff=lfs merge=lfs -text
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  bin/*.so.* filter=lfs diff=lfs merge=lfs -text
37
+ bin/libggml-*.so filter=lfs diff=lfs merge=lfs -text
38
  bin/llama-* filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,14 +1,27 @@
1
  FROM nvidia/cuda:12.8.0-runtime-ubuntu22.04
2
 
3
  RUN apt-get update && apt-get install -y --no-install-recommends \
4
- curl ca-certificates git libgomp1 nginx openssl python3 \
5
  && rm -rf /var/lib/apt/lists/* \
6
  && chown -R 1000:1000 /var/lib/nginx /var/log/nginx /run
7
 
 
 
 
 
 
8
  RUN useradd -m -u 1000 user
9
  USER user
10
  ENV HOME=/home/user PATH="/home/user/.local/bin:/app/bin:$PATH"
11
 
 
 
 
 
 
 
 
 
12
  WORKDIR /app
13
 
14
  COPY --chown=user bin/ /app/bin/
 
1
  FROM nvidia/cuda:12.8.0-runtime-ubuntu22.04
2
 
3
  RUN apt-get update && apt-get install -y --no-install-recommends \
4
+ curl ca-certificates git libgomp1 libssl3 nginx openssl python3 \
5
  && rm -rf /var/lib/apt/lists/* \
6
  && chown -R 1000:1000 /var/lib/nginx /var/log/nginx /run
7
 
8
+ # Node.js 20 (for JS-based MCP servers + supergateway bridge)
9
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
10
+ && apt-get install -y --no-install-recommends nodejs \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
  RUN useradd -m -u 1000 user
14
  USER user
15
  ENV HOME=/home/user PATH="/home/user/.local/bin:/app/bin:$PATH"
16
 
17
+ # uv + arxiv-mcp-server (Python, stdio β€” bridged to HTTP via supergateway)
18
+ RUN curl -fsSL https://astral.sh/uv/install.sh | sh \
19
+ && /home/user/.local/bin/uv tool install 'arxiv-mcp-server[pdf]'
20
+
21
+ # Brave Search MCP (native HTTP) + supergateway (stdio→SSE bridge)
22
+ RUN npm config set prefix /home/user/.local \
23
+ && npm install -g @brave/brave-search-mcp-server supergateway
24
+
25
  WORKDIR /app
26
 
27
  COPY --chown=user bin/ /app/bin/
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Bonsai 1-bit GPU
3
  emoji: 🌿
4
  colorFrom: green
5
  colorTo: blue
@@ -7,11 +7,14 @@ sdk: docker
7
  app_port: 7860
8
  suggested_hardware: l40sx1
9
  pinned: true
10
- short_description: Run 1-bit Bonsai LLMs on GPUs
11
  models:
12
  - prism-ml/Bonsai-8B-gguf
13
  - prism-ml/Bonsai-4B-gguf
14
  - prism-ml/Bonsai-1.7B-gguf
 
 
 
15
  ---
16
 
17
  # Bonsai Demo
@@ -20,20 +23,36 @@ Interactive demo for **[Bonsai](https://huggingface.co/collections/prism-ml/bons
20
 
21
  Bonsai models run at **true 1-bit precision** β€” every weight is a single bit. An 8B model fits in **1.15 GB**, a 1.7B model in just **240 MB**. Small enough to run in a browser, on a phone, or on any laptop β€” while remaining competitive with full-precision models on benchmarks.
22
 
23
- > **This demo will be available for a limited time (approximately 1–2 weeks).** Enjoy it while it lasts!
 
 
24
 
25
  ## Highlights
26
 
27
  Bonsai-8B fits in **1.15 GB** (14x smaller than FP16) and generates at **~330 tok/s** on an L40S (6.3x faster than FP16). Scores 70.5 average across 6 benchmark tasks, competitive with full-precision 8B models.
28
 
 
 
 
 
29
  ## Models
30
 
 
 
31
  | Model | Size | GGUF | MLX |
32
  |---|---|---|---|
33
  | **Bonsai-8B** | 1.15 GB | [prism-ml/Bonsai-8B-gguf](https://huggingface.co/prism-ml/Bonsai-8B-gguf) | [prism-ml/Bonsai-8B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-8B-mlx-1bit) |
34
  | **Bonsai-4B** | 570 MB | [prism-ml/Bonsai-4B-gguf](https://huggingface.co/prism-ml/Bonsai-4B-gguf) | [prism-ml/Bonsai-4B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-4B-mlx-1bit) |
35
  | **Bonsai-1.7B** | 240 MB | [prism-ml/Bonsai-1.7B-gguf](https://huggingface.co/prism-ml/Bonsai-1.7B-gguf) | [prism-ml/Bonsai-1.7B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-1.7B-mlx-1bit) |
36
 
 
 
 
 
 
 
 
 
37
  ## Resources
38
 
39
  - [1-bit Bonsai Whitepaper](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/1-bit-bonsai-8b-whitepaper.pdf)
 
1
  ---
2
+ title: Bonsai {1, 1.58}-bit GPU
3
  emoji: 🌿
4
  colorFrom: green
5
  colorTo: blue
 
7
  app_port: 7860
8
  suggested_hardware: l40sx1
9
  pinned: true
10
+ short_description: Run {1, 1.58}-bit Bonsai LLMs on GPUs
11
  models:
12
  - prism-ml/Bonsai-8B-gguf
13
  - prism-ml/Bonsai-4B-gguf
14
  - prism-ml/Bonsai-1.7B-gguf
15
+ - prism-ml/Ternary-Bonsai-8B-gguf
16
+ - prism-ml/Ternary-Bonsai-4B-gguf
17
+ - prism-ml/Ternary-Bonsai-1.7B-gguf
18
  ---
19
 
20
  # Bonsai Demo
 
23
 
24
  Bonsai models run at **true 1-bit precision** β€” every weight is a single bit. An 8B model fits in **1.15 GB**, a 1.7B model in just **240 MB**. Small enough to run in a browser, on a phone, or on any laptop β€” while remaining competitive with full-precision models on benchmarks.
25
 
26
+ **Ternary-Bonsai** is the 1.58-bit sibling series β€” each weight is one of {βˆ’1, 0, +1}. It trades a bit of size for a quality bump over the pure 1-bit models. An 8B Ternary-Bonsai fits in **2.03 GB**, a 1.7B in just **430 MB**.
27
+
28
+ > **This demo will be available for a limited time.** Enjoy it while it lasts!
29
 
30
  ## Highlights
31
 
32
  Bonsai-8B fits in **1.15 GB** (14x smaller than FP16) and generates at **~330 tok/s** on an L40S (6.3x faster than FP16). Scores 70.5 average across 6 benchmark tasks, competitive with full-precision 8B models.
33
 
34
+ **Ternary-Bonsai-8B** (1.58-bit, 2.03 GB) is also available in the chat UI β€” pick it from the model dropdown for a quality bump at a modest size increase over the 1-bit models.
35
+
36
+ **Tool calling & MCP**: the chat UI supports OpenAI-style tool calling and comes with Brave Search and ArXiv MCP servers pre-wired β€” open the MCP tab in the chat settings to use them.
37
+
38
  ## Models
39
 
40
+ ### 1-bit Bonsai
41
+
42
  | Model | Size | GGUF | MLX |
43
  |---|---|---|---|
44
  | **Bonsai-8B** | 1.15 GB | [prism-ml/Bonsai-8B-gguf](https://huggingface.co/prism-ml/Bonsai-8B-gguf) | [prism-ml/Bonsai-8B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-8B-mlx-1bit) |
45
  | **Bonsai-4B** | 570 MB | [prism-ml/Bonsai-4B-gguf](https://huggingface.co/prism-ml/Bonsai-4B-gguf) | [prism-ml/Bonsai-4B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-4B-mlx-1bit) |
46
  | **Bonsai-1.7B** | 240 MB | [prism-ml/Bonsai-1.7B-gguf](https://huggingface.co/prism-ml/Bonsai-1.7B-gguf) | [prism-ml/Bonsai-1.7B-mlx-1bit](https://huggingface.co/prism-ml/Bonsai-1.7B-mlx-1bit) |
47
 
48
+ ### 1.58-bit Ternary-Bonsai
49
+
50
+ | Model | Size | GGUF |
51
+ |---|---|---|
52
+ | **Ternary-Bonsai-8B** | 2.03 GB | [prism-ml/Ternary-Bonsai-8B-gguf](https://huggingface.co/prism-ml/Ternary-Bonsai-8B-gguf) |
53
+ | **Ternary-Bonsai-4B** | 1.00 GB | [prism-ml/Ternary-Bonsai-4B-gguf](https://huggingface.co/prism-ml/Ternary-Bonsai-4B-gguf) |
54
+ | **Ternary-Bonsai-1.7B** | 430 MB | [prism-ml/Ternary-Bonsai-1.7B-gguf](https://huggingface.co/prism-ml/Ternary-Bonsai-1.7B-gguf) |
55
+
56
  ## Resources
57
 
58
  - [1-bit Bonsai Whitepaper](https://github.com/PrismML-Eng/Bonsai-demo/blob/main/1-bit-bonsai-8b-whitepaper.pdf)
bin/libggml-base.so.0 CHANGED
@@ -1 +1 @@
1
- libggml-base.so.0.9.7
 
1
+ libggml-base.so.0.9.11
bin/{libggml-base.so.0.9.7 β†’ libggml-base.so.0.9.11} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:34c567f790d8f6b6ce63ae446431d737e382d10bbb7f634e79855749d75c79a6
3
- size 787520
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:519961d682cb8b740fec46229a918ecae9b7dd072d7d0c40cc5ce0de4c3c0f85
3
+ size 845400
bin/{libllama.so.0.0.8190 β†’ libggml-cpu-alderlake.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2303b49c572d5b7b36123046cad7469d8b3caf8778834b37dc6df546fb341588
3
- size 3203944
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09c2d6908b8bab3e2503d9d4991be2465ddc86e4bd7a3c5bb1f2dcac77d7974e
3
+ size 1116024
bin/{libggml-cpu.so.0.9.7 β†’ libggml-cpu-cannonlake.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:57b6c7bf5e9424bc52df6fc8f5503b22f029df912fee65f342b441d5032fb8e3
3
- size 1107144
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ca4934d1a66c3a9e28a79eade62a5ca6310060ea5503965de1e9c6b6bf2dc31
3
+ size 1261008
bin/libggml-cpu-cascadelake.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc5f7d431f0ef0cb1d93a3ae217a5980029a8c4855bbac0b73383a89b8ea3b3e
3
+ size 1261008
bin/libggml-cpu-cooperlake.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb9f78486f6febcc349290a537d33812ed354684cb2a40003138c8104ba3a212
3
+ size 1256976
bin/libggml-cpu-haswell.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af894b9c5dd734af5e8268eec8410ff0e0d6f672180a1b4f4f86e9fac23b928c
3
+ size 1120120
bin/libggml-cpu-icelake.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79a268a1247da905951bfecf391b81798dd5dba8a08a25e44f663adee02eceb6
3
+ size 1261008
bin/libggml-cpu-ivybridge.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3eef94fd02e558f9fcdb438cb4298b3a42b96ae7f50ee0a9f4dc3649a19fa821
3
+ size 1069488
bin/libggml-cpu-piledriver.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4541790316c2273f736b96de564aa90862e7edb6be78a704a3108ceb9e88f7da
3
+ size 1065392
bin/libggml-cpu-sandybridge.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee54b58402ef7959d8a2b93545be6fd4cc155367b682a7d4feec314a7d73b468
3
+ size 1060176
bin/libggml-cpu-sapphirerapids.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:210624b50dd11f91aef30477e12c5ecdb27da514063a413464c205df1a06b6b0
3
+ size 1527440
bin/libggml-cpu-skylakex.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f844ef94bad71edae865c147d9de55d0e52f8ee75f5cfc518a238a2e976092c4
3
+ size 1261008
bin/{libmtmd.so.0.0.8190 β†’ libggml-cpu-sse42.so} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ff0f675a01f13961e6f545ef414ae6cc50fcfa65379aa9ca1032437cd16194a3
3
- size 943272
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ce33ec9c53629a14c2ee94ce515913a53cb642d36ac15bc241700e1a48c36a9
3
+ size 861016
bin/libggml-cpu-x64.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d051bc7971d8febf2cb1307b6259018ca83870c72a1e98c36ce328ded3e70695
3
+ size 852960
bin/libggml-cpu-zen4.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d6377df73d036b3e3200087f16277dbd51b07eb6e043c7d239364c730bfff82e
3
+ size 1256976
bin/libggml-cpu.so DELETED
@@ -1 +0,0 @@
1
- libggml-cpu.so.0
 
 
bin/libggml-cpu.so.0 DELETED
@@ -1 +0,0 @@
1
- libggml-cpu.so.0.9.7
 
 
bin/libggml-cuda.so DELETED
@@ -1 +0,0 @@
1
- libggml-cuda.so.0
 
 
bin/libggml-cuda.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26bde851064e0e6cf25a51a2d5f6b2121e9f173112366c648db30c6e83011a85
3
+ size 62558664
bin/libggml-cuda.so.0 DELETED
@@ -1 +0,0 @@
1
- libggml-cuda.so.0.9.7
 
 
bin/libggml-cuda.so.0.9.7 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f9274ff637e09a5beb5d2ec55a475790bbd22ea3b6095b975ab4bbc18001ccd9
3
- size 55252864
 
 
 
 
bin/libggml.so.0 CHANGED
@@ -1 +1 @@
1
- libggml.so.0.9.7
 
1
+ libggml.so.0.9.11
bin/{libggml.so.0.9.7 β†’ libggml.so.0.9.11} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cebe9400f91bbea8c0c1663d8a7582299835bd1d040dcd4a326ac067b4adddd9
3
- size 55184
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5f77f5eb813abd62f00a19a77acbb02d8257838bb31298e566029c26d53686a
3
+ size 54936
bin/libllama.so.0 CHANGED
@@ -1 +1 @@
1
- libllama.so.0.0.8190
 
1
+ libllama.so.0.0.8799
bin/libllama.so.0.0.8799 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b46095aee60fa50ff13916c4f2c5370404d10c779409d11ec3a1a6e2c0e6781
3
+ size 3274176
bin/libmtmd.so.0 CHANGED
@@ -1 +1 @@
1
- libmtmd.so.0.0.8190
 
1
+ libmtmd.so.0.0.8799
bin/libmtmd.so.0.0.8799 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b4a300955c9404de480b2ae78e51da5d6fa365417cd147861c3f45365bd1143
3
+ size 1117184
bin/llama-bench CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:52825c5cbf617cd86db04a143188bee3d666e789168a897ced04001882afe2aa
3
- size 592680
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de3f39974acab8b31b45a87f5e487ba7c40ae6d4613abf06c2cdc8e17686515e
3
+ size 2158088
bin/llama-cli CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4c09f893698bf498dc872b950635bcae961de90ce67dadc83c62d34c9812ead0
3
- size 5665432
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:525b05afaccb7616203e1fb8c325375ce44d0b5cc6ab4a643b03123f920ef5cd
3
+ size 6047952
bin/llama-completion CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1b126040b118cb1bf0c041e2951e78a00aa2c619c414cc380b361c59c1d5980d
3
- size 4642520
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11fe8f49f3459dc33fade5018962dd655727b34aa94fb10d5c09d9ab4d99a764
3
+ size 4979792
bin/llama-perplexity CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:445b36510eaa53b9ee1ee641a5672b0dd7642be921a2a043f7ebd639b084dd64
3
- size 4680640
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57d5d0fa5b6dca19860214d14ea3657dc0790af631416951f4f082c062ca5f53
3
+ size 5021280
bin/llama-quantize CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6114cda3bf733678f49dab714d689b53f8505889ccae88650003d7a86a90f783
3
- size 442464
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55a7a8c1669f412ca96987944c2def5b1c6820e5d5c6a2614128f4b5e340b0b6
3
+ size 457888
bin/llama-server CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b33f7d0abc362fdd49175df2b66741b4784c737f348cba5175220c6c871246dd
3
- size 7354688
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15c431ef81e57245b64bde067025f4732f7f61e6d47761329fb00881b9fd3bb7
3
+ size 13416216
entrypoint.sh CHANGED
@@ -3,30 +3,28 @@ set -e
3
 
4
  echo "Starting Bonsai-demo entrypoint..."
5
 
6
- # ── Validate required secrets ─────────────────────────────────────────────────
7
- if [ -z "$MODEL_REPO" ] || [ -z "$MODEL_FILE" ]; then
8
- echo ""
9
- echo "ERROR: MODEL_REPO and MODEL_FILE secrets must be set."
10
- echo " Go to Space Settings β†’ Repository Secrets and add:"
11
- echo " MODEL_REPO = prism-ml/Bonsai-8B-gguf"
12
- echo " MODEL_FILE = Bonsai-8B.gguf"
13
- echo ""
14
- exit 1
15
- fi
16
 
17
  MODEL_DIR="/app/models"
18
  mkdir -p "$MODEL_DIR"
19
 
20
  download_model() {
21
  local repo file path retries=5
22
- repo=$(echo "$1" | tr -d '[:space:]')
23
- file=$(echo "$2" | tr -d '[:space:]')
24
  path="$MODEL_DIR/$file"
25
  local url="https://huggingface.co/$repo/resolve/main/$file"
26
  for attempt in $(seq 1 $retries); do
27
  echo "Downloading (attempt $attempt/$retries): $url"
28
  rm -f "$path"
29
- if curl -fL --retry 3 --retry-delay 5 -C - -o "$path" "$url" 2>&1; then
 
 
30
  echo "Downloaded: $(ls -lh "$path")"
31
  return 0
32
  fi
@@ -37,23 +35,10 @@ download_model() {
37
  exit 1
38
  }
39
 
40
- # Primary model (required)
41
- MODEL_REPO=$(echo "$MODEL_REPO" | tr -d '[:space:]')
42
- MODEL_FILE=$(echo "$MODEL_FILE" | tr -d '[:space:]')
43
- download_model "$MODEL_REPO" "$MODEL_FILE"
44
-
45
- # Additional models (optional)
46
- MODELS_MAX=1
47
- for suffix in B C; do
48
- repo_var="MODEL_REPO_${suffix}"
49
- file_var="MODEL_FILE_${suffix}"
50
- repo=$(echo "${!repo_var:-}" | tr -d '[:space:]')
51
- file=$(echo "${!file_var:-}" | tr -d '[:space:]')
52
- if [ -n "$repo" ] && [ -n "$file" ]; then
53
- download_model "$repo" "$file"
54
- MODELS_MAX=$((MODELS_MAX + 1))
55
- fi
56
  done
 
57
 
58
  # ── Dashboard auth ────────────────────────────────────────────────────────────
59
  if [ -n "$DASHBOARD_KEY" ]; then
@@ -68,6 +53,24 @@ fi
68
  # ── nginx temp dirs ───────────────────────────────────────────────────────────
69
  mkdir -p /tmp/nginx-{client-body,proxy,fastcgi,uwsgi,scgi}
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  # ── Detect GPUs and start one llama-server per GPU ───────────────────────────
72
  GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l || echo 1)
73
  echo "GPUs detected: $GPU_COUNT"
@@ -77,7 +80,8 @@ for i in $(seq 0 $((GPU_COUNT - 1))); do
77
  PORT=$((7861 + i))
78
  echo "Starting llama-server on GPU $i β†’ port $PORT"
79
  CUDA_VISIBLE_DEVICES=$i /app/bin/llama-server \
80
- -m "$MODEL_DIR/$MODEL_FILE" \
 
81
  --host 127.0.0.1 \
82
  --port "$PORT" \
83
  -ngl 99 \
@@ -85,6 +89,8 @@ for i in $(seq 0 $((GPU_COUNT - 1))); do
85
  -np 4 \
86
  -c 262144 \
87
  --metrics \
 
 
88
  --temp 0.5 --top-p 0.85 --top-k 20 --min-p 0 \
89
  --reasoning-budget 0 --reasoning-format none \
90
  --chat-template-kwargs '{"enable_thinking": false}' \
 
3
 
4
  echo "Starting Bonsai-demo entrypoint..."
5
 
6
+ # ── Hardcoded models (edit and push to change) ───────────────────────────────
7
+ # Format: "repo|file"
8
+ MODELS=(
9
+ "prism-ml/Bonsai-8B-gguf|Bonsai-8B-Q1_0.gguf"
10
+ "prism-ml/Ternary-Bonsai-8B-gguf|Ternary-Bonsai-8B-Q2_0.gguf"
11
+ )
 
 
 
 
12
 
13
  MODEL_DIR="/app/models"
14
  mkdir -p "$MODEL_DIR"
15
 
16
  download_model() {
17
  local repo file path retries=5
18
+ repo="$1"
19
+ file="$2"
20
  path="$MODEL_DIR/$file"
21
  local url="https://huggingface.co/$repo/resolve/main/$file"
22
  for attempt in $(seq 1 $retries); do
23
  echo "Downloading (attempt $attempt/$retries): $url"
24
  rm -f "$path"
25
+ if curl -fL --retry 3 --retry-delay 5 -C - -o "$path" \
26
+ ${HF_TOKEN:+-H "Authorization: Bearer $HF_TOKEN"} \
27
+ "$url" 2>&1; then
28
  echo "Downloaded: $(ls -lh "$path")"
29
  return 0
30
  fi
 
35
  exit 1
36
  }
37
 
38
+ for entry in "${MODELS[@]}"; do
39
+ download_model "${entry%%|*}" "${entry#*|}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  done
41
+ MODELS_MAX=${#MODELS[@]}
42
 
43
  # ── Dashboard auth ────────────────────────────────────────────────────────────
44
  if [ -n "$DASHBOARD_KEY" ]; then
 
53
  # ── nginx temp dirs ───────────────────────────────────────────────────────────
54
  mkdir -p /tmp/nginx-{client-body,proxy,fastcgi,uwsgi,scgi}
55
 
56
+ # ── MCP servers (shared across all GPU backends) ─────────────────────────────
57
+ echo ""
58
+ echo "=== Starting MCP servers ==="
59
+
60
+ # Brave Search MCP (native HTTP) on 127.0.0.1:8001/mcp
61
+ if [ -n "$BRAVE_API_KEY" ]; then
62
+ echo "Starting Brave Search MCP on 127.0.0.1:8001"
63
+ brave-search-mcp-server --transport http --host 127.0.0.1 --port 8001 &
64
+ else
65
+ echo "BRAVE_API_KEY not set -- skipping Brave Search MCP"
66
+ fi
67
+
68
+ # ArXiv MCP (stdio) bridged via supergateway on 127.0.0.1:8002/sse
69
+ echo "Starting ArXiv MCP on 127.0.0.1:8002 (via supergateway)"
70
+ supergateway --stdio "arxiv-mcp-server" --port 8002 --baseUrl http://127.0.0.1:8002 &
71
+
72
+ sleep 1
73
+
74
  # ── Detect GPUs and start one llama-server per GPU ───────────────────────────
75
  GPU_COUNT=$(nvidia-smi -L 2>/dev/null | wc -l || echo 1)
76
  echo "GPUs detected: $GPU_COUNT"
 
80
  PORT=$((7861 + i))
81
  echo "Starting llama-server on GPU $i β†’ port $PORT"
82
  CUDA_VISIBLE_DEVICES=$i /app/bin/llama-server \
83
+ --models-dir "$MODEL_DIR" \
84
+ --models-max "$MODELS_MAX" \
85
  --host 127.0.0.1 \
86
  --port "$PORT" \
87
  -ngl 99 \
 
89
  -np 4 \
90
  -c 262144 \
91
  --metrics \
92
+ --jinja \
93
+ --webui-mcp-proxy \
94
  --temp 0.5 --top-p 0.85 --top-k 20 --min-p 0 \
95
  --reasoning-budget 0 --reasoning-format none \
96
  --chat-template-kwargs '{"enable_thinking": false}' \