| --- |
| title: Speculative Decoding Trace |
| emoji: π― |
| colorFrom: blue |
| colorTo: green |
| sdk: static |
| app_file: index.html |
| pinned: false |
| license: mit |
| short_description: Watch rejection sampling accept/reject every draft token |
| --- |
| |
| # Speculative decoding, token by token |
|
|
| Two layers, both client-side (static Space β free tier, no ZeroGPU quota, |
| no cold starts): |
|
|
| 1. **Interactive explainer** (`index.html`) β drag toy draft/target |
| distributions and watch the acceptance probability min(1, p/q), the |
| residual norm(max(p β q, 0)), the losslessness histogram, and the |
| `E[tokens] = (1 β Ξ±^{Ξ³+1})/(1 β Ξ±)` speedup curve respond live. |
| 2. **Real inference in your browser** (`live.html`) β quantized ONNX |
| `distilgpt2` drafts, `gpt2` verifies, via transformers.js |
| (WebGPU/WASM). The actual rejection sampling on actual logits, with the |
| per-position math rendered for every token. |
|
|
| The repo also ships a Gradio app with KV-cached speculative decoding, |
| draft-vs-target **attention-trace diffing**, and an optional 70B cloud |
| cross-check β run it locally with `python app.py`. |
|
|
| Source: https://github.com/aabhimittal/attention-trace-differ-for-speculative-decoding |
|
|