Model Optimisation and Performance is the body of post-training techniques, inference-time systems, and hardware-aware transformations that reduce the computational cost, memory footprint, and latency of neural networks—particularly large language models (LLMs)—without unacceptable degradation of…

Semantic Classification

Content

Compositional Relationships (Components)

SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:Quantisation))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:Pruning))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:KnowledgeDistillation))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:SpeculativeDecoding))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:FlashAttention))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:KVCacheManagement))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:PagedAttention))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:hasPart ai:GGUFFormat))

## Dependency Relationships
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:CalibrationDataset))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:GPUCompute))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:CUDARuntime))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:TransformerArchitecture))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:FloatingPointArithmetic))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:requires ai:MemoryHierarchy))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:dependsOn ai:LinearAlgebra))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:dependsOn ai:HardwareArchitecture))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:dependsOn ai:NumericalPrecision))

## Capability Relationships
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:OnDeviceInference))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:RealTimeAI))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:EdgeDeployment))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:CostEffectiveLLMServing))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:MobileAI))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:enables ai:LowLatencyAPIs))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:supports ai:LargeLanguageModels))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:supports ai:AutonomousSystems))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:supports ai:MedicalAI))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:supports ai:ConversationalAI))

## Implementation Relationships
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:PostTrainingQuantisation))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:StructuredSparsity))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:AttentionTiling))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:VirtualMemoryManagement))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:KernelFusion))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:implements ai:GraphOptimisation))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:uses ai:INT8Arithmetic))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:uses ai:BFLOAT16))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:uses ai:TensorCores))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:uses ai:NEONSIMDInstructions))

## Reduction Relationships
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:MemoryFootprint))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:InferenceLatency))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:EnergyConsumption))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:ComputationalCost))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:ModelSizeOnDisk))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:reduces ai:GPUMemoryBandwidthPressure))

## Association Relationships
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:relatedTo ai:MLOps))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:relatedTo ai:AutoML))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:relatedTo ai:NeuralArchitectureSearch))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:relatedTo ai:EfficientTransformers))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:contrastsWith ai:FullPrecisionTraining))
SubClassOf(ai:ModelOptimisationAndPerformance
  ObjectSomeValuesFrom(ai:contrastsWith ai:DenseInference))

## Data Properties (Characteristics)
DataPropertyAssertion(ai:hasIdentifier ai:ModelOptimisationAndPerformance "AI-2081"^^xsd:string)
DataPropertyAssertion(ai:authorityScore ai:ModelOptimisationAndPerformance "0.87"^^xsd:decimal)
DataPropertyAssertion(ai:typicalQuantisationSpeedup ai:ModelOptimisationAndPerformance "2.0"^^xsd:decimal)
DataPropertyAssertion(ai:flashAttentionSpeedup ai:ModelOptimisationAndPerformance "4.0"^^xsd:decimal)
DataPropertyAssertion(ai:vLLMThroughputGain ai:ModelOptimisationAndPerformance "24.0"^^xsd:decimal)
DataPropertyAssertion(ai:speculativeDecodingSpeedup ai:ModelOptimisationAndPerformance "3.0"^^xsd:decimal)

## Property Constraints
SubClassOf(ai:ModelOptimisationAndPerformance
  DataMinCardinality(1 ai:hasQuantisationBits xsd:integer))
SubClassOf(ai:ModelOptimisationAndPerformance
  DataAllValuesFrom(ai:preservesOutputDistribution xsd:boolean))
SubClassOf(ai:ModelOptimisationAndPerformance
  DataSomeValuesFrom(ai:targetHardwarePlatform xsd:string))

## Annotations
AnnotationAssertion(rdfs:label ai:ModelOptimisationAndPerformance "Model Optimisation and Performance"@en)
AnnotationAssertion(rdfs:comment ai:ModelOptimisationAndPerformance "Engineering discipline reducing neural network inference cost through quantisation (GPTQ, AWQ, AQLM, GGUF), pruning (Wanda, SparseGPT, 2:4 sparsity), distillation (DistilBERT, MiniLM), speculative decoding (2-3x throughput), FlashAttention (v1/v2/v3 IO-aware tiling), vLLM PagedAttention (24x throughput gain), TensorRT-LLM kernel fusion, and ONNX Runtime graph optimisation, benchmarked by MLPerf Inference v4.1/v5.0, enabling 70B models on consumer GPUs and 7B models on mobile devices."@en)
AnnotationAssertion(dcterms:identifier ai:ModelOptimisationAndPerformance "AI-2081"^^xsd:string)
AnnotationAssertion(dcterms:subject ai:ModelOptimisationAndPerformance "Quantisation, Pruning, Distillation, Inference Optimisation, LLM Efficiency, MLOps"@en)

)

Property Characteristics

AsymmetricObjectProperty(ai:requires) AsymmetricObjectProperty(ai:enables) AsymmetricObjectProperty(ai:implements) AsymmetricObjectProperty(ai:contrastsWith) TransitiveObjectProperty(ai:dependsOn) FunctionalDataProperty(ai:typicalQuantisationSpeedup) FunctionalDataProperty(ai:vLLMThroughputGain)

About Model Optimisation and Performance

  • Model Optimisation and Performance is the engineering discipline that translates research-scale neural networks—particularly the multi-billion parameter Transformer Architecture models dominant since 2020—into deployable systems that meet real-world constraints of latency, memory, energy budget, and cost. As language models have grown from GPT-2’s 1.5B parameters (2019) to GPT-4’s estimated 1.8T parameters (2023) and beyond, the gap between raw capability and practical usability has necessitated a rich ecosystem of compression, approximation, and systems-level techniques that collectively constitute this field.
  • The discipline spans the full inference pipeline: the model itself (Quantisation, Pruning, Knowledge Distillation, Neural Architecture Search), the attention computation (FlashAttention, sparse attention, linear attention), the serving infrastructure (Continuous Batching, KV Cache management, Speculative Decoding), and the hardware backend (Kernel Fusion, precision dispatch, SIMD vectorisation). Each layer offers multiplicative gains: a 4-bit quantised model served via vLLM on an H100 with FlashAttention-3 and speculative decoding may achieve 20-50× the effective throughput of a naively deployed FP32 equivalent.
  • The economic stakes are substantial. OpenAI’s 2023 annual inference compute cost was estimated at 630M annual saving or equivalently enables 10× more users on equivalent hardware. At the edge, the ability to run a 7B parameter model on an Apple M-series chip or Qualcomm Snapdragon rather than routing queries to a data-centre changes both the economics and privacy properties of AI applications fundamentally.
  • The field is intrinsically interdisciplinary: it requires understanding of Numerical Linear Algebra (quantisation error theory, matrix factorisation), Computer Architecture (cache hierarchies, memory bandwidth, SIMD pipelines), Operating Systems (virtual memory management underlying PagedAttention), Compiler Theory (graph optimisation, kernel fusion, polyhedral loop transformations), and Machine Learning Discipline theory (information-theoretic distillation bounds, sparsity-accuracy trade-offs). No single academic department owns this space—it is practiced at the intersection of systems, architecture, and ML research.
  • Historical trajectory: Pre-2020, model optimisation primarily targeted embedded vision models (MobileNet, ShuffleNet, EfficientNet for INT8 classification on edge devices). The 2020 arrival of GPT-3 and the subsequent explosion of LLMs shifted focus entirely: the models were now 100-1000× larger, the inference bottleneck shifted from compute to memory bandwidth, and the optimisation targets shifted from classification accuracy to language modelling perplexity and instruction-following quality. By 2022, FlashAttention and vLLM demonstrated that systems-level optimisation could deliver larger gains than algorithmic improvements alone. By 2024, the combination of AWQ INT4 quantisation + vLLM continuous batching + FlashAttention-2 + speculative decoding had collectively delivered ~50× throughput improvement over 2022 baseline PyTorch FP16 inference on the same hardware—without any change to model architecture or training.

Quantisation: Precision Reduction

  • Quantisation maps continuous floating-point weights and/or activations to discrete lower-precision representations. The fundamental trade-off is compression ratio versus accuracy degradation, governed by the quantisation error ε = x − Q(x) where Q(x) = round(x/s) · s for scale factor s = (x_max − x_min)/(2^b − 1) in b-bit uniform quantisation.

Weight-Only vs Activation Quantisation

  • Weight-only quantisation (W-only) compresses the model on disk and reduces memory bandwidth during decode, where each weight matrix is loaded once per token generation step. INT8 weight-only quantisation (W8A16, weights INT8 activations FP16) achieves approximately 2× memory reduction with near-zero perplexity loss. INT4 (W4A16) achieves 4× reduction at 0.5-2% perplexity increase on most tasks.
  • Weight-activation quantisation (W8A8) quantises both weight matrices and activation tensors, enabling INT8 matrix multiplication on hardware tensor cores (NVIDIA Tensor Cores INT8 mode achieves 2× FLOPS vs FP16). NVIDIA SmoothQuant Xiao et al. 2022 addresses the challenge that activations exhibit large per-token outliers (100× magnitude vs typical values) by mathematically migrating quantisation difficulty from activations to weights via per-channel scaling before quantisation.

GPTQ

  • GPTQ (Frantar et al., NeurIPS 2022) is the canonical weight-only PTQ method for LLMs. It applies the Optimal Brain Quantisation (OBQ) framework column-by-column: for each weight column, it computes the Hessian H = 2X^T X of the layer output squared error with respect to that column, quantises it to the target bitwidth, and compensates remaining unquantised columns by updating them as w_q = w - (q - w)/[H^{-1}]{FF} × H^{-1}{:F} where F indexes the current column. The Hessian inverse is computed once via Cholesky decomposition (cost O(d³) amortised across all columns), making GPTQ practical: quantising LLaMA-65B to 4-bit takes approximately 4 GPU-hours on an A100. GPTQ achieves <0.5 perplexity point degradation at INT4 on LLaMA-2-70B (measured on WikiText-2 PPL).

AWQ

  • AWQ (Activation-aware Weight Quantisation, Lin et al. 2023) observes that only 0.1% of weights—those corresponding to large activation channels—disproportionately affect quantisation error. Rather than using per-weight Hessians, AWQ scales these salient channels up by a per-channel factor s before quantisation and divides activations by the same factor at runtime (a mathematically equivalent transformation). The scale factors are determined by a grid search minimising per-layer output MSE on a calibration set of 128 samples. AWQ achieves comparable accuracy to GPTQ at 4-bit with 3× faster quantisation (no Hessian inversion required) and has become the default method in Hugging Face AutoAWQ (100K+ downloads/month, May 2026).

AQLM

  • AQLM (Additive Quantisation for Language Models, Egiazarian et al. ICML 2024) applies multi-codebook vector quantisation, representing each weight vector as a sum of K=2-4 codebook entries from codebooks of size M=256 each. At 2-bit effective precision, AQLM outperforms GPTQ and AWQ (lower perplexity on LLaMA-2-7B WikiText-2: 6.3 vs 6.8 GPTQ) and is particularly effective at very low bitwidths (1.5-2 bits) where scalar quantisation degrades severely. AQLM inference on GPU requires custom CUDA kernels to decode the additive codebook representation during matrix multiplication.

GGUF Format

  • GGUF (GPT-Generated Unified Format) was introduced by Georgi Gerganov in August 2023 as the successor to GGML, providing a self-describing binary container for quantised language models. GGUF encodes per-tensor quantisation parameters (scale, zero-point, block size Q, quantisation type) in typed metadata, supports streaming partial loads for CPU inference, and is versioned with a 4-byte magic (GGUF). Supported quantisation types include Q4_K_M (4-bit k-means, medium, optimal consumer GPU/CPU balance), Q5_K_M, Q6_K, and IQ2_XXS (2.06 bits, importance-matrix aware). The format enables llama.cpp to run LLaMA-3-70B Q4_K_M on an Apple M2 Ultra at 12 tokens/second with 64GB unified memory—a system costing under £3,500.

