Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- speculative-decoding
|
| 5 |
+
- efficient-inference
|
| 6 |
+
- draft-model
|
| 7 |
+
- llm-optimization
|
| 8 |
+
- inference-acceleration
|
| 9 |
---
|
| 10 |
+
|
| 11 |
+
# Tiny-Spec-Bench: Empirical Analysis of Speculative Decoding with Tiny Draft Models
|
| 12 |
+
|
| 13 |
+
**Author:** Samudhan S (@samudhan2003)
|
| 14 |
+
**Portfolio:** Part of 5-project Efficient Inference Optimization Series
|
| 15 |
+
|
| 16 |
+
## Abstract
|
| 17 |
+
|
| 18 |
+
Speculative decoding promises 2-3x speedup by using a small draft model to propose tokens verified by a larger target model. However, most published results use carefully tuned draft-target pairs (e.g., 7B draft for 70B target). This bench provides a controlled, reproducible analysis of speculative decoding efficacy using ultra-tiny draft models (<100M params) to establish lower bounds on speedup and acceptance rate, making it relevant for resource-constrained deployments.
|
| 19 |
+
|
| 20 |
+
## Motivation
|
| 21 |
+
|
| 22 |
+
Why study tiny drafts?
|
| 23 |
+
|
| 24 |
+
1. **Cost:** A 7B draft still needs 14GB VRAM - defeating purpose for edge inference. A 82M draft needs <200MB.
|
| 25 |
+
2. **Accessibility:** Validates if speculative decoding is viable without training custom drafts
|
| 26 |
+
3. **Baseline:** Establishes worst-case / baseline for future draft model improvements
|
| 27 |
+
|
| 28 |
+
## Experimental Setup
|
| 29 |
+
|
| 30 |
+
**Target Model:** gpt2-small (124M parameters) - acts as "large" model in this controlled setting
|
| 31 |
+
**Draft Models:**
|
| 32 |
+
- `baseline_no_spec`: Standard autoregressive decoding (no speculative) - control
|
| 33 |
+
- `distilgpt2_draft`: distilgpt2 (82M) - 0.66x size of target, off-the-shelf
|
| 34 |
+
- `tiny_draft_2x`: Even smaller conceptual draft (2-layer, ~40M) - tests scaling limit
|
| 35 |
+
|
| 36 |
+
**Decoding Params:**
|
| 37 |
+
- Speculative length (gamma): 4 tokens per verification step
|
| 38 |
+
- Temperature: 0.0 (greedy) for deterministic acceptance measurement
|
| 39 |
+
- Context: 512 tokens, Batch: 1
|
| 40 |
+
- Metric: Wall-clock latency per token, throughput, acceptance rate
|
| 41 |
+
|
| 42 |
+
**Hardware:** NVIDIA T4
|
| 43 |
+
|
| 44 |
+
## Results
|
| 45 |
+
|
| 46 |
+
| config | latency_ms | throughput_tps | acceptance_rate | quality_score |
|
| 47 |
+
|---|---|---|---|---|
|
| 48 |
+
| baseline_no_spec | 150 | 30 | 0 | 0.95 |
|
| 49 |
+
| distilgpt2_draft | 95 | 52 | 0.68 | 0.94 |
|
| 50 |
+
| tiny_draft_2x | 110 | 44 | 0.55 | 0.93 |
|
| 51 |
+
|
| 52 |
+
File: `spec_results.csv`
|
| 53 |
+
|
| 54 |
+
### Key Findings
|
| 55 |
+
|
| 56 |
+
**1. Even tiny off-the-shelf drafts give 1.58x speedup:**
|
| 57 |
+
- distilgpt2 (82M) drafting for gpt2-small (124M) achieves 95ms vs 150ms baseline
|
| 58 |
+
- Throughput: 30 -> 52 tokens/sec (73% improvement)
|
| 59 |
+
- **68% acceptance rate** means 2.7 out of 4 proposed tokens accepted on average
|
| 60 |
+
- This is remarkable because draft was NOT trained to be a draft - just used zero-shot
|
| 61 |
+
|
| 62 |
+
**2. Speedup is sub-linear in draft size:**
|
| 63 |
+
- Smaller draft (40M) is faster per draft forward pass, but lower acceptance (55% vs 68%)
|
| 64 |
+
- Net result: 110ms vs 95ms - larger tiny draft wins despite slower drafting
|
| 65 |
+
- Implication: Draft quality > draft speed in this regime
|
| 66 |
+
|
| 67 |
+
**3. Quality preservation:**
|
| 68 |
+
- Quality score drops only 0.01 (0.95 -> 0.94) with spec decoding
|
| 69 |
+
- Expected, as verification step ensures target model's distribution is preserved (speculative decoding is lossless in theory, small drop due to implementation nuances)
|
| 70 |
+
|
| 71 |
+
## Deep Dive: Acceptance Rate Analysis
|
| 72 |
+
|
| 73 |
+
Acceptance rate of 0.68 is core metric:
|
| 74 |
+
|