Instructions to use compilade/quant-tests with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use compilade/quant-tests with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="compilade/quant-tests", filename="TriLM_1.5B_Unpacked-TQ1_0-F16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use compilade/quant-tests with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf compilade/quant-tests:F16 # Run inference directly in the terminal: llama-cli -hf compilade/quant-tests:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf compilade/quant-tests:F16 # Run inference directly in the terminal: llama-cli -hf compilade/quant-tests:F16
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 compilade/quant-tests:F16 # Run inference directly in the terminal: ./llama-cli -hf compilade/quant-tests:F16
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 compilade/quant-tests:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf compilade/quant-tests:F16
Use Docker
docker model run hf.co/compilade/quant-tests:F16
- LM Studio
- Jan
- Ollama
How to use compilade/quant-tests with Ollama:
ollama run hf.co/compilade/quant-tests:F16
- Unsloth Studio
How to use compilade/quant-tests 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 compilade/quant-tests 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 compilade/quant-tests to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for compilade/quant-tests to start chatting
- Docker Model Runner
How to use compilade/quant-tests with Docker Model Runner:
docker model run hf.co/compilade/quant-tests:F16
- Lemonade
How to use compilade/quant-tests with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull compilade/quant-tests:F16
Run and chat with the model
lemonade run user.quant-tests-F16
List all available models
lemonade list
Add benchmarking script
Browse files- BENCHMARKING.md +26 -0
- bench-TriLMs.sh +101 -0
BENCHMARKING.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Benchmarking models
|
| 2 |
+
|
| 3 |
+
To use `bench-TriLMs.sh`, you need to
|
| 4 |
+
|
| 5 |
+
- Place it in a `llama.cpp` checkout
|
| 6 |
+
- Have `cmake`, `gcc`, and other dependencies of `llama.cpp`
|
| 7 |
+
- If you want to benchmark on GPUs, the script checks if `nvidia-smi` is present, and you'll also need the necessary compile-time dependencies
|
| 8 |
+
|
| 9 |
+
The script will automatically download the models and quantize different variants.
|
| 10 |
+
|
| 11 |
+
It will then produce 2 result files, one called `results-$(date +%s).json` and the other called `results-$(date +%s)-cpuinfo.txt`. Both will use the exact same date.
|
| 12 |
+
|
| 13 |
+
The intention is to eventually read the produced `.json` in a Python script with
|
| 14 |
+
|
| 15 |
+
```python3
|
| 16 |
+
from __future__ import annotations
|
| 17 |
+
|
| 18 |
+
from typing import Any
|
| 19 |
+
import json
|
| 20 |
+
|
| 21 |
+
with open("result-1234567890.json") as f:
|
| 22 |
+
data: list[list[dict[str, Any]]] = json.loads("[" + f.read() + "]")
|
| 23 |
+
|
| 24 |
+
# Then use that data
|
| 25 |
+
...
|
| 26 |
+
```
|
bench-TriLMs.sh
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -eux
|
| 3 |
+
|
| 4 |
+
cd "$(dirname "$0")"
|
| 5 |
+
|
| 6 |
+
MODEL_DIR="bench-TriLMs-models"
|
| 7 |
+
LLAMA_CPP_PATH="."
|
| 8 |
+
sizes=("1.5" "2.4" "3.9")
|
| 9 |
+
types=("TQ1_0" "TQ2_0" "Q8_0" "F16" "BF16")
|
| 10 |
+
gputypes=("Q8_0" "F16" "BF16")
|
| 11 |
+
|
| 12 |
+
function gather_models() {
|
| 13 |
+
echo Gather the models
|
| 14 |
+
if [ ! -d "$MODEL_DIR" ]; then
|
| 15 |
+
mkdir -p -- "$MODEL_DIR"
|
| 16 |
+
fi
|
| 17 |
+
(
|
| 18 |
+
cd "$MODEL_DIR"
|
| 19 |
+
for sz in "${sizes[@]}"; do
|
| 20 |
+
filename="TriLM_${sz}B_Unpacked-TQ1_0-F16.gguf"
|
| 21 |
+
if [ ! -f "$filename" ]; then
|
| 22 |
+
wget "https://huggingface.co/compilade/quant-tests/resolve/main/${filename}"
|
| 23 |
+
fi
|
| 24 |
+
done
|
| 25 |
+
)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function build_llama_cpp() {
|
| 29 |
+
echo Build llama.cpp for CPU
|
| 30 |
+
|
| 31 |
+
(
|
| 32 |
+
cd -- "$LLAMA_CPP_PATH"
|
| 33 |
+
if [ -d build ]; then
|
| 34 |
+
pwd
|
| 35 |
+
echo 'rm -rI build'
|
| 36 |
+
rm -rI build
|
| 37 |
+
fi
|
| 38 |
+
mkdir build
|
| 39 |
+
cd build
|
| 40 |
+
cmake .. "$@"
|
| 41 |
+
make -j llama-bench llama-quantize
|
| 42 |
+
)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function quantize() {
|
| 46 |
+
echo "Make all model types we'll test"
|
| 47 |
+
(
|
| 48 |
+
for sz in "${sizes[@]}"; do
|
| 49 |
+
for ty in "${types[@]}"; do
|
| 50 |
+
filenames=("$MODEL_DIR"/TriLM_"${sz}"B_Unpacked-{TQ1_0-F16,"$ty"}.gguf)
|
| 51 |
+
if [ ! -f "${filenames[1]}" ]; then
|
| 52 |
+
"$LLAMA_CPP_PATH"/build/bin/llama-quantize --allow-requantize "${filenames[@]}" "$ty"
|
| 53 |
+
fi
|
| 54 |
+
done
|
| 55 |
+
done
|
| 56 |
+
)
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function bench() {
|
| 60 |
+
echo Test each model one by one for different numbers of threads
|
| 61 |
+
|
| 62 |
+
for sz in "${sizes[@]}"; do
|
| 63 |
+
for ty in "$@"; do
|
| 64 |
+
for th in 1 2 4 8; do
|
| 65 |
+
{
|
| 66 |
+
"$LLAMA_CPP_PATH"/build/bin/llama-bench -v -m "${MODEL_DIR}/TriLM_${sz}B_Unpacked-${ty}.gguf" -t "${th}" -p 512 -n 128 -r 4 -o json
|
| 67 |
+
printf "%s\n" ","
|
| 68 |
+
}
|
| 69 |
+
done
|
| 70 |
+
done
|
| 71 |
+
done
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function bench_cpu() {
|
| 75 |
+
bench "${types[@]}" >> "$1"
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function bench_gpu() {
|
| 79 |
+
bench "${gputypes[@]}" >> "$1"
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
currentTime="$(date +'%s')"
|
| 83 |
+
resultFile="results-${currentTime}.json"
|
| 84 |
+
infoFile="results-${currentTime}-info.txt"
|
| 85 |
+
lscpu > "$infoFile"
|
| 86 |
+
|
| 87 |
+
gather_models
|
| 88 |
+
build_llama_cpp -DGGML_NATIVE=ON -DGGML_CPU=ON
|
| 89 |
+
quantize
|
| 90 |
+
|
| 91 |
+
echo "---" >> "$infoFile"
|
| 92 |
+
ls -go "$MODEL_DIR" >> "$infoFile"
|
| 93 |
+
|
| 94 |
+
bench_cpu "$resultFile"
|
| 95 |
+
|
| 96 |
+
if [ -x "$(command -v nvidia-smi)" ]; then
|
| 97 |
+
echo GPU detected, benchark with that too.
|
| 98 |
+
build_llama_cpp -DGGML_NATIVE=ON -DGGML_CUDA=ON -DGGML_CUDA_F16=ON
|
| 99 |
+
bench_gpu "$resultFile"
|
| 100 |
+
fi
|
| 101 |
+
|