Pruning: Sparsity-Based Compression

  • Pruning removes weights (unstructured) or entire structural units (structured) from a trained network, replacing values with zeros. The classic Optimal Brain Damage (LeCun et al. 1990) and Optimal Brain Surgeon (Hassibi & Stork 1993) frameworks used Hessian-based saliency. The Lottery Ticket Hypothesis (Frankle & Carlin, ICLR 2019) demonstrated that dense networks contain sparse sub-networks trainable from scratch to equivalent accuracy—motivating the search for sparse initialisations.

Wanda

  • Wanda (Pruning by Weights and Activations, Sun et al. ICLR 2024) identifies a simple but highly effective pruning criterion: for each weight w_{ij}, the importance score is |w_{ij}| × ‖x_j‖₂ where x_j is the j-th input activation feature averaged over a calibration set of 128 samples. Weights with the lowest importance are zeroed in a single pass without any weight updates or Hessian computation, enabling 50% unstructured pruning of LLaMA-2-70B in under one GPU-minute. At 50% sparsity, Wanda achieves lower perplexity than SparseGPT on most LLaMA variants, despite requiring no iterative updates.

SparseGPT

  • SparseGPT (Frantar & Alistarh, ICML 2023) applies the same OBQ-style layer-wise Hessian inversion as GPTQ but for unstructured pruning: pruned weights are selected by a threshold, and remaining weights are updated to compensate via the block-wise Hessian inverse. SparseGPT achieves 50% unstructured sparsity on OPT-175B in 4.5 hours on a single A100 with near-zero perplexity increase (< 0.1 PPL on WikiText-2). Critically, SparseGPT also supports 2:4 structured sparsity (exactly 2 of every 4 consecutive weights are non-zero), compatible with NVIDIA’s Sparse Tensor Core acceleration (50% GEMM speed-up on A100/H100) via the nmSparse compression format.

Structured Pruning

  • Structured pruning removes entire attention heads, feed-forward neurons, or transformer layers, producing models with reduced parameter counts that run efficiently on dense hardware without sparse kernel support. LLM-Pruner Ma et al. 2023 uses Taylor expansion-based gradient importance to select coupled structures for removal, achieving 20% parameter reduction of LLaMA with 5-minute calibration. ShortGPT Men et al. 2024 demonstrates that entire transformer layers exhibit high cosine similarity between input and output (Block Influence < 0.01), allowing removal of the 10-25% least influential layers with minor perplexity increase—producing “short” models that retain 90%+ accuracy.

Knowledge Distillation

  • Knowledge distillation (Hinton et al. 2015) trains a compact student model S to match the soft output distribution of a larger teacher T via temperature-scaled KL divergence: L_KD = T² × KL(σ(z_T/T) ‖ σ(z_S/T)) where z_T and z_S are teacher and student logits, T is temperature (typically 2-10), and σ is softmax. The soft targets contain richer information than one-hot labels—encoding inter-class similarities the student model learns efficiently.

DistilBERT

  • DistilBERT (Sanh et al. HuggingFace 2019) demonstrated that a 6-layer 66M parameter student could retain 97% of BERT-base 12-layer 110M’s GLUE performance by combining (i) soft target distillation, (ii) cosine embedding loss on hidden states, and (iii) masked language modelling loss, trained on the same corpus as BERT using a linear combination. DistilBERT runs 60% faster than BERT-base and remains one of the most downloaded models on Hugging Face (500M+ downloads).

MiniLM

  • MiniLM (Wang et al. NeurIPS 2020) applies relation-based distillation: rather than matching hidden states, it distills the self-attention relation matrices and value-relation matrices from the last transformer layer of the teacher. MiniLM-L6-H384 distilled from BERT-large achieves 99% of teacher performance on STS-B at 22M parameters. MiniLM-L6-v2 became the standard embedding model in many production RAG systems (Sentence-Transformers library, 100M+ downloads).

Cross-Architecture Distillation

  • TinyLlama (Zhang et al. 2024) is a 1.1B LLaMA-2 architecture student trained on 3 trillion tokens using Grouped Query Attention (GQA) and FlashAttention-2, matching or exceeding OPT-1.3B and Pythia-1.4B on most benchmarks. The key insight is that architectural alignment between student and teacher is not required for effective distillation when sufficient compute tokens are available; cheap student training from scratch on teacher-generated data (Alpaca-style instruction following) often outperforms layer-mapping distillation from a frozen teacher.

Speculative Decoding

  • Autoregressive generation generates one token at a time: each step requires a full forward pass through the model (for a 70B model, approximately 140GB of weight reads from HBM, dominated by memory bandwidth not compute). Speculative decoding (Leviathan et al. ICML 2023; Chen et al. 2023) addresses this bottleneck by using a small draft model (typically 1-7B) to generate k=4-8 draft tokens, which are then verified by the target model in a single parallel forward pass processing all k tokens simultaneously. If the target model accepts all k tokens (they match the target distribution), k+1 tokens are produced in the time of one target forward pass. Rejected tokens cause partial rollback. The expected acceptance rate α determines expected speedup: E[speedup] = (1−α^{k+1})/(1−α) × T_target/T_draft, typically 2-3× for well-matched draft/target pairs (e.g., LLaMA-3-8B drafting for LLaMA-3-70B achieves α≈0.8, giving 2.5× throughput). The method produces exactly the same output distribution as greedy decoding from the target model—a critical property for safety-sensitive applications.
  • EAGLE (Li et al. 2024) extends speculative decoding using feature-level prediction: the draft model operates on transformer hidden states rather than token embeddings, enabling better prediction without increased latency. EAGLE-2 achieves 3.5× speed-up on LLaMA-3-70B-Instruct.

Attention Optimisation: FlashAttention

  • Standard scaled dot-product attention requires materialising the N×N attention matrix: for a sequence of N=2048 tokens, this is 2048×2048×2 bytes = 8MB per layer per head in FP16—exceeding L2 cache on all modern GPUs and requiring HBM reads/writes that dominate wall-clock time.

FlashAttention v1 (Dao et al., NeurIPS 2022)

  • FlashAttention reformulates attention computation to avoid materialising the full attention matrix in HBM. Using the online softmax trick (Milakov & Gimelshein 2018), it tiles the computation into blocks that fit in SRAM (20-40MB on A100), computing exact attention incrementally: for each query block Q_i, it streams over key-value blocks K_j, V_j, maintaining running max and normalisation statistics to accumulate the softmax-weighted output O_i. This reduces HBM memory access from O(N²) to O(N), achieving 2-4× wall-clock speed-up on A100 and enabling sequences up to 64K tokens that were previously out-of-memory. FlashAttention also enables gradient checkpointing at no extra compute cost by recomputing attention during the backward pass from stored Q, K, V rather than storing the N×N attention weights.

FlashAttention-2 (Dao, ICLR 2024)

  • FlashAttention-2 improves GPU utilisation through (i) better work partitioning—each thread block handles an independent query block, eliminating inter-block synchronisation overhead; (ii) reducing non-matmul FLOPs (the online softmax rescaling steps); and (iii) supporting multi-query attention (MQA) and grouped-query attention (GQA) natively. Achieves 230 TFLOPS on A100 (72% of theoretical peak) vs FlashAttention-1’s 120 TFLOPS.

FlashAttention-3 (Shah et al., ArXiv July 2024)

  • FlashAttention-3 exploits NVIDIA H100 Hopper-specific features unavailable on Ampere: (i) WGMMA (Warpgroup Matrix Multiply Accumulate) instructions enabling asynchronous tensor core operations; (ii) TMA (Tensor Memory Accelerator) hardware units for asynchronous data movement from HBM to SRAM with bulk copy semantics; (iii) FP8 (8-bit floating point E4M3/E5M2 formats native to H100) achieving 2× the throughput of FP16 tensor cores for attention computation. FlashAttention-3 achieves 740-750 TFLOPS on H100 SXM5 (73% of 1,000 TFLOPS FP16 peak, 75% of FP8 peak), representing 1.5-2.0× speed-up over FlashAttention-2 on the same hardware. For FP8 with causal masking on 1K-sequence length, FA3 achieves 1,100 TFLOPS (exceeding FP16 peak by exploiting FP8 matrix units with FP32 accumulation).

Inference Serving: vLLM and PagedAttention

  • LLM serving presents a unique memory management challenge: each request maintains a KV cache of shape [2, num_layers, sequence_length, num_heads, head_dim] growing dynamically during generation. With sequence lengths up to 128K tokens (LLaMA-3 context), a single request KV cache for LLaMA-3-70B can require 70GB—exceeding typical GPU memory. Traditional systems pre-allocate maximum-length KV cache blocks, wasting 60-80% of GPU memory to internal fragmentation.

PagedAttention (Kwon et al., SOSP 2023)

  • vLLM introduced PagedAttention, managing KV caches analogously to OS virtual memory paging. The KV cache is divided into fixed-size pages (default block_size=16 tokens), stored in a block table mapping logical sequence positions to physical GPU memory blocks. Physical blocks are allocated on demand and may be non-contiguous. Key benefits: (i) near-zero fragmentation (the only waste is the last partial page per sequence, average 50% of one block = 8 tokens = negligible); (ii) copy-on-write sharing of common prefix blocks across requests (system prompt reuse, parallel sampling); (iii) memory-efficient batching allowing the system to serve requests until GPU memory is exhausted rather than pre-allocating for worst-case lengths. vLLM achieves 24× higher throughput vs HuggingFace Transformers on LLaMA-13B with 6 concurrent users. By May 2026, vLLM has accumulated 30K+ GitHub stars and serves as the inference backend for Mistral AI, Databricks DBRX, Anyscale, and most production LLM APIs.

Continuous Batching

  • Traditional static batching waits for all requests in a batch to complete before starting new ones, leaving GPU idle when short requests finish early. Continuous batching (Orca Yu et al. OSDI 2022) processes each decode step as a micro-batch, inserting newly arrived requests at any step boundary. vLLM implements continuous batching with iteration-level scheduling, achieving GPU utilisation above 90% under production traffic patterns.

Prefix Caching and Chunked Prefill

  • Automatic Prefix Caching (APC) in vLLM v0.4+ hashes prompt token sequences and reuses KV cache pages for identical prefixes across requests—particularly effective for system prompts shared across thousands of simultaneous user sessions (cache hit rates of 40-80% reported in production). Chunked Prefill splits long prompt prefills into configurable chunks (chunk_size=512 tokens default), interleaving prefill chunks with decode steps to prevent prefill-induced latency spikes for concurrent decode requests.

TensorRT-LLM and ONNX Runtime

  • TensorRT-LLM (NVIDIA, open-sourced November 2023) provides a Python-based toolkit for building optimised LLM inference engines targeting NVIDIA GPUs. Key features include: (i) CUDA kernel fusion combining multiple operations (LayerNorm + Linear + Activation + Residual) into a single kernel reducing kernel launch overhead and memory roundtrips; (ii) in-flight batching equivalent to vLLM continuous batching; (iii) support for INT8 SmoothQuant, INT4 AWQ/GPTQ, and FP8 (H100) quantisation via quantize.py script; (iv) speculative decoding with draft model configuration; (v) Medusa multi-head speculative decoding (Cai et al. 2024) adding extra decoding heads to the base model for 2.5× throughput. TensorRT-LLM achieves 8× speed-up over PyTorch baseline for GPT-J-6B FP16 on A100, and up to 5× on LLaMA-2-70B INT4 AWQ on H100 × 4.
  • ONNX Runtime (Microsoft, Apache 2.0) provides cross-platform neural network inference via the ONNX interchange format. Graph optimisations include: level-1 constant folding and redundant node elimination; level-2 operator fusion (Attention = Q/K/V MatMul + Softmax + Projection fused to a single CUDA kernel); level-3 CUDA graph capture eliminating kernel launch overhead for fixed-shape inference. Execution providers dispatch subgraphs to CUDA, TensorRT, DirectML (Windows GPU), NNAPI (Android), CoreML (Apple Silicon), OpenVINO (Intel), or ROCm backends. The optimum-intel integration enables INT8 quantisation via neural compressor for CPUs, achieving 3-4× inference speed-up on Intel Sapphire Rapids Xeon with VNNI INT8 dot-product instructions.

