Most LLM inference benchmarks assume US-East to US-East. We optimized for Casablanca-to-Dakar, Tunis-to-Lagos, and achieved p95 inference under 12ms using speculative decoding, model quantization, and edge caching.

Inference latency benchmarks in the AI industry are almost universally measured between co-located endpoints: the client and the server sit in the same data center, often the same rack. Under these conditions, achieving sub-10ms inference is a model optimization problem — quantize the weights, prune the attention heads, and call it done. Our problem is different. Our clients are in Casablanca, Dakar, Tunis, Lagos, Nairobi, and Johannesburg. Our inference servers are in Dakhla, Tangier, and Dakar. The network distance between a client in Lagos and our nearest inference server in Dakar is approximately 3,200 kilometers with a round-trip time of 28ms over submarine and terrestrial fiber — before any computation begins. Achieving p95 inference under 12ms for African markets required rethinking not just the model, but the entire inference architecture from client to GPU and back. This article describes the three techniques that got us there.
The first technique is edge caching with semantic awareness. Traditional CDN caching works for static content: the same URL returns the same bytes, so the cache key is the URL. Inference results are not static — the same prompt can produce different outputs depending on model version, temperature, and context. However, many real-world inference workloads have significant semantic overlap. Our financial fraud detection system receives thousands of queries per hour about the same transaction patterns. Our agricultural recommendation engine gets repeated queries about the same crop and soil conditions. Our utility optimization system processes the same grid configurations daily. We built a semantic cache that stores inference results keyed on a hash of the input embedding, not the raw input text. When a new query arrives, the cache computes the input embedding, checks for a match within a cosine similarity threshold (default: 0.98), and returns the cached result if found. The cache hit rate varies by workload: 67% for financial fraud detection, 54% for agricultural recommendations, and 72% for utility optimization. Average cache lookup time: 0.3ms. This single technique reduces p95 end-to-end latency from 28ms (network RTT alone) to under 5ms for cached queries — a 5.6x improvement for the majority of requests.
The second technique is speculative decoding. In conventional autoregressive LLM inference, each token is generated sequentially: the model processes the input, produces one output token, appends it to the input, and repeats. For a 100-token output, this requires 100 sequential forward passes through the model, each taking 0.8-1.2ms for our 7B-parameter inference model. Total generation time: 80-120ms — well over our 12ms budget. Speculative decoding solves this by running two models in parallel: a small, fast draft model (1.3B parameters, 0.15ms per token) that generates candidate tokens, and the full verification model (7B parameters) that validates them in a single forward pass. When the draft model's predictions are correct (which they are approximately 85% of the time for our African-language models), the verification model accepts 5-8 tokens per forward pass instead of 1. This reduces the number of sequential forward passes from 100 to approximately 15-20, cutting generation time from 80-120ms to 12-24ms. Combined with edge caching (which eliminates generation entirely for cached queries), speculative decoding brings our p95 uncached inference latency to 11.2ms — just under our 12ms target.
The third technique is model quantization with accuracy-aware calibration. Reducing model precision from FP16 to INT8 halves memory bandwidth requirements and doubles throughput, but naive quantization can degrade model accuracy — particularly for low-resource African languages where the model has less margin for error. We developed a calibration procedure that quantizes each layer independently, measuring the accuracy impact of quantization on a held-out validation set for each target language. Layers where INT8 quantization causes more than 1% accuracy degradation are kept at FP16; all other layers are quantized. The result: 78% of layers are quantized to INT8, 22% remain at FP16, and average accuracy across our benchmark suite (Amazigh, Wolof, Swahili, French, Arabic) drops by only 0.3% — well within acceptable bounds. The performance impact is significant: inference throughput increases by 1.7x, and per-token latency decreases by 42%. This is the margin that makes speculative decoding fast enough to hit our 12ms target, because the draft model's 0.15ms per-token latency is achieved only with INT8 quantization.
The deployment architecture distributes inference across our three hubs according to demand patterns and network topology. The Dakhla hub serves North Africa and the Sahel, with direct fiber connections to Mauritania, Mali, and Niger. The Tangier hub serves Morocco and Southern Europe, with sub-5ms latency to Madrid and sub-8ms to Marseille. The Dakar hub serves West Africa, with sub-15ms latency to Abidjan, Accra, and Lagos via the MainOne and ACE submarine cables. A global load balancer routes each inference request to the nearest hub based on the client's IP geolocation and the hub's current load. If the nearest hub is overloaded (queue depth exceeds a threshold), the request is routed to the next-nearest hub with available capacity, with a maximum allowed additional latency of 8ms. This architecture ensures that 95% of inference requests are served by the nearest hub, and the remaining 5% are served by a backup hub with acceptable latency overhead.
The measured performance after deploying all three techniques is as follows. P50 end-to-end inference latency: 4.2ms. P95: 11.3ms. P99: 18.7ms. Cache hit rate: 64% weighted average across all workloads. Uncached p95: 11.2ms (speculative decoding + INT8 quantization). Cached p95: 0.8ms (cache lookup + network). Geographic breakdown: Casablanca clients p95 = 3.1ms, Dakar clients p95 = 6.8ms, Tunis clients p95 = 8.4ms, Lagos clients p95 = 10.9ms, Nairobi clients p95 = 14.2ms (exceeds target due to distance from nearest hub — a Nairobi hub is planned for 2027). These numbers represent a 4-10x improvement over routing African inference requests to European data centers, where the network RTT alone exceeds our entire latency budget. Sub-12ms inference for African markets is not a marketing claim. It is a measured, reproducible result achieved through systematic optimization across the entire inference stack.
Related Topics
More Technical Posts