Commit a7795a5
feat(feedback-quick-wins): act on 2026-04-12 external user report (#59)
Four scoped fixes addressing the highest-impact items in
docs/feedback/2026-04-12_0900.md. Each is independently useful and
nothing experimental — Phi-3 architecture support is intentionally
deferred to a separate PR.
## Changes
### P0-A — SmolLM2-1.7B as the recommended default
External tester measured SmolLM2-1.7B at ~12.5 tok/s vs Llama-3.2-1B at
~2.3 tok/s on Apple M3. Same llama arch family, but vocab 49K vs 128K.
The lm_head matmul (vocab × hidden_dim per token) is the bottleneck —
fewer params don't help if the vocab is bigger.
- Add SmolLM2-1.7B-Instruct (Q8) to `_MODEL_REGISTRY`
- Add `smollm2:1.7b` and bare `smollm2` aliases (the bare alias now
points at 1.7B; users wanting the demo model ask for `smollm2:135m`)
- `cmd_chat_default` now uses SmolLM2-1.7B
- Module + class docstrings + CLI help epilog all updated to reflect
the new recommendation
### P0-B — Hard-fail load on unsupported architecture
Previously: loading a Phi-3 GGUF reported `loaded N layers (0 self_attn)`
in the success log and returned a model that produced page after page of
garbage tokens. Phi-3 uses fused `attn_qkv` projection which the loader
doesn't recognize.
Now: when `tq_load_gguf` finishes a model with zero standard self_attn
layers AND no DeltaNet weights, it logs a clear ERROR naming the
architecture and returns NULL. Callers see the failure immediately
instead of debugging garbage output.
```
tq_load_gguf: ERROR — model architecture 'phi3' is not supported.
Detected 0 self_attn layers and no DeltaNet weights.
...
```
### P0-C — ChatML template marker filter
External tester reported `<|im_start|>`, `<|im_end|>`, `<line>assistant`
etc. leaking into chat output. Root cause: BPE tokenizers fragment these
markers across multiple tokens, so the existing per-token strstr check
in the generation loop never matches.
Fix: a 32-byte lookahead filter inside `chat_accum_callback`. The filter
buffers the most recent text, scans for known markers, and:
- `<|im_start|>` at the very start of the response → strip the
`<|im_start|>assistant\n` header (model is echoing the chat prompt)
- any END marker (`<|im_end|>`, `<|eot_id|>`, `<end_of_turn>`,
`<|endoftext|>`, `<|im_start|>` mid-response, `<|start_header_id|>`,
`<|eom_id|>`) → emit clean prefix, set `stop_requested`, fast-path
loop checks the flag and breaks
Streaming latency cost: ~CHAT_LOOKAHEAD bytes (32) of in-flight buffer.
Verified by a standalone harness that drives the filter with simulated
token streams (8 cases including BPE-split markers — all pass).
### P1-C — `docs/supported_models.md`
New page documenting the architecture compatibility matrix, the vocab
size → speed relationship, why Phi-3 is hard, and how to report a
broken model. Linked from the feedback file.
## Verified
- ctest --test-dir build → 35/35 passed
- cmake --build build → all targets clean (no new warnings)
- wasm/build.sh → 320K bundle rebuilt
- Standalone chat_accum filter test → 8/8 passed
- Python `from quantcpp import Model` + `available_models()` works
- `quantcpp --help` epilog reflects new defaults
quant.h and src/engine/tq_generate.c kept in lockstep (filter logic
mirrored byte-for-byte).
## Deferred
- Phi-3 (`attn_qkv` / `gate_up_proj`) loader support — separate PR with
prototype + validation gate
- Server fallback in pure Python (so `quantcpp serve` works without a
CMake build) — separate PR
- Server request queueing / 429 — separate PR
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 0623b16 commit a7795a5
File tree
7 files changed
+739
-50
lines changed- bindings/python/quantcpp
- docs
- feedback
- src/engine
- wasm
7 files changed
+739
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
57 | 71 | | |
58 | 72 | | |
59 | 73 | | |
60 | 74 | | |
61 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
62 | 86 | | |
63 | 87 | | |
64 | 88 | | |
65 | 89 | | |
66 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
67 | 94 | | |
68 | 95 | | |
69 | 96 | | |
| |||
170 | 197 | | |
171 | 198 | | |
172 | 199 | | |
173 | | - | |
| 200 | + | |
174 | 201 | | |
175 | 202 | | |
176 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | | - | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
329 | 333 | | |
330 | 334 | | |
331 | 335 | | |
332 | | - | |
333 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
334 | 343 | | |
335 | 344 | | |
336 | 345 | | |
| |||
354 | 363 | | |
355 | 364 | | |
356 | 365 | | |
357 | | - | |
| 366 | + | |
358 | 367 | | |
359 | | - | |
360 | | - | |
361 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
362 | 371 | | |
363 | 372 | | |
364 | 373 | | |
365 | 374 | | |
366 | 375 | | |
367 | | - | |
| 376 | + | |
368 | 377 | | |
369 | | - | |
| 378 | + | |
370 | 379 | | |
371 | 380 | | |
372 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
0 commit comments