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 "target" model, static draft-length configurations break down across diverse workloads—wasting compute on high-entropy creative tasks while under-utilizing parallel verification on predictable boilerplate code. We built NeuroEdge to bring dynamic, entropy-aware speculative decoding to local inference pipelines.
What it does
NeuroEdge is a lightweight C++ and Python inference runtime wrapper that accelerates local LLM generation without altering output distributions (maintaining 100% mathematical equivalence to the target model):
Dynamic Draft-Window Controller:
Continuously monitors token probability entropy at each generation step, automatically expanding the draft lookahead window (up to 12 tokens) during deterministic syntax generation and shrinking it (down to 1–2 tokens) during high-uncertainty reasoning.
Unified KV-Cache Sharing:
Eliminates redundant memory allocation by sharing quantized key-value cache pages between a 0.5B draft model and an 8B target model via custom ring-buffer memory mapping.
Real-Time Telemetry Profiler:
Exposes a live terminal and browser dashboard tracking tokens-per-second (TPS), draft acceptance rates, and memory bandwidth utilization per prompt category.
How we built it
Core Inference Engine: Built on top of llama.cpp bindings using C++17 and custom CUDA/Metal kernel hooks for batched target-model verification.
Adaptive Policy Controller: Implemented a lightweight Exponential Moving Average (EMA) acceptance-rate tracker in Python (PyTorch & NumPy) that dynamically tunes the speculation tree depth every 16 tokens.
API & Compatibility Layer: Wrapped the engine in an OpenAI-compatible FastAPI local server so existing developer tools, IDE extensions, and agent frameworks can connect out of the box.
Observability UI: Built a real-time performance monitor using Streamlit and Plotly to visualize acceptance-rate heatmaps across different coding and reasoning benchmarks.
Challenges we ran into
Synchronizing KV-cache rollbacks when the target model rejected mid-sequence draft tokens initially caused severe memory fragmentation and latency spikes. Naive cache truncation added nearly 18ms of overhead per rejection cycle. We solved this by implementing a pointer-based virtual ring buffer that invalidates rejected token slots in $O(1)$ time without copying underlying tensor blocks.
Accomplishments that we're proud of
Achieved a 2.6x end-to-end throughput speedup on local code-generation benchmarks (jumping from 28 TPS to 73 TPS on a single consumer GPU) with zero degradation in output accuracy.Reduced peak VRAM overhead of running dual draft-and-target models to less than 420 MB above the standalone target model footprint.
What's next for NeuroEdgeAdding
support for multi-draft tree attention (Medusa-style parallel heads) to eliminate the need for a separate draft model checkpoint.Packaging pre-compiled binaries for seamless one-command installation across Windows, Linux, and macOS.