Skip to main content

A CLI benchmarking framework for LLM inference across FP16/INT8/INT4 quantization

Project description

litmus-lab

A CLI tool for benchmarking LLM inference across quantization formats and backends. Load a model once per format, measure VRAM, throughput, latency, and quality side by side, then get a deployment recommendation based on the actual numbers.

┏━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Mode            ┃ VRAM (MB) ┃ Tokens/sec (TPS) ┃ Time to First Token (TTFT) ┃ Perplexity ┃
┡━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ HF · FP16       │ 7297.83   │ 32.69            │ 0.0300 sec                 │ 5.64       │
│ HF · INT8       │ 3846.47   │ 14.26            │ 0.0828 sec                 │ 5.81       │
│ HF · INT4 (NF4) │ 2334.96   │ 25.98            │ 0.0686 sec                 │ 7.34       │
│ vLLM · FP16     │ 12687.31  │ 111.68           │ 0.4477 sec                 │ 5.65       │
└─────────────────┴───────────┴──────────────────┴────────────────────────────┴────────────┘

• Deploy vLLM FP16 for production serving.
• vLLM is 241.5% faster than HF FP16 with negligible quality difference (PPL delta 0.01),
  using 5390 MB more VRAM for its KV cache pool. For memory-constrained or single-user
  setups, HF INT4 (NF4) is the best fallback (saves 4963 MB vs FP16, perplexity +1.70 PPL).

Installation

# HF Transformers only
pip install litmus-lab

# HF + vLLM backend
pip install "litmus-lab[vllm]"

# HF + AI-powered recommendations (Groq)
pip install "litmus-lab[ai]"

# Everything
pip install "litmus-lab[all]"

vLLM requires Linux or WSL2. It does not run on Windows natively.


Usage

litmus-lab inference \
  --model microsoft/Phi-3-mini-4k-instruct \
  --prompt "Explain the transformer architecture" \
  --backend hf

Flags

Flag Description Default
--model HuggingFace model repo ID required
--prompt Input prompt for generation required
--token HuggingFace token for gated models None
--backend hf / vllm / all hf

Backend modes

Mode What runs
hf HF Transformers — FP16, INT8, INT4 (NF4)
vllm vLLM — FP16 only
all All four passes in sequence

Examples

# HF only — compare quantization formats
litmus-lab inference \
  --model Qwen/Qwen2.5-7B-Instruct \
  --prompt "Explain quantum gravity" \
  --backend hf

# vLLM only
litmus-lab inference \
  --model mistralai/Mistral-7B-Instruct-v0.3 \
  --prompt "Write a Linux shell script" \
  --backend vllm

# Full comparison — HF + vLLM
litmus-lab inference \
  --model meta-llama/Llama-3.1-8B-Instruct \
  --token hf_xxxxxxx \
  --prompt "Explain TCP congestion control" \
  --backend all

AI Recommendations

Set a Groq API key (free tier) to get an AI-powered recommendation from llama-3.3-70b-versatile instead of the built-in heuristic:

export GROQ_API_KEY=gsk_...

No extra flags needed. If the key is missing, the rate limit is hit, or there is no internet, the tool silently falls back to the offline engine.


Metrics

Metric What it measures
VRAM (MB) Peak GPU memory consumed — model weights + KV cache
TPS Tokens generated per second — throughput
TTFT Time to first token — generation latency
Perplexity Language quality on WikiText-2. Lower is better. Delta >2.0 vs FP16 signals degradation

Supported models

HF backend (FP16 / INT8 / INT4)

Any HuggingFace causal language model that loads via AutoModelForCausalLM:

  • Meta — Llama 3, 3.1, 3.2, 3.3
  • Mistral AI — Mistral 7B, Mixtral 8x7B
  • Microsoft — Phi-3, Phi-3.5, Phi-4
  • Google — Gemma, Gemma 2
  • Alibaba — Qwen2, Qwen2.5
  • DeepSeek — DeepSeek-R1, DeepSeek-V2
  • Falcon, Yi, BLOOM, and most community fine-tunes

Gated models (Llama, Gemma) require --token.

vLLM backend (FP16)

Same model coverage as HF. vLLM runs FP16 only — VRAM usage will be higher than HF FP16 but throughput is significantly better.


What is NOT supported

  • BERT, RoBERTa, and other masked language models
  • T5, BART, mT5, and other sequence-to-sequence models
  • AWQ / GPTQ quantization on the vLLM backend
  • Models that exceed your GPU VRAM at FP16
  • vLLM on Windows (use Linux or WSL2)
  • Multi-GPU / tensor parallel setups

Requirements

  • Python 3.10+
  • CUDA-capable GPU (CPU works but is very slow)
  • CUDA 11.8+ / 12.x

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litmus_lab-0.2.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litmus_lab-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file litmus_lab-0.2.1.tar.gz.

File metadata

  • Download URL: litmus_lab-0.2.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for litmus_lab-0.2.1.tar.gz
Algorithm Hash digest
SHA256 809bc8ba4414f63cf750b386b2cc7ed5f48768aedede619e14d0a12e644ca22b
MD5 fea7b2ed2781dcc0c9375403d6cb40bb
BLAKE2b-256 aa4484d92f14ac60d42bbae141e1d92433ceebddd3fc23974243af1167c67378

See more details on using hashes here.

File details

Details for the file litmus_lab-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: litmus_lab-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for litmus_lab-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48fcdb8bed12d56a9c784aee584e33279acb37c87cef87024461c284e74288a6
MD5 8f9cff170e036f9d924efb78bc74fc93
BLAKE2b-256 354fbee64fbd5bfd3f497f190f9168154ed069bc8e6c85252d11fd5e0e2ed4e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page