NeuroEdge: Sub-50ms Adaptive Speculative Decoding Engine for Local Small Language Models
Inspiration Running capable Large Language Models on edge hardware or consumer laptops typically forces a painful trade-off: either use a tiny quantized model that sacrifices reasoning quality, or run a larger 7B–8B model at sluggish token-generation speeds. While speculative decoding accelerates inference by using a fast "draft" model to predict multiple tokens verified in parallel by a larger…
NeuroEdge is an adaptive decoding engine designed to speed up local Large Language Model (LLM) generation, specifically small language models, by implementing speculative decoding. Traditional edge computing or consumer laptop setups often struggle with a trade-off between using a smaller quantized model that lacks reasoning depth or a larger 7B–8B model that generates tokens slowly.
NeuroEdge aims to overcome this challenge by utilizing a fast "draft" model to predict text, which is then verified in parallel by a larger "target" model. However, the static configuration of draft lengths in speculative decoding leads to inefficiencies in diverse scenarios, wasting computational resources on high-entropy tasks and underutilizing parallel verification on predictable tasks.
NeuroEdge addresses this by introducing a Dynamic Draft-Window Controller that adapts the draft lookahead window based on the token probability entropy, ranging from 1–12 tokens. It also features a Unified KV-Cache Sharing mechanism that eliminates redundant memory allocation by sharing quantized key-value cache pages between the lightweight 0.5B draft model and the robust 8B target model.
A Real-Time Telemetry Profiler offers live insights into performance metrics like tokens-per-second, draft acceptance rates, and memory bandwidth utilization.
Built on llama.cpp bindings with custom CUDA/Metal kernel hooks, NeuroEdge's Adaptive Policy Controller uses an Exponential Moving Average (EMA) acceptance-rate tracker to adjust the speculation depth every 16 tokens. The API and Compatibility Layer is wrapped in an OpenAI-compatible FastAPI local server, allowing seamless integration with existing developer tools. NeuroEdge's Observability UI leverages Streamlit and Plotly to provide real-time performance monitoring.
One of the significant challenges faced was synchronizing KV-cache rollbacks when the target model rejected mid-sequence draft tokens, causing memory fragmentation and latency spikes. This was resolved by implementing a pointer-based virtual ring buffer that invalidates rejected token slots in constant time without copying tensor blocks.
NeuroEdge has demonstrated a remarkable 2.6x improvement in end-to-end throughput speed on local code-generation benchmarks, boosting token generation from 28 TPS to 73 TPS on a single consumer GPU, without compromising output accuracy. Memory overhead has also been reduced to under 420 MB above the standalone target model footprint.
Looking ahead, NeuroEdge plans to introduce multi-draft tree attention, potentially eliminating the need for a separate draft model checkpoint, and will focus on packaging pre-compiled binaries for easy installation across multiple platforms.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to