⚡ DSpark is a speculative decoding visualizer that demonstrates LLM inference acceleration using a fast draft model to speculate ahead, followed by parallel verification from a larger target model.
- Dashboard & Engine: Streamlit (single-file implementation, <100 lines)
- Target LLM: Ollama (serving the target
qwen3:4bmodel) - Draft Model: Hugging Face
dspark_qwen3_4b_block7(localmodel.safetensors+config.jsonin the current folder)
Install the required python libraries:
pip install streamlit requests pandas safetensors torchDownload and start the target base model in Ollama:
ollama pull qwen3:4bDownload the draft head weights (model.safetensors and config.json) from the official Hugging Face dspark_qwen3_4b_block7 Repo and place them directly in the root of this project folder.
Start the visual dashboard:
streamlit run app.pyapp.py— Consolidated dashboard and speculative verifier. Loads local weights, runs Ollama inference, and generates visual charts.sample_output.md— Pre-run benchmark report.output.md— Dynamically updated benchmark report generated upon clicking run in the UI.
- Real-Time Code Completion: Accelerate IDE autocomplete suggestions by speculative drafting of syntax blocks.
- Low-Latency Conversational Agents: Deliver instant response generation for responsive local chat interfaces.
- Resource-Constrained Edge Devices: Run high-quality models on edge nodes by leveraging tiny draft models.
- Agentic Planning loops: Speed up recursive step-by-step reasoning calls.
- High-Throughput API Gateways: Optimize server-side inference load by validating batched speculations in parallel.
- Native GGUF Draft Tensors: Support direct execution of multi-token prediction (MTP) draft heads.
-
Dynamic Block-Size Scheduling: Adaptively scale draft length (
$K$ ) based on token acceptance confidence. - Tree-Search Speculative Drafting: Speculate multiple generation paths simultaneously.
- Hardware-Aware Truncation: Automatically trim draft sequences when system resources spike.
- Self-Correction Draft Heads: Train tiny, localized draft heads on specialized system logs.