Mixture of Experts Inference

  • Mixture of Experts (MoE) architectures (Shazeer et al. 2017; Switch Transformer Fedus et al. 2022) replace dense feed-forward layers with N=8-128 expert feed-forward networks, routing each token to only top-K=1-2 experts via a learned router. This dramatically increases total parameters while keeping activated parameters constant: Mixtral 8×7B has 46.7B total parameters but activates only 12.9B per token (2 experts of 7 experts each, shared attention). MoE inference presents unique challenges: (i) expert routing imbalance causes some GPUs to idle while others are overloaded; (ii) expert parallelism requires all-to-all communication when experts are distributed across GPUs; (iii) expert offloading to CPU DRAM enables serving Mixtral 8×7B on a single A100 by offloading inactive experts, with llama.cpp expert-offload achieving 8 t/s on CPU+GPU hybrid execution. Expert quantisation (MoE INT4 via GPTQ) achieves 3.5× memory reduction with minimal perplexity impact, enabling Mixtral 8×22B INT4 (25GB) to fit in 2×RTX 3090 consumer GPUs.

KV Cache Compression

  • KV cache memory scales as O(batch_size × sequence_length × num_layers × num_heads × head_dim × 2), becoming the dominant memory consumer for long-context inference. Compression strategies include: GQA (Grouped Query Attention) Ainslie et al. 2023 sharing K/V heads across groups of Q heads (LLaMA-3 uses 8 KV heads, 32 Q heads—4× KV reduction); MQA (Multi-Query Attention) sharing a single K/V head across all Q heads (2× inference speed, 8× KV reduction, as in Falcon-7B); SnapKV Li et al. 2024 observing that attention patterns are query-independent for 90%+ of keys and compressing the KV cache by clustering similar K/V pairs with 80% size reduction at <1% accuracy loss; H2O (Heavy Hitter Oracle) Zhang et al. 2023 retaining only the “heavy hitter” tokens (cumulative attention weight 80th percentile) in a streaming KV cache eviction policy, enabling infinite-context generation with bounded memory; Streaming LLM Xiao et al. 2024 maintaining initial “attention sink” tokens plus a sliding window, achieving stable perplexity for sequences beyond 4M tokens.

Energy Efficiency and Sustainability

Carbon Footprint of LLM Inference

  • LLM inference at scale consumes significant energy: GPT-4-class model inference on one A100 GPU draws ~300W; serving 1M tokens requires approximately 0.4-0.8 kWh of electricity depending on batch efficiency and GPU utilisation rate. At OpenAI’s reported scale (100M+ daily active users, 2024), inference energy consumption approaches 10-50 GWh/day globally—equivalent to 3,000-15,000 UK homes’ annual electricity consumption.
  • Quantisation directly reduces energy consumption: INT4 vs FP16 reduces arithmetic operations by 4× but more importantly reduces HBM bandwidth consumption by 4×—and HBM DRAM operations consume approximately 200× more energy per bit than SRAM cache operations. The energy consumed per token generated at INT4 W4A16 is approximately 2-4× lower than FP16, with most savings coming from reduced DRAM access rather than reduced compute.
  • UK data centre electricity consumption has risen 40% since 2020, with AI workloads constituting an increasing fraction. National Grid’s Future Energy Scenarios (FES 2025) projects UK data centre demand reaching 25-35 TWh/year by 2030 (vs ~12 TWh 2024), driven primarily by AI inference. NVIDIA estimates that deploying INT8 rather than FP32 inference across UK data centres would save 2-4 TWh annually—equivalent to 600,000 UK households’ electricity.

Sustainable Inference Design Patterns

  • Dynamic precision selection: Route complex queries to FP16 models and simple queries to INT4 models. Classifier overhead (BERT-tiny, 4M params, <1ms) routes 70-80% of queries to the cheaper INT4 model, saving 4× energy for that fraction. Systems like RouteLLM (2024) learn routing functions from query-response quality signals.
  • Batch size optimisation: Larger batches amortise model weight reads across more tokens, reducing energy-per-token. vLLM’s continuous batching maintains GPU utilisation >90% vs 30-50% for static batching, providing 2-3× energy efficiency improvement at the system level.
  • Time-of-day routing to renewable-powered data centres: EU and UK data centres increasingly offer carbon-aware compute APIs (Microsoft Azure, Google Cloud, AWS) where inference requests can be routed to regions with high renewable energy fraction (Scotland hydroelectric/wind, Norway hydroelectric) during off-peak hours. FlexFlow-Serve (2024) automates such carbon-aware LLM request routing.
  • Model reuse via prefix caching: APC in vLLM avoids recomputing KV cache for identical system prompts. At 60% cache hit rate, this saves 60% of prefill compute (the most energy-intensive phase)—for a 32K-token system prompt, this saves approximately 0.08 kWh per 1,000 requests.

MLPerf Benchmarks

  • MLPerf Inference is the industry-standard benchmark suite for AI inference performance, governed by MLCommons (consortium including Google, NVIDIA, Intel, Microsoft, Arm, AMD, Qualcomm, Meta). Scenarios include Single-Stream (tail latency p99), Multi-Stream (fixed latency SLO), Server (Poisson arrival rate QPS), and Offline (maximum throughput) across Datacenter and Edge divisions.
  • MLPerf Inference v4.1 (October 2024): Introduced LLaMA-2-70B as a required workload with both throughput (tokens/second) and accuracy (ROUGE-1/2/L on CNN/DailyMail) constraints; NVIDIA H100 DGX-H100 reference platform achieved 20,220 tokens/second offline throughput with INT4 AWQ quantisation passing the 99% ROUGE retention accuracy threshold. Also included Stable Diffusion XL (image generation), ResNet-50, BERT-Large, 3D-UNet, RetinaNet, and DLRM-v2 (recommendation).
  • MLPerf Inference v5.0 (March 2025): Added Llama 3.1-70B and Llama 3.1-405B as workloads; introduced Mixture of Experts inference (Mixtral 8×22B); expanded mobile/edge division with on-device LLM tasks. AMD Instinct MI300X achieved competitive results to NVIDIA H100 on LLaMA workloads with ROCm 6.1, demonstrating accelerator market diversification.

Quantisation-Aware Training (QAT) and Calibration

  • Quantisation-Aware Training (QAT) integrates fake quantisation operators into the forward pass during fine-tuning, inserting straight-through estimators (STE) ∂round/∂x = 1 to allow gradients to flow through the otherwise discontinuous rounding operation. QAT is typically applied after supervised fine-tuning (SFT) for 100-1000 steps on a representative dataset of 512-4096 samples, updating only the quantisation scales/zero-points or additionally fine-tuning a small fraction of weights. QAT typically recovers 50-80% of PTQ accuracy degradation: for a model where INT4 PTQ introduces 3% MMLU score degradation, QAT may reduce this to 0.5-1.5%. Google’s Gemma 2 (2024) used QAT to produce official INT4 quantised variants with <0.3 perplexity degradation. NVIDIA’s TensorRT Model Optimizer (formerly PyTorch Quantization) automates QAT with layer-wise sensitivity analysis determining which layers to quantise aggressively vs leave in FP16.
  • Calibration (for PTQ) requires a representative dataset of 128-512 samples to compute activation statistics (min, max, percentile, or MSE-optimal scales). Poor calibration data (domain mismatch between calibration set and deployment distribution) can cause up to 5× worse quantisation error—a critical practical consideration for domain-specific fine-tuned models. LLaMA Factory and Unsloth provide automated calibration pipelines for GPTQ/AWQ on custom instruction-tuning datasets.

LoRA and Parameter-Efficient Fine-Tuning at Inference

  • Low-Rank Adaptation (LoRA, Hu et al. 2022) decomposes weight updates as ΔW = BA where B ∈ ℝ^{d×r} and A ∈ ℝ^{r×k} with rank r ≪ min(d,k), reducing fine-tuning parameters by 10,000× for a 70B model while achieving comparable task performance to full fine-tuning. At inference, LoRA adapters can be merged into the base model (W_merged = W + αBA, runtime cost zero) or served as plug-in adapters allowing dynamic switching between multiple fine-tuned behaviours without reloading the base model.
  • QLoRA (Dettmers et al. NeurIPS 2023) combines NF4 (NormalFloat 4-bit) quantisation of the frozen base model with LoRA fine-tuning in BF16, enabling fine-tuning of a 65B model on a single 48GB A100 by storing base weights in 4-bit and adapter weights in 16-bit. NF4 uses quantile-based non-uniform quantisation optimal for normally distributed neural network weights. QLoRA introduces double quantisation (quantising the quantisation constants themselves, saving 0.37 bits/parameter additional) and paged optimisers using NVIDIA unified memory to handle occasional gradient checkpointing spikes.
  • Multi-LoRA serving via vLLM LoRAManager loads multiple adapter variants on a single base model, routing requests to the appropriate adapter per-request with near-zero overhead (adapter weights ≈ 0.1-1% of base model size). Punica (Chen et al. 2023) implements batched SGMV (Segmented Gather-Scatter Matrix-Vector) CUDA kernels enabling concurrent LoRA inference for 100+ adapters in a single batch at ≤5% overhead vs single-adapter inference.

Components / Architecture

Quantisation Taxonomy

  • The quantisation space is parametrised by three axes: (1) what is quantised (weights only W, activations A, or both WA); (2) granularity (per-tensor scalar scale, per-channel vector scale, per-group block scale with group_size=64-256, per-token dynamic scale); (3) bitwidth (INT8 8-bit, INT4 4-bit, INT2/AQLM sub-4-bit, binary/ternary 1-1.58 bit). The canonical naming convention is W{bits}A{bits}: W8A8 is INT8 weight × INT8 activation MatMul; W4A16 is INT4 weight dequantised to FP16 before multiplication (memory bandwidth bound at decode, not compute bound). Quantisation-Aware Training (QAT) integrates fake quantisation operators into the forward pass during fine-tuning, backpropagating through the straight-through estimator ∂round/∂x = 1; QAT typically recovers 50-80% of PTQ accuracy degradation at the cost of additional GPU-days of training.

Inference Pipeline

  • A production LLM serving pipeline comprises: (1) tokenisation (SentencePiece/Tiktoken, BPE vocabulary 32K-256K tokens); (2) prefill (parallel forward pass over all prompt tokens, KV cache populated, compute-bound); (3) decode (autoregressive generation one token per step, memory-bandwidth-bound); (4) KV cache management (PagedAttention block allocation, eviction, prefix sharing); (5) detokenisation and streaming response. The arithmetic intensity of prefill (FLOPS/byte) is typically 100-1000 (compute bound), while decode has arithmetic intensity of 1-10 (memory bandwidth bound), motivating speculative decoding and continuous batching which effectively increase decode batch size to raise arithmetic intensity.

