Instructions to use badtheorylabs/BTL-3-Compact with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use badtheorylabs/BTL-3-Compact with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="badtheorylabs/BTL-3-Compact", filename="model/BTL-3-Compact-AVQ2.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use badtheorylabs/BTL-3-Compact with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf badtheorylabs/BTL-3-Compact # Run inference directly in the terminal: llama cli -hf badtheorylabs/BTL-3-Compact
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf badtheorylabs/BTL-3-Compact # Run inference directly in the terminal: llama cli -hf badtheorylabs/BTL-3-Compact
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf badtheorylabs/BTL-3-Compact # Run inference directly in the terminal: ./llama-cli -hf badtheorylabs/BTL-3-Compact
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf badtheorylabs/BTL-3-Compact # Run inference directly in the terminal: ./build/bin/llama-cli -hf badtheorylabs/BTL-3-Compact
Use Docker
docker model run hf.co/badtheorylabs/BTL-3-Compact
- LM Studio
- Jan
- vLLM
How to use badtheorylabs/BTL-3-Compact with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "badtheorylabs/BTL-3-Compact" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "badtheorylabs/BTL-3-Compact", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/badtheorylabs/BTL-3-Compact
- Ollama
How to use badtheorylabs/BTL-3-Compact with Ollama:
ollama run hf.co/badtheorylabs/BTL-3-Compact
- Unsloth Studio
How to use badtheorylabs/BTL-3-Compact with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for badtheorylabs/BTL-3-Compact to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for badtheorylabs/BTL-3-Compact to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for badtheorylabs/BTL-3-Compact to start chatting
- Pi
How to use badtheorylabs/BTL-3-Compact with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf badtheorylabs/BTL-3-Compact
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "badtheorylabs/BTL-3-Compact" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use badtheorylabs/BTL-3-Compact with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf badtheorylabs/BTL-3-Compact
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default badtheorylabs/BTL-3-Compact
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use badtheorylabs/BTL-3-Compact with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf badtheorylabs/BTL-3-Compact
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "badtheorylabs/BTL-3-Compact" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use badtheorylabs/BTL-3-Compact with Docker Model Runner:
docker model run hf.co/badtheorylabs/BTL-3-Compact
- Lemonade
How to use badtheorylabs/BTL-3-Compact with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull badtheorylabs/BTL-3-Compact
Run and chat with the model
lemonade run user.BTL-3-Compact-{{QUANT_TAG}}List all available models
lemonade list
BTL-3 consumer integrations
This document separates three products that must not be conflated:
| Surface | How BTL-3 executes | Current status |
|---|---|---|
| Stock Ollama | Stock runner | Does not execute AVQ2 |
| BTL-3 Patched Ollama | Ollama directly spawns BTL's native llama-server |
Packaging scaffold complete; target packages pending |
| LM Studio | Official generator plugin calls BTL's native local endpoint | Plugin type-checks; macOS native endpoint verified |
No HTTP translation bridge sits between patched Ollama and the runner.
Why the runner replacement is small
At official Ollama commit
573386c35eac76124ffce571f4b0fefa0a7fe13c,
llm.NewLlamaServer delegates every GGUF model to a llama-server
subprocess. Ollama locates that executable under lib/ollama, starts it on an
ephemeral loopback port, and speaks its native /health, /completion,
/v1/chat/completions, tokenization, and embedding endpoints. The relevant
upstream files are
llm/server.go,
llm/llama_server.go,
and
llm/llama_binary.go.
BTL's native runner already exposes that contract. The patched distribution replaces Ollama's runtime payload, not its public API, scheduler, CLI, model store, or UI.
Build the CUDA runner payload
Build on the target machine so CMake selects the target GPU:
cmake -S native/llama.cpp -B native/llama.cpp/build-btl3-cuda \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_ARCHITECTURES=native \
-DBUILD_SHARED_LIBS=ON \
-DGGML_BACKEND_DL=ON \
-DGGML_CUDA=ON \
-DLLAMA_CURL=OFF
cmake --build native/llama.cpp/build-btl3-cuda \
--target llama-server --parallel
Stage the executable and its shared libraries. Use cuda_v13 with CUDA 13 and
cuda_v12 with CUDA 12:
payload=/tmp/btl3-runner
cuda_dir=cuda_v13
rm -rf "$payload"
mkdir -p "$payload/$cuda_dir"
cp native/llama.cpp/build-btl3-cuda/bin/llama-server "$payload/"
cp native/llama.cpp/build-btl3-cuda/bin/libggml*.so* "$payload/"
cp native/llama.cpp/build-btl3-cuda/bin/libllama*.so* "$payload/"
mv "$payload"/libggml-cuda.so* "$payload/$cuda_dir/"
"$payload/llama-server" --help
Do not package until --help exposes --model, --host, --port,
--no-webui, --offline, and -np. The packager enforces that contract.
Hardware targets
- RTX 4090: build
linux-amd64-cuda12orcuda13on that machine. - RTX 5090: build on the 5090 so
nativeincludes its Blackwell target. - Windows RTX 4090/5090: build
windows-amd64-cuda13on Windows x64. - DGX Spark: build
linux-arm64-cuda13on Spark. Current DGX Spark software is ARM64 and ships CUDA 13; do not reuse an x86_64 payload. See NVIDIA's hardware overview and current release notes.
Build BTL-3 Patched Ollama
Build Ollama from the pinned source commit using its official Linux build, or
unpack a distribution built from that exact commit into OLLAMA_DIST. Then:
.venv/bin/python tools/build_patched_ollama.py \
--ollama-dist "$OLLAMA_DIST" \
--runner-payload /tmp/btl3-runner \
--platform linux-amd64-cuda13 \
--output dist/btl3-patched-ollama-linux-amd64-cuda13
The output contains:
bin/ollama
bin/btl3-ollama
lib/ollama/llama-server
lib/ollama/cuda_v13/libggml-cuda.so
share/btl3/patched-ollama-manifest.json
btl3-ollama --btl3-info prints the patched label. All other arguments are
passed to the packaged Ollama binary.
Create the local model only with the patched distribution:
cp artifacts/release/BTL-3-Compact-AVQ2.gguf integrations/ollama/
dist/btl3-patched-ollama-linux-amd64-cuda13/bin/btl3-ollama serve
# in another terminal
dist/btl3-patched-ollama-linux-amd64-cuda13/bin/btl3-ollama \
create btl3-compact -f integrations/ollama/Modelfile
dist/btl3-patched-ollama-linux-amd64-cuda13/bin/btl3-ollama \
run btl3-compact
The GGUF stores BTL's packed representation in ordinary I8/F32/BF16 tensors with custom names, so no new GGUF tensor-type enum is required. Actual model creation and generation remain release gates on each CUDA target.
Windows x64 CUDA 13
The pinned Ollama source has the same direct subprocess architecture on
Windows. Its
llama_binary.go
adds .exe and searches beside a top-level ollama.exe at
lib\ollama\llama-server.exe; the pinned
build_windows.ps1
installs CUDA payloads under that same directory.
Build the native runner from an x64 Visual Studio developer shell with CUDA 13:
cmake -S native/llama.cpp -B native/llama.cpp/build-btl3-win-cuda13 `
-A x64 `
-DBUILD_SHARED_LIBS=ON `
-DGGML_BACKEND_DL=ON `
-DGGML_CUDA=ON `
-DLLAMA_CURL=OFF
cmake --build native/llama.cpp/build-btl3-win-cuda13 `
--config Release --target llama-server --parallel
$Bin = "native/llama.cpp/build-btl3-win-cuda13/bin/Release"
$Payload = "$env:TEMP/btl3-runner-win"
Remove-Item -Recurse -Force $Payload -ErrorAction SilentlyContinue
New-Item -ItemType Directory "$Payload/cuda_v13" | Out-Null
Copy-Item "$Bin/llama-server.exe" $Payload
Copy-Item "$Bin/*.dll" $Payload
Move-Item "$Payload/ggml-cuda.dll" "$Payload/cuda_v13/"
powershell -ExecutionPolicy Bypass -File tools/probe_windows_runner.ps1 `
-Runner "$Payload/llama-server.exe" `
-Output "$Payload/runner-cli-contract.json"
The target-side probe executes the exact runner and binds its required Ollama
CLI flags to its SHA-256. Cross-platform packaging refuses a missing, stale,
or wrong-platform contract. It also checks that ollama.exe,
llama-server.exe, and every staged DLL are PE x64.
Package an official pinned Windows x64 distribution:
python tools/build_patched_ollama.py `
--ollama-dist "$env:TEMP/ollama-windows-amd64" `
--runner-payload "$env:TEMP/btl3-runner-win" `
--platform windows-amd64-cuda13 `
--output dist/btl3-patched-ollama-windows-amd64-cuda13
dist\btl3-patched-ollama-windows-amd64-cuda13\btl3-ollama.cmd --btl3-info
dist\btl3-patched-ollama-windows-amd64-cuda13\btl3-ollama.cmd serve
The Windows output uses top-level ollama.exe and btl3-ollama.cmd, with the
runner at lib\ollama\llama-server.exe and CUDA backend at
lib\ollama\cuda_v13\ggml-cuda.dll. This path is source-verified and
package-tested, but still requires generation conformance on real Windows
CUDA hardware before release.
Required Ollama release gates
For each 4090, 5090, and DGX Spark artifact:
- Verify runner and CUDA library architecture with
file/lddon Linux, ordumpbin /headersand/dependentson Windows. - Run
btl3-ollama --btl3-infoand verify the manifest hashes. - Create the model in a temporary
OLLAMA_MODELSdirectory. - Confirm Ollama itself spawns the packaged runner PID.
- Exercise streaming chat, cancellation, reasoning, single and parallel tool calls, JSON schema output, context reuse, and unload/reload.
- Reverify the exact model SHA-256:
2ddf9527620a17a2a6739d184a7096c45712092e6589128792ec6254e94dc30c.
Until those checks pass on a real CUDA executable, the output is a packaging candidate—not an Ollama-compatible release.
LM Studio generator
LM Studio's official plugin API treats generators as replacement token sources. The BTL plugin therefore calls the native runner's OpenAI-compatible endpoint; it does not ask LM Studio's stock engine to interpret AVQ2. Official generator and tool-call APIs are documented in LM Studio's generator introduction and tool-calling guide.
Install the BTL native runner and model into the platform-default BTL-3 data directory (or configure their paths in the plugin), then:
cd integrations/lmstudio/btl3-native
./run-local
The script installs the locked dependencies and runs the official lms dev
workflow. The model appears in LM Studio's model picker as the generator
plugin. Its default endpoint is http://127.0.0.1:8080/v1. When that endpoint
is offline, the Node plugin starts the installed native runner directly with
the configured model; no separately launched compatibility server is required.
The plugin preserves:
- streamed content;
- reasoning fragments through
reasoningType: "reasoning"; - cancellation through
ctl.abortSignal; - full chat history and tool results;
- parallel tool-call IDs, names, and JSON argument fragments;
- explicit propagation of cancellation, connection, and API failures.
Content and reasoning stream live. LM Studio's generator event lifecycle represents one active tool call at a time and its argument-fragment callback does not include a call ID. To preserve BTL-3's parallel calls correctly, the plugin buffers tool fragments by upstream call index and emits each complete lifecycle sequentially when the server stream ends. It does not misattribute interleaved arguments merely to make the tool UI look live.
The included model.yaml is catalog metadata, not a claim that the stock LM
Studio GGUF engine supports AVQ2. It uses the explicit compatibility label
btl3-avq2-native.