bots-garden/razorbillpublic Fork
⑂ caefc12
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/razorbill.git
git clone ssh://git@rickub.com/bots-garden/razorbill.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

demos/test-qwen: max_tokens 4096, --thinking-budget, say when the reasoning ate every token

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k33g committed 2026-11-26T15:17:29+01:00 Browse files
caefc12 parent: f95af71
modified .memory/history.md +11 -0
@@ -374,3 +374,14 @@ User runs `rzb serve --host 0.0.0.0` and wants to test mlx-community/Qwen3.5-9B-
374374 reasoning dimmed, TTFT / time to answer / decode tokens/s / overall throughput / cached tokens,
375375 --no-think, --runs) and its README; listed in the root README. Tested on Linux against a
376376 fake-engine `rzb serve` (2 runs + unreachable server message); not run against the real model.
377+
378+## 2026-11-26 — demos/test-qwen: first real run on Qwen3.5-9B
379+
380+User's run (3 runs, thinking on): every run spent the whole max_tokens 1024 on reasoning (no
381+answer), cached_tokens 0, generation 20.1 → 18.3 → 14.6 tok/s and TTFT 0.45 → 1.08 s. Explained:
382+max_tokens too low for Qwen3.5's reasoning (script default now 4096, `--thinking-budget`, a message
383+when finish_reason is length with no answer); no cache reuse is expected — Qwen3.5 is hybrid
384+(recurrent state cannot be trimmed), as documented. Not explained yet: the slowdown across runs
385+(thermal? memory pressure? something accumulating in the server?) — asked the user for the chip and
386+a comparison run. Idea not ticketed yet: checkpoint the recurrent state at the end of the prompt
387+so hybrid models can reuse it (llama.cpp does this).
@@ -374,3 +374,14 @@ User runs `rzb serve --host 0.0.0.0` and wants to test mlx-community/Qwen3.5-9B-
374 reasoning dimmed, TTFT / time to answer / decode tokens/s / overall throughput / cached tokens,374 reasoning dimmed, TTFT / time to answer / decode tokens/s / overall throughput / cached tokens,
375 --no-think, --runs) and its README; listed in the root README. Tested on Linux against a375 --no-think, --runs) and its README; listed in the root README. Tested on Linux against a
376 fake-engine `rzb serve` (2 runs + unreachable server message); not run against the real model.376 fake-engine `rzb serve` (2 runs + unreachable server message); not run against the real model.
377+
378+## 2026-11-26 — demos/test-qwen: first real run on Qwen3.5-9B
379+
380+User's run (3 runs, thinking on): every run spent the whole max_tokens 1024 on reasoning (no
381+answer), cached_tokens 0, generation 20.1 → 18.3 → 14.6 tok/s and TTFT 0.45 → 1.08 s. Explained:
382+max_tokens too low for Qwen3.5's reasoning (script default now 4096, `--thinking-budget`, a message
383+when finish_reason is length with no answer); no cache reuse is expected — Qwen3.5 is hybrid
384+(recurrent state cannot be trimmed), as documented. Not explained yet: the slowdown across runs
385+(thermal? memory pressure? something accumulating in the server?) — asked the user for the chip and
386+a comparison run. Idea not ticketed yet: checkpoint the recurrent state at the end of the prompt
387+so hybrid models can reuse it (llama.cpp does this).
modified .quality/history.jsonl +1 -0
@@ -31,3 +31,4 @@
3131 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "fe0695f", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 546, "cyclo": 604, "fields": 1209, "funcs": 582, "lcom": 115, "lines": 10669, "loc": 8492}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 31, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:11:39Z"}
3232 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "6e6d79e", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 32, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:29:39Z"}
3333 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "83271da", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 33, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T14:05:13Z"}
34+{"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "f95af71", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 34, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T14:17:19Z"}
@@ -31,3 +31,4 @@
31 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "fe0695f", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 546, "cyclo": 604, "fields": 1209, "funcs": 582, "lcom": 115, "lines": 10669, "loc": 8492}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 31, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:11:39Z"}31 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "fe0695f", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 546, "cyclo": 604, "fields": 1209, "funcs": 582, "lcom": 115, "lines": 10669, "loc": 8492}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 31, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:11:39Z"}
32 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "6e6d79e", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 32, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:29:39Z"}32 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "6e6d79e", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 32, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T07:29:39Z"}
33 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "83271da", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 33, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T14:05:13Z"}33 {"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "83271da", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 33, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T14:05:13Z"}
34+{"branch": "feature/v0.2-openai-server", "breaches": [], "commit": "f95af71", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 234, "complex": 547, "cyclo": 605, "fields": 1210, "funcs": 583, "lcom": 115, "lines": 10687, "loc": 8507}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 34, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-26T14:17:19Z"}
added .quality/report-20261126T141719Z.md +73 -0
new file mode 100644
@@ -0,0 +1,73 @@
1+# Quality report — 2026-11-26T14:17:19Z
2+
3+- **Gate**: ✅ **PASS**
4+- **Commit**: `f95af71` on `feature/v0.2-openai-server`
5+- **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6+- **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7+- **Run**: #34 (previous: 2026-11-26T14:05:13Z)
8+
9+## Lint issues (`qlty check`)
10+
11+_none_
12+
13+### Top rules
14+
15+_none_
16+
17+### Most affected files
18+
19+_none_
20+
21+## Code smells (`qlty smells`)
22+
23+Total: **0** (vs previous: ±0)
24+
25+_none_
26+
27+## Metrics (`qlty metrics`)
28+
29+| metric | total | vs previous |
30+|---|---|---|
31+| funcs | 583 | ±0 |
32+| classes | 234 | ±0 |
33+| fields | 1210 | ±0 |
34+| cyclo | 605 | ±0 |
35+| complex | 547 | ±0 |
36+| lcom | 115 | ±0 |
37+| lines | 10687 | ±0 |
38+| loc | 8507 | ±0 |
39+
40+### Most complex files
41+
42+| file | complex | cyclo | loc |
43+|---|---|---|---|
44+| Sources/RazorbillServer/CompletionsRoute.swift | 47 | 20 | 242 |
45+| Sources/RazorbillServer/Chat/CompletionStream.swift | 31 | 20 | 125 |
46+| experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
47+| Sources/RazorbillMLX/MLXEngine.swift | 23 | 35 | 246 |
48+| tools/host-runner/host_runner.py | 22 | 22 | 141 |
49+| Sources/RazorbillCore/Config/ConfigValue+JSON.swift | 20 | 25 | 71 |
50+| Sources/RazorbillCore/Config/ServerConfigLoader.swift | 20 | 17 | 227 |
51+| Sources/RazorbillServer/Chat/ToolsAndFormats.swift | 18 | 30 | 170 |
52+| Sources/RazorbillServer/Chat/ChatCompletionRequest.swift | 17 | 24 | 276 |
53+| Sources/RazorbillServer/Chat/ChatCompletionChunk.swift | 16 | 11 | 137 |
54+| Sources/RazorbillServer/ModelManager.swift | 16 | 22 | 220 |
55+| Sources/RazorbillCore/Config/OrderedJSONReader.swift | 15 | 24 | 140 |
56+| Sources/RazorbillCore/Config/GenerationOverrides.swift | 14 | 15 | 67 |
57+| Sources/RazorbillCLI/Commands/ModelsCommand.swift | 13 | 7 | 100 |
58+| Sources/RazorbillServer/EmbeddingsRoute.swift | 13 | 13 | 143 |
59+
60+## Trend
61+
62+| run | timestamp | error | warning | smells | complex | gate |
63+|---|---|---|---|---|---|---|
64+| 25 | 2026-11-25T21:37:51Z | 0 | 1 | 0 | 544 | FAIL |
65+| 26 | 2026-11-25T21:38:24Z | 0 | 0 | 0 | 544 | PASS |
66+| 27 | 2026-11-25T22:01:44Z | 0 | 0 | 0 | 546 | PASS |
67+| 28 | 2026-11-25T22:03:59Z | 0 | 0 | 0 | 546 | PASS |
68+| 29 | 2026-11-26T04:34:58Z | 0 | 0 | 0 | 546 | PASS |
69+| 30 | 2026-11-26T05:21:18Z | 0 | 0 | 0 | 546 | PASS |
70+| 31 | 2026-11-26T07:11:39Z | 0 | 0 | 0 | 546 | PASS |
71+| 32 | 2026-11-26T07:29:39Z | 0 | 0 | 0 | 547 | PASS |
72+| 33 | 2026-11-26T14:05:13Z | 0 | 0 | 0 | 547 | PASS |
73+| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
new file mode 100644
@@ -0,0 +1,73 @@
1+# Quality report — 2026-11-26T14:17:19Z
2+
3+- **Gate**: ✅ **PASS**
4+- **Commit**: `f95af71` on `feature/v0.2-openai-server`
5+- **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6+- **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7+- **Run**: #34 (previous: 2026-11-26T14:05:13Z)
8+
9+## Lint issues (`qlty check`)
10+
11+_none_
12+
13+### Top rules
14+
15+_none_
16+
17+### Most affected files
18+
19+_none_
20+
21+## Code smells (`qlty smells`)
22+
23+Total: **0** (vs previous: ±0)
24+
25+_none_
26+
27+## Metrics (`qlty metrics`)
28+
29+| metric | total | vs previous |
30+|---|---|---|
31+| funcs | 583 | ±0 |
32+| classes | 234 | ±0 |
33+| fields | 1210 | ±0 |
34+| cyclo | 605 | ±0 |
35+| complex | 547 | ±0 |
36+| lcom | 115 | ±0 |
37+| lines | 10687 | ±0 |
38+| loc | 8507 | ±0 |
39+
40+### Most complex files
41+
42+| file | complex | cyclo | loc |
43+|---|---|---|---|
44+| Sources/RazorbillServer/CompletionsRoute.swift | 47 | 20 | 242 |
45+| Sources/RazorbillServer/Chat/CompletionStream.swift | 31 | 20 | 125 |
46+| experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
47+| Sources/RazorbillMLX/MLXEngine.swift | 23 | 35 | 246 |
48+| tools/host-runner/host_runner.py | 22 | 22 | 141 |
49+| Sources/RazorbillCore/Config/ConfigValue+JSON.swift | 20 | 25 | 71 |
50+| Sources/RazorbillCore/Config/ServerConfigLoader.swift | 20 | 17 | 227 |
51+| Sources/RazorbillServer/Chat/ToolsAndFormats.swift | 18 | 30 | 170 |
52+| Sources/RazorbillServer/Chat/ChatCompletionRequest.swift | 17 | 24 | 276 |
53+| Sources/RazorbillServer/Chat/ChatCompletionChunk.swift | 16 | 11 | 137 |
54+| Sources/RazorbillServer/ModelManager.swift | 16 | 22 | 220 |
55+| Sources/RazorbillCore/Config/OrderedJSONReader.swift | 15 | 24 | 140 |
56+| Sources/RazorbillCore/Config/GenerationOverrides.swift | 14 | 15 | 67 |
57+| Sources/RazorbillCLI/Commands/ModelsCommand.swift | 13 | 7 | 100 |
58+| Sources/RazorbillServer/EmbeddingsRoute.swift | 13 | 13 | 143 |
59+
60+## Trend
61+
62+| run | timestamp | error | warning | smells | complex | gate |
63+|---|---|---|---|---|---|---|
64+| 25 | 2026-11-25T21:37:51Z | 0 | 1 | 0 | 544 | FAIL |
65+| 26 | 2026-11-25T21:38:24Z | 0 | 0 | 0 | 544 | PASS |
66+| 27 | 2026-11-25T22:01:44Z | 0 | 0 | 0 | 546 | PASS |
67+| 28 | 2026-11-25T22:03:59Z | 0 | 0 | 0 | 546 | PASS |
68+| 29 | 2026-11-26T04:34:58Z | 0 | 0 | 0 | 546 | PASS |
69+| 30 | 2026-11-26T05:21:18Z | 0 | 0 | 0 | 546 | PASS |
70+| 31 | 2026-11-26T07:11:39Z | 0 | 0 | 0 | 546 | PASS |
71+| 32 | 2026-11-26T07:29:39Z | 0 | 0 | 0 | 547 | PASS |
72+| 33 | 2026-11-26T14:05:13Z | 0 | 0 | 0 | 547 | PASS |
73+| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
modified .quality/report-latest.md +4 -4
@@ -1,10 +1,10 @@
1-# Quality report — 2026-11-26T14:05:13Z
1+# Quality report — 2026-11-26T14:17:19Z
22
33 - **Gate**: ✅ **PASS**
4-- **Commit**: `83271da` on `feature/v0.2-openai-server`
4+- **Commit**: `f95af71` on `feature/v0.2-openai-server`
55 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
66 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7-- **Run**: #33 (previous: 2026-11-26T07:29:39Z)
7+- **Run**: #34 (previous: 2026-11-26T14:05:13Z)
88
99 ## Lint issues (`qlty check`)
1010
@@ -61,7 +61,6 @@ _none_
6161
6262 | run | timestamp | error | warning | smells | complex | gate |
6363 |---|---|---|---|---|---|---|
64-| 24 | 2026-11-25T21:37:24Z | 0 | 1 | 1 | 559 | FAIL |
6564 | 25 | 2026-11-25T21:37:51Z | 0 | 1 | 0 | 544 | FAIL |
6665 | 26 | 2026-11-25T21:38:24Z | 0 | 0 | 0 | 544 | PASS |
6766 | 27 | 2026-11-25T22:01:44Z | 0 | 0 | 0 | 546 | PASS |
@@ -71,3 +70,4 @@ _none_
7170 | 31 | 2026-11-26T07:11:39Z | 0 | 0 | 0 | 546 | PASS |
7271 | 32 | 2026-11-26T07:29:39Z | 0 | 0 | 0 | 547 | PASS |
7372 | 33 | 2026-11-26T14:05:13Z | 0 | 0 | 0 | 547 | PASS |
73+| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
@@ -1,10 +1,10 @@
1-# Quality report — 2026-11-26T14:05:13Z1+# Quality report — 2026-11-26T14:17:19Z
2 2
3 - **Gate**: ✅ **PASS**3 - **Gate**: ✅ **PASS**
4-- **Commit**: `83271da` on `feature/v0.2-openai-server`4+- **Commit**: `f95af71` on `feature/v0.2-openai-server`
5 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)5 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)6 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7-- **Run**: #33 (previous: 2026-11-26T07:29:39Z)7+- **Run**: #34 (previous: 2026-11-26T14:05:13Z)
8 8
9 ## Lint issues (`qlty check`)9 ## Lint issues (`qlty check`)
10 10
@@ -61,7 +61,6 @@ _none_
61 61
62 | run | timestamp | error | warning | smells | complex | gate |62 | run | timestamp | error | warning | smells | complex | gate |
63 |---|---|---|---|---|---|---|63 |---|---|---|---|---|---|---|
64-| 24 | 2026-11-25T21:37:24Z | 0 | 1 | 1 | 559 | FAIL |
65 | 25 | 2026-11-25T21:37:51Z | 0 | 1 | 0 | 544 | FAIL |64 | 25 | 2026-11-25T21:37:51Z | 0 | 1 | 0 | 544 | FAIL |
66 | 26 | 2026-11-25T21:38:24Z | 0 | 0 | 0 | 544 | PASS |65 | 26 | 2026-11-25T21:38:24Z | 0 | 0 | 0 | 544 | PASS |
67 | 27 | 2026-11-25T22:01:44Z | 0 | 0 | 0 | 546 | PASS |66 | 27 | 2026-11-25T22:01:44Z | 0 | 0 | 0 | 546 | PASS |
@@ -71,3 +70,4 @@ _none_
71 | 31 | 2026-11-26T07:11:39Z | 0 | 0 | 0 | 546 | PASS |70 | 31 | 2026-11-26T07:11:39Z | 0 | 0 | 0 | 546 | PASS |
72 | 32 | 2026-11-26T07:29:39Z | 0 | 0 | 0 | 547 | PASS |71 | 32 | 2026-11-26T07:29:39Z | 0 | 0 | 0 | 547 | PASS |
73 | 33 | 2026-11-26T14:05:13Z | 0 | 0 | 0 | 547 | PASS |72 | 33 | 2026-11-26T14:05:13Z | 0 | 0 | 0 | 547 | PASS |
73+| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
modified demos/test-qwen/README.md +3 -2
@@ -31,7 +31,8 @@
3131 | `--url` | `$RZB_URL`, else `http://127.0.0.1:7920/v1` | Base URL of the server; from another machine, the Mac's address (`http://192.168.1.20:7920/v1`), never `0.0.0.0` |
3232 | `--model` | `mlx-community/Qwen3.5-9B-MLX-4bit` | Any model the server can load |
3333 | `--prompt`, `--system` | a short poem | The messages sent |
34-| `--max-tokens` | 1024 | Upper bound, reasoning included |
34+| `--max-tokens` | 4096 | Upper bound, reasoning included: Qwen3.5 often reasons for more than 1000 tokens, and a request that stops during the reasoning has no answer (the script says so) |
35+| `--thinking-budget` | none | Most reasoning tokens before the model must answer (razorbill's `thinking_budget` extension) |
3536 | `--temperature` | 0.7 | |
3637 | `--no-think` | off | Turns the reasoning off (`chat_template_kwargs.enable_thinking: false`) |
3738 | `--hide-reasoning` | off | Does not print the reasoning; it is still generated and counted |
@@ -56,4 +57,4 @@ overall throughput 28.6 tokens/s (first token wait included)
5657 - **Generation speed** is the decoding speed: tokens after the first one, divided by the time since the first one. This is the figure to compare between models.
5758 - **Time to first token** covers the prompt processing; on the first run it also covers loading the model into memory (several seconds for a 9B model).
5859 - Reasoning tokens are tokens too: a thinking model takes longer to start its answer, not to generate each token. Compare with `--no-think`.
59-- With `--runs 2` or more, **reused from the cache** shows the prompt tokens the server did not have to recompute ([prompt cache](../../docs/en/explanation/model-lifecycle.md#reusing-the-previous-prompt)).
60+- **Reused from the cache** counts the prompt tokens the server did not recompute because the previous request started the same way ([prompt cache](../../docs/en/explanation/model-lifecycle.md#reusing-the-previous-prompt)). It stays at 0 with Qwen3.5: it is a hybrid model whose recurrent state cannot be rewound, so the server starts each request from an empty cache. With an attention-only model, `--runs 2 --model mlx-community/Qwen3-4B-4bit` shows the prompt reused from the second run on.
@@ -31,7 +31,8 @@
31 | `--url` | `$RZB_URL`, else `http://127.0.0.1:7920/v1` | Base URL of the server; from another machine, the Mac's address (`http://192.168.1.20:7920/v1`), never `0.0.0.0` |31 | `--url` | `$RZB_URL`, else `http://127.0.0.1:7920/v1` | Base URL of the server; from another machine, the Mac's address (`http://192.168.1.20:7920/v1`), never `0.0.0.0` |
32 | `--model` | `mlx-community/Qwen3.5-9B-MLX-4bit` | Any model the server can load |32 | `--model` | `mlx-community/Qwen3.5-9B-MLX-4bit` | Any model the server can load |
33 | `--prompt`, `--system` | a short poem | The messages sent |33 | `--prompt`, `--system` | a short poem | The messages sent |
34-| `--max-tokens` | 1024 | Upper bound, reasoning included |34+| `--max-tokens` | 4096 | Upper bound, reasoning included: Qwen3.5 often reasons for more than 1000 tokens, and a request that stops during the reasoning has no answer (the script says so) |
35+| `--thinking-budget` | none | Most reasoning tokens before the model must answer (razorbill's `thinking_budget` extension) |
35 | `--temperature` | 0.7 | |36 | `--temperature` | 0.7 | |
36 | `--no-think` | off | Turns the reasoning off (`chat_template_kwargs.enable_thinking: false`) |37 | `--no-think` | off | Turns the reasoning off (`chat_template_kwargs.enable_thinking: false`) |
37 | `--hide-reasoning` | off | Does not print the reasoning; it is still generated and counted |38 | `--hide-reasoning` | off | Does not print the reasoning; it is still generated and counted |
@@ -56,4 +57,4 @@ overall throughput 28.6 tokens/s (first token wait included)
56 - **Generation speed** is the decoding speed: tokens after the first one, divided by the time since the first one. This is the figure to compare between models.57 - **Generation speed** is the decoding speed: tokens after the first one, divided by the time since the first one. This is the figure to compare between models.
57 - **Time to first token** covers the prompt processing; on the first run it also covers loading the model into memory (several seconds for a 9B model).58 - **Time to first token** covers the prompt processing; on the first run it also covers loading the model into memory (several seconds for a 9B model).
58 - Reasoning tokens are tokens too: a thinking model takes longer to start its answer, not to generate each token. Compare with `--no-think`.59 - Reasoning tokens are tokens too: a thinking model takes longer to start its answer, not to generate each token. Compare with `--no-think`.
59-- With `--runs 2` or more, **reused from the cache** shows the prompt tokens the server did not have to recompute ([prompt cache](../../docs/en/explanation/model-lifecycle.md#reusing-the-previous-prompt)).60+- **Reused from the cache** counts the prompt tokens the server did not recompute because the previous request started the same way ([prompt cache](../../docs/en/explanation/model-lifecycle.md#reusing-the-previous-prompt)). It stays at 0 with Qwen3.5: it is a hybrid model whose recurrent state cannot be rewound, so the server starts each request from an empty cache. With an attention-only model, `--runs 2 --model mlx-community/Qwen3-4B-4bit` shows the prompt reused from the second run on.
modified demos/test-qwen/test_qwen.py +14 -3
@@ -28,7 +28,10 @@ def parse_args() -> argparse.Namespace:
2828 parser.add_argument("--model", default="mlx-community/Qwen3.5-9B-MLX-4bit")
2929 parser.add_argument("--prompt", default="Write a short poem about a razorbill diving into the sea.")
3030 parser.add_argument("--system", default="You are a helpful assistant.")
31- parser.add_argument("--max-tokens", type=int, default=1024)
31+ parser.add_argument("--max-tokens", type=int, default=4096,
32+ help="upper bound on generated tokens, reasoning included (default: %(default)s)")
33+ parser.add_argument("--thinking-budget", type=int,
34+ help="most reasoning tokens before the model must answer (razorbill extension)")
3235 parser.add_argument("--temperature", type=float, default=0.7)
3336 parser.add_argument("--no-think", action="store_true", help="turn the model's reasoning off")
3437 parser.add_argument("--hide-reasoning", action="store_true",
@@ -41,9 +44,11 @@ def parse_args() -> argparse.Namespace:
4144 def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
4245 """Streams one answer; returns the timings and the token counts of the server's usage."""
4346 extra = {"chat_template_kwargs": {"enable_thinking": not args.no_think}}
47+ if args.thinking_budget is not None:
48+ extra["thinking_budget"] = args.thinking_budget
4449 start = time.perf_counter()
4550 first_token = first_answer = None
46- usage = None
51+ usage = finish = None
4752 in_reasoning = False
4853
4954 stream = client.chat.completions.create(
@@ -60,6 +65,7 @@ def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
6065 usage = chunk.usage
6166 if not chunk.choices:
6267 continue
68+ finish = chunk.choices[0].finish_reason or finish
6369 delta = chunk.choices[0].delta
6470 reasoning = getattr(delta, "reasoning_content", None) # razorbill's extension field
6571 if reasoning:
@@ -81,7 +87,7 @@ def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
8187 print(RESET if in_reasoning else "", end="")
8288 print("\n")
8389 return {"start": start, "first_token": first_token, "first_answer": first_answer, "end": end,
84- "usage": usage}
90+ "usage": usage, "finish": finish}
8591
8692
8793 def report(result: dict) -> None:
@@ -109,6 +115,11 @@ def report(result: dict) -> None:
109115 # The first token comes with the prompt processing: speed over the tokens after it.
110116 print(f"generation speed {(completion - 1) / decode:>8.1f} tokens/s")
111117 print(f"overall throughput {completion / total:>8.1f} tokens/s (first token wait included)")
118+ if result["finish"] == "length":
119+ print("stopped at --max-tokens" + (
120+ ": the reasoning used them all, so there is no answer. Raise --max-tokens, cap the"
121+ " reasoning with --thinking-budget, or use --no-think." if result["first_answer"] is None
122+ else "."))
112123
113124
114125 def main() -> int:
@@ -28,7 +28,10 @@ def parse_args() -> argparse.Namespace:
28 parser.add_argument("--model", default="mlx-community/Qwen3.5-9B-MLX-4bit")28 parser.add_argument("--model", default="mlx-community/Qwen3.5-9B-MLX-4bit")
29 parser.add_argument("--prompt", default="Write a short poem about a razorbill diving into the sea.")29 parser.add_argument("--prompt", default="Write a short poem about a razorbill diving into the sea.")
30 parser.add_argument("--system", default="You are a helpful assistant.")30 parser.add_argument("--system", default="You are a helpful assistant.")
31- parser.add_argument("--max-tokens", type=int, default=1024)31+ parser.add_argument("--max-tokens", type=int, default=4096,
32+ help="upper bound on generated tokens, reasoning included (default: %(default)s)")
33+ parser.add_argument("--thinking-budget", type=int,
34+ help="most reasoning tokens before the model must answer (razorbill extension)")
32 parser.add_argument("--temperature", type=float, default=0.7)35 parser.add_argument("--temperature", type=float, default=0.7)
33 parser.add_argument("--no-think", action="store_true", help="turn the model's reasoning off")36 parser.add_argument("--no-think", action="store_true", help="turn the model's reasoning off")
34 parser.add_argument("--hide-reasoning", action="store_true",37 parser.add_argument("--hide-reasoning", action="store_true",
@@ -41,9 +44,11 @@ def parse_args() -> argparse.Namespace:
41 def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:44 def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
42 """Streams one answer; returns the timings and the token counts of the server's usage."""45 """Streams one answer; returns the timings and the token counts of the server's usage."""
43 extra = {"chat_template_kwargs": {"enable_thinking": not args.no_think}}46 extra = {"chat_template_kwargs": {"enable_thinking": not args.no_think}}
47+ if args.thinking_budget is not None:
48+ extra["thinking_budget"] = args.thinking_budget
44 start = time.perf_counter()49 start = time.perf_counter()
45 first_token = first_answer = None50 first_token = first_answer = None
46- usage = None51+ usage = finish = None
47 in_reasoning = False52 in_reasoning = False
48 53
49 stream = client.chat.completions.create(54 stream = client.chat.completions.create(
@@ -60,6 +65,7 @@ def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
60 usage = chunk.usage65 usage = chunk.usage
61 if not chunk.choices:66 if not chunk.choices:
62 continue67 continue
68+ finish = chunk.choices[0].finish_reason or finish
63 delta = chunk.choices[0].delta69 delta = chunk.choices[0].delta
64 reasoning = getattr(delta, "reasoning_content", None) # razorbill's extension field70 reasoning = getattr(delta, "reasoning_content", None) # razorbill's extension field
65 if reasoning:71 if reasoning:
@@ -81,7 +87,7 @@ def stream_once(client: OpenAI, args: argparse.Namespace) -> dict:
81 print(RESET if in_reasoning else "", end="")87 print(RESET if in_reasoning else "", end="")
82 print("\n")88 print("\n")
83 return {"start": start, "first_token": first_token, "first_answer": first_answer, "end": end,89 return {"start": start, "first_token": first_token, "first_answer": first_answer, "end": end,
84- "usage": usage}90+ "usage": usage, "finish": finish}
85 91
86 92
87 def report(result: dict) -> None:93 def report(result: dict) -> None:
@@ -109,6 +115,11 @@ def report(result: dict) -> None:
109 # The first token comes with the prompt processing: speed over the tokens after it.115 # The first token comes with the prompt processing: speed over the tokens after it.
110 print(f"generation speed {(completion - 1) / decode:>8.1f} tokens/s")116 print(f"generation speed {(completion - 1) / decode:>8.1f} tokens/s")
111 print(f"overall throughput {completion / total:>8.1f} tokens/s (first token wait included)")117 print(f"overall throughput {completion / total:>8.1f} tokens/s (first token wait included)")
118+ if result["finish"] == "length":
119+ print("stopped at --max-tokens" + (
120+ ": the reasoning used them all, so there is no answer. Raise --max-tokens, cap the"
121+ " reasoning with --thinking-budget, or use --no-think." if result["first_answer"] is None
122+ else "."))
112 123
113 124
114 def main() -> int:125 def main() -> int: