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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MTP Viability Test Plan: Quant x Temperature x Task Type
|
| 2 |
+
|
| 3 |
+
## Goal
|
| 4 |
+
|
| 5 |
+
Map the complete MTP speculative decoding viability landscape for Qwen3.6-27B on M2 Max 96GB.
|
| 6 |
+
Produce a recommendation table for each quant/temperature/task combination showing whether
|
| 7 |
+
MTP helps, hurts, or is neutral, with measured speedups.
|
| 8 |
+
|
| 9 |
+
## Test Parameters
|
| 10 |
+
|
| 11 |
+
- **Token budget**: `-n 2500` per test (expect 1500-2500 actual, model may stop early)
|
| 12 |
+
- **Context**: `-c 4096` (sufficient for prompt + 2500 generation)
|
| 13 |
+
- **MTP config**: `--spec-type mtp --spec-draft-n-max 3` (N=3)
|
| 14 |
+
- **Chat template**: `--jinja --chat-template-file <path> -sys '<system prompt>'`
|
| 15 |
+
- **Exit**: `printf '/exit\n'` piped to stdin
|
| 16 |
+
- **Verbosity**: `-v` to capture acceptance stats
|
| 17 |
+
- **GPU layers**: `-ngl 99`
|
| 18 |
+
|
| 19 |
+
## Variables
|
| 20 |
+
|
| 21 |
+
### Quants (4 levels)
|
| 22 |
+
Q4_K_M (16G), Q5_K_M (18G), Q6_K (21G), Q8_0 (27G)
|
| 23 |
+
|
| 24 |
+
Rationale: Skip iQ quants (IQ2_M, IQ3_M, IQ4_XS) — they showed inconsistent results
|
| 25 |
+
and imatrix has no measurable effect on acceptance. Focus on Q quants for clean data.
|
| 26 |
+
|
| 27 |
+
### Temperatures (3 levels)
|
| 28 |
+
0.0 (greedy/deterministic), 0.3 (low randomness), 0.7 (standard creative)
|
| 29 |
+
|
| 30 |
+
### Task Types (5 categories, determinism-ordered)
|
| 31 |
+
|
| 32 |
+
Tasks are ordered from most deterministic (highest expected acceptance) to least.
|
| 33 |
+
|
| 34 |
+
#### T1: Code Generation (very high determinism)
|
| 35 |
+
Syntax is rigid, most tokens are forced by grammar. Greedy draft ≈ verification.
|
| 36 |
+
```
|
| 37 |
+
Write a complete Python implementation of an LRU cache class with get(key), put(key, value),
|
| 38 |
+
delete(key), size(), and clear(). Use a doubly-linked list combined with a hash map for O(1)
|
| 39 |
+
operations. Include type hints, docstrings, and 10 unit tests using pytest with good coverage
|
| 40 |
+
of edge cases.
|
| 41 |
+
```
|
| 42 |
+
Expected: ~1500-2000 tokens
|
| 43 |
+
|
| 44 |
+
#### T2: Factual Explanation (high determinism)
|
| 45 |
+
Technical content with specific terminology and logical structure. One dominant token per position.
|
| 46 |
+
```
|
| 47 |
+
Explain in detail how the Transformer architecture works. Cover: token embedding, positional
|
| 48 |
+
encoding (sinusoidal and RoPE), multi-head self-attention including Q/K/V projections and
|
| 49 |
+
scaled dot-product attention, feed-forward networks, layer normalization (pre-norm vs post-norm),
|
| 50 |
+
residual connections, and the difference between encoder-decoder and decoder-only variants.
|
| 51 |
+
Include the key mathematical equations for attention and positional encoding.
|
| 52 |
+
```
|
| 53 |
+
Expected: ~1500-2500 tokens
|
| 54 |
+
|
| 55 |
+
#### T3: Technical Analysis (medium determinism)
|
| 56 |
+
Constrained by technical facts but allows structural freedom in organization and phrasing.
|
| 57 |
+
```
|
| 58 |
+
Analyze the tradeoffs of quantization in large language models. Cover: memory reduction,
|
| 59 |
+
inference speed gains on bandwidth-limited hardware, quality degradation patterns, different
|
| 60 |
+
quantization schemes (uniform quantization, k-quant mixtures, importance matrix guided),
|
| 61 |
+
perplexity impact at different bit widths, and the practical recommendations for selecting
|
| 62 |
+
a quantization level for deployment. Be thorough and technical.
|
| 63 |
+
```
|
| 64 |
+
Expected: ~1500-2500 tokens
|
| 65 |
+
|
| 66 |
+
#### T4: Expository Essay (low determinism)
|
| 67 |
+
Structured but high freedom in content organization, word choice, and emphasis.
|
| 68 |
+
```
|
| 69 |
+
Write a detailed 1500-word essay on the history and cultivation of lychee. Cover its origins
|
| 70 |
+
in southern China, spread to Southeast Asia and beyond, ideal growing conditions, major
|
| 71 |
+
commercial varieties, harvesting and post-harvest handling challenges, and economic importance
|
| 72 |
+
in global trade.
|
| 73 |
+
```
|
| 74 |
+
Expected: ~1500-2000 tokens
|
| 75 |
+
|
| 76 |
+
#### T5: Creative Writing (very low determinism)
|
| 77 |
+
Maximum freedom — many equally valid continuations at every position. Worst case for MTP.
|
| 78 |
+
```
|
| 79 |
+
Write a short story (about 1500 words) about a lone astronaut aboard a generation ship who
|
| 80 |
+
discovers that the ship's AI has been secretly altering the crew's memories over centuries.
|
| 81 |
+
The story should build tension gradually and have a surprising but logically consistent ending.
|
| 82 |
+
```
|
| 83 |
+
Expected: ~1500-2000 tokens
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## Already Completed
|
| 88 |
+
|
| 89 |
+
| Quant | Temp | Task | Type | Speed | Acceptance | Source |
|
| 90 |
+
|-------|------|------|------|-------|------------|--------|
|
| 91 |
+
| Q4_K_M | 0.0 | Essay | MTP | 15.56 | 59.4% | Previous |
|
| 92 |
+
| Q4_K_M | 0.0 | Essay | Base | 14.96 | — | Previous |
|
| 93 |
+
| Q4_K_M | 0.3 | Essay | MTP | 15.18 | 57.2% | Previous |
|
| 94 |
+
| Q4_K_M | 0.3 | Essay | Base | 15.09 | — | Previous |
|
| 95 |
+
| Q4_K_M | 0.7 | Essay | MTP | 14.95 | 55.8% | Previous |
|
| 96 |
+
| Q4_K_M | 0.7 | Essay | Base | 15.07 | — | Previous |
|
| 97 |
+
| Q4_K_M+imat | 0.7 | Essay | MTP | 14.86 | 55.0% | Previous |
|
| 98 |
+
| Q5_K_M | 0.7 | Essay | MTP | 13.83 | 55.1% | Previous |
|
| 99 |
+
| Q6_K | 0.7 | Essay | MTP | 14.97 | 54.8% | Previous |
|
| 100 |
+
| Q8_0 | 0.7 | Essay | MTP | 18.33 | 55.7% | Previous |
|
| 101 |
+
| Q8_0 | 0.7 | Essay | Base | ? | — | Running |
|
| 102 |
+
| IQ3_M | 0.7 | Essay | MTP | 12.48 | 54.1% | Previous |
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## Test Plan
|
| 107 |
+
|
| 108 |
+
### Phase 1: Task Type Effect (16 tests, ~45 min)
|
| 109 |
+
|
| 110 |
+
Test all 4 quants × 4 new task types (T1-T3, T5) at temp 0.7 with MTP.
|
| 111 |
+
Essay (T4) already done for all quants.
|
| 112 |
+
|
| 113 |
+
| # | Quant | Task | Temp | Type | Notes |
|
| 114 |
+
|---|-------|------|------|------|-------|
|
| 115 |
+
| 1 | Q4_K_M | Code | 0.7 | MTP | |
|
| 116 |
+
| 2 | Q4_K_M | Factual | 0.7 | MTP | |
|
| 117 |
+
| 3 | Q4_K_M | Analysis | 0.7 | MTP | |
|
| 118 |
+
| 4 | Q4_K_M | Creative | 0.7 | MTP | |
|
| 119 |
+
| 5 | Q5_K_M | Code | 0.7 | MTP | |
|
| 120 |
+
| 6 | Q5_K_M | Factual | 0.7 | MTP | |
|
| 121 |
+
| 7 | Q5_K_M | Analysis | 0.7 | MTP | |
|
| 122 |
+
| 8 | Q5_K_M | Creative | 0.7 | MTP | |
|
| 123 |
+
| 9 | Q6_K | Code | 0.7 | MTP | |
|
| 124 |
+
| 10 | Q6_K | Factual | 0.7 | MTP | |
|
| 125 |
+
| 11 | Q6_K | Analysis | 0.7 | MTP | |
|
| 126 |
+
| 12 | Q6_K | Creative | 0.7 | MTP | |
|
| 127 |
+
| 13 | Q8_0 | Code | 0.7 | MTP | |
|
| 128 |
+
| 14 | Q8_0 | Factual | 0.7 | MTP | |
|
| 129 |
+
| 15 | Q8_0 | Analysis | 0.7 | MTP | |
|
| 130 |
+
| 16 | Q8_0 | Creative | 0.7 | MTP | |
|
| 131 |
+
|
| 132 |
+
### Phase 2: Temperature x Task Interaction (8 tests, ~25 min)
|
| 133 |
+
|
| 134 |
+
Test code (T1, most deterministic) and creative (T5, least deterministic) at temp 0.0
|
| 135 |
+
and 0.3 for Q4_K_M and Q8_0 (representing low and high quality bounds).
|
| 136 |
+
|
| 137 |
+
| # | Quant | Task | Temp | Type | Notes |
|
| 138 |
+
|---|-------|------|------|------|-------|
|
| 139 |
+
| 17 | Q4_K_M | Code | 0.0 | MTP | Best case: low quant + deterministic task |
|
| 140 |
+
| 18 | Q4_K_M | Code | 0.3 | MTP | |
|
| 141 |
+
| 19 | Q4_K_M | Creative | 0.0 | MTP | Low quant + creative at greedy |
|
| 142 |
+
| 20 | Q4_K_M | Creative | 0.3 | MTP | |
|
| 143 |
+
| 21 | Q8_0 | Code | 0.0 | MTP | Best case: high quant + deterministic task |
|
| 144 |
+
| 22 | Q8_0 | Code | 0.3 | MTP | |
|
| 145 |
+
| 23 | Q8_0 | Creative | 0.0 | MTP | High quant + creative at greedy |
|
| 146 |
+
| 24 | Q8_0 | Creative | 0.3 | MTP | |
|
| 147 |
+
|
| 148 |
+
### Phase 3: Missing Baselines (3 tests, ~10 min)
|
| 149 |
+
|
| 150 |
+
One baseline per quant at temp 0.7. Task type doesn't significantly affect baseline speed.
|
| 151 |
+
|
| 152 |
+
| # | Quant | Temp | Type | Notes |
|
| 153 |
+
|---|-------|------|------|-------|
|
| 154 |
+
| 25 | Q5_K_M | 0.7 | Base | |
|
| 155 |
+
| 26 | Q6_K | 0.7 | Base | |
|
| 156 |
+
| 27 | IQ3_M | 0.7 | Base | Optional, lower priority |
|
| 157 |
+
|
| 158 |
+
Q4_K_M baselines already done. Q8_0 baseline running.
|
| 159 |
+
|
| 160 |
+
### Phase 4: Fill-in Tests (conditional, ~15 min)
|
| 161 |
+
|
| 162 |
+
Based on Phase 1-3 results, test additional combinations to clarify transitions:
|
| 163 |
+
|
| 164 |
+
- If code at Q4_K_M/temp 0.7 is above breakeven: test Q4_K_M/factual at temp 0.3
|
| 165 |
+
- If creative at Q8_0/temp 0.7 is above breakeven: verify with analysis task
|
| 166 |
+
- Test any quant/task/temperature combinations near the breakeven threshold
|
| 167 |
+
|
| 168 |
+
Up to 6 additional tests, TBD based on results.
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
## Total: 27 core tests + ~6 conditional = ~33 tests, ~90 min
|
| 173 |
+
|
| 174 |
+
## Test Execution
|
| 175 |
+
|
| 176 |
+
### Command Template
|
| 177 |
+
|
| 178 |
+
```bash
|
| 179 |
+
CLI="/Volumes/ssd/ai/llm-dev/llama.cpp-mtp/build/bin/llama-cli"
|
| 180 |
+
MODEL="<quant-file>"
|
| 181 |
+
TEMPLATE="/Volumes/ssd/ai/llm-models/froggeric/Qwen-Fixed-Chat-Templates/qwen3.6/chat_template-v9.jinja"
|
| 182 |
+
SYS='You are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|think_off|>'
|
| 183 |
+
PROMPT="<task-prompt>"
|
| 184 |
+
|
| 185 |
+
# MTP test
|
| 186 |
+
printf '/exit\n' | $CLI -m "$MODEL" \
|
| 187 |
+
--spec-type mtp --spec-draft-n-max 3 \
|
| 188 |
+
-c 4096 -n 2500 --temp <temp> -ngl 99 \
|
| 189 |
+
--jinja --chat-template-file "$TEMPLATE" -sys "$SYS" -p "$PROMPT" \
|
| 190 |
+
-v 2>&1 | tee <output-file> | grep -E "accept|draft|statistics|tokens per second|eval time|prompt eval" | tail -10
|
| 191 |
+
|
| 192 |
+
# Baseline test
|
| 193 |
+
printf '/exit\n' | $CLI -m "$MODEL" \
|
| 194 |
+
-c 4096 -n 2500 --temp <temp> -ngl 99 \
|
| 195 |
+
--jinja --chat-template-file "$TEMPLATE" -sys "$SYS" -p "$PROMPT" \
|
| 196 |
+
-v 2>&1 | tee <output-file> | grep -E "tokens per second|eval time|prompt eval" | tail -5
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
### Execution Strategy
|
| 200 |
+
|
| 201 |
+
Run tests sequentially (single GPU). Chain commands in groups:
|
| 202 |
+
- Phase 1: 4 quants × 4 tasks = 16 sequential tests, ~45 min
|
| 203 |
+
- Phase 2: 8 sequential tests, ~25 min
|
| 204 |
+
- Phase 3: 3 sequential tests, ~10 min
|
| 205 |
+
- Phase 4: conditional
|
| 206 |
+
|
| 207 |
+
Use `tee` to capture full output for post-hoc analysis if grep misses something.
|
| 208 |
+
|
| 209 |
+
### Metrics to Extract
|
| 210 |
+
|
| 211 |
+
From each test output:
|
| 212 |
+
- **eval time** and **tokens generated** → decode speed (tok/s)
|
| 213 |
+
- **draft acceptance rate** (MTP tests only)
|
| 214 |
+
- **#gen tokens** and **#acc tokens** from statistics line
|
| 215 |
+
|
| 216 |
+
---
|
| 217 |
+
|
| 218 |
+
## Analysis Plan
|
| 219 |
+
|
| 220 |
+
### 1. Acceptance Rate Heatmap
|
| 221 |
+
|
| 222 |
+
```
|
| 223 |
+
Code Factual Analysis Essay Creative
|
| 224 |
+
Q4_K_M 0.0 ? ? ? 59.4% ?
|
| 225 |
+
Q4_K_M 0.3 ? ? ? 57.2% ?
|
| 226 |
+
Q4_K_M 0.7 ? ? ? 55.8% ?
|
| 227 |
+
Q5_K_M 0.7 ? ? ? 55.1% ?
|
| 228 |
+
Q6_K 0.7 ? ? ? 54.8% ?
|
| 229 |
+
Q8_0 0.0 ? ? ? ? ?
|
| 230 |
+
Q8_0 0.3 ? ? ? ? ?
|
| 231 |
+
Q8_0 0.7 ? ? ? 55.7% ?
|
| 232 |
+
```
|
| 233 |
+
|
| 234 |
+
### 2. Speedup Table
|
| 235 |
+
|
| 236 |
+
```
|
| 237 |
+
Code Factual Analysis Essay Creative
|
| 238 |
+
Q4_K_M ?% ?% ?% -0.8% ?%
|
| 239 |
+
Q5_K_M ?% ?% ?% ?% ?%
|
| 240 |
+
Q6_K ?% ?% ?% ?% ?%
|
| 241 |
+
Q8_0 ?% ?% ?% ?% ?%
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
Speedup = (MTP_speed / Base_speed - 1) × 100%
|
| 245 |
+
Breakeven acceptance for N=3 ≈ 59% (but depends on MTP overhead ratio)
|
| 246 |
+
|
| 247 |
+
### 3. Final Recommendation Matrix
|
| 248 |
+
|
| 249 |
+
For each quant, recommend:
|
| 250 |
+
- **Green**: MTP recommended (measurable speedup)
|
| 251 |
+
- **Yellow**: MTP neutral (marginal, task-dependent)
|
| 252 |
+
- **Red**: MTP not recommended (net slowdown)
|
| 253 |
+
|
| 254 |
+
Organized by use case:
|
| 255 |
+
- Coding assistant (temp 0.0-0.3)
|
| 256 |
+
- General chatbot (temp 0.7)
|
| 257 |
+
- Technical writing (temp 0.3-0.5)
|
| 258 |
+
- Creative writing (temp 0.7-1.0)
|