- Attention Mechanism
- The component of transformer models that lets the model weigh the relevance of different input tokens when generating each output token. Computationally expensive and quadratic in sequence length. Flash Attention is a popular optimization that reduces VRAM usage.
- Batching (Dynamic Batching)
- Grouping multiple inference requests together and processing them in a single GPU forward pass. Dramatically improves GPU utilization and throughput. vLLM, TGI, and TensorRT-LLM all implement dynamic batching.
- Context Window
- The maximum number of tokens a model can consider at once - both input and output combined. Llama 3.1 supports up to 128K tokens. Longer context means more VRAM required for the KV cache.
- Fine-tuning
- The process of continuing to train a pre-trained model on a smaller, task-specific dataset to adapt its behavior. Techniques include full fine-tuning, LoRA, QLoRA, and DPO. Requires more GPU memory and longer runtimes than inference.
- Flash Attention
- An optimized attention algorithm that reorders matrix operations to avoid writing intermediate results to HBM, dramatically reducing memory bandwidth consumption. Nearly all modern inference stacks ship with Flash Attention support.
- GQA (Grouped Query Attention)
- An attention variant used in Llama 3, Mistral, and other modern models that reduces KV cache size by sharing key-value heads across multiple query heads. Significantly improves inference throughput and reduces VRAM pressure.
- Inference
- Running a trained model on new input to generate output. When you send a prompt to an API and get a response, that's inference. GPU-intensive but shorter than training. Token Factory is packet.ai's inference layer.
- KV Cache
- The stored key-value attention states from previously processed tokens, reused to avoid recomputation on each new token. Grows with sequence length and batch size. On long-context workloads, KV cache can consume more VRAM than the model weights themselves.
- LoRA (Low-Rank Adaptation)
- A parameter-efficient fine-tuning technique that inserts small trainable matrices into each layer of a model instead of updating all weights. Trains 10-100x faster, uses far less VRAM, and produces a small adapter file. QLoRA adds quantization on top.
- Prefill
- The first phase of LLM inference where the full input prompt is processed to build the initial KV cache. Computationally intensive and scales with prompt length. After prefill, the model enters the decode (token generation) phase.
- Prefix Caching
- A technique where the KV cache for a shared prefix (e.g., a long system prompt) is computed once and reused across multiple requests. Reduces time-to-first-token and compute cost. Supported by vLLM and TGI.
- Quantization
- Reducing the numerical precision of model weights to compress model size and speed up inference. Common schemes: INT8, INT4, GPTQ, AWQ. A 70B model in FP16 needs ~140 GB VRAM; in INT4 it fits in ~35 GB. Trade-off: slight quality degradation.
- RLHF (Reinforcement Learning from Human Feedback)
- A training technique used to align LLMs with human preferences by training a reward model on human comparisons, then using RL to optimize the base model against it. Used to produce instruction-following models like ChatGPT and Claude.
- Speculative Decoding
- An inference acceleration technique where a small draft model generates several candidate tokens, and the larger target model verifies them in parallel. Achieves 2-3x speedups on latency-sensitive workloads with no quality loss.
- TGI (Text Generation Inference)
- Hugging Face's production-grade inference server. Supports continuous batching, tensor parallelism, Flash Attention, and quantization. A common choice for self-hosted LLM serving on GPU cloud.
- Tokens
- The basic units models operate on - roughly 1 token = 0.75 words in English. Models are priced per million input/output tokens. Token Factory charges $0.10/million tokens across supported open-source models.
- TTFT (Time to First Token)
- The latency between sending a request and receiving the first output token. Drives perceived responsiveness in chat and interactive applications. Dominated by prefill time for long prompts.
- vLLM
- An open-source inference engine with PagedAttention, continuous batching, and tensor parallelism. The most widely deployed open-source LLM serving framework. First-class support for Llama, Mistral, Qwen, DeepSeek, and most open models.