Prerequisites
Before you begin, confirm that you have:- Python 3.11 (exactly —
>=3.11, <3.12is required) - A CUDA-capable GPU (required for Triton kernels and torch CUDA ops)
- Git to clone the repository
Installation
1
Install uv
miniVLLM uses uv for dependency management. Install it with:
2
Clone the repository
3
Sync dependencies
uv sync reads pyproject.toml and installs all dependencies into an isolated virtual environment. No manual pip install is needed.Run the inference demo
The main demo runs end-to-end inference through the custom engine:- Loads the
Qwen/Qwen3-0.6Btokenizer - Initializes
LLMEnginewith a small Qwen3 model (random weights for speed) - Creates chat prompts and tokenizes them using the model’s chat template
- Processes them through the engine using paged attention and KV cache management
- Generates up to 256 new tokens per prompt with temperature sampling
- Prints each prompt alongside its completion
Configuration
The demo is configured by theconfig dict at the top of main.py. The engine requires both scheduling/memory keys and model architecture keys:
Multi-GPU setup
To run with multiple GPUs, setworld_size in the config dict to the number of GPUs you want to use:
Run benchmarks
- PyTorch standard attention (O(N²) memory)
- Naive Triton kernel (O(N²) memory, limited to ≤128 tokens)
- Flash attention Triton kernel (O(N) memory)
- Naive PyTorch loop over paged KV cache
- Optimized PyTorch with vectorized gathering and masking
- Custom Triton paged attention kernel
Use the API directly
You can useLLMEngine and SamplingParams directly in your own scripts:
SamplingParams fields
Understanding the output
During agenerate() call, the engine prints throughput statistics for each scheduling step:
- Prefilling processes all input prompt tokens in parallel — throughput is high.
- Decoding generates one token per active sequence per step — throughput reflects the cost of paged attention over the growing KV cache.
outputs dict contains:
outputs["text"]— list of decoded completion strings, one per promptoutputs["token_ids"]— list of token ID lists for each completion