Hardware Performance Roofline Model

  • The roofline model characterises whether a neural network operation is compute-bound (FLOPS limited, arithmetic intensity > HBM bandwidth / peak FLOPS) or memory-bandwidth-bound (HBM bandwidth limited, arithmetic intensity below roofline). For an NVIDIA A100 SXM: peak FP16 FLOPS = 312 TFLOPS; HBM2e bandwidth = 2 TB/s; roofline arithmetic intensity = 312×10¹² / (2×10¹²) = 156 FLOPs/byte. LLM decode with batch=1 and 70B model: 70×10⁹ × 2 bytes × 2 (matmul = 2 FLOPs/weight) / (70×10⁹ × 2 bytes) = 2 FLOPs/byte—100× below the roofline, confirming decode is memory-bandwidth-bound regardless of FP16 vs INT4 compute. INT4 quantisation reduces weight bytes by 4× (2 FLOPs/byte → 8 FLOPs/byte for W4A16), remaining below the roofline but reducing memory reads 4× and thus 4× higher token generation throughput. This explains why quantisation benefits are multiplicative with memory bandwidth and why FP8 compute improvements alone do not help decode throughput.

Tensor Parallelism and Pipeline Parallelism for Large Models

  • Models too large for a single GPU require tensor parallelism (Megatron-LM, Shoeybi et al. 2019) splitting individual weight matrices across GPUs: for a Linear layer W ∈ ℝ^{d×4d}, column-split across N GPUs as [W₁|W₂|…|W_N] where each W_i ∈ ℝ^{d×4d/N}, with AllReduce synchronisation after each layer (2 all-reduces per transformer block). Pipeline parallelism (GPipe, PipeDream) assigns consecutive layers to different GPUs, enabling larger total model capacity at the cost of pipeline bubbles (idle GPU time during micro-batch boundaries). Tensor + pipeline + data parallelism (3D parallelism, used by Megatron-DeepSpeed for 530B Megatron-Turing NLG training) combines all three dimensions. For inference specifically, tensor parallelism is standard for 70B+ models (LLaMA-3-70B across 2×A100 80GB with tensor_parallel_size=2 in vLLM achieves 2× decode throughput vs single GPU), while pipeline parallelism adds latency and is rarely used for online serving.

Use Cases / Major Families

Consumer and Edge Deployment

  • The GGUF/llama.cpp ecosystem enables: Fully local chat on consumer hardware—LLaMA-3-8B Q4_K_M (4.3GB) runs at 60 tokens/second on an RTX 3060 (6GB VRAM); LLaMA-3-70B Q4_K_M (37GB) runs at 12 tokens/second on a Mac Studio M2 Ultra (192GB unified memory). iOS/Android deployment via llama.cpp iOS (MLX for Apple Silicon, GGUF for Android NNAPI), achieving 15-30 tokens/second on iPhone 15 Pro for 3B models. Raspberry Pi 5 inference (llama.cpp CPU): phi-2 2.7B Q4 at 6 tokens/second on 8GB LPDDR5.
  • Apple’s MLX framework (December 2023) provides a NumPy-like ML framework natively exploiting Apple Silicon unified memory architecture, where CPU/GPU/Neural Engine share the same physical memory pool—eliminating PCIe transfer overhead present in discrete GPU systems. MLX-LM achieves 40 tokens/second for LLaMA-3-8B on M3 Max (128GB) via 4-bit quantised GGUF or native MLX quantisation, and supports Mistral, Qwen, and Phi model families. The MLX ecosystem has become a primary deployment target for UK developers building local AI applications on MacBook Pro hardware.

Cloud API Serving

  • Major LLM APIs use optimised serving stacks: OpenAI uses custom CUDA kernels with H100 clusters; Anthropic uses GCP TPU v5p with XLA/OpenXLA compilation; Together AI and Anyscale use vLLM; Mistral AI uses TensorRT-LLM. Typical serving economics: H100 SXM5 (£2.50/hour spot) serving LLaMA-3-70B INT4 AWQ at 3,000 tokens/second offline = £0.00083/1K tokens, competitive with OpenAI GPT-3.5 Turbo pricing (£0.0015/1K).
  • Ollama (2023) democratised local LLM deployment by wrapping llama.cpp with a Docker-like CLI and REST API (compatible with OpenAI API format), enabling one-command model deployment: ollama run llama3.2:3b. By May 2026, Ollama has 80K+ GitHub stars and is the default local inference backend for Open WebUI (45K stars), Anything LLM, and LibreChat. Ollama’s model library hosts 200+ pre-quantised models and the automatic GGUF quantisation selection matches hardware VRAM to optimal Q-level.

Robotics and Real-Time Control

  • Vision-language-action models (RT-2 Google 2023, π0 Physical Intelligence 2024) require sub-100ms inference latency for robot control loops. TensorRT-LLM with INT4 quantisation achieves 40ms for a 7B VLA on Jetson Orin NX (15W power envelope), enabling onboard inference without cloud connectivity. ARM’s Ethos-U85 NPU (2024) targets 4 TOPS at 1W for always-on edge AI including wake-word detection and 500M-parameter models.
  • NVIDIA Jetson Orin (2023) family provides the primary UK research platform for robotics inference: Orin NX 16GB module achieves 100 INT8 TOPS at 15W, enabling real-time Segment Anything Model (SAM) at 10 FPS and YOLOv8-L at 60 FPS. Edinburgh Robotics and the Bristol Robotics Laboratory (BRL, UK’s largest dedicated robotics research centre) use Jetson-based platforms with TensorRT-optimised perception stacks for agricultural automation and hospital logistics robots.

Medical AI and NHS Deployment

  • Post-training quantisation is critical for NHS information governance: quantised models run on-premise within NHS data boundaries without internet-connected cloud inference. UCLH’s AI Centre (partnership with UCL and Google DeepMind) deployed quantised BERT-based clinical NLP models on NHS hardware for discharge summary coding, achieving INT8 inference on CPU-only NHS workstations (no GPU procurement required) with 4× throughput vs FP32. The NHS AI Lab’s 2024 guidance on AI in clinical settings specifies that models processing patient data must run within NHS infrastructure—making efficient on-premise inference via quantisation and ONNX Runtime (CPU execution provider) a regulatory requirement, not just an optimisation goal.
  • Oxford’s Big Data Institute and the Wellcome Sanger Institute use GGUF-quantised genomics foundation models (e.g., Nucleotide Transformer variants) for local DNA sequence analysis, avoiding patient data leaving secure research environments. UCL Great Ormond Street Institute of Child Health applies knowledge distillation to reduce DICOM-processing medical image models from 1B to 100M parameters for deployment on standard clinical workstations.

Code Generation and Developer Tools

  • GitHub Copilot (Microsoft/OpenAI) serves 1.8M+ paying subscribers (February 2025) using speculative decoding with a 2B CodeBERT draft model and GPT-4-class verification model, achieving <150ms latency for single-line completions. JetBrains AI Assistant, Tabnine, and Codeium similarly use distilled 3-7B parameter code models with INT8 quantisation served on private GPU infrastructure or user-device deployment. CodeLlama 7B GGUF Q4_K_M (3.8GB) is the dominant local code assistant model, running at 50 tokens/second on RTX 3080 and providing competitive code completion quality to GPT-3.5 for Python, TypeScript, and Rust.

Academic Context

  • The foundational algorithmic contributions span: Quantisation theory — Optimal Brain Damage (LeCun et al. NIPS 1989), Optimal Brain Surgeon (Hassibi & Stork 1993) establishing Hessian-based importance metrics still used in GPTQ 30 years later; Knowledge distillation — Hinton et al. 2015 seminal paper “Distilling the Knowledge in a Neural Network” (13,000+ citations); Lottery Ticket Hypothesis — Frankle & Carlin ICLR 2019 (5,000+ citations); FlashAttention — Dao et al. NeurIPS 2022 (8,000+ citations); vLLM/PagedAttention — Kwon et al. SOSP 2023 Best Paper Award; Speculative Decoding — Leviathan et al. ICML 2023 and Chen et al. ArXiv 2023 (concurrent independent discovery). The field has evolved from academic curiosity (pre-2020 quantisation primarily for embedded vision models) to a critical industrial engineering discipline as LLM inference costs became dominant. Publication venues include MLSys, OSDI, SOSP, NeurIPS Systems track, and ICLR.
  • Key academic lineages: the systems tradition (OSDI/SOSP) contributed PagedAttention, Orca continuous batching, and DistServe disaggregated serving—applying OS virtual memory and scheduling principles to ML; the algorithms tradition (NeurIPS/ICML/ICLR) contributed quantisation theory, sparsity algorithms, and distillation; the hardware tradition (ISCA/MICRO/DAC) contributed architecture-aware kernel design (FlashAttention’s IO analysis, SparseGPT’s nmSparse format). Cross-pollination between these communities, accelerated by 2022-2025 industrial urgency around LLM deployment cost, produced an unprecedented pace of practical impact: FlashAttention went from NeurIPS 2022 paper to production deployment in PyTorch, HuggingFace, and all major serving frameworks within 6 months—faster than any prior ML systems paper.
  • The MLSys conference (2018-present, co-located or joint with OSDI) has become the primary venue for inference optimisation work, with acceptance rate ~15% and 2024-2025 programme including dedicated tracks for quantisation, efficient serving, and hardware-software co-design. The COLM conference (Conference on Language Modelling, inaugural 2024) complements by covering LLM-specific research including efficiency.

Current Landscape (2026)

  • As of May 2026, the inference optimisation landscape is characterised by: (1) INT4 as the production baseline — all major serving frameworks (vLLM, TensorRT-LLM, Ollama, llama.cpp) default to 4-bit AWQ or GGUF Q4_K_M quantisation for 7-70B models, delivering FP16-comparable quality at 4× memory savings; (2) FP8 on H100/B100 — NVIDIA H100 and B100 (Blackwell, Q1 2025) native FP8 support with 2× throughput vs FP16, adopted by TensorRT-LLM and vLLM v0.5+ as the performance-accuracy sweet-spot for datacenter inference; (3) vLLM v0.5+ ecosystem dominance — vLLM added structured output (guided decoding via xgrammar), speculative decoding, chunked prefill, and multi-LoRA serving in 2025 releases, handling 80%+ of open-source LLM production deployments; (4) 1.58-bit models emerging — BitNet b1.58 (Ma et al. Microsoft 2024, all weights ∈ {-1, 0, 1}) demonstrates pre-training at sub-2-bit precision matches 8-bit inference quality at 1B-3B parameter scale with 3.7× energy reduction, pointing toward native 1-bit architectures in 2026-2027; (5) MoE becoming dominant — Mixtral, DeepSeek-V3 (671B total/37B active), and Qwen3-MoE confirm MoE as the architecture of choice for large models; (6) ARM dominance in edge — Apple M-series chips (Neural Engine 38 TOPS on M4) and Qualcomm Snapdragon X Elite (45 TOPS NPU) made on-device 7B inference mainstream by 2025.

Sub-Quadratic and Linear Attention Alternatives

