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.2.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.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litmus_lab-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 2dcbfef1af517262ebc9fb8181263ea3581c87ffd030dc4c48b30887116b1ade
MD5 2ce91cfa3f00aa3c622b1441addae1db
BLAKE2b-256 cc89def91ac1ce31a68ef996c2246800c45d48832f541ceeb6e3613b6264063c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: litmus_lab-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b15578e98a0b5c81ea52e4a757756cd925ac8f0390e391892e81c8a42e768920
MD5 1bdb9dece3b413d4f7139247fc0204b0
BLAKE2b-256 993519058428e3cad9ef71db2249c9343ea6c00f0fa9958a610e385beddd6195

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