Upload folder using huggingface_hub
Browse filesFiles changed (13)
- .gitattributes+1
- .gitignoreAdded+7
- LICENSEAdded+21
- README.mdAdded+163
- assets/banner.pngAdded
- provision.shAdded+122
- relay.pyAdded+96
- start-coder-40gb.ps1Added+11
- start-coder.ps1Added+9
- start.ps1Added+60
- start.shAdded+220
- status.ps1Added+69
- stop.ps1Added+62
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textassets/banner.png filter=lfs diff=lfs merge=lfs -text
1234567# runtime state - never publish.tunnel-state.jsonrelay.log.*.pid.*.py*.log~/123456789101112131415161718192021MIT License
Copyright (c) 2026 DevGwardo
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163---license: mittags:- llama.cpp- llama-server- google-colab- a100- GGUF- tool- uncensored- vision-language-modellibrary_name: llama.cpp---

# Colab A100 LLM Runner
**Rent an A100 on Google Colab, serve a 26B vision LLM to your local tools, tear it down with one command.**
A minimal, battle-tested launcher kit that turns a Colab Pro GPU session into alocal OpenAI-compatible LLM endpoint — with budget guards, clean teardown, andzero SSH hassle. Built for agentic workflows where several coding agents shareone GPU behind one localhost port.
```$ .\start.ps1 huihui-inkling-2-mini-uncensored - READY Status ONLINE (Colab session: a100) Model / Context unsloth/Inkling-2-Mini-UD-Q4_K_XL.gguf (256K total ctx, 2 slots) Local endpoint 127.0.0.1:18100 (no key needed - relay injects it) Manage .\status.ps1 to check, .\stop.ps1 to end billing```
Point OpenCode, Cursor, or any OpenAI-API client at `http://127.0.0.1:18100/v1`and it just works. `.\stop.ps1` ends billing and verifies it ended.
## How it works
The Colab SSH proxy stopped attaching to GPU sessions in late 2026, so this kituses a fully detached architecture:
```start.ps1 ──> start.sh ──> colab exec ──> provision.sh (on the VM) │ ├─ pinned llama.cpp build (CUDA sm_80) │ ├─ aria2c 8-conn GGUF download │ └─ llama-server (key-auth, 127.0.0.1:8081) └──> cloudflared quick tunnel (on the VM) └──> relay.py (local 127.0.0.1:18100, injects the API key) └──> keepalive (pings the kernel so Colab doesn't idle-teardown)```
- No SSH keys, no port forwarding, no Colab notebooks.- The public URL rotates every cold start; the relay reads it from `.tunnel-state.json` so local clients never care.- Local clients need **no API key** — the relay injects `Authorization` itself, and the key is random per session.
## Requirements
| What | Where ||---|---|| Windows + Git for Windows (bash) | any recent version || [google-colab-cli](https://pypi.org/project/google-colab-cli/) | `pip install google-colab-cli`, then `colab` once to OAuth || Colab subscription with A100 entitlement (Pro/Pro+) | check the runtime picker shows A100 || ~40 min cold start on first run (llama.cpp build + ~18 GB model) | later cold starts reuse Drive-less cache; ~15 min |
## Quickstart
```powershellgit clone https://huggingface.co/DevGwardo/colab-a100-llm-runnercd colab-a100-llm-runner
.\start.ps1 # vision model, 2 x 131K slots, relay on 18100# ...wait for READY (banner shows live progress)...
# from any other terminal / agent:curl http://127.0.0.1:18100/v1/chat/completions -d "..." # no key needed
.\status.ps1 # health, slots, cache hits, budget hours remaining.\stop.ps1 # ends billing, verifies clean teardown```
## Model profiles
| Profile | Model | GPU | Slots / ctx | Measured ||---|---|---|---|---|| Default (vision) | [Inkling-2-Mini abliterated](https://huggingface.co/huihui-ai/Huihui-Inkling-2-Mini-abliterated-GGUF) UD-Q4_K_XL, 26B MoE (3.4B active) | A100 40GB | 2 x 131K | ~50 tok/s single, 2.4s image answer || Fast coder | [Qwen3-Coder-30B-A3B abliterated](https://huggingface.co/mradermacher/Huihui-Qwen3-Coder-30B-A3B-Instruct-abliterated-GGUF) Q4_K_M | A100 80GB high-mem | 4 x 96K | 153.8 tok/s single / 237.7 aggregate (4 agents) || Budget coder | same | A100 40GB | 2 x 131K | same model, **~26% cheaper per hour** || Deep / prose | Qwen3.8-27B heretic Q5_K_M + MTP spec-decode | A100 40GB | single slot | 124.5 tok/s with MTP |
```powershell.\stop.ps1; .\start-coder.ps1 # fast coding profile.\stop.ps1; .\start-coder-40gb.ps1 # budget coding profile```
Any HF GGUF works with parameters: `.\start.ps1 -Model <repo> -File <gguf> -Ctx N -Parallel N`.
## Cost control
Real burn rates, measured over a month of use:
| GPU | Colab compute units ||---|---|| A100 80GB high-mem | 10.99 CU/hr || A100 40GB | 8.16 CU/hr || L4 | 2.33 CU/hr |
- `start.ps1` and `status.ps1` print **hours remaining** at the current burn rate before you commit.- Session allocation **fails fast on quota** (no 30-minute retry loop) and only retries on real capacity errors.- `stop.ps1` kills the local relay + keepalive, stops the VM, then *verifies* zero active assignments before declaring clean.
## Engineering decisions
Why this kit is shaped the way it is — each of these was a real failure once:
- **Pinned llama.cpp commit.** Upstream flag churn (`-fa on`, `--spec-type`, reasoning flags) broke a mid-month cold start once; `LLAMA_COMMIT` in `provision.sh` pins a known-good build. Bump deliberately after testing.- **aria2c 8-connection downloads.** Single-stream curl took 5–8 min per cold start for an ~18 GB GGUF; aria2c cuts that to ~2 min.- **`--cache-reuse 256`.** Agents resend a ~7K-token system prompt every turn; KV-shift prompt-cache reuse skips re-processing the shared prefix. Free speedup.- **Repeat penalty 1.0 on coder profiles.** Qwen3-Coder measurably degrades on code with repeat penalty on.- **Kernel keepalive.** Colab tears down idle kernels (~90 min); a background ping every 40 min keeps long sessions alive and exits by itself once the session is gone.- **Random per-session API key**, injected by the local relay — the public trycloudflare URL is authenticated, and localhost needs no credentials.- **Port 8081 on the VM.** 8080 is reserved by Colab's internal node service; using it causes confusing, intermittent failures.
## Files
| File | Role ||---|---|| `start.ps1` / `start-coder*.ps1` | PowerShell entry points (one per profile) || `start.sh` | session creation, provisioning, tunnel, relay, keepalive orchestration || `provision.sh` | runs ON the VM: pinned build, fast download, llama-server || `relay.py` | localhost:18100 -> tunnel relay, stdlib-only, SSE streaming, key injection || `status.ps1` / `stop.ps1` | one-glance health check / verified teardown || `.tunnel-state.json` | generated at runtime: live URL, key, model info (gitignored) |
## Credits
- Base model: [Inkling-2-Mini](https://huggingface.co/thinkingmachines/Inkling-2-Mini) by Thinking Machines (Apache-2.0)- Abliterated GGUFs: [huihui-ai](https://huggingface.co/huihui-ai), [mradermacher](https://huggingface.co/mradermacher), [unsloth](https://huggingface.co/unsloth), [0bserverx](https://huggingface.co/0bserverx)- Server: [llama.cpp](https://github.com/ggml-org/llama.cpp) by ggml-org- Session manager: [google-colab-cli](https://pypi.org/project/google-colab-cli/)
This repo contains **no model weights** — it launches whatever GGUF you point itat. Uncensored ("abliterated") model variants are intended for adults; you areresponsible for your use of them and for the licenses of the models you serve.
## License
MIT — the launcher scripts, relay, and docs. Model weights are the property oftheir respective authors under their own licenses.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122#!/bin/bash# provision.sh - runs ON the Colab VM (uploaded + launched detached via `colab exec`).# Builds pinned llama.cpp (CUDA sm_80), downloads the model with aria2 (8 connections),# then serves llama-server on 127.0.0.1:8081 with an API key.# Port 8080 is RESERVED by Colab's internal node service - never use it.## usage: provision.sh HF_REPO HF_FILE ALIAS CTX PARALLEL API_KEY [MMPROJ_FILE] [SPEC_TYPE] [SPEC_N_MAX]set -euo pipefailHF_REPO="$1"; HF_FILE="$2"; ALIAS="$3"; CTX="$4"; PARALLEL="$5"; API_KEY="$6"MMPROJ_FILE="${7:-}"SPEC_TYPE="${8:-none}"SPEC_N_MAX="${9:-3}"TEMP="${10:-0.6}"TOP_P="${11:-0.95}"PORT=8081DIR=/content/work
export PATH="/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:$PATH"# Pin llama.cpp so a mid-month upstream flag/API change can't break a cold start.# Bump deliberately after testing. Empty = floating HEAD (not recommended).LLAMA_COMMIT="${LLAMA_COMMIT:-c82b7988662405e595b2ac5ac4bafd2915606db8}"
echo "=== gpu ==="nvidia-smi --query-gpu=name,memory.total --format=csv,noheader || trueecho "=== disk ==="df -h /content | tail -1
if ! command -v cmake >/dev/null 2>&1 || ! command -v aria2c >/dev/null 2>&1; then echo "=== installing build deps ===" apt-get update -qq >/dev/null DEBIAN_FRONTEND=noninteractive apt-get install -y -qq cmake git curl build-essential aria2 >/dev/nullfi
if [ ! -x "$DIR/llama.cpp/build/bin/llama-server" ]; then echo "=== building llama.cpp (CUDA sm_80, pinned ${LLAMA_COMMIT:-HEAD}) ===" [ -d "$DIR/llama.cpp/.git" ] || git clone --depth 1 https://github.com/ggml-org/llama.cpp "$DIR/llama.cpp" if [ -n "$LLAMA_COMMIT" ]; then cd "$DIR/llama.cpp" git fetch --depth 1 origin "$LLAMA_COMMIT" 2>/dev/null || true git checkout --quiet FETCH_HEAD 2>/dev/null || git checkout --quiet "$LLAMA_COMMIT" 2>/dev/null || \ echo "WARN: could not pin $LLAMA_COMMIT, building current HEAD instead" cd /content fi cmake -S "$DIR/llama.cpp" -B "$DIR/llama.cpp/build" \ -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=80 -DLLAMA_CURL=OFF -DCMAKE_BUILD_TYPE=Release cmake --build "$DIR/llama.cpp/build" -j"$(nproc)" --target llama-serverfi
dl_file() { # $1 = dest, $2 = URL. aria2 (8 conns) when available, curl fallback. local dest="$1" url="$2" mkdir -p "$(dirname "$dest")" if command -v aria2c >/dev/null 2>&1; then aria2c -x8 -s8 --continue=true --allow-overwrite=true \ --console-log-level=warn --summary-interval=0 -d "$(dirname "$dest")" \ -o "$(basename "$dest")" "$url" else curl -fL --retry 3 --retry-delay 5 -C - -o "$dest" "$url" fi}
MODEL="$DIR/$HF_FILE"SIZE=0[ -f "$MODEL" ] && SIZE=$(stat -c %s "$MODEL")T0=$(date +%s)if [ "$SIZE" -lt 1000000000 ]; then echo "=== downloading $HF_REPO/$HF_FILE (aria2 8-conn) ===" rm -f "$MODEL" dl_file "$MODEL" "https://huggingface.co/${HF_REPO}/resolve/main/${HF_FILE}"fiT1=$(date +%s)echo "DOWNLOAD_SECONDS=$((T1-T0))"ls -lh "$MODEL"
MMPROJ_ARGS=()if [ -n "$MMPROJ_FILE" ]; then MMPROJ="$DIR/$MMPROJ_FILE" MSIZE=0 [ -f "$MMPROJ" ] && MSIZE=$(stat -c %s "$MMPROJ") if [ "$MSIZE" -lt 1000000 ]; then echo "=== downloading $MMPROJ_FILE ===" rm -f "$MMPROJ" dl_file "$MMPROJ" "https://huggingface.co/${HF_REPO}/resolve/main/${MMPROJ_FILE}" fi ls -lh "$MMPROJ" MMPROJ_ARGS=(--mmproj "$MMPROJ")fi
# NOTE: pkill patterns use [x] so they can never match this script's own bash -c cmdline.pkill -f 'llama-serve[r] --model' 2>/dev/null || truesleep 2
echo "=== starting llama-server on 127.0.0.1:$PORT (np=$PARALLEL, ctx=$CTX) ==="setsid nohup "$DIR/llama.cpp/build/bin/llama-server" \ --model "$MODEL" --alias "$ALIAS" \ --host 127.0.0.1 --port "$PORT" \ -ngl 99 -fa on \ -c "$CTX" -np "$PARALLEL" \ -ctk q8_0 -ctv q8_0 \ --cache-reuse 256 \ -b 4096 -ub 1024 \ --spec-type "$SPEC_TYPE" --spec-draft-n-max "$SPEC_N_MAX" \ "${MMPROJ_ARGS[@]}" \ --api-key "$API_KEY" \ --temp "$TEMP" --top-p "$TOP_P" --repeat-penalty 1.0 \ --reasoning-effort low --reasoning-budget 2048 \ > /content/serve.log 2>&1 < /dev/null &
for i in $(seq 1 90); do if curl -s -H "Authorization: Bearer $API_KEY" "http://127.0.0.1:$PORT/health" | grep -q ok; then echo "SERVER_READY" break fi sleep 5doneif ! curl -s -H "Authorization: Bearer $API_KEY" "http://127.0.0.1:$PORT/health" | grep -q ok; then echo "SERVER_FAILED - last serve.log lines:" tail -20 /content/serve.log exit 1figrep -E "n_slots|n_ctx_slot|KV size|CUDA0 model size|listening" /content/serve.log | tail -6 || trueecho "DONE"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596# relay.py - local relay: 127.0.0.1:18100 -> cloudflared tunnel URL (Colab VM llama-server)# Injects the Authorization header so local clients (OpenCode) need no API key.# stdlib only; supports streaming (SSE) via chunked passthrough.# env: TUNNEL_URL (https://...trycloudflare.com) RELAY_PORT (default 18100) API_KEYimport http.clientimport jsonimport osimport socketserverimport sysimport urllib.parse
TUNNEL_URL = os.environ.get("TUNNEL_URL", "")RELAY_PORT = int(os.environ.get("RELAY_PORT", "18100"))API_KEY = os.environ.get("API_KEY", "")STATE = os.environ.get("RELAY_STATE", "")
class Handler(socketserver.BaseRequestHandler): def handle(self): if not TUNNEL_URL: self.request.sendall(b"HTTP/1.1 503 Bad Gateway\r\nContent-Length: 0\r\n\r\n") return data = b"" while b"\r\n\r\n" not in data: chunk = self.request.recv(65536) if not chunk: return data += chunk head, _, rest = data.partition(b"\r\n\r\n") lines = head.decode("latin1").split("\r\n") try: method, path, _ = lines[0].split(" ", 2) except ValueError: return headers = {} for l in lines[1:]: if ":" in l: k, v = l.split(":", 1) headers[k.strip().lower()] = v.strip() body = rest try: clen = int(headers.get("content-length", "0") or 0) except ValueError: clen = 0 while len(body) < clen: chunk = self.request.recv(65536) if not chunk: break body += chunk
u = urllib.parse.urlparse(TUNNEL_URL) fwd = {"Host": u.netloc, "Content-Type": "application/json", "Accept": "application/json"} if headers.get("content-type"): fwd["Content-Type"] = headers["content-type"] if headers.get("accept"): fwd["Accept"] = headers["accept"] if API_KEY: fwd["Authorization"] = "Bearer " + API_KEY elif headers.get("authorization"): fwd["Authorization"] = headers["authorization"]
conn = None try: conn = http.client.HTTPSConnection(u.netloc, timeout=600) conn.request(method, path, body=body if body else None, headers=fwd) resp = conn.getresponse() self.request.sendall(f"HTTP/1.1 {resp.status} {resp.reason}\r\n".encode()) self.request.sendall(b"Transfer-Encoding: chunked\r\n") self.request.sendall(b"Connection: keep-alive\r\n\r\n") while True: block = resp.read(16384) if not block: break self.request.sendall(f"{len(block):x}\r\n".encode() + block + b"\r\n") self.request.sendall(b"0\r\n\r\n") except Exception: try: self.request.sendall(b"HTTP/1.1 502 Bad Gateway\r\nContent-Length: 0\r\n\r\n") except Exception: pass finally: if conn: conn.close()
class Server(socketserver.ThreadingTCPServer): allow_reuse_address = True daemon_threads = True
if __name__ == "__main__": if not TUNNEL_URL: print("relay.py: TUNNEL_URL env required", file=sys.stderr) sys.exit(1) print(f"relay listening 127.0.0.1:{RELAY_PORT} -> {TUNNEL_URL}", flush=True) Server(("127.0.0.1", RELAY_PORT), Handler).serve_forever()1234567891011# Budget coding profile: Qwen3-Coder-30B-A3B Q4_K_M on the plain A100 40GB# (8.16 CU/hr instead of 10.99 high-mem = ~26% cheaper per hour).# 2 x 131K slots instead of 4 x 96K so weights + q8 KV fit in 40 GB.# Stop the current model first: .\stop.ps1$Dir = Split-Path -Parent $MyInvocation.MyCommand.Path& "$Dir\start.ps1" ` -Model "mradermacher/Huihui-Qwen3-Coder-30B-A3B-Instruct-abliterated-GGUF" ` -File "Huihui-Qwen3-Coder-30B-A3B-Instruct-abliterated.Q4_K_M.gguf" ` -Alias "qwen3-coder-30b-a3b-uncensored" ` -Ctx 262144 -Parallel 2 -SpecType none -Temp 0.3 -TopP 0.9 -RepeatPenalty 1.0 -Mmproj "" # RepeatPenalty 1.0: Qwen3 coder models degrade with repeat penalty on code.123456789# Fast coding profile: Qwen3-Coder-30B-A3B MoE Q4_K_M (3B active), text only, 4 x 96K.# A100 80GB high-mem. Stop the current model first: .\stop.ps1$Dir = Split-Path -Parent $MyInvocation.MyCommand.Path& "$Dir\start.ps1" ` -Model "mradermacher/Huihui-Qwen3-Coder-30B-A3B-Instruct-abliterated-GGUF" ` -File "Huihui-Qwen3-Coder-30B-A3B-Instruct-abliterated.Q4_K_M.gguf" ` -Alias "qwen3-coder-30b-a3b-uncensored" ` -Ctx 393216 -Parallel 4 -SpecType none -Temp 0.3 -TopP 0.9 -RepeatPenalty 1.0 -Mmproj "" # RepeatPenalty 1.0: Qwen3 coder models degrade with repeat penalty on code.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960# A100 40GB + uncensored GGUF start (exec + cloudflared architecture - no SSH)# .\start.ps1 # huihui Inkling-2-Mini abliterated, vision, 2x131K, relay on 18100# .\start-coder.ps1 # fast Qwen3-Coder-30B-A3B profile (80GB high-mem)# .\start-coder-40gb.ps1 # coder profile on the 40GB A100 (8.16 CU/hr)# .\start.ps1 -HighMem # 80GB A100 for bigger ctx / quants# .\start.ps1 -Model "0bserverx/Qwen3.8-27B-Heretic-Abliterated-Uncensored-GGUF" -File "RVN-Q5_K_M-multilingual-mtp.gguf" -Alias qwen3.8-27b-uncensored -Ctx 262144 -Parallel 2 -SpecType draft-mtp -Mmproj ""# .\start.ps1 -Foreground # watch the build/download in this windowparam( [string]$Model = "huihui-ai/Huihui-Inkling-2-Mini-abliterated-GGUF", [string]$File = "unsloth/Inkling-2-Mini-UD-Q4_K_XL.gguf", [string]$Alias = "huihui-inkling-2-mini-uncensored", [int]$Ctx = 262144, [int]$Port = 18100, [int]$Parallel = 2, [string]$SpecType = "none", [int]$SpecNMax = 3, [double]$Temp = 0.6, [double]$TopP = 0.95, [double]$RepeatPenalty = 1.0, # unused (provision.sh pins 1.0); kept for profile compat [string]$Mmproj = "unsloth/mmproj-BF16.gguf", [switch]$HighMem, [switch]$Foreground)
$ErrorActionPreference = "Stop"$Dir = Split-Path -Parent $MyInvocation.MyCommand.Path$Bash = (Get-Command bash.exe -ErrorAction SilentlyContinue).Sourceif (-not $Bash) { $Bash = "C:\Program Files\Git\bin\bash.exe" }$Colab = (Get-Command colab.exe -ErrorAction SilentlyContinue).Sourceif (-not $Colab) { $Colab = Join-Path $env:USERPROFILE ".local\bin\colab.exe" }
if (-not (Test-Path $Bash)) { throw "Git Bash not found at $Bash (install Git for Windows)" }if (-not (Test-Path $Colab)) { throw "colab CLI not found at $Colab (see README: Requirements)" }
$existing = (& $Colab sessions 2>&1 | Out-String)if ($existing -match "a100") { Write-Host "A session named 'a100' already exists:" -ForegroundColor Yellow Write-Host $existing Write-Host "Use .\stop.ps1 first." -ForegroundColor Yellow exit 1}
& $Colab usage
# Balance -> hours remaining at the known A100 burn rates$usage = (& $Colab usage 2>&1 | Out-String)if ($usage -match 'balance:\s*([\d.]+)') { $bal = [double]$Matches[1] Write-Host (" [budget] {0:N2} CU = {1:N1} h on A100 80GB high-mem (10.99/hr) | {2:N1} h on A100 40GB (8.16/hr)" -f $bal, ($bal/10.99), ($bal/8.16)) -ForegroundColor Yellow}
$bashDir = "/" + $Dir.Substring(0, 1).ToLower() + $Dir.Substring(2).Replace('\', '/')$mode = if ($Foreground) { "--foreground" } else { "" }
$hm = if ($HighMem) { 1 } else { 0 }$bashColab = "/" + $Colab.Substring(0, 1).ToLower() + $Colab.Substring(2).Replace('\', '/')$envs = "export COLAB_BIN='$bashColab' NO_COLOR=1 " + "HF_REPO='$Model' HF_FILE='$File' MODEL_ALIAS='$Alias' CTX=$Ctx LOCAL_PORT=$Port HIGH_MEM=$hm " + "PARALLEL=$Parallel SPEC_TYPE=$SpecType SPEC_N_MAX=$SpecNMax TEMP=$Temp TOP_P=$TopP MMPROJ_FILE='$Mmproj'"& $Bash -c "cd '$bashDir' && $envs && ./start.sh $mode"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220#!/bin/bash# start.sh - Colab A100 launcher (exec + cloudflared architecture, NO SSH).# The ssh-proxy bridge stopped attaching to GPU sessions (Colab-side change,# 2026-12-01). Provisioning now runs via `colab exec` + setsid, and the server# is exposed through a cloudflared quick tunnel + a local relay on 127.0.0.1:18100.## Env (usually set by start.ps1):# HF_REPO HF_FILE MODEL_ALIAS CTX LOCAL_PORT PARALLEL MMPROJ_FILE SPEC_TYPE# SPEC_N_MAX TEMP TOP_P HIGH_MEMset -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"# colab CLI: whatever command -v finds, else the standard ~/.local/bin installif [ -z "${COLAB_BIN:-}" ]; then COLAB_BIN="$(command -v colab 2>/dev/null || command -v colab.exe 2>/dev/null || true)" [ -n "$COLAB_BIN" ] || COLAB_BIN="$HOME/.local/bin/colab"fiexport COLAB_BIN NO_COLOR=1
SESSION="${SESSION:-a100}"HF_REPO="${HF_REPO:-huihui-ai/Huihui-Inkling-2-Mini-abliterated-GGUF}"HF_FILE="${HF_FILE:-unsloth/Inkling-2-Mini-UD-Q4_K_XL.gguf}"MMPROJ_FILE="${MMPROJ_FILE:-unsloth/mmproj-BF16.gguf}"MODEL_ALIAS="${MODEL_ALIAS:-huihui-inkling-2-mini-uncensored}"CTX="${CTX:-262144}"LOCAL_PORT="${LOCAL_PORT:-18100}"PARALLEL="${PARALLEL:-2}"SPEC_TYPE="${SPEC_TYPE:-none}"SPEC_N_MAX="${SPEC_N_MAX:-3}"TEMP="${TEMP:-0.6}"TOP_P="${TOP_P:-0.95}"HIGH_MEM="${HIGH_MEM:-0}"STATE_FILE="$SCRIPT_DIR/.tunnel-state.json"RELAY_LOG="$SCRIPT_DIR/relay.log"
# ---------------------------------------------------------------- helpersdie() { echo "[a100] ERROR: $*" >&2; exit 1; }
require() { command -v "$1" >/dev/null 2>&1 || die "$1 not found in PATH"; }require "$COLAB_BIN"; require python; require curl
exec_py() { # run a local python file on the VM, echo its stdout timeout 100 "$COLAB_BIN" --auth=oauth2 exec -s "$SESSION" -f "$1" 2>&1 | grep -v '^\[colab\]' | sed 's/\r$//'}
# ---------------------------------------------------------------- 1. create sessioncreate_session() { local attempt=1 out local extra=() [ "$HIGH_MEM" = "1" ] && extra+=(--high-mem) while [ "$attempt" -le 20 ]; do if out="$("$COLAB_BIN" new -s "$SESSION" --gpu A100 "${extra[@]}" 2>&1)"; then printf '%s\n' "$out" | grep -v '^\[colab\]' return 0 fi # Quota/entitlement rejection is permanent for this account - fail fast. if printf '%s' "$out" | grep -qiE "quota|entitlement"; then echo "[a100] ERROR: account not entitled for A100 (quota). Not retrying." >&2 printf '%s\n' "$out" >&2 return 1 fi if printf '%s' "$out" | grep -qiE "503|Service[[:space:]]*Unavailable|capacity|Resource[[:space:]]*Exhausted|timed out|Temporary"; then echo "[a100] A100 capacity busy (attempt $attempt/20), retrying in 90s..." sleep 90 attempt=$((attempt + 1)) continue fi printf '%s\n' "$out" >&2 return 1 done echo "[a100] could not allocate A100 after 20 attempts (~30 min)" >&2 return 1}
"$COLAB_BIN" sessions 2>/dev/null | grep -q "\[$SESSION\]" && \ die "session '$SESSION' already exists - run ./stop.ps1 first"
create_session || die "session creation failed"
# ---------------------------------------------------------------- 2. provisionAPI_KEY="a100-$(python -c 'import secrets; print(secrets.token_hex(16))')"
echo "[a100] uploading provision.sh..."uploaded=0for try in 1 2 3 4 5; do if "$COLAB_BIN" upload -s "$SESSION" "$SCRIPT_DIR/provision.sh" /content/provision.sh >/dev/null 2>&1; then uploaded=1; break fi echo "[a100] upload failed (try $try/5), retrying in 20s..." sleep 20done[ "$uploaded" = "1" ] || die "upload failed after 5 tries"
DRV="$SCRIPT_DIR/.launch_driver.py"cat > "$DRV" <<EOFimport subprocesscmd = ("setsid nohup bash /content/provision.sh " "'$HF_REPO' '$HF_FILE' '$MODEL_ALIAS' '$CTX' '$PARALLEL' '$API_KEY' " "'$MMPROJ_FILE' '$SPEC_TYPE' '$SPEC_N_MAX' '$TEMP' '$TOP_P' " "> /content/provision.log 2>&1 < /dev/null & sleep 2; echo LAUNCHED")r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60)print(r.stdout.strip())EOFecho "[a100] provisioning (build + download can take ~15 min on a fresh VM)..."exec_py "$DRV" | grep -q LAUNCHED || die "could not launch provisioning"
# poll provisioning logPOLL="$SCRIPT_DIR/.poll.py"cat > "$POLL" <<'EOF'import subprocessr = subprocess.run("grep -E 'SERVER_READY|SERVER_FAILED|DOWNLOAD_SECONDS' /content/provision.log | tail -3", shell=True, capture_output=True, text=True, timeout=60)print(r.stdout)EOFdeadline=$((SECONDS + 1500))out=""while [ $SECONDS -lt $deadline ]; do out="$(exec_py "$POLL")" if printf '%s' "$out" | grep -q SERVER_READY; then printf '%s\n' "$out" | sed 's/^/[a100] /' break fi if printf '%s' "$out" | grep -q SERVER_FAILED; then FAILLOG="$SCRIPT_DIR/.faillog.py" cat > "$FAILLOG" <<'EOF'import subprocessr = subprocess.run("tail -20 /content/provision.log", shell=True, capture_output=True, text=True, timeout=60)print(r.stdout)EOF exec_py "$FAILLOG" | sed 's/^/ /' die "llama-server failed to start (see provision.log above)" fi sleep 30doneprintf '%s' "$out" | grep -q SERVER_READY || die "provisioning timed out after 25 min"
# ---------------------------------------------------------------- 3. tunnelCF="$SCRIPT_DIR/.cfstart.py"cat > "$CF" <<'EOF'import subprocesscmd = ("cd /content && (ls cloudflared >/dev/null 2>&1 || " "curl -sL -o cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64) && " "chmod +x cloudflared && " "setsid nohup ./cloudflared tunnel --url http://127.0.0.1:8081 --no-autoupdate " "> /content/cf.log 2>&1 < /dev/null & " "sleep 12; grep -oE 'https://[a-z0-9-]+\\.trycloudflare\\.com' /content/cf.log | head -1")r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=120)print(r.stdout.strip())EOFecho "[a100] starting cloudflared tunnel..."TUNNEL_URL=""for try in 1 2 3; do TUNNEL_URL="$(exec_py "$CF" | grep -oE 'https://[a-z0-9-]+\.trycloudflare\.com' | head -1)" [ -n "$TUNNEL_URL" ] && break sleep 5done[ -n "$TUNNEL_URL" ] || die "cloudflared did not produce a tunnel URL"
# ---------------------------------------------------------------- 4. local relayRELPID="$SCRIPT_DIR/.relay.pid"[ -f "$RELPID" ] && { kill "$(cat "$RELPID")" 2>/dev/null; rm -f "$RELPID"; }RELAY="$SCRIPT_DIR/.run_relay.py"cat > "$RELAY" <<EOFimport os, runpy, sysos.environ["TUNNEL_URL"] = "$TUNNEL_URL"os.environ["RELAY_PORT"] = "$LOCAL_PORT"os.environ["API_KEY"] = "$API_KEY"sys.argv = ["relay.py"]runpy.run_path(r"$SCRIPT_DIR/relay.py", run_name="__main__")EOFnohup python "$RELAY" > "$RELAY_LOG" 2>&1 &echo $! > "$RELPID"disown 2>/dev/null
for i in $(seq 1 10); do if curl -s --max-time 5 "http://127.0.0.1:$LOCAL_PORT/health" | grep -q ok; then break; fi sleep 2donecurl -s --max-time 5 "http://127.0.0.1:$LOCAL_PORT/health" | grep -q ok || die "relay did not come up on $LOCAL_PORT"
# ---------------------------------------------------------------- 4b. keepalive# Colab disconnects idle kernels (~90 min without activity) and tears down the# VM. Ping the kernel every 40 min so a long-running session survives.KA="$SCRIPT_DIR/.keepalive.sh"HELLO="$SCRIPT_DIR/.ka.py"printf 'print("ka")\n' > "$HELLO"cat > "$KA" <<EOF#!/bin/bashcd "$SCRIPT_DIR"while true; do sleep 2400 if ! "$COLAB_BIN" sessions 2>/dev/null | grep -q "\[$SESSION\]"; then exit 0; fi timeout 100 "$COLAB_BIN" --auth=oauth2 exec -s "$SESSION" -f "$HELLO" >/dev/null 2>&1 || truedoneEOFnohup bash "$KA" >/dev/null 2>&1 &echo $! > "$SCRIPT_DIR/.keepalive.pid"disown 2>/dev/null
# ---------------------------------------------------------------- 5. state + bannerpython - "$STATE_FILE" "$TUNNEL_URL" "$API_KEY" "$LOCAL_PORT" "$MODEL_ALIAS" "$SESSION" "$HF_FILE" "$CTX" "$PARALLEL" <<'EOF'import json, sysstate = {"tunnel_url": sys.argv[2], "api_key": sys.argv[3], "local_port": int(sys.argv[4]), "model_alias": sys.argv[5], "session": sys.argv[6], "model_file": sys.argv[7], "ctx": int(sys.argv[8]), "parallel": int(sys.argv[9])}open(sys.argv[1], "w").write(json.dumps(state, indent=2))EOF
C_GREEN=$'\033[32m'; C_BOLD=$'\033[1m'; C_DIM=$'\033[2m'; C_RESET=$'\033[0m'printf '\n'printf '%s %s%s - READY%s\n' "$C_GREEN" "$C_GREEN$C_BOLD" "$MODEL_ALIAS" "$C_RESET"printf ' %s%-19s%s %sONLINE%s (Colab session: %s)\n' "$C_DIM" "Status" "$C_RESET" "$C_GREEN$C_BOLD" "$C_RESET" "$SESSION"printf ' %s%-19s%s %s (%dK total ctx, %s slots)\n' "$C_DIM" "Model / Context" "$C_RESET" "$HF_FILE" "$(($CTX / 1024))" "$PARALLEL"printf ' %s%-19s%s 127.0.0.1:%s (no key needed - relay injects it)\n' "$C_DIM" "Local endpoint" "$C_RESET" "$LOCAL_PORT"printf ' %s%-19s%s %s\n' "$C_DIM" "Public URL" "$C_RESET" "$TUNNEL_URL"printf ' %s%-19s%s %s (llama-server auth)\n' "$C_DIM" "API key" "$C_RESET" "$API_KEY"printf ' %s%-19s%s ./status.ps1 to check, ./stop.ps1 to end billing\n' "$C_DIM" "Manage" "$C_RESET"printf '\n'rm -f "$DRV" "$POLL" "$CF" "$RELAY"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869# One-glance health check for the Colab A100 model server.# Usage: .\status.ps1$ErrorActionPreference = "Continue"$Port = 18100$Colab = (Get-Command colab.exe -ErrorAction SilentlyContinue).Sourceif (-not $Colab) { $Colab = Join-Path $env:USERPROFILE ".local\bin\colab.exe" }
Write-Host "== A100 model server (relay) ==" -ForegroundColor Cyan$state = Join-Path $PSScriptRoot ".tunnel-state.json"if (Test-Path $state) { $s = Get-Content $state | ConvertFrom-Json Write-Host " model : $($s.model_alias)" Write-Host " public URL : $($s.tunnel_url)" Write-Host " session : $($s.session)"}
function Get-Text($url) { try { $c = (Invoke-WebRequest $url -TimeoutSec 5).Content if ($c -is [byte[]]) { $c = [System.Text.Encoding]::UTF8.GetString($c) } return $c } catch { return $null }}
try { $h = Get-Text "http://127.0.0.1:$Port/health" if ($h) { Write-Host " health : $h" -ForegroundColor Green } else { throw "down" }} catch { Write-Host " health : DOWN" -ForegroundColor Red}
try { $p = Get-Text "http://127.0.0.1:$Port/props" | ConvertFrom-Json Write-Host " model : $($p.model_alias)" Write-Host " slots : $($p.total_slots) x $($p.default_generation_settings.n_ctx) ctx"} catch { Write-Host " model : unavailable" -ForegroundColor Yellow}
try { $s = Get-Text "http://127.0.0.1:$Port/slots" | ConvertFrom-Json $busy = @($s | Where-Object { $_.is_processing }).Count Write-Host " busy slots : $busy / $($s.Count)" foreach ($x in $s) { $cache = if ($x.n_prompt_tokens_cache) { $x.n_prompt_tokens_cache } else { 0 } Write-Host (" slot {0}: busy={1,-5} prompt={2,-6} cached={3}" -f $x.id, $x.is_processing, $x.n_prompt_tokens, $cache) }} catch { Write-Host " slots : unavailable" -ForegroundColor Yellow}
$listen = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinueif ($listen) { Write-Host " tunnel : UP (pid $($listen[0].OwningProcess))" -ForegroundColor Green} else { Write-Host " tunnel : DOWN" -ForegroundColor Red}
Write-Host "== Colab session ==" -ForegroundColor Cyan& $Colab status -s a100 2>&1 | ForEach-Object { " $_" }
Write-Host "== Budget ==" -ForegroundColor Cyan$usage = (& $Colab usage 2>&1 | Out-String)Write-Host $usage.Trim()if ($usage -match 'balance:\s*([\d.]+)') { $bal = [double]$Matches[1] Write-Host (" [budget] {0:N2} CU = {1:N1} h on A100 80GB high-mem (10.99/hr) | {2:N1} h on A100 40GB (8.16/hr)" -f $bal, ($bal/10.99), ($bal/8.16)) -ForegroundColor Yellow}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162# A100 session stop: kills the local tunnel + launcher, stops the VM, verifies.
$ErrorActionPreference = "Continue"$Colab = (Get-Command colab.exe -ErrorAction SilentlyContinue).Sourceif (-not $Colab) { $Colab = Join-Path $env:USERPROFILE ".local\bin\colab.exe" }$me = $PID
Write-Host "== 1. Killing local relay / launcher (a100) ==" -ForegroundColor Cyan# relay from the current state$relpid = Join-Path $PSScriptRoot ".relay.pid"if (Test-Path $relpid) { $p = Get-Content $relpid -ErrorAction SilentlyContinue if ($p) { Write-Host " kill relay pid $p"; taskkill /F /PID $p 2>$null | Out-Null } Remove-Item $relpid -ErrorAction SilentlyContinue}$kapid = Join-Path $PSScriptRoot ".keepalive.pid"if (Test-Path $kapid) { $p = Get-Content $kapid -ErrorAction SilentlyContinue if ($p) { Write-Host " kill keepalive pid $p"; taskkill /F /PID $p 2>$null | Out-Null } Remove-Item $kapid -ErrorAction SilentlyContinue}$procs = Get-CimInstance Win32_Process | Where-Object { $_.ProcessId -ne $me -and $_.Name -ne "pwsh.exe" -and ( $_.CommandLine -match "run_relay|relay\.py" -or $_.CommandLine -match "colab-a100" -or $_.CommandLine -match "proxy-mode -s a100" -or $_.CommandLine -match "colab\.exe new -s a100" -or $_.CommandLine -match "colab-tunnel-a100" )}if ($procs) { foreach ($p in $procs) { Write-Host (" kill {0} ({1})" -f $p.ProcessId, $p.Name) taskkill /F /PID $p.ProcessId 2>$null | Out-Null }} else { Write-Host " no local tunnel/launcher processes found"}
Write-Host "== 2. Stopping the Colab session (ends billing) ==" -ForegroundColor Cyan$sessions = (& $Colab sessions 2>&1 | Out-String)if ($sessions -match "No active sessions") { Write-Host " no active sessions - nothing to stop"} else { & $Colab stop -s a100 2>&1 | ForEach-Object { " $_" }}
Write-Host "== 3. Verifying ==" -ForegroundColor CyanStart-Sleep -Seconds 2$s2 = (& $Colab sessions 2>&1 | Out-String)$u = (& $Colab usage 2>&1 | Out-String)Write-Host $s2.Trim()Write-Host $u.Trim()
if (($s2 -match "No active sessions") -and ($u -match "Active assignments:\s*0")) { Write-Host "CLEAN: no session, no active assignment, nothing billing." -ForegroundColor Green} else { Write-Host "WARNING: something is still active. Run: colab.exe sessions ; colab.exe stop -s a100" -ForegroundColor Red exit 1}.gitattributes+1
.gitignoreAdded+7
LICENSEAdded+21
README.mdAdded+163
assets/banner.pngAdded

Large File Pointer Details
- SHA256: e2621f63dcbc6abb5132355865814bd7702c4e134b041565843bbbc9d012df10
- Pointer size: 131 Bytes
- Size of remote file: 704 kB
provision.shAdded+122
relay.pyAdded+96
start-coder-40gb.ps1Added+11
start-coder.ps1Added+9
start.ps1Added+60
start.shAdded+220
status.ps1Added+69
stop.ps1Added+62