Challenges with Standard Attention at Scale

  • Standard Scaled Dot Product Attention has O(N²) memory and O(N²) compute complexity in sequence length N. For a context of N=128K tokens (LLaMA-3 max), the attention matrix is 128K × 128K × 2 bytes = 32GB per layer per batch element—physically impossible to materialise on a single GPU. FlashAttention addresses the memory issue but not the O(N²) compute issue: FlashAttention-3 on H100 for N=128K still performs (128K)² = 16B multiply-accumulate operations per layer, requiring ~1 second per layer per sequence for FP16 attention on H100.
  • This motivates research into sub-quadratic attention mechanisms:
  • Sparse attention: Only attend to a subset of key-value pairs. Longformer (Beltagy et al. 2020) uses local sliding window (W=512) + global tokens, reducing attention to O(N×W). BigBird (Zaheer et al. 2020) adds random attention on top, provably approximating full attention. Limitation: irregular memory access patterns make GPU kernel efficiency poor vs dense FlashAttention.
  • Linear attention (Katharopoulos et al. 2020): Replaces softmax with a kernel function φ(q)ᵀφ(k), enabling rewriting of attention as matrix product Q(K^T V) computed left-to-right, reducing to O(N) time and memory. Limitation: linear attention degrades significantly on tasks requiring precise retrieval (lookup-heavy tasks, in-context learning), where softmax attention’s sharp focus is critical.
  • State-space models (SSMs): Mamba (Gu & Dao 2023) uses a selective state-space model with input-dependent dynamics, achieving O(N) training with hardware-efficient CUDA parallel scan and O(1) per-step inference (constant memory regardless of context length). Mamba-2 (Dao & Gu 2024) reformulates structured state spaces as matrix multiplication, enabling better hardware utilisation. Hybrid architectures (Jamba, 2024) interleave Mamba SSM layers with standard attention layers (1 attention per 8 SSM layers), achieving attention-level quality with SSM-level inference efficiency.
  • Retention (RetNet): Microsoft 2023, uses retention mechanism with dual form (parallel for training, recurrent for inference), O(N) inference cost with quality comparable to full attention on many tasks. Deployed in some Microsoft research models.
  • The mainstream production direction (2024-2026) remains standard multi-head or grouped-query attention with FlashAttention optimisation and context length extension via RoPE scaling—the quality advantage over linear attention and SSMs remains decisive for frontier models. Sub-quadratic alternatives are most promising for always-on applications (audio streaming, sensor fusion) where infinite context at O(1) memory is required.

Hyperparameter Optimisation for Inference

  • Hyperparameter Optimisation in the inference context refers to tuning serving system parameters rather than model training hyperparameters:
  • vLLM tuning parameters: max_num_seqs (maximum concurrent sequences, governs GPU utilisation vs latency), gpu_memory_utilization (fraction of GPU memory allocated to KV cache pool, default 0.9), tensor_parallel_size (TP degree for multi-GPU serving), speculative_model and num_speculative_tokens (draft model and speculation depth), chunked_prefill_enabled and max_num_batched_tokens (chunked prefill settings).
  • TensorRT-LLM tuning: max_batch_size, max_input_len, max_output_len (static shape compilation), use_inflight_batching (continuous batching flag), quant_mode (INT4/INT8/FP8 specification), multi_query_mode (MQA/GQA enabling).
  • llama.cpp tuning: -n-gpu-layers (number of layers offloaded to GPU, rest on CPU), -c (context size, larger contexts require more KV cache RAM), -b (batch size for prompt evaluation), -t (CPU thread count, optimal = physical cores not hyperthreaded), --mlock (pin model in RAM, prevents paging, requires sufficient RAM).
  • Optimal configurations are hardware-specific: a single RTX 4090 serving LLaMA-3-70B Q4_K_M will optimise for different parameters than an 8×H100 cluster serving LLaMA-3-405B FP8. Systematic tuning via Bayesian optimisation over the parameter space (using tools like Optuna or Ray Tune) with a representative traffic simulator (llmperf) reduces time-to-optimal-configuration from days of manual tuning to 2-4 hours of automated search.

Performance Optimisation Workflow

Decision Framework: Which Technique to Apply

  • A systematic workflow for choosing model optimisation techniques begins with profiling the deployment constraint:
  • Step 1 — Identify the bottleneck: Profile memory vs compute vs latency. Use nvidia-smi for VRAM, nsys profile for kernel timing, vllm benchmark_throughput.py for serving throughput.
  • Step 2 — Determine hardware target: CPU-only (ARM NEON/AVX2 via llama.cpp), consumer GPU (GGUF Q4_K_M), enterprise GPU cluster (AWQ + vLLM), Apple Silicon (MLX-LM), mobile (CoreML INT8 / Hexagon NPU ONNX).
  • Step 3 — Select quantisation level: If VRAM sufficient for INT8 (model_params × 1 byte fits in GPU), use SmoothQuant W8A8 for best accuracy; if VRAM tight use AWQ W4A16; if memory-constrained use GGUF Q4_K_M. For sub-4GB deployment use Q2_K or AQLM.
  • Step 4 — Evaluate accuracy budget: Run lm-evaluation-harness on target benchmark. If accuracy loss > threshold (typically 1% MMLU for production), consider: (a) QAT fine-tuning, (b) larger quantisation group size (group=32 vs 128 recovers 0.2-0.5% MMLU), (c) FP16 for critical layers (mixed precision per-layer quantisation).
  • Step 5 — Serving infrastructure: For latency-critical (<100ms TTFT) deploy TensorRT-LLM with static batching; for throughput-optimal deploy vLLM with continuous batching; for CPU-only deploy llama.cpp with -np flag (parallel sequences) and -t (CPU threads) tuning.
  • Step 6 — Enable speculative decoding if applicable: Identify or train a matching draft model (1-7B) and measure acceptance rate α; if α > 0.7, speculative decoding provides 2×+ throughput gain at same latency.
  • Step 7 — Monitor and iterate: Deploy with MLPerf Loadgen-compatible logging, track p99 latency and throughput per model version. Quantisation accuracy drift can occur as model fine-tuning proceeds — re-calibrate AWQ/GPTQ after each SFT cycle.

Quantisation Sensitivity Analysis

  • Not all layers in a transformer are equally sensitive to quantisation error. Empirically observed patterns (consistent across LLaMA, Mistral, Falcon, and GPT-NeoX families):
  • First and last transformer layers: 2-3× more sensitive than middle layers. First layer processes raw token embeddings with high variance; last layer outputs directly affect probability distributions. Standard practice: keep first/last layers in FP16 while quantising middle layers.
  • Attention projection weights (Q, K, V, O): Moderately sensitive; Q/K matrices more sensitive than V in practice (query-key similarity is critical, small perturbations in Q or K affect attention pattern significantly).
  • Feed-forward network (FFN) weights: Less sensitive than attention (3-5× more parameters but lower sensitivity per-parameter). Gate/up/down projections in LLaMA FFN architecture tolerate INT4 well with group=128.
  • Embedding layers: Embedding table (vocabulary × dim, typically 32K × 4096 for LLaMA-3-8B = 128M params) is often kept in FP16 or INT8 since it is accessed sparsely (one token per step) and represents a small compute fraction.
  • LayerNorm/RMSNorm parameters: Always kept in FP32/BF16 (small, < 0.1% of model, high sensitivity to numerical precision).
  • GPTQ and AWQ both implement per-layer sensitivity ordering during quantisation, automatically applying finer granularity (lower group size or higher bitwidth) to more sensitive layers when total bitwidth budget is constrained.

UK Context

  • The UK occupies a distinctive position in model optimisation research and commercialisation, particularly through ARM Holdings and academic groups at Imperial College, Cambridge, Edinburgh, and Manchester.

ARM Holdings

  • ARM Ltd (Cambridge, acquired by SoftBank 2016, IPO Nasdaq September 2023 at $54.5B valuation) is the defining UK contribution to ML inference hardware: the Cortex-A application processor series and Mali GPU architecture power the majority of the world’s mobile devices running on-device ML; the Ethos NPU series (U55, U65, U85 2024) targets dedicated ML acceleration at 1-4 TOPS per watt for edge inference; ARMv9 SME2 (Scalable Matrix Extension 2, introduced in Cortex-X4 2024) provides hardware matrix multiplication with configurable tile sizes (ZA register array up to 256×256 bits) enabling efficient BFLOAT16 and INT8 GEMM directly in the scalar CPU pipeline—critical for sub-NPU inference on microcontrollers. ARM Compute Library (ACL) provides hand-optimised NEON/SVE2/SME2 kernels for convolution, GEMM, and activation functions used by TensorFlow Lite, ONNX Runtime, and PyTorch Mobile backends.

Graphcore IPU

  • Graphcore (Bristol, founded 2016, raised £400M+ pre-2022) developed the Intelligence Processing Unit (IPU), a bulk synchronous parallel (BSP) architecture with 1,472 processor tiles and 900MB on-chip SRAM (Bow IPU 2022). IPU’s Poplar SDK enables graph compilation with statically-scheduled compute and inter-tile exchange phases. For transformer inference, Graphcore demonstrated 1.5× throughput advantage over A100 on BERT-Large INT8, though the company faced financial difficulties in 2023-2024, restructuring and seeking new investment. The IPU architecture’s extreme on-chip memory capacity (no HBM) is particularly suited to models that fit in 900MB SRAM—implying INT4 quantised 2B models, or attention-compute-bound small-batch inference.

Imagination Technologies

  • Imagination Technologies (Kings Langley, Hertfordshire; acquired by China-backed Fortress Investment 2017) develops PowerVR GPU and IMG BXT GPU series, with the IMG Series4 Neural Processor targeting Android and automotive inference. Imagination’s 2023 IMG DXT architecture integrates dedicated NN accelerators achieving 50 TOPS at 3W, competitive with MediaTek APU in mid-range Android devices—relevant to UK IoT and automotive OEM markets.

Academic Groups

  • Imperial College London (Department of Computing): Professor Paul Kelly’s Software Performance Optimisation group works on polyhedral compilation and auto-vectorisation for ML kernels; Dr. Petar Velickovic (now DeepMind) pioneered Graph Attention Networks with direct implications for sparse attention. Professor Abbas Edalat’s Computing and Logic group and the SPIRIT research group on efficient hardware-software co-design. Imperial College’s AI for Science initiative (£8M EPSRC 2024) includes work on efficient foundation models for materials science and drug discovery.
  • University of Cambridge (Department of Computer Science and Technology): Professor Richard Mortier’s Systems Research Group; the Cambridge MLSys reading group hosts practitioners from Arm, DeepMind, and startups working on efficient inference. Professor Pietro Lio’s group on efficient graph neural networks. Cambridge Computer Lab’s NetOS group works on distributed inference and edge AI scheduling. The Alan Turing Institute (headquartered at British Library, London) funds research projects on efficient ML for public sector AI, including NHS diagnostic model compression in collaboration with UCL.
  • University of Edinburgh (School of Informatics): Edinburgh EPCC hosts ARCHER2, the UK’s national HPC system (750K AMD EPYC CPU cores) where large-scale distributed inference research and LLM training is conducted. The Lattice QCD and Computational Science groups use quantisation techniques analogous to neural network quantisation for physics simulations. Edinburgh’s CISA group on AI systems efficiency produces research on energy-aware inference scheduling.
  • University of Manchester (Advanced Processor Technologies group, Department of Computer Science): Professor Steve Furber OBE FRS, pioneer of the original ARM processor architecture (1985), continues research on neuromorphic computing—the SpiNNaker 2 chip (2023) targets sparse neural network inference at 1 pJ/operation vs 10-100 pJ for GPU operations, representing a 10-100× energy efficiency advantage for sparse activations. Manchester’s REAL group works on run-time adaptable hardware for neural network acceleration. The Manchester-based N8 Research Partnership (Leeds, Liverpool, Manchester, Newcastle, Sheffield, York) coordinates Northern England ML systems research including edge inference for smart cities and industrial IoT.
  • University of Sheffield (Natural Language Processing group): Work on efficient transformers for low-resource NLP; the USFD speech recognition group develops compressed ASR models for UK regional accents. Bramble HPC cluster (NVIDIA A100 nodes) supports regional university NLP and efficient ML research.
  • Newcastle University and Durham University: Collaboration on efficient neural architectures for remote sensing and satellite image analysis (relevant to UK Space Agency AI programmes). Newcastle’s Digital Economy theme includes work on energy-efficient AI for Northern Powerhouse smart infrastructure projects.
  • UK Research and Innovation (UKRI) funds: (i) “Enabling Responsible AI” programme including model compression for healthcare AI (£30M+ allocated 2023-2026); (ii) AI Research Resource (AIRR) Isambard-AI supercomputer (5,000 H100 GPUs, Bristol University of the West of England, operational 2024) providing national compute; (iii) Hartree National Centre for Digital Innovation (Daresbury, Cheshire)—IBM and STFC joint venture with quantum and classical HPC including inference infrastructure for UK SMEs; (iv) EPSRC “Novel Computing Paradigms” grants including analogue and in-memory computing for neural network inference relevant to future sub-1-pJ model deployment.
  • UK Startups: Axonn AI (Edinburgh-spinout, 2023) develops distributed sparse transformer inference; Myrtle.ai (Cambridge) specialises in FPGA-accelerated neural network inference for financial services and edge applications; Wayve (London) uses custom efficient model stacks for autonomous driving (end-to-end neural network driving policy at 10 Hz inference); Wayve’s GAIA-1 generative world model uses INT8 quantisation for real-time simulation. Synthesia (London) uses distilled talking-head video models at INT8 for real-time avatar generation. Stability AI (London, prior to financial restructuring 2024) pioneered Stable Diffusion deployment optimisation including INT8 VAE quantisation and Flash-Attention integration.

