@octocodeai/freellama-mcp-server 0.1.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,290 @@
1
+ # FreeLlama findings and open-source comparison
2
+
3
+ Reviewed on October 3, 2026, for developers and local-AI operators evaluating the `0.2.1` candidate.
4
+
5
+ ```mermaid
6
+ flowchart LR
7
+ Caller["Agent selects task controls and optional scope"] --> Core["FreeLlama qualifies model and checks resources"]
8
+ Core -->|"admitted"| Engine["Ollama loads models and executes inference"]
9
+ Core -->|"held"| Wait["Bounded queue or refusal"]
10
+ Wait -->|"resources recover"| Core
11
+ Engine --> Receipt["Routing, timing, and placement receipt"]
12
+ Receipt --> History["Commit successful scoped history"]
13
+ ```
14
+
15
+ The diagram describes managed tasks. Raw Ollama API requests retain the primary-backend compatibility path.
16
+
17
+ **Feature and logic assessment: 8.5/10 for local Ollama agent workflows.**
18
+ The [feature assessment](#feature-and-logic-assessment) excludes speed, utilization, thermal measurements, packaging, and release readiness.
19
+ The earlier evidence-based control-plane assessment remains 8/10 under its broader rubric.
20
+ Real inference throughput, hardware efficiency, and sustained thermal behavior remain unqualified for this candidate on the latest Mac.
21
+ This review combines repository contracts, retained local receipts, an independent SOL examination, and primary project documentation.
22
+ It does not establish a speed ranking among projects.
23
+
24
+ ## What the findings establish
25
+
26
+ | Finding | Established behavior | Evidence boundary |
27
+ |---|---|---|
28
+ | Model discovery and qualification | FreeLlama checks installed models, capabilities, policy, and requested controls. | Model names alone do not establish fit, placement, or task quality. |
29
+ | Preview and execution | A preview returns a decision without submitting inference or reserving capacity. Execution checks admission again. | A preview does not reserve later admission. |
30
+ | Resource control | Managed tasks use weighted admission, bounded queues, deadlines, cancellation, and host resource holds. | This controls submitted work; it does not schedule hardware kernels or prove optimal utilization. |
31
+ | Per-task controls | Callers select model, task profile, runtime controls, priority, and placement requirements through supported contracts. | Ollama and its runners retain final execution authority. |
32
+ | CPU/GPU routing | Explicit assignments can direct eligible tasks to separate Ollama backends. Returned receipts distinguish configuration from observed residency. | Overlap remains unqualified for this candidate on the latest Mac; an older M4 measurement is summarized below. |
33
+ | Placement feedback | Runtime feedback uses bounded samples and comparable work units before changing a placement preference. | These checks do not establish optimal placement for every task or machine. |
34
+ | Independent work | Batches dispatch caller-declared independent tasks with bounded fairness. | FreeLlama does not infer task dependencies from prompts. |
35
+ | Scoped history | Scope IDs retain managed chat history, support forks, and reject stale revisions. Successful scoped execution commits history within storage limits. | Scope storage is process-local and does not own an engine KV cache. |
36
+ | Model affinity and warming | Sessions retain model affinity. Managed warming checks resources and requests residency from Ollama. | Cached context, future admission, and placement require separate checks. |
37
+ | Research delegation | Bounded adapters provide read-only code lookup, pagination, context fitting, repair, and repeat suppression. | The caller retains decomposition, judgment, mutation authority, and verification. An escalation result must be discarded. |
38
+ | Compatibility | Native Ollama APIs pass through to the primary upstream. | Managed routing contracts apply to managed calls. |
39
+
40
+ The architecture is coherent for agents that must decide whether local delegation is admissible.
41
+ Its value lies in explicit decisions, bounded execution, and inspectable evidence.
42
+ The reviewed receipts do not establish faster decoding or a universal model-quality improvement.
43
+
44
+ See [Architecture](../ARCHITECTURE.md), [CPU/GPU routing](../CPU_GPU_ROUTING.md),
45
+ [Scopes and warming](../SCOPES_AND_WARMING.md), and [MCP contracts](../../packages/mcp/README.md).
46
+
47
+ ## Warm models and separate task context
48
+
49
+ Warm models and scoped history solve separate problems.
50
+ Ollama supports preloading and `keep_alive` to retain a loaded model. [Ollama FAQ](https://docs.ollama.com/faq)
51
+ FreeLlama adds managed resource checks and receipts around those operations.
52
+
53
+ A scope retains application-level history for one task or related tasks.
54
+ A session records model affinity.
55
+ Neither handle reserves an Ollama runner or owns its KV cache.
56
+ Scope forks preserve independent histories, while revision checks prevent stale writes.
57
+ Model switching can reuse retained history without guaranteeing engine cache reuse.
58
+
59
+ These features can reduce repeated caller setup and cold loading for related work.
60
+ Their net benefit remains workload-dependent: retained history consumes context, and warm models consume memory.
61
+ Measure cold loading separately from warm execution before claiming a throughput improvement.
62
+ Use [Scopes and warming](../SCOPES_AND_WARMING.md) for the operation contract.
63
+
64
+ ## Repairs and audit findings
65
+
66
+ | Area | Completed repair or examination | Remaining limit |
67
+ |---|---|---|
68
+ | Research confinement | Confirmed writing and outside-workspace escapes were repaired. Valid quoted `jq`, bounded `sed`, and output-only `xargs` fixtures passed independently. | The checks are not a general proof for every internal behavior of each allowed program. |
69
+ | Agent context | Full observations remain available for pagination. Context fitting preserves pinned content, compacts older observations, and suppresses repeated execution. | Task accuracy must still be measured with representative questions and installed models. |
70
+ | MCP instructions | Contracts clarify preview payloads, error handling, opaque cursors, scope revisions, lifecycle approval, and research escalation. | The discovery-size gate measures a character-based estimate, not billed tokens or model reliability. |
71
+ | Health helper | Checks distinguish intentional ephemeral feedback, resource holds, and authenticated remote transport from contract errors. | Model metadata age does not establish last use. |
72
+ | Dependencies | Compatible updates resolved six reported advisories across three transitive dependencies during the audit. | Audit results describe the checked dependency set and available advisory database at that time. |
73
+ | Package contents | Gates check runtime files, adapters, both license texts, versions, and native artifacts across ten public npm packages. | Automatic optional-native selection from the published registry remains unqualified for this unpublished candidate. |
74
+ | Artifact assembly | Assembly validates all eight artifact pairs before replacing outputs and rejects unsafe output paths. | Compilation and binary headers do not prove foreign runtime execution. |
75
+ | Native artifacts | Two stale musl addons were rejected and replaced. All sixteen candidate artifacts received build, timestamp, architecture, and hash checks. | Foreign runtime and driver checks remain pending. |
76
+ | Registry gate | All ten exact `0.2.1` versions were absent during the read-only registry check. | The check neither reserves versions nor establishes account publication permissions. |
77
+ | Release workflow | CI precedes artifact builds; target checks load native addons, including an Alpine musl check. | Changed workflows were not executed remotely for this working-tree candidate. |
78
+ | Examples | The installer passed controlled checksum fixtures. The RAG example passed indexing and query plumbing with synthetic vectors. | Remote installation and real retrieval quality remain separate checks. |
79
+
80
+ Dependency resolutions changed to `fast-uri` 3.1.8, `hono` 4.13.12, and `ip-address` 10.7.3.
81
+ The final production and fresh-consumer audits reported zero advisories at that time.
82
+
83
+ The captured MCP surface contained eleven tools and 17,981 characters of instructions and tool definitions.
84
+ The existing gate estimated 4,495 tokens, compared with a baseline of 4,498.
85
+ This small reduction does not establish a meaningful inference or reliability improvement.
86
+
87
+ One full validation attempt recorded a ten-second launcher timeout.
88
+ Direct binary and launcher reruns completed in 31–61 ms, and the unchanged full validation passed afterward.
89
+ The timeout cause remains unclassified; repeated startup measurements are still needed.
90
+
91
+ An extra MCP confidence preflight remains a possible optimization.
92
+ It also protects older servers, so removal requires a compatibility decision and measured latency evidence.
93
+ Execution revalidation, resource sampling, and permit-release handoffs remain necessary boundaries.
94
+
95
+ See [Testing](../TESTING.md), [Production](../PRODUCTION.md), and [Release procedure](../../RELEASE.md) for their owning contracts.
96
+
97
+ ## Historical candidate verification
98
+
99
+ These results describe the retained prepublication audit snapshot, not a fresh validation of every subsequent repository edit.
100
+ Later logo and documentation changes occurred after the captured build and packed-consumer checks.
101
+ The new performance guide was absent from the examined package.
102
+ Run the current release gates again before publishing the changed candidate.
103
+
104
+ | Check | Captured result |
105
+ |---|---|
106
+ | Rust formatting, strict Clippy, release build, and native build | Passed |
107
+ | Rust tests | 386 passed |
108
+ | JavaScript unit tests | 152 passed |
109
+ | Python adapter and health-helper tests | 58 passed |
110
+ | Context and pagination assertions | 94 passed |
111
+ | Hardware harness contracts | 77 passed |
112
+ | Package and registry contracts | 40 passed |
113
+ | MCP integration | 111 passed; two real-inference cases skipped |
114
+ | End-to-end tests | Seven passed; four lifecycle or inference cases skipped |
115
+ | Separate control-timing and telemetry checks | Four passed |
116
+ | Packed consumer | Nineteen operation checks; thirty-six exact source-to-installed file matches |
117
+
118
+ Test counts establish exercised contracts, not physical performance or universal feature correctness.
119
+ Controlled upstream timings do not qualify real inference throughput.
120
+ The packed consumer installed the matching host native package explicitly because the candidate was unpublished.
121
+
122
+ An independent SOL examiner used the actual SDK with the packed MCP server.
123
+ It checked eleven tools, fifteen documentation resources, diagnosis, status, and empty job inventory.
124
+ All fourteen captured operator guides matched their source bytes at examination time.
125
+ The owned child process exited after the exam.
126
+
127
+ | Operation | One measured duration |
128
+ |---|---:|
129
+ | SDK initialization | 104.79 ms |
130
+ | Tool discovery | 10.55 ms |
131
+ | Resource discovery | 1.04 ms |
132
+ | Individual resource reads | 0.42–1.31 ms |
133
+ | Diagnosis summary | 292.82 ms |
134
+ | Status | 39.20 ms |
135
+ | Job inventory | 1.23 ms |
136
+ | Complete examination | 467.70 ms |
137
+
138
+ These durations describe one control-plane examination. They do not establish sustained latency or model throughput.
139
+
140
+ ## Earlier measured workloads
141
+
142
+ Earlier guides retain physical results from other snapshots and workloads.
143
+ They establish feasibility within their measured limits, not a fresh performance qualification for this candidate or Mac.
144
+
145
+ | Earlier measurement | Reported result | Boundary |
146
+ |---|---|---|
147
+ | Warmed CPU/GPU overlap on a 48 GB Apple M4 Pro | Three sequential trials: 34.586, 38.988, and 37.997 seconds. Three parallel trials: 27.499, 28.233, and 38.167 seconds. | Median speedup was 1.346 times; one parallel trial was slower. This is overlap feasibility, not sustained utilization. |
148
+ | Placement mismatch guard | An explicitly CPU-assigned Qwen runner still reported GPU residency. FreeLlama rejected feedback and a later request requiring observed placement. | Configured intent differs from physical evidence. |
149
+ | Grounded delegation context | Six questions used 59,208 source tokens and returned 1,742 tokens: 97.1% context offload. | One workload; returned-token reduction is not runtime or billed-cost savings. |
150
+ | Raw Ollama prefix reuse | A 2,462-token prefix took 18,631 ms cold, 281 ms warm, and 285 ms after another conversation interjected. | Engine cache reuse was observed on that path; scope IDs do not own or reserve it. |
151
+ | Structured versus Bash research | The documented thirty-question Qwen suite had equal pass rates, with about 2.8 times more time and 4.7 times more input tokens for Octocode. | A structured tool did not improve efficiency on that measured suite. |
152
+ | Code retrieval and judgment | Historical fixtures reported imperfect semantic-search recall and about 67% code-review accuracy. | Similarity and generated review findings require verification; they cannot authorize deletion or approve changes. |
153
+
154
+ See [the measured CPU/GPU result](../CPU_GPU_ROUTING.md#interpret-the-measured-mac-result),
155
+ [token economics](../ECONOMICS.md), [adapter caveats](../../benchmark/local/docs/07-adapter-contracts.md), and
156
+ [historical delegation evidence](../../skills/freellama/assets/evidence/task-delegation.md).
157
+ This review did not rerun those workloads or independently regrade their quality results.
158
+
159
+ ## Latest check on this Mac
160
+
161
+ The quick check started isolated, owned Ollama and FreeLlama services and inspected the approved installed embedding model.
162
+ Three route previews held under host memory pressure.
163
+ The check submitted zero inference requests and downloaded zero models.
164
+ Both owned services stopped after the examination.
165
+
166
+ | Observation | Measured result | Interpretation |
167
+ |---|---|---|
168
+ | Host | Apple M2 Pro, 32 GiB RAM, twelve logical CPUs | One machine, not cross-platform qualification |
169
+ | Available-memory estimate | About 5.050 GB during host sampling; 3.691 GB at the final preview | Admission remained held under the configured policy |
170
+ | Recovery reserve | 6.872 GB | A recovery threshold, not this model's measured allocation |
171
+ | Latest hold reason | `low_available_memory` | Normal OS memory-pressure status did not override FreeLlama's reserve |
172
+ | Swap counters | Zero swap-outs and eight swap-in pages in the final sampled interval | This interval does not establish an absence of swapping overall |
173
+ | GPU activity | Host samples of 28%, 33%, and 28% over about 2.4 seconds | Driver-defined activity across all processes; no FreeLlama attribution |
174
+ | Thermal, power, and energy | Unknown; `powermetrics` required administrator access | No temperature or thermal-efficiency result |
175
+ | Embedding model | `nomic-embed-text:v1.5`, installed size 274,302,450 bytes | Installation was verified; execution and physical placement were not qualified |
176
+ | Inference trials | Zero | No throughput, quality, or CPU/GPU overlap result |
177
+
178
+ Values marked GB use decimal gigabytes; the installed 32 GiB uses binary units.
179
+ Earlier audit observations also held admission under low memory and active swapping.
180
+ The latest check establishes resource refusal and cleanup, not an inference failure or a defective model.
181
+
182
+ Local receipts remain under ignored `.octocode/tmp/` paths:
183
+ `prepublish/final-audit.md`, `prepublish/final-test-counts.json`,
184
+ `prepublish/independent-packed-readonly.json`, `quick-local/receipt.json`, and `quick-local-host.json`.
185
+ They are local audit artifacts, not required installation files.
186
+ Use [Local performance testing](LOCAL_PERFORMANCE_TESTING.md) for the repeatable measurement procedure.
187
+
188
+ ## Comparison with open-source projects
189
+
190
+ Primary documentation was inspected on October 3, 2026.
191
+ This table compares documented roles and mechanisms; none of these projects received a common-hardware benchmark in this review.
192
+ Related projects can combine engine optimization, routing, and orchestration within their ecosystems.
193
+ The categories describe emphasis, not exclusive feature ownership.
194
+
195
+ | Project | Documented role and mechanisms | FreeLlama's position |
196
+ |---|---|---|
197
+ | [Ollama](https://docs.ollama.com/faq) | Local model runtime with residency controls, parallel requests, memory-dependent loading, and request queueing. | FreeLlama adds agent qualification, host admission, task scopes, and receipts around managed Ollama calls. |
198
+ | [llama.cpp server](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) | Inference server with parallel slots, continuous batching, GPU offload, and slot prompt-cache save/restore. | FreeLlama scopes store application history with revisions and forks; engine prompt-cache snapshots store a different kind of state. Direct llama.cpp integration requires separate engineering and qualification. |
199
+ | [vLLM](https://github.com/vllm-project/vllm) | Inference serving with PagedAttention, continuous batching, prefix caching, and distributed parallelism. | FreeLlama `0.2.1` targets Ollama; it does not implement these engine mechanisms or qualify a direct vLLM backend. |
200
+ | [SGLang](https://github.com/sgl-project/sglang) | Inference serving for language and multimodal models. Its ecosystem includes hierarchical KV caching and deployment gateways. | FreeLlama focuses on bounded local delegation over Ollama. SGLang illustrates engine and deployment capabilities beyond that current integration. |
201
+ | [LiteLLM Router](https://docs.litellm.ai/docs/routing) | Deployment routing supports weighted selection, least-busy, latency and cost strategies, session affinity, retries, fallbacks, and usage limits. | Both projects have routing and affinity concepts. FreeLlama focuses on installed Ollama eligibility, host admission, scoped history, and observed placement. |
202
+ | [RouteLLM](https://github.com/lm-sys/RouteLLM) | Trained prompt routers select stronger or weaker models using calibrated quality-cost thresholds. | FreeLlama uses explicit policy and available evidence for local eligibility. Adding learned prompt routing requires a separate quality dataset and evaluation. |
203
+
204
+ **Positioning judgment:** FreeLlama is a specialized control plane for developer agents operating local Ollama workloads.
205
+ It is complementary to Ollama and narrower than general provider gateways or inference frameworks.
206
+ Its most defensible contribution is an explicit delegation contract that combines admission, task history, and verifiable receipts.
207
+ Competitive advantage in useful throughput remains a hypothesis requiring matched real workloads.
208
+
209
+ Ollama already owns warming and runtime scheduling.
210
+ FreeLlama must demonstrate additional workload value rather than claim these mechanisms as unique inventions.
211
+ Engine-level batching, cache reuse, and device execution should remain engine responsibilities unless a measured integration justifies a change.
212
+ See [Product positioning](../PRODUCT_POSITIONING.md) for the audience and product boundaries.
213
+
214
+ ## Feature and logic assessment
215
+
216
+ This assessment answers the feature-only comparison requested after the broader audit.
217
+ It uses reviewed contracts and documented mechanisms, excluding performance, hardware measurements, packaging, and publication readiness.
218
+ Scores are subjective design judgments for developer agents using local Ollama workloads.
219
+ They do not rank the other projects by a purpose they were not designed to serve.
220
+
221
+ | Dimension | Score | Reason and limit |
222
+ |---|---:|---|
223
+ | Agent workflow and authority | 9/10 | Preview, qualification, explicit controls, bounded delegation, and error handling form a clear contract. The caller still owns task dependencies and judgment. |
224
+ | Admission and execution logic | 8.5/10 | Weighted fairness, resource holds, deadlines, cancellation, and execution revalidation compose coherently. Operator policy and memory estimates remain part of admission. |
225
+ | Task context and residency | 8.5/10 | Revisions, forks, finite history, affinity, and warming have separate ownership. Scopes and deferred jobs do not survive a service restart. |
226
+ | Adaptive decisions | 7.5/10 | Comparable observed feedback can influence eligible backend choices without overriding explicit controls. It is not a learned prompt-quality router or general hardware scheduler. |
227
+ | Explanation and evidence | 9/10 | Receipts distinguish eligibility, configured placement, observed placement, and feedback acceptance. Engine cache state remains outside scope ownership. |
228
+
229
+ Each dimension carries equal weight: the average is **8.5/10**.
230
+ A score of 10 requires complete, coherent behavior within this stated purpose, including lifecycle and recovery semantics.
231
+ Additional features count only when they improve that purpose; engine responsibilities need not move into FreeLlama.
232
+
233
+ ### Decision logic compared directly
234
+
235
+ | Decision | FreeLlama's mechanism | Related project mechanism |
236
+ |---|---|---|
237
+ | Which model or deployment? | Qualify installed candidates against task, capability, context, policy, and evidence requirements. | [RouteLLM](https://github.com/lm-sys/RouteLLM) uses trained prompt routers and calibrated strong/weak thresholds. [LiteLLM](https://docs.litellm.ai/docs/routing) offers multiple deployment-selection strategies. |
238
+ | Can work start? | Check weighted capacity and host resources; queue, refuse, or execute within bounded deadlines. | [Ollama](https://docs.ollama.com/faq) manages runtime loading and queues requests when models cannot load. Its runtime checks complement FreeLlama's admission checks. |
239
+ | What context survives a switch? | Replay bounded application history through scope IDs; fork histories and reject stale writes. | [llama.cpp](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md) can save and restore slot prompt caches. Application history and engine cache snapshots are different contracts. |
240
+ | How are active requests scheduled inside a model? | Submit admitted requests through Ollama and leave engine scheduling to the runner. | [vLLM](https://github.com/vllm-project/vllm) implements continuous batching, PagedAttention, and prefix caching. [SGLang's ecosystem](https://github.com/sgl-project/sglang) includes hierarchical KV caching and deployment gateways. |
241
+ | When can adaptation override a preference? | Only comparable eligible feedback can influence automatic choices; explicit model, affinity, and policy retain authority. | [LiteLLM](https://docs.litellm.ai/docs/routing) supports latency, cost, load, and custom routing strategies. [RouteLLM](https://github.com/lm-sys/RouteLLM) calibrates query-level quality-cost tradeoffs. |
242
+
243
+ **Judgment:** FreeLlama offers a strong combination of local agent controls, context ownership, and evidence semantics.
244
+ Its current specialization is narrower than provider gateways and separate from inference-engine optimization.
245
+ The comparison establishes feature differences; it does not establish exclusive capabilities or global superiority.
246
+
247
+ Three feature gaps limit the score:
248
+
249
+ 1. **Restart recovery:** scopes and deferred jobs are process-local. Optional durable storage needs explicit privacy, expiry, and recovery contracts.
250
+ 2. **Task-quality adaptation:** backend timing feedback does not learn prompt-specific answer quality across models.
251
+ 3. **Backend breadth:** direct llama.cpp, vLLM, and SGLang integrations need adapters that preserve controls, cancellation, and evidence semantics.
252
+
253
+ These are potential extensions, not confirmed correctness defects or authorization to implement them.
254
+ The strongest priority depends on whether users need long-lived tasks, quality-based selection, or additional inference backends.
255
+
256
+ ## Historical assessment and remaining qualification work
257
+
258
+ The independent SOL judge retained the overall **8/10** rating after inspecting the latest receipts.
259
+ This is a judgment of the bounded control plane, not a weighted average or a hardware-performance score.
260
+
261
+ | Dimension | Rating | Basis |
262
+ |---|---:|---|
263
+ | Architecture | 8/10 | Clear ownership and execution boundaries; optimization decisions still need workload evidence |
264
+ | Agent contracts | 8.5/10 | Explicit shapes, authority, error handling, and evidence semantics; measured agent reliability remains incomplete |
265
+ | Documentation | 8/10 | Operational guides and examples; this review corrects a stale MCP tool count |
266
+ | Package engineering | 8.5/10 | Historical artifact, integrity, and consumer checks; current release and foreign execution checks remain pending |
267
+ | Real throughput evidence completeness | 3/10 | Harnesses and controlled checks exist; no admissible matched real-inference trial in the latest qualification |
268
+ | Hardware-utilization evidence completeness | 3/10 | Host telemetry exists; no attributed sustained inference, verified device overlap, or thermal qualification for this candidate on the latest Mac |
269
+
270
+ Evidence-completeness scores describe measurement coverage, not slow execution or poor utilization.
271
+ The earlier 7/10 and 6/10 evidence ratings overstated qualification relative to the retained physical receipts.
272
+ For this rubric, 3 means instrumentation and contracts exist; 5 requires a real pilot; 7 requires repeated matched trials.
273
+ A score of 9 requires sustained, attributable results across representative workloads and documented operating limits.
274
+ A score of 10 also requires reproducibility beyond this single host.
275
+
276
+ The following evidence is needed before increasing the ratings:
277
+
278
+ 1. Run matched direct-Ollama and managed trials under an admissible host with identical models, inputs, context, concurrency, and residency.
279
+ 2. Measure correct requests per minute, aggregate tokens per second, failures, queue waits, and p50/p95 latency against declared limits.
280
+ 3. Separate cold loading from warm execution, then increase concurrency to locate useful saturation rather than maximum busy time.
281
+ 4. Verify CPU/GPU overlap with observed placement and actual runner telemetry. Attribute activity wherever the platform permits.
282
+ 5. Capture sustained early and late throughput, clocks, thermal pressure, and available power telemetry. Record missing temperature readings explicitly.
283
+ 6. Repeat startup measurements and investigate the unclassified ten-second timeout.
284
+ 7. Rerun current release gates and fresh packed-consumer checks after all edits. Execute foreign native and installer checks on target runtimes.
285
+ 8. Evaluate research accuracy and context retention on held-out tasks. Use identical workloads before making competitor performance claims.
286
+
287
+ Use [Local performance testing](LOCAL_PERFORMANCE_TESTING.md) and the
288
+ [hardware benchmark contracts](../../benchmark/hardware/README.md) for measurement.
289
+ Use the [local adapter benchmark](../../benchmark/local/README.md) for research quality.
290
+ The [release procedure](../../RELEASE.md) owns publication readiness.
@@ -0,0 +1,298 @@
1
+ # Test throughput, CPU/GPU activity, and thermal behavior on macOS
2
+
3
+ Use this procedure to measure the resource-management cost and benefit of offloading tasks
4
+ through FreeLlama on your Mac. It compares direct and managed Ollama execution for useful output,
5
+ request latency, device activity, and thermal behavior under a declared workload.
6
+ Run every command from the repository root.
7
+
8
+ ```mermaid
9
+ flowchart TD
10
+ Prepare["Prepare services and fixed inputs"] --> Ready{"Resource checks clear?"}
11
+ Ready -->|"No"| Wait["Free resources, wait, and check again"]
12
+ Wait --> Ready
13
+ Ready -->|"Yes"| Warm["Warm exact model and verify placement"]
14
+ Warm --> Capture["Start host and thermal capture"]
15
+ Capture --> Trials["Run matched direct and managed trials"]
16
+ Trials --> Review["Check correctness, latency, activity, and pressure"]
17
+ Review --> Next{"Another concurrency setting?"}
18
+ Next -->|"Yes"| Prepare
19
+ Next -->|"No"| Cleanup["Retain receipts and stop owned services"]
20
+ ```
21
+
22
+ Each result applies to the measured model, workload, configuration, and machine.
23
+
24
+ ## 1. Prepare the machine and inputs
25
+
26
+ Connect mains power and keep the cooling environment consistent.
27
+ Close unused applications and heavy builds.
28
+ Record the macOS version, hardware, Ollama version, model digest, context, output limit, and concurrency.
29
+ Use independently checked expected answers and representative input lengths.
30
+ Choose latency and overhead limits before running the test.
31
+
32
+ Do not disable resource admission to obtain a passing result.
33
+ An active swapping or memory-pressure hold means the machine needs preparation before inference.
34
+ Existing swap occupancy alone does not prove current swapping; inspect counter changes.
35
+
36
+ Create a directory for this experiment:
37
+
38
+ ```bash
39
+ mkdir -p .octocode/hardware/local-test
40
+ ```
41
+
42
+ The earlier local audit prepared eight OCR cases under `.octocode/tmp/throughput-qualification/heldout-eight/`.
43
+ If that directory exists, copy its inputs:
44
+
45
+ ```bash
46
+ cp .octocode/tmp/throughput-qualification/heldout-eight/workload.json \
47
+ .octocode/tmp/throughput-qualification/heldout-eight/comparison.json \
48
+ .octocode/tmp/throughput-qualification/heldout-eight/*.png \
49
+ .octocode/hardware/local-test/
50
+ ```
51
+
52
+ Those ignored fixtures are absent from a clean checkout and published packages.
53
+ If they are absent, create a workload using the [hardware manifest example](../../benchmark/hardware/README.md#measure-a-useful-gpu-workload).
54
+ Supply at least two distinct cases with independently checked expected answers.
55
+ Image paths resolve relative to the workload file.
56
+ For text generation, omit images and select a supported text task.
57
+ Do not change expected answers to make a model pass.
58
+
59
+ Inspect `workload.json` before using the example commands below.
60
+ They assume the prepared OCR model `glm-ocr:latest`, concurrency `2`, and context `4096`.
61
+ Confirm the exact tag is installed; its name does not prove installation or memory fit.
62
+ This procedure never authorizes a model download.
63
+
64
+ Create `comparison.json` beside the workload if it is missing:
65
+
66
+ ```json
67
+ {
68
+ "schema_version": 1,
69
+ "workload": "workload.json",
70
+ "repeats_per_phase": 20,
71
+ "minimum_measured_seconds": 120,
72
+ "maximum_overhead_ratio": 1.15,
73
+ "latency_slo_ms": 500
74
+ }
75
+ ```
76
+
77
+ These are example limits, not universal performance targets.
78
+ Select limits appropriate to your workload before inference.
79
+ The runner performs at least three alternating direct/managed pairs.
80
+ Its repeated cases increase timing samples, not the number of independent quality cases.
81
+
82
+ ## 2. Start isolated services
83
+
84
+ Use unused loopback ports and dedicated terminals.
85
+ Do not reuse a running production service for this experiment.
86
+ If necessary, build the local CLI with `yarn build:rust`.
87
+
88
+ In terminal A, start Ollama:
89
+
90
+ ```bash
91
+ OLLAMA_HOST=127.0.0.1:11439 \
92
+ OLLAMA_NO_CLOUD=1 \
93
+ OLLAMA_NUM_PARALLEL=2 \
94
+ OLLAMA_MAX_LOADED_MODELS=1 \
95
+ OLLAMA_CONTEXT_LENGTH=4096 \
96
+ ollama serve
97
+ ```
98
+
99
+ Set `OLLAMA_NUM_PARALLEL` to the workload's concurrency before starting Ollama.
100
+ The comparison requires an observed process setting, not an inferred default.
101
+
102
+ Create `.octocode/hardware/local-test/runtime.toml`:
103
+
104
+ ```toml
105
+ context_mode = "explicit"
106
+ adaptive_concurrency = "off"
107
+ ```
108
+
109
+ In terminal B, start the gateway:
110
+
111
+ ```bash
112
+ ./target/release/freellama serve \
113
+ --listen 127.0.0.1:11438 \
114
+ --upstream http://127.0.0.1:11439 \
115
+ --max-concurrent-tasks 8 \
116
+ --runtime-config .octocode/hardware/local-test/runtime.toml \
117
+ --ephemeral-feedback \
118
+ --ephemeral-usage
119
+ ```
120
+
121
+ This sample freezes adaptive concurrency for a controlled comparison.
122
+ The eight-unit budget permits two default four-unit vision tasks, subject to resource checks.
123
+ It is an experiment setting, not a recommended production default.
124
+ Record it, and test deployment defaults separately.
125
+ For another task or concurrency, choose a matching weighted budget using the [routing guide](../CPU_GPU_ROUTING.md).
126
+
127
+ If you enable gateway authentication, supply `--auth-token-file` to the gateway and each benchmark runner.
128
+ Keep tokens out of manifests and telemetry logs.
129
+
130
+ ## 3. Check admission and warm the model
131
+
132
+ Inspect current gateway health and status:
133
+
134
+ ```bash
135
+ curl --fail --silent --show-error http://127.0.0.1:11438/_freellama/v1/health
136
+ curl --fail --silent --show-error http://127.0.0.1:11438/_freellama/v1/status
137
+ OLLAMA_HOST=127.0.0.1:11439 ollama list
138
+ ```
139
+
140
+ Require an idle backend, fresh host observations, and normal memory pressure.
141
+ Wait until resource holds clear before warming.
142
+ The comparison runner independently validates its supported resource conditions.
143
+ Treat a refusal as a diagnostic result, not throughput evidence.
144
+
145
+ Warm the exact installed profile:
146
+
147
+ ```bash
148
+ ./target/release/freellama warm \
149
+ --endpoint http://127.0.0.1:11438 \
150
+ --model glm-ocr:latest \
151
+ --task vision \
152
+ --context-tokens 4096 \
153
+ --execution-preference prefer-gpu \
154
+ --min-placement-evidence configured \
155
+ --keep-alive 300s \
156
+ --timeout-seconds 60
157
+ OLLAMA_HOST=127.0.0.1:11439 ollama ps
158
+ ```
159
+
160
+ Review the warm receipt's placement observation.
161
+ The initial configured requirement permits a cold load; the comparison requires verified GPU residency afterward.
162
+ Require the installed/resident digest and context to match the workload.
163
+ Start the benchmark before the warm keepalive expires.
164
+
165
+ The `100% GPU` label in `ollama ps` describes model placement.
166
+ It does not mean the GPU is busy for every instant. See the [Ollama FAQ](https://docs.ollama.com/faq).
167
+
168
+ ## 4. Capture telemetry while running inference
169
+
170
+ In terminal C, start a ten-minute macOS capture:
171
+
172
+ ```bash
173
+ sudo /usr/bin/powermetrics \
174
+ --samplers tasks,cpu_power,gpu_power,thermal \
175
+ --show-process-gpu \
176
+ -i 1000 -n 600 \
177
+ --output-file .octocode/hardware/local-test/power-thermal.txt
178
+ ```
179
+
180
+ Run this command yourself with administrator access.
181
+ On the inspected Mac, the unprivileged tool reports that it requires the superuser.
182
+ It captures available process activity, CPU/GPU clocks, estimated subsystem power, and thermal pressure.
183
+ The selected samplers may omit temperature readings in degrees Celsius.
184
+ If a sampler is unavailable, retain the error and report that measurement as unknown.
185
+
186
+ Run the [host sampler](../../benchmark/hardware/sample_host.py) in another terminal for memory and process observations.
187
+ Find the exact PIDs and executable paths for the owned gateway, Ollama server, and inference runners.
188
+ Repeat `--process PID=/absolute/executable` for those processes.
189
+ For example, replace both placeholders before execution:
190
+
191
+ ```bash
192
+ python3 benchmark/hardware/sample_host.py \
193
+ --process PID=/absolute/executable \
194
+ --duration-seconds 180 \
195
+ --interval-seconds 1 \
196
+ --output .octocode/hardware/local-test/host-observations.json
197
+ ```
198
+
199
+ The host sampler supports at most 180 seconds per invocation.
200
+ Use successive captures for a longer experiment, with separate output files.
201
+ Process CPU and RSS exclude children; include the actual runner processes.
202
+ In its interval CPU scale, 100% means one logical CPU.
203
+ RSS does not equal physical memory footprint.
204
+ GPU driver activity covers all processes; close unrelated GPU workloads and retain the idle baseline.
205
+ Subsystem power estimates do not establish per-task energy.
206
+
207
+ In terminal D, run the comparison:
208
+
209
+ ```bash
210
+ python3 benchmark/hardware/run_comparison.py \
211
+ --endpoint http://127.0.0.1:11438 \
212
+ --ollama-endpoint http://127.0.0.1:11439 \
213
+ --comparison .octocode/hardware/local-test/comparison.json \
214
+ --output .octocode/hardware/local-test/comparison-receipt.json
215
+ ```
216
+
217
+ Both paths use the same engine, logical payloads, context, and output controls.
218
+ The runner warms each path and shares the resident runner and prefix cache.
219
+ It does not establish independent cache states or measure time to first token.
220
+ Keep model, runtime settings, and goldens unchanged within a run.
221
+
222
+ ## 5. Read the results and check sustained behavior
223
+
224
+ Inspect `verdict`, `failures`, `completion`, and `performance` in the JSON receipt.
225
+ Accept a run only when every planned request completes correctly and the declared gates pass.
226
+ Keep rejected and incomplete receipts.
227
+
228
+ | Measurement | What to examine |
229
+ |---|---|
230
+ | Useful throughput | Correctness-qualified requests/minute and qualified output tokens/second |
231
+ | Responsiveness | Request wall latency p50/p95, sample counts, and latency-objective pass rate |
232
+ | Gateway overhead | Median paired managed/direct wall ratio; above one means extra duration |
233
+ | Waiting | Managed queue and total admission wait; direct queue breakdown remains unknown |
234
+ | Model execution | Load, prefill, and decode durations, with reported token counts |
235
+ | CPU/GPU activity | Process CPU, available GPU activity, and clocks during matched workload windows |
236
+ | Memory | Pressure, compressor occupancy, reservation levels, and swap-counter changes |
237
+ | Thermal behavior | Thermal pressure and clocks alongside early/late performance |
238
+
239
+ Small-sample p95 values are descriptive; retain their sample counts.
240
+ High CPU/GPU activity alone does not establish efficient execution.
241
+ Prefer higher correct throughput at the required latency, with acceptable resource and thermal behavior.
242
+
243
+ The copied example has a five-minute whole-run budget.
244
+ A ten-minute telemetry capture does not extend that workload.
245
+ For a sustained thermal experiment, freeze a separate plan before execution.
246
+ Choose enough cases/repeats for continuous measured work and an adequate `run_budget_seconds` in `workload.json`.
247
+ Set `minimum_measured_seconds` to the required measured duration, such as `600`.
248
+ The comparison rejects an unmet duration target; it does not automatically loop until that target.
249
+ Keep the plan within the runner's 10,000-request and 3,600-second whole-run limits.
250
+ Ensure telemetry overlaps the entire measured interval.
251
+
252
+ Compare early and late request windows at the same concurrency.
253
+ Interpret clock changes alongside thermal pressure and workload phase; clock variation alone does not prove thermal throttling.
254
+ If the host reports no thermal state, leave thermal status unknown.
255
+
256
+ Measure cold loading in a separate experiment before warming.
257
+ Retain load duration and total wall time without mixing them into the warm baseline.
258
+ To test another concurrency, create a separate plan and restart the owned Ollama with the matching parallelism.
259
+ Keep other settings comparable and record every change.
260
+ Higher parallelism can require more context-cache memory. See [Ollama concurrency settings](https://docs.ollama.com/faq).
261
+
262
+ ## 6. Test simultaneous CPU and GPU work separately
263
+
264
+ Configure a dedicated CPU upstream and exact CPU model assignment using the [CPU/GPU setup guide](../CPU_GPU_ROUTING.md).
265
+ Ensure both installed models can coexist under the resource policy.
266
+ Replace `EXACT_INSTALLED_GPU_TAG` with your qualified generation tag:
267
+
268
+ ```bash
269
+ python3 benchmark/hardware/run_validation.py \
270
+ --endpoint http://127.0.0.1:11438 \
271
+ --gpu-model EXACT_INSTALLED_GPU_TAG \
272
+ --cpu-model nomic-embed-text:v1.5 \
273
+ --trials 3 \
274
+ --minimum-speedup 1.05 \
275
+ --output .octocode/hardware/local-test/cpu-gpu-receipt.json
276
+ ```
277
+
278
+ Confirm `nomic-embed-text:v1.5` is installed and assigned to the CPU upstream first.
279
+ This runner warms both tasks and compares matched sequential/parallel pairs.
280
+ It requires observed CPU/GPU placement and correct responses.
281
+ The default 1.05 speedup gate is configurable; declare the chosen target before execution.
282
+ This short overlap check does not qualify sustained saturation or general model quality.
283
+
284
+ Use [fixed-arrival load tests](../../benchmark/hardware/README.md#check-fixed-arrival-load-and-queue-ownership) for burst and queue behavior.
285
+ Use real resident mode for physical measurements.
286
+ Synthetic controlled mode supplies no inference throughput or physical placement proof.
287
+
288
+ ## 7. Retain evidence and clean up
289
+
290
+ Keep input hashes, model/runtime identities, manifests, JSON receipts, telemetry, and failure logs together.
291
+ Record the workload interval so reviewers can align it with telemetry timestamps.
292
+ After pending jobs finish or cancel, stop only the services started for this experiment.
293
+ Use Ctrl-C in their dedicated terminals.
294
+ Verify no owned tasks or waiters remain before stopping the gateway.
295
+ An inference keepalive expiry or service stop does not delete installed models.
296
+
297
+ See the [hardware harness reference](../../benchmark/hardware/README.md) for schemas, bounds, and qualification details.
298
+ See [production checks](../PRODUCTION.md) for promotion requirements beyond this local experiment.