Commit dbaffc5
feat(opt-s01): Speculative Decoding — 2-3x generation speed, 14 tests
speculative_decoding.zig (647 lines):
- Draft-verify-accept cycle with min(1, p_target/p_draft) acceptance
- Adjusted rejection sampling from max(0, p_target - p_draft) / Z
- LCG PRNG for reproducible deterministic tests
- Mock ProbDist (uniform/peaked/temperature) for self-contained testing
- SpeedupAnalysis with theoretical speedup formula
- Fixed-size arrays (MAX_SPEC_LEN=16, MAX_VOCAB=64)
- 14 tests: config, math, PRNG, distributions, acceptance, rounds, stats
- build.zig wired: test-speculative-decoding step
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent cf8f0b1 commit dbaffc5
3 files changed
Lines changed: 664 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1856 | 1856 | | |
1857 | 1857 | | |
1858 | 1858 | | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
1859 | 1872 | | |
0 commit comments