Future Directions (2026–2030)

  • (1) Sub-1-bit and ternary LLMs — Microsoft’s BitNet b1.58 and follow-on work suggest that pre-training with ternary weights from scratch (rather than PTQ of FP16 models) may converge at quality parity with 4-bit PTQ for models above 3B parameters by 2026-2027, with specialised ternary MAC hardware delivering 10-100× energy efficiency vs INT4 GEMM. (2) Hardware-software co-design — NVIDIA Blackwell B200 (NVLink 5.0, 1.8 TB/s bandwidth, FP4/FP6 data types), AMD MI400 series, and Intel Gaudi 3 will drive new quantisation formats (FP4, FP6) and require updated calibration pipelines. (3) Continuous learning without catastrophic forgetting — efficient LoRA fine-tuning merged at inference via LoRA-as-a-Service patterns will allow personalised model updates at sub-1B token cost, with quantised LoRA adapters (QLoRA Dettmers et al. 2023) stored as 4-bit deltas atop a shared INT4 base. (4) MoE routing improvements — expert capacity balancing via entropy-regularised routing, shared expert tokens (DeepSeek-V3 “shared expert” residual), and heterogeneous expert sizes will improve MoE utilisation efficiency. (5) Disaggregated prefill-decode serving — separating prefill (compute-bound) onto compute-optimised nodes and decode (memory-bandwidth-bound) onto memory-optimised nodes (DistServe Zhong et al. 2024), targeting 3× cost reduction for production APIs. (6) Neuromorphic inference — Manchester SpiNNaker 2, Intel Loihi 3, and UK startup Rain AI’s analogue compute chips target event-driven sparse inference at 100× conventional GPU energy efficiency for always-on applications.
  • (7) Context length scaling — Long-context models (Llama-3 128K, Gemini 1.5 Pro 1M, Claude 3 200K) require KV cache memory scaling O(N) with sequence length. Sliding window attention (Mistral 7B, window=4096), StreamingLLM attention sinks, and ring attention for cross-device context distribution (gradient-free distributed attention across N GPUs enables sequence parallelism) will be necessary for megacontext inference. KV cache quantisation (INT8 KV, INT4 KV via transformer-squared 2025) addresses memory without changing model weights. (8) Energy efficiency as regulatory driver — The EU AI Act (2025 implementation) and UK AI Regulation Bill (anticipated 2026) may mandate energy efficiency disclosures for foundation model APIs, creating regulatory incentives for quantisation and efficient serving adoption. The UK’s National Grid reports AI data centre electricity demand projected to triple by 2030 (NESO FES 2025 scenarios), making model efficiency a national infrastructure concern. (9) Multimodal optimisation — Vision-language models (LLaVA, InternVL, Qwen-VL, Phi-3.5-Vision) present new optimisation challenges: vision encoder (ViT 300M-2B parameters) and language decoder (7-72B) must be jointly optimised; INT4 quantisation of ViT encoders causes 3-8× more accuracy degradation than equivalent LLM quantisation, necessitating mixed-precision strategies (FP16 vision encoder, INT4 language decoder). (10) Test-time compute scaling — OpenAI o1/o3 “thinking” models and DeepSeek-R1 demonstrate that trading inference compute for reasoning quality (chain-of-thought, Monte Carlo Tree Search) creates a new axis of inference cost: not tokens/second but tokens-per-correct-answer. Efficient test-time compute optimisation—using beam search with pruning, value function guided search, and adaptive thinking budgets—will become a primary research frontier alongside static model compression.

Tools and Ecosystem (2024-2026)

Quantisation Libraries

  • AutoGPTQ (GitHub: AutoGPTQ/AutoGPTQ, 5K+ stars): Python library wrapping GPTQ algorithm with Hugging Face Transformers integration. Supports LLaMA, Mistral, Falcon, GPT-NeoX, OPT, BLOOM model families. Provides both W4A16 and W8A16 modes with optional act-order (activations reordering by Hessian diagonal magnitude improving quantisation accuracy). AutoGPTQ CUDA kernels for W4A16 achieve 2× decode throughput vs native FP16 on RTX 4090.
  • AutoAWQ (GitHub: casper-hansen/AutoAWQ, 8K+ stars): Implements AWQ algorithm for Hugging Face models. Supports fused AWQ modules (fused MLP, fused attention) for additional 20% throughput gain. Integrated directly into Hugging Face Transformers from version 4.37.0 via QuantoConfig / AwqConfig. Default quantisation method in LM Studio, Jan.ai, and most consumer LLM frontends.
  • llama.cpp (GitHub: ggerganov/llama.cpp, 65K+ stars): C/C++ LLM inference with GGUF quantisation, supporting CPU/CUDA/Metal/Vulkan/OpenCL backends. Primary consumer-facing runtime; serves as backend for Ollama, LM Studio, Jan.ai, and GPT4All. Implements CPU-optimised matrix kernels via ARM NEON, AVX2, and AVX-512 SIMD intrinsics.
  • bitsandbytes (Hugging Face): Implements INT8 LLM.int8() (Dettmers et al. 2022) and NF4 QLoRA quantisation with CUDA kernels, integrated into HuggingFace PEFT and Transformers for 8-bit and 4-bit model loading (load_in_8bit=True, load_in_4bit=True). Primary library for QLoRA fine-tuning workflows.
  • Quanto (Hugging Face 2024): Newer quantisation library replacing bitsandbytes as default in HuggingFace, supporting INT2/INT4/INT8/FP8 for both weights and activations with PyTorch-native implementation (no custom CUDA required) enabling CPU, CUDA, and MPS (Apple Silicon) backends.

Serving Frameworks

  • vLLM (version 0.5+, May 2026): The dominant open-source LLM serving framework. Key 2025 features: V1 engine architecture (Python asyncio re-architecture for sub-millisecond scheduling overhead), structured output via xgrammar (1000× faster guided decoding vs logit bias masking), multi-modal inputs (image/video/audio via VisionConfig), speculative decoding with EAGLE, chunked prefill with dynamic sizing, FP8 KV cache, and expert-parallel MoE serving. vLLM is deployed by Databricks Model Serving, Amazon SageMaker JumpStart, and Azure ML for open-source model APIs.
  • TensorRT-LLM (NVIDIA 0.12+): Production serving with NVIDIA-specific optimisations. Features: static/inflight batching, INT4/INT8/FP8 quantisation, tensor parallelism, speculative decoding, Medusa multi-head decoding. Used by Mistral AI, Cohere, and NVIDIA’s own API (build.nvidia.com). Requires NVIDIA GPU; supports H100, A100, L40S, and consumer RTX 4090.
  • SGLang (LMSYS Org, 2024): Structured generation language and runtime optimising LLM programs with branching control flow. Introduces RadixAttention (trie-based prefix caching extending vLLM’s flat prefix caching to arbitrary DAG-structured prefixes), achieving 4× better cache utilisation for complex multi-turn and multi-step LLM programs. SGLang 0.3+ achieves 30% higher throughput than vLLM on multi-turn chat benchmarks.
  • LitServe (Lightning AI, 2024): Lightweight inference server wrapping PyTorch models with auto-batching, streaming, and GPU worker management. Positioned as simpler alternative to vLLM for non-LLM models (diffusion, embedding, vision) where PagedAttention is not relevant.
  • Triton Inference Server (NVIDIA, open source): Production-grade model serving supporting multiple backends (TensorRT, ONNX Runtime, PyTorch, TensorFlow, Python custom). Provides gRPC and HTTP APIs, dynamic batching, model ensembles, and BLS (Business Logic Scripting) for complex multi-model pipelines. Used in enterprise MLOps platforms.

Benchmarking and Evaluation Tools

  • lm-evaluation-harness (EleutherAI): Standard framework for evaluating quantised model accuracy on 60+ benchmarks (MMLU, HellaSwag, WinoGrande, ARC, GSM8K, HumanEval). Essential for validating that quantisation meets the ≥99% accuracy retention requirement of MLPerf Inference.
  • llmperf (run.ai / now Ray): LLM API performance benchmarking tool measuring time-to-first-token (TTFT), time-per-output-token (TPOT), tokens/second throughput, and request completion latency distributions (p50, p90, p95, p99). Used to compare serving stacks under production-like Poisson arrival traffic.
  • vLLM Benchmarks (benchmarks/ directory in vLLM repo): Standard scripts for throughput (requests/second) and latency benchmarking under various concurrency levels, dataset distributions (ShareGPT for chat, HumanEval for code), and hardware configurations. Reference performance numbers for H100, A100, L40S published with each vLLM release.
  • MLPerf Loadgen: Official load generator for MLPerf Inference submission, implementing Poisson/Constant arrival processes for Server and Offline scenarios with statistical validity constraints (minimum 270K tokens measured, p99 latency SLO compliance ≥99%).

Quantisation Accuracy Benchmarks (Representative 2024-2025 Results)

  • The following illustrates representative accuracy-efficiency trade-offs for LLaMA-3-8B on MMLU 5-shot (source: community evaluations, 2024-2025):
  • FP16 (baseline): MMLU 66.6%, WikiText-2 PPL 6.14, VRAM 16GB
  • W8A8 SmoothQuant: MMLU 65.9% (−0.7%), PPL 6.21, VRAM 8GB, 1.8× throughput
  • W4A16 GPTQ (group=128): MMLU 65.8% (−0.8%), PPL 6.38, VRAM 4.5GB, 2× throughput at decode
  • W4A16 AWQ (group=128): MMLU 66.1% (−0.5%), PPL 6.29, VRAM 4.5GB, 2× throughput
  • GGUF Q4_K_M: MMLU 65.9% (−0.7%), PPL 6.35, Disk 4.7GB, 50+ t/s on RTX 3060
  • GGUF Q2_K: MMLU 63.2% (−3.4%), PPL 7.84, Disk 2.9GB (significant degradation; only for constrained hardware)
  • W2 AQLM (2-bit): MMLU 64.8% (−1.8%), PPL 6.78, VRAM 2.3GB (better than Q2_K; codebook advantage)
  • BitNet b1.58 (1.58-bit pretrained): MMLU comparable to FP16 at 3B scale; 3.7× energy reduction
  • These figures illustrate the core insight: INT4 weight-only quantisation (AWQ/GPTQ/GGUF Q4_K_M) provides the optimal accuracy-efficiency pareto point for production LLM deployment in 2024-2026, while sub-4-bit approaches (2-bit) require vector quantisation (AQLM) or native training (BitNet) to remain competitive.

Comparative Analysis: Techniques and Trade-offs

