Commit a8f6d8a
fix(cli): -s seed flag was documented but not implemented
The CLI's --help text has long advertised "-s <seed> Random seed
(default: 42)", but tools/quant.c had no parser case for -s and
src/engine/tq_generate.c hardcoded `unsigned long long rng_state = 42`
in two places. As a result, passing -s 1337 silently fell through
to the positional-arg branch, getting parsed as the model path:
$ ./build_metal/quant model.gguf -p "..." -n 32 -T 0.7 -s 1337
Loading model from 1337...
tq_load_model: cannot open '1337'
Failed to load model
Discovered while running the cliff-cell seed sweep for the
working-memory-cliff tech report (Phase 1B), where 60 of 60
attempted sampled trials degenerated to "model path = <seed>".
This commit:
1. Adds `unsigned long long rng_seed` to tq_gen_config_t in both
include/turboquant/tq_engine.h and quant.h (the single header
used by embedded users via QUANT_IMPLEMENTATION).
2. Initialises rng_seed to 42ULL in tq_default_gen_config (in both
src/engine/tq_ops.c and quant.h).
3. Wires rng_state from config->rng_seed in tq_generate (both
src/engine/tq_generate.c and quant.h), with a `?: 42ULL` fallback
so legacy callers that never set rng_seed get bit-identical
behaviour.
4. Adds the -s parser case in tools/quant.c, with `0 -> 42` reserved
for "use default" so the documented default is preserved.
5. Adds build_metal/ to .gitignore alongside the existing
build_nomt/ and build_nometal/ entries.
Backwards compatibility: zero behaviour change for any caller that
doesn't pass -s. Same RNG state, same first sampled token, same
output bit-for-bit. Verified by running both with and without -s 42
on Llama-3.2-1B-Q8_0 at T=0.7 and confirming identical output. Also
verified -s 42 vs -s 1337 produce *different* outputs (the test
that was previously impossible).
All 35 tests in build_metal/ pass after the change.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent f527939 commit a8f6d8a
6 files changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
| 869 | + | |
869 | 870 | | |
870 | 871 | | |
871 | 872 | | |
| |||
4129 | 4130 | | |
4130 | 4131 | | |
4131 | 4132 | | |
| 4133 | + | |
4132 | 4134 | | |
4133 | 4135 | | |
4134 | 4136 | | |
| |||
15453 | 15455 | | |
15454 | 15456 | | |
15455 | 15457 | | |
15456 | | - | |
| 15458 | + | |
| 15459 | + | |
| 15460 | + | |
15457 | 15461 | | |
15458 | | - | |
| 15462 | + | |
15459 | 15463 | | |
15460 | 15464 | | |
15461 | 15465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
363 | 366 | | |
364 | | - | |
| 367 | + | |
365 | 368 | | |
366 | 369 | | |
367 | 370 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1682 | 1682 | | |
1683 | 1683 | | |
1684 | 1684 | | |
| 1685 | + | |
1685 | 1686 | | |
1686 | 1687 | | |
1687 | 1688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| |||
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
| |||
1265 | 1269 | | |
1266 | 1270 | | |
1267 | 1271 | | |
| 1272 | + | |
1268 | 1273 | | |
1269 | 1274 | | |
1270 | 1275 | | |
| |||
0 commit comments