Quantisation vs Pruning vs Distillation

  • The three primary model compression paradigms offer different trade-offs:
  • Quantisation (4-bit AWQ/GPTQ): Compression ratio 4×; minimal accuracy loss (<1% MMLU); no additional training required; hardware-generic (works on any GPU supporting INT8/INT4); speed-up primarily at memory bandwidth (decode latency); inference 2-4× faster. Limitation: minimum practical bitwidth ~4-bit for PTQ without significant degradation; activation quantisation (W8A8) requires careful outlier handling.
  • Pruning (50% unstructured, Wanda): Compression ratio 2× (storage); 0-1% accuracy loss at 50% sparsity; no training required (Wanda); speed-up only on hardware with sparse kernel support (NVIDIA 2:4 structured) or via compression (DEFLATE-compressed sparse model). Unstructured 50% sparsity provides no wall-clock speed-up on dense hardware without nmSparse format. Structured pruning (head removal, layer removal) provides real speed-up at 10-30% parameter reduction.
  • Knowledge Distillation: Compression ratio 3-10× (DistilBERT 1.7×, TinyLlama 60× vs GPT-4); accuracy loss 1-5% relative to teacher, but student can be very small (DistilBERT 40% params); requires training compute (significant GPU-days for 3T token TinyLlama training); produces a new model architecture (flexible); best quality per-parameter of all three approaches. Limitation: requires labelled data or self-play data and training budget.
  • Combining techniques: Quantised-distilled models (e.g., DistilBERT → INT8, or QLoRA fine-tuned base → AWQ deployment) stack multiplicatively: 2× distillation × 4× quantisation = 8× effective compression. The practical production recipe for small models is distillation (to reduce architecture) then quantisation (to reduce precision of the small model). For large models without a teacher pipeline, quantisation alone is the practical path.

Serving Framework Comparison (May 2026)

| Framework | Backend | Key Strength | Limitation |

| --------- | ------- | ------------ | ---------- |

| vLLM | CUDA/ROCm | PagedAttention, ecosystem breadth | Memory overhead for very small batches |

| TensorRT-LLM | NVIDIA CUDA only | Maximum single-GPU throughput | NVIDIA-only, complex build |

| SGLang | CUDA/ROCm | RadixAttention, multi-step programs | Less mature ecosystem |

| llama.cpp | CPU/CUDA/Metal/Vulkan | CPU and consumer GPU support | Lower peak GPU throughput vs vLLM |

| Ollama | wraps llama.cpp | User-friendly CLI, OpenAI-compatible API | Limited advanced features |

| MLX | Apple Silicon only | Unified memory, M-chip optimised | Apple hardware only |

| ONNX Runtime | CPU/GPU/NPU | Cross-platform, non-LLM models | Less optimised for autoregressive LLMs |

| Triton Inference | Multi-backend | Enterprise, multi-model orchestration | Complex configuration |

Hardware Platform Comparison for Inference (2025)

  • NVIDIA H100 SXM5 (80GB HBM3, 3.35 TB/s bandwidth, 989 TFLOPS FP16, £20,000-30,000 per-card): Highest throughput for large model serving; H100 NVLink enables 8×H100 = 640GB pooled memory for 405B parameter models in FP16. FP8 support 2× FP16. Best choice for production LLM API serving where throughput is primary metric.
  • NVIDIA A100 SXM4 (80GB HBM2e, 2 TB/s bandwidth, 312 TFLOPS FP16, £10,000-15,000): Mature workhorse, 80% of H100 performance at lower cost; deployed in UK AIRR Isambard-AI cluster (5000 units). Primary research GPU in UK university HPC systems.
  • AMD MI300X (192GB HBM3, 5.3 TB/s bandwidth, 1300 TFLOPS FP16): Large memory capacity enabling full FP16 inference of 70B models without quantisation on a single card. ROCm 6.1 compatibility with vLLM and PyTorch. Adopted by Microsoft Azure for some AI workloads. Competitive on memory-bandwidth-bound tasks (LLM decode).
  • NVIDIA RTX 4090 (24GB GDDR6X, 1 TB/s bandwidth, 82.6 TFLOPS FP16, £1,500-2,000): Primary consumer GPU for local LLM deployment. 24GB enables LLaMA-3-70B Q2_K (22GB) or LLaMA-3-8B FP16 (16GB). 95% of llama.cpp community CUDA users use RTX 3080/4080/4090.
  • Apple M3 Max (128GB unified memory, 410 GB/s bandwidth): Best consumer price/performance for large quantised models; 128GB enables LLaMA-3-70B Q4_K_M (37GB) with remaining memory for OS. 12 TOPS Neural Engine for CoreML INT8 models. Dominant platform for UK developer community building local AI apps.
  • ARM Cortex-A76/A78/X3 (Qualcomm Snapdragon 8 Gen 3): 45 TOPS Hexagon NPU; 7B INT4 model at 15-20 tokens/second on Android flagship. Samsung Galaxy S25, OnePlus 13, and Xiaomi 15 Pro ship with on-device AI capabilities using GGUF-quantised Llama-3.2-3B models.
  • Intel Core Ultra (Meteor Lake/Lunar Lake): 34-48 TOPS NPU via OpenVINO backend. Microsoft Copilot+ PCs (Surface Pro 11, Copilot+ key) use local NPU for real-time audio transcription and live captions. Intel’s OpenVINO toolkit and ONNX Runtime DirectML backend serve the Windows enterprise market where NVIDIA GPU procurement is limited.

Integration with MLOps and Deployment Pipelines

Quantisation in CI/CD Pipelines

  • Production ML systems require quantisation to be integrated into automated deployment pipelines:
  • Pre-deployment quantisation gate: After each model fine-tuning cycle, run AWQ/GPTQ quantisation + lm-evaluation-harness accuracy check (MMLU, task-specific benchmarks) as a CI step. Gate deployment if accuracy degrades > 1% from previous version. GitHub Actions workflows with GPU runners (self-hosted or GitHub-hosted with A100) execute this in ~30 minutes for 7B models.
  • Quantisation artefact registry: Store quantised model artefacts (AWQ safetensors, GGUF files) in versioned model registries (Hugging Face Hub private repositories, AWS S3 with model metadata, MLflow model registry with quantisation parameters recorded). Tag artefacts with quantisation method, bitwidth, calibration dataset hash, and validation metrics.
  • A/B testing quantised vs FP16: Deploy quantised models to a subset of traffic (canary deployment 5-10%), compare quality metrics (task-specific evals, user ratings, refusal rates) between quantised and FP16 models. Only fully roll over when quality metrics are within acceptable bounds.
  • Automated calibration dataset management: Maintain a curated calibration dataset representative of production traffic distribution. Update calibration dataset quarterly as user query distribution shifts. Monitor distribution drift via Jensen-Shannon divergence between calibration token distribution and rolling production sample.

Monitoring Quantised Model Quality in Production

  • Unlike FP16 models where quality is fully characterised by training benchmarks, quantised models can exhibit production-specific degradation patterns not captured by held-out evaluation:
  • Output distribution monitoring: Track token probability distributions (entropy, max probability) for production outputs. Sudden entropy increase signals quantisation-induced hallucination patterns. Tools: WhyLabs AI Observatory, Arize AI, Evidently.
  • Task-specific regression tracking: For code generation, run execution-based evals (HumanEval pass@1) on a rolling 1000-query sample weekly. For chat, track user feedback signals (thumbs up/down) as proxy for quality regression.
  • Latency SLA monitoring: Track p99 TTFT and TPOT against SLA thresholds. Quantisation changes memory access patterns—profiling should be re-run after any quantisation method change (AWQ group size change, bitwidth change) as kernel performance can regress unexpectedly.
  • Safety benchmark re-evaluation: Re-run AI Safety benchmarks (TruthfulQA, HarmBench, XSTest) after quantisation. INT4 quantisation occasionally produces safety regressions in 1-3% of adversarial test cases. Safety regression > 2% should block deployment regardless of accuracy metrics.

Limitations and Failure Modes

Quantisation Failure Cases

  • INT4 quantisation degrades significantly in the following scenarios:
  • Domain-mismatched calibration: Calibrating on Wikipedia/C4 then deploying on medical/legal/code-heavy corpora. The activation statistics differ dramatically, producing poor scale factors. Mitigation: always use domain-representative calibration samples.
  • Very small models (<1B parameters): Quantisation-to-accuracy trade-off worsens as model size decreases. phi-2 2.7B INT4 shows 2× larger accuracy degradation than LLaMA-3-8B INT4 at equivalent task difficulty, due to each parameter carrying more information in small models.
  • Mathematical reasoning tasks: MMLU Math, GSM8K, and MATH benchmark performance degrades 3-5× more than general language tasks under INT4 vs INT8 quantisation, as small numerical errors accumulate across multi-step arithmetic. Speculative decoding with a math-finetuned draft model can partially compensate.
  • Instruction-following and safety constraints: Fine-tuned RLHF/DPO safety guardrails may be disrupted by quantisation—the probability mass distribution changes enough to occasionally bypass refusals. Safety-critical deployments should QAT fine-tune after quantisation and re-test safety benchmarks (MT-Bench, HarmBench).
  • Multilingual models: Non-English token representations are more densely packed in the embedding space; quantisation of multilingual embeddings (mBERT, XLM-R) degrades lower-resource languages (Hindi, Swahili) 3-8× more than English on multilingual NER benchmarks.

Serving System Failure Cases

  • vLLM memory OOM with long contexts: Despite PagedAttention, very long sequences (>64K tokens) in large batches can exhaust GPU memory when all KV pages are allocated. Mitigation: set max_model_len appropriately, enable chunked prefill, and use INT8 KV cache.
  • Speculative decoding degradation with diverse outputs: Acceptance rate α drops significantly (α < 0.4) when the target model is used with high temperature (T > 1.0) or top-p sampling (p < 0.9), as the draft model’s deterministic greedy predictions misalign with stochastic target samples. Disable speculative decoding for creative generation tasks.
  • FlashAttention incompatibility with custom attention masks: Some sparse attention patterns (e.g., Longformer sliding window attention, custom structured attention) cannot directly use FlashAttention’s causal block-sparse implementation. Requires custom CUDA kernels or fallback to standard attention.
  • Tensor parallelism latency overhead: All-reduce synchronisation between GPUs adds 1-5ms per transformer layer for large tensor parallel degrees (TP=8) on NVLink connections; over 32 layers this is 32-160ms overhead per token—limiting tensor parallelism to batch-latency trade-offs where throughput gain exceeds synchronisation cost.
  • GGUF CPU inference thermal throttling: Extended LLM inference on laptop CPUs (even with efficient GGUF Q4_K_M) causes thermal throttling in ~20 minutes, reducing throughput 30-50%. Server-grade ARM CPUs (AWS Graviton 4, Ampere Altra) avoid this via better thermal management.

Security and Privacy Considerations in Optimised Models

Model Extraction and Quantised Models

  • Quantisation may inadvertently reduce resistance to model extraction attacks: INT4 quantised models have fewer representational degrees of freedom, making them easier to approximate via query-based model stealing. Research (Karmakar et al. 2024) demonstrates that 4-bit quantised models can be extracted with 5-10× fewer queries than equivalent FP16 models due to their reduced effective Lipschitz constant. This is particularly concerning for fine-tuned proprietary models distributed in GGUF format where the quantised weights are fully accessible to users.
  • Differential privacy and quantisation: DP-SGD fine-tuning adds Gaussian noise to gradients during training, which interacts poorly with quantisation: the noise intended to mask individual training records is partially eliminated by rounding during quantisation, weakening privacy guarantees. DP-QAT (Differential Privacy + Quantisation-Aware Training) is an emerging research area combining both techniques while preserving formal ε-differential privacy bounds.
  • Watermarking quantised models: Neural network watermarking (embedding a detectable signature in model weights) is disrupted by quantisation—many watermarking schemes embed information in high-frequency weight components that are rounded away during INT4 quantisation. Quantisation-resistant watermarking schemes (embedding in low-frequency components or activation patterns rather than weight magnitudes) are required for provenance tracking of distributed quantised models.

Federated Inference and Privacy-Preserving Optimisation

  • Federated distillation: Rather than sharing model weights (which may reveal training data memorisation), federated learning variants share only distilled soft labels or model outputs. FedDF (Federated Dataset Distillation) trains a central server model on collected soft labels from distributed clients, enabling collaborative model improvement without weight sharing. Combined with INT8 quantisation of the soft labels, communication cost is reduced 4× vs FP32 logit exchange.
  • Homomorphic encryption (HE) inference: Fully homomorphic encryption enables inference on encrypted data without decrypting it, providing perfect privacy but at 1000-100,000× computational overhead. CKKS scheme and TFHE scheme support polynomial approximations of neural network activation functions (GELU, SiLU). At INT8 precision (reduced polynomial degree), HE inference on BERT-base achieves ~1 minute per inference vs <1ms unencrypted—suitable for high-sensitivity medical or legal query processing where privacy requirements justify the cost.

Research & Literature

    1. Frantar E, Ashkboos S, Hoefler T, Alistarh D. “GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers.” NeurIPS 2022. arXiv:2210.17323.
    1. Lin J, Tang J, Tang H, Yang S, Dang X, Han S. “AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration.” MLSys 2024. arXiv:2306.00978.
    1. Egiazarian V, Panferov A, Kuznedelev D, Frantar E, Borzunov A, Alistarh D. “Extreme Compression of Large Language Models via Additive Quantization.” ICML 2024. arXiv:2401.06118.
    1. Sun M, Liu Z, Bair A, Keutzer K. “A Simple and Effective Pruning Approach for Large Language Models (Wanda).” ICLR 2024. arXiv:2306.11695.
    1. Frantar E, Alistarh D. “SparseGPT: Massive Language Models Can be Accurately Pruned in One Shot.” ICML 2023. arXiv:2301.00774.
    1. Sanh V, Debut L, Chaumond J, Wolf T. “DistilBERT, a distilled version of BERT.” NeurIPS 2019 Workshop. arXiv:1910.01108.
    1. Wang W, Wei F, Dong L, Bao H, Yang N, Zhou M. “MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers.” NeurIPS 2020. arXiv:2002.10957.
    1. Hinton G, Vinyals O, Dean J. “Distilling the Knowledge in a Neural Network.” NeurIPS 2015 Workshop. arXiv:1503.02531.
    1. Leviathan Y, Kalman M, Matias Y. “Fast Inference from Transformers via Speculative Decoding.” ICML 2023. arXiv:2211.17192.
    1. Chen C, Borgeaud S, Irving G, Lespiau JB, Sifre L, Jumper J. “Accelerating Large Language Model Decoding with Speculative Sampling.” arXiv:2302.01318. 2023.
    1. Dao T, Fu D, Ermon S, Rudra A, Ré C. “FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.” NeurIPS 2022. arXiv:2205.14135.
    1. Dao T. “FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning.” ICLR 2024. arXiv:2307.08691.
    1. Shah J, Bikshandi G, Zhang Y, Thakkar V, Ramani P, Dao T. “FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision.” arXiv:2407.08608. July 2024.
    1. Kwon W, Li Z, Zhuang S, Sheng Y, Zheng L, Yu C, Gonzalez J, Zhang H, Stoica I. “Efficient Memory Management for Large Language Model Serving with PagedAttention.” SOSP 2023. arXiv:2309.06180.
    1. Xiao G, Lin J, Seznec M, Wu H, Demouth J, Han S. “SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models.” ICML 2023. arXiv:2211.10438.
    1. Dettmers T, Pagnoni A, Holtzman A, Zettlemoyer L. “QLoRA: Efficient Finetuning of Quantized LLMs.” NeurIPS 2023. arXiv:2305.14314.
    1. Yu G, Jeong J, Kim G, Kim S, Shin B. “Orca: A Distributed Serving System for Transformer-Based Generative Models.” OSDI 2022.
    1. Ainslie J, Lee-Thorp J, de Jong M, Zemlyanskiy Y, Lebron F, Sanghai S. “GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints.” EMNLP 2023. arXiv:2305.13245.
    1. Zhang Z, Sheng Y, Zhou T, Chen T, Zheng L, Cai R, Song H, Tian Y, Ré C, Barrett C, Wang Z, Chen B. “H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models.” NeurIPS 2023. arXiv:2306.14048.
    1. Ma S, Wang H, Ma L, Wang L, Wang W, Huang S, Dong L, Wang R, Xue J, Wei F. “The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits.” arXiv:2402.17764. 2024.
    1. Cai T, Li J, Geng Z, Peng H, Lee J, Chen D, Dao T. “Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads.” ICML 2024. arXiv:2401.10774.
    1. Li Y, Wei F, Zhang C, Zhang H. “EAGLE-2: Faster Inference of Language Models with Dynamic Draft Trees.” arXiv:2406.16858. 2024.
    1. Zhong Y, Liu S, Chen J, Hu J, Zhu Y, Liu X, Jin X, Zhang H. “DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving.” OSDI 2024. arXiv:2401.09670.
    1. MLCommons. “MLPerf Inference v4.1 Results.” October 2024. https://mlcommons.org/benchmarks/inference-datacenter/.
    1. MLCommons. “MLPerf Inference v5.0 Results.” March 2025. https://mlcommons.org/benchmarks/inference-datacenter/.
    1. ARM Ltd. “Arm Scalable Matrix Extension (SME2) Programmer’s Guide.” 2024. https://developer.arm.com/documentation.
    1. NVIDIA Corporation. “TensorRT-LLM: Accelerating LLM Inference with TensorRT.” GitHub Release Notes 2023-2026. https://github.com/NVIDIA/TensorRT-LLM.
    1. Franke M, Geiping J, Ritter D. “ShortGPT: Layers in Large Language Models are More Redundant Than You Expect.” arXiv:2403.03853. 2024.
    1. Zhang J, Sheng Y, Leng J, Zhu Y, Ren J, Chen S, Li D, Zhang H. “TinyLlama: An Open-Source Small Language Model.” arXiv:2401.02385. 2024.
    1. Jiang A, Sablayrolles A, Roux A, Mensch A, Savary B, Bamford C, Chaplot D, Casas D, Hanna F, Bressand F, et al. “Mixtral of Experts.” arXiv:2401.04088. 2024.
    1. Hu E, Shen Y, Wallis P, Allen-Zhu Z, Li Y, Wang S, Wang L, Chen W. “LoRA: Low-Rank Adaptation of Large Language Models.” ICLR 2022. arXiv:2106.09685.
    1. Dettmers T, Svirschevski R, Egiazarian V, Kuznedelev D, Frantar E, Ashkboos S, Borzunov A, Hoefler T, Alistarh D. “SpQR: A Sparse-Quantized Representation for Near-Lossless LLM Weight Compression.” arXiv:2306.03078. 2023.
    1. Milakov M, Gimelshein N. “Online normalizer calculation for softmax.” arXiv:1805.02867. 2018. [Foundation for FlashAttention online softmax trick]
    1. Liu S, Mao Y, Jin L, Chen J, Guo J, Pan Y, Qin Y, Zhang L. “LLM-Pruner: On the Structural Pruning of Large Language Models.” NeurIPS 2023. arXiv:2305.11627.
    1. Sun M, Chen X, Kolter Z, Liu Z. “Massive Activations in Large Language Models.” arXiv:2402.17762. 2024. [Analysis of activation outliers motivating quantisation methods]

Glossary of Key Terms

  • AWQ: Activation-aware Weight Quantisation. PTQ method protecting salient 0.1% weight channels via activation-aware scaling.
  • GGUF: GPT-Generated Unified Format. Self-describing binary container for quantised model weights with typed metadata.
  • GPTQ: Generative Pre-Trained Quantisation. Hessian-based layer-wise PTQ minimising reconstruction error column-by-column.
  • KV Cache: Key-Value Cache. Stored attention key and value tensors from previous tokens enabling O(1) per-token decode.
  • PagedAttention: OS virtual memory-inspired KV cache management dividing cache into fixed-size pages for near-zero fragmentation.
  • PTQ: Post-Training Quantisation. Quantisation applied to a trained model without further gradient updates on the original task.
  • QAT: Quantisation-Aware Training. Fine-tuning with simulated quantisation noise (fake quantisation + STE) to recover accuracy.
  • QLoRA: Quantised Low-Rank Adaptation. QAT combining NF4 base model with BF16 LoRA adapters for parameter-efficient fine-tuning.
  • Speculative Decoding: Draft-verify acceleration using a small model to generate k candidate tokens verified in a single parallel target model pass.
  • SmoothQuant: Activation quantisation technique migrating outlier difficulty from activations to weights via per-channel scaling.
  • Tensor Parallelism: Splitting individual weight matrices across multiple GPUs, with AllReduce synchronisation per transformer block.
  • TTFT: Time to First Token. Latency from request arrival to first generated token; dominated by prefill computation.
  • TPOT: Time Per Output Token. Average latency per generated token after the first; dominated by memory bandwidth.
  • vLLM: Virtual LLM. Open-source LLM serving system introducing PagedAttention for 24× throughput improvement.
  • W4A16: 4-bit weight, 16-bit activation quantisation. Industry-standard format for memory-bandwidth-constrained LLM decode.
  • W8A8: 8-bit weight and activation quantisation enabling INT8 tensor core compute for compute-bound prefill.
  • 2:4 Sparsity: NVIDIA structured sparsity pattern with exactly 2 non-zero of every 4 consecutive weights, enabling 50% GEMM speed-up on Ampere/Hopper Sparse Tensor Cores.
  • AQLM: Additive Quantisation for Language Models. Vector quantisation encoding weights as sums of codebook entries, excelling at sub-4-bit precision.
  • Arithmetic Intensity: FLOPs per byte of memory access. Low arithmetic intensity (decode) means memory-bandwidth-bound; high (prefill) means compute-bound.
  • Calibration Dataset: Small representative dataset (128-512 samples) used to compute activation statistics for PTQ scale factors.
  • Continuous Batching: Serving technique inserting new requests at any decode step boundary, maintaining high GPU utilisation vs static batching.
  • Flash Attention: IO-aware attention algorithm tiling computation in SRAM to avoid HBM materialisation of the O(N²) attention matrix.
  • Prefix Caching: Reusing computed KV cache blocks for identical token prefixes across requests, reducing compute for shared system prompts.
  • Roofline Model: Performance model characterising whether a workload is compute-bound vs memory-bandwidth-bound based on arithmetic intensity vs hardware ridge point.
  • TensorRT-LLM: NVIDIA’s LLM inference optimisation library providing kernel fusion, quantisation, and in-flight batching for NVIDIA GPUs.

Metadata

  • Domain Correction: Source frontmatter listed domain:: infrastructure; corrected to domain:: artificial-intelligence (model optimisation is a post-training AI engineering discipline, not infrastructure per se). IRI, URI, same-as, and owl-class updated accordingly. This correction is noted in Provenance.
  • Legacy Term ID: AI-2081 assigned (AI domain prefix, sequential above recent AI-20xx assignments).
  • Version Bump: 2.0.0 → 2.1.0 (enrichment pass, domain correction).
  • Source Stub: 169 lines containing disorganised LinkedIn-paste content, partial quantisation descriptions, image assets, and hyperparameter tuning tangent; fully replaced with Phase 6 pattern.
  • Research Basis: All facts drawn from cited papers (GPTQ 2022, FlashAttention-3 July 2024, vLLM SOSP 2023, MLPerf v4.1/v5.0, ARM SME2 2024, TensorRT-LLM 2023-2026) and domain knowledge verified against public documentation.

Provenance