lemonmatrix 0.1.0__tar.gz

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.
Files changed (91) hide show
  1. lemonmatrix-0.1.0/LICENSE +201 -0
  2. lemonmatrix-0.1.0/MANIFEST.in +1 -0
  3. lemonmatrix-0.1.0/PKG-INFO +169 -0
  4. lemonmatrix-0.1.0/README.md +136 -0
  5. lemonmatrix-0.1.0/pyproject.toml +51 -0
  6. lemonmatrix-0.1.0/setup.cfg +4 -0
  7. lemonmatrix-0.1.0/src/lemonmatrix/__init__.py +8 -0
  8. lemonmatrix-0.1.0/src/lemonmatrix/backend_version.py +70 -0
  9. lemonmatrix-0.1.0/src/lemonmatrix/bench.py +2158 -0
  10. lemonmatrix-0.1.0/src/lemonmatrix/capabilities.py +320 -0
  11. lemonmatrix-0.1.0/src/lemonmatrix/cli.py +2127 -0
  12. lemonmatrix-0.1.0/src/lemonmatrix/client.py +545 -0
  13. lemonmatrix-0.1.0/src/lemonmatrix/discover.py +61 -0
  14. lemonmatrix-0.1.0/src/lemonmatrix/importers.py +233 -0
  15. lemonmatrix-0.1.0/src/lemonmatrix/profile.py +284 -0
  16. lemonmatrix-0.1.0/src/lemonmatrix/prompt_sets.py +52 -0
  17. lemonmatrix-0.1.0/src/lemonmatrix/results_store.py +540 -0
  18. lemonmatrix-0.1.0/src/lemonmatrix/routing_cost.py +179 -0
  19. lemonmatrix-0.1.0/src/lemonmatrix/schema/audiogen_result.schema.json +103 -0
  20. lemonmatrix-0.1.0/src/lemonmatrix/schema/classify_result.schema.json +101 -0
  21. lemonmatrix-0.1.0/src/lemonmatrix/schema/embeddings_result.schema.json +102 -0
  22. lemonmatrix-0.1.0/src/lemonmatrix/schema/imagegen_result.schema.json +106 -0
  23. lemonmatrix-0.1.0/src/lemonmatrix/schema/imported_result.schema.json +89 -0
  24. lemonmatrix-0.1.0/src/lemonmatrix/schema/meshgen_result.schema.json +103 -0
  25. lemonmatrix-0.1.0/src/lemonmatrix/schema/rerank_result.schema.json +101 -0
  26. lemonmatrix-0.1.0/src/lemonmatrix/schema/result.schema.json +202 -0
  27. lemonmatrix-0.1.0/src/lemonmatrix/schema/stt_result.schema.json +101 -0
  28. lemonmatrix-0.1.0/src/lemonmatrix/schema/tts_result.schema.json +103 -0
  29. lemonmatrix-0.1.0/src/lemonmatrix/static/dashboard.css +217 -0
  30. lemonmatrix-0.1.0/src/lemonmatrix/submit.py +129 -0
  31. lemonmatrix-0.1.0/src/lemonmatrix/sweep_batch.py +188 -0
  32. lemonmatrix-0.1.0/src/lemonmatrix/sweep_store.py +148 -0
  33. lemonmatrix-0.1.0/src/lemonmatrix/templates/audiogen.html +114 -0
  34. lemonmatrix-0.1.0/src/lemonmatrix/templates/base.html +25 -0
  35. lemonmatrix-0.1.0/src/lemonmatrix/templates/classify.html +112 -0
  36. lemonmatrix-0.1.0/src/lemonmatrix/templates/downloads.html +71 -0
  37. lemonmatrix-0.1.0/src/lemonmatrix/templates/embeddings.html +115 -0
  38. lemonmatrix-0.1.0/src/lemonmatrix/templates/failures.html +33 -0
  39. lemonmatrix-0.1.0/src/lemonmatrix/templates/imagegen.html +116 -0
  40. lemonmatrix-0.1.0/src/lemonmatrix/templates/imported.html +52 -0
  41. lemonmatrix-0.1.0/src/lemonmatrix/templates/index.html +145 -0
  42. lemonmatrix-0.1.0/src/lemonmatrix/templates/meshgen.html +140 -0
  43. lemonmatrix-0.1.0/src/lemonmatrix/templates/models_add.html +84 -0
  44. lemonmatrix-0.1.0/src/lemonmatrix/templates/profile_debug.html +27 -0
  45. lemonmatrix-0.1.0/src/lemonmatrix/templates/profile_detail.html +155 -0
  46. lemonmatrix-0.1.0/src/lemonmatrix/templates/profiles.html +96 -0
  47. lemonmatrix-0.1.0/src/lemonmatrix/templates/queue.html +327 -0
  48. lemonmatrix-0.1.0/src/lemonmatrix/templates/rerank.html +122 -0
  49. lemonmatrix-0.1.0/src/lemonmatrix/templates/result_detail.html +74 -0
  50. lemonmatrix-0.1.0/src/lemonmatrix/templates/run_form.html +279 -0
  51. lemonmatrix-0.1.0/src/lemonmatrix/templates/stt.html +114 -0
  52. lemonmatrix-0.1.0/src/lemonmatrix/templates/sweep_form.html +281 -0
  53. lemonmatrix-0.1.0/src/lemonmatrix/templates/sweep_status.html +62 -0
  54. lemonmatrix-0.1.0/src/lemonmatrix/templates/trials_detail.html +18 -0
  55. lemonmatrix-0.1.0/src/lemonmatrix/templates/tts.html +114 -0
  56. lemonmatrix-0.1.0/src/lemonmatrix/validate.py +163 -0
  57. lemonmatrix-0.1.0/src/lemonmatrix/webapp.py +1880 -0
  58. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/PKG-INFO +169 -0
  59. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/SOURCES.txt +89 -0
  60. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/dependency_links.txt +1 -0
  61. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/entry_points.txt +2 -0
  62. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/requires.txt +7 -0
  63. lemonmatrix-0.1.0/src/lemonmatrix.egg-info/top_level.txt +1 -0
  64. lemonmatrix-0.1.0/tests/conftest.py +721 -0
  65. lemonmatrix-0.1.0/tests/test_audiogen.py +131 -0
  66. lemonmatrix-0.1.0/tests/test_backend_version.py +46 -0
  67. lemonmatrix-0.1.0/tests/test_bench.py +463 -0
  68. lemonmatrix-0.1.0/tests/test_capabilities.py +189 -0
  69. lemonmatrix-0.1.0/tests/test_classify.py +151 -0
  70. lemonmatrix-0.1.0/tests/test_cli.py +805 -0
  71. lemonmatrix-0.1.0/tests/test_client.py +128 -0
  72. lemonmatrix-0.1.0/tests/test_discover.py +32 -0
  73. lemonmatrix-0.1.0/tests/test_embeddings.py +105 -0
  74. lemonmatrix-0.1.0/tests/test_group_by_base_model.py +25 -0
  75. lemonmatrix-0.1.0/tests/test_imagegen.py +191 -0
  76. lemonmatrix-0.1.0/tests/test_importers.py +197 -0
  77. lemonmatrix-0.1.0/tests/test_job_sweep.py +131 -0
  78. lemonmatrix-0.1.0/tests/test_meshgen.py +117 -0
  79. lemonmatrix-0.1.0/tests/test_model_options.py +46 -0
  80. lemonmatrix-0.1.0/tests/test_packaging.py +66 -0
  81. lemonmatrix-0.1.0/tests/test_profile.py +121 -0
  82. lemonmatrix-0.1.0/tests/test_profile_real_shape.py +101 -0
  83. lemonmatrix-0.1.0/tests/test_rerank.py +114 -0
  84. lemonmatrix-0.1.0/tests/test_results_store.py +57 -0
  85. lemonmatrix-0.1.0/tests/test_router_and_store.py +420 -0
  86. lemonmatrix-0.1.0/tests/test_routing_cost.py +341 -0
  87. lemonmatrix-0.1.0/tests/test_stt.py +133 -0
  88. lemonmatrix-0.1.0/tests/test_submit.py +165 -0
  89. lemonmatrix-0.1.0/tests/test_sweep_batch.py +161 -0
  90. lemonmatrix-0.1.0/tests/test_tts.py +106 -0
  91. lemonmatrix-0.1.0/tests/test_webapp.py +1581 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ include tests/conftest.py
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: lemonmatrix
3
+ Version: 0.1.0
4
+ Summary: Benchmark Lemonade local AI servers and publish comparable, validated results.
5
+ Author-email: Salah Eddine Bekhouche <bekhouchesalah@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://lemonmatrix.github.io
8
+ Project-URL: Guide, https://lemonmatrix.github.io/guide.html
9
+ Project-URL: Source, https://github.com/Bekhouche/LemonMatrix
10
+ Project-URL: Issues, https://github.com/Bekhouche/LemonMatrix/issues
11
+ Keywords: lemonade,benchmark,llm,local-ai,amd,ryzen-ai,radeon,llama.cpp
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: System :: Benchmark
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: click>=8.0
27
+ Requires-Dist: requests>=2.28
28
+ Requires-Dist: jsonschema>=4.18
29
+ Requires-Dist: flask>=3.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # LemonMatrix
35
+
36
+ A benchmarking control plane for [Lemonade](https://lemonade-server.ai) instances.
37
+ One profile = one Lemonade instance, auto-discovered and reused as the environment
38
+ fingerprint for every run on that machine. See
39
+ [schema/result.schema.json](https://github.com/Bekhouche/LemonMatrix/blob/main/schema/result.schema.json) for the canonical result
40
+ schema.
41
+
42
+ **Live public leaderboard: [lemonmatrix.github.io](https://lemonmatrix.github.io)**
43
+ -- results and the site's own generator live in the sibling
44
+ [LemonMatrix/lemonmatrix.github.io](https://github.com/LemonMatrix/lemonmatrix.github.io)
45
+ repo; this repo is code (CLI, library, tests, schema) only. Community
46
+ submissions go through a PR adding a result JSON under `results/<profile>/`
47
+ there, gated by CI running `lemonmatrix validate-submission` against the
48
+ schemas in this repo.
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ pip install lemonmatrix
54
+ ```
55
+
56
+ Python 3.10 or newer. The [step-by-step guide](https://lemonmatrix.github.io/guide.html)
57
+ walks from a running Lemonade to a result on the leaderboard.
58
+
59
+ To work on LemonMatrix itself:
60
+
61
+ ```bash
62
+ git clone https://github.com/Bekhouche/LemonMatrix.git
63
+ cd LemonMatrix
64
+ pip install -e ".[dev]"
65
+ ```
66
+
67
+ ## Quickstart
68
+
69
+ ```bash
70
+ # Find a Lemonade instance running on this machine and save it as a profile.
71
+ lemonmatrix profile detect --save my-machine
72
+
73
+ # Or add one you already know the address of.
74
+ lemonmatrix profile add my-machine --host 192.168.1.42 --port 13305 --token $LEMONADE_API_KEY
75
+
76
+ lemonmatrix profile list
77
+ lemonmatrix profile show my-machine
78
+
79
+ # Run a sweep and write a schema-conformant result JSON under results/.
80
+ # OS isn't a flag -- it's derived from the profile's own discovered
81
+ # environment, since a different OS is a different profile, not a per-run
82
+ # setting.
83
+ lemonmatrix run --profile my-machine \
84
+ --model Llama-3.1-8B-Instruct-GGUF --model-class dense --quant Q4_K_M \
85
+ --context-length 4096 --engine igpu --backend llama.cpp-vulkan \
86
+ --power-state plugged
87
+
88
+ # Browse profiles and results, or launch new sweeps, from a local dashboard.
89
+ lemonmatrix dashboard
90
+ ```
91
+
92
+ `lemonmatrix profile detect --subnet 192.168.1.0/24` extends the scan to a LAN
93
+ range for the multi-machine fleet case. Lemonade has no
94
+ announce/broadcast mechanism, so this is a bounded port scan, not magic
95
+ discovery -- capped at 1024 hosts per scan.
96
+
97
+ ## Router cost runs
98
+
99
+ A `collection.router` that mixes local and cloud candidates answers one
100
+ question: how much of the cloud bill does local hardware take over? Give the
101
+ router a mixed prompt set and LemonMatrix records where each request went and
102
+ prices it:
103
+
104
+ ```bash
105
+ lemonmatrix run --profile my-machine --run-type router \
106
+ --model user.My-Router --context-length 4096 --power-state plugged \
107
+ --prompt-set router-mix --trials 10
108
+ ```
109
+
110
+ The result's `metrics.routing` block holds the share of requests per
111
+ candidate, the share that stayed local, the cost of the run, and the cost of
112
+ sending every request to the most expensive candidate instead. Prices are USD
113
+ per million tokens. They come from Lemonade's own `estimated_cost` when the
114
+ candidate carries cost metadata (cloud models get it from their provider), and
115
+ non-cloud candidates count as free. `--cost MODEL=IN,OUT` sets or overrides a
116
+ price, `--cost-baseline MODEL` picks the comparison model, and
117
+ `--prompts-file` takes your own prompts (one per line, or JSONL).
118
+
119
+ After the trials, each prompt the router sent elsewhere goes once to the
120
+ baseline model, and the baseline is priced on the tokens that model actually
121
+ wrote. This matters for reasoning models, which can write ten times the tokens
122
+ of a small local model for the same prompt. The extra requests run outside the
123
+ measured window; `--estimate-baseline` skips them and reuses the routed
124
+ model's token counts, and the result's `baseline_method` says which was used.
125
+
126
+ ## Submitting results
127
+
128
+ `lemonmatrix submit results/my-machine/<run_id>.json` opens a pull request
129
+ that adds the file to the public leaderboard
130
+ ([LemonMatrix/lemonmatrix.github.io](https://github.com/LemonMatrix/lemonmatrix.github.io)).
131
+ It validates the file against the same schemas the leaderboard's CI uses, forks
132
+ the repo (or reuses your fork), keeps the file's `results/<profile>/...` path,
133
+ pushes and opens the PR with the GitHub CLI. `--dry-run` shows the PR without
134
+ touching GitHub.
135
+
136
+ ## Importing other tools' results
137
+
138
+ `lemonmatrix import FILE...` reads results from
139
+ [lemonade_lab](https://github.com/skywalk1411/lemonade_lab) (as published in
140
+ amdaibenchmarks) and [LemonMetrics](https://github.com/lemonmetrics/lemonmetrics)
141
+ `report.json` files, which carry Ryzen AI NPU/hybrid rows and energy
142
+ estimates. Each file is normalized into `results/imported/<tool>/` and listed
143
+ with `lemonmatrix imported-results`. These numbers did not go through
144
+ LemonMatrix's validity checks, so they are marked `validated: false` and never
145
+ appear on the leaderboard. Host names, commands, URLs and raw power samples are
146
+ not copied. When several backends report the same number for one model, the
147
+ import warns that the backend switch may not have taken effect.
148
+
149
+ ## Dashboard
150
+
151
+ `lemonmatrix dashboard` starts a local Flask app (default
152
+ `http://127.0.0.1:5050`) with:
153
+
154
+ - A sortable, filterable leaderboard over every result under `results/`.
155
+ - Profile management: detect, add, and inspect environment fingerprints.
156
+ - A form to launch a new sweep against a saved profile (runs synchronously,
157
+ same as the CLI's `run` command).
158
+
159
+ It's a single-user local tool with no job queue -- submitting a run blocks the
160
+ page until the sweep finishes.
161
+
162
+ ## Development
163
+
164
+ ```bash
165
+ pytest tests/
166
+ ```
167
+
168
+ Tests run against a fake Lemonade server (`tests/conftest.py`) modeled on the
169
+ documented `/api/v1/*` response shapes, so they don't require real AMD hardware.
@@ -0,0 +1,136 @@
1
+ # LemonMatrix
2
+
3
+ A benchmarking control plane for [Lemonade](https://lemonade-server.ai) instances.
4
+ One profile = one Lemonade instance, auto-discovered and reused as the environment
5
+ fingerprint for every run on that machine. See
6
+ [schema/result.schema.json](https://github.com/Bekhouche/LemonMatrix/blob/main/schema/result.schema.json) for the canonical result
7
+ schema.
8
+
9
+ **Live public leaderboard: [lemonmatrix.github.io](https://lemonmatrix.github.io)**
10
+ -- results and the site's own generator live in the sibling
11
+ [LemonMatrix/lemonmatrix.github.io](https://github.com/LemonMatrix/lemonmatrix.github.io)
12
+ repo; this repo is code (CLI, library, tests, schema) only. Community
13
+ submissions go through a PR adding a result JSON under `results/<profile>/`
14
+ there, gated by CI running `lemonmatrix validate-submission` against the
15
+ schemas in this repo.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install lemonmatrix
21
+ ```
22
+
23
+ Python 3.10 or newer. The [step-by-step guide](https://lemonmatrix.github.io/guide.html)
24
+ walks from a running Lemonade to a result on the leaderboard.
25
+
26
+ To work on LemonMatrix itself:
27
+
28
+ ```bash
29
+ git clone https://github.com/Bekhouche/LemonMatrix.git
30
+ cd LemonMatrix
31
+ pip install -e ".[dev]"
32
+ ```
33
+
34
+ ## Quickstart
35
+
36
+ ```bash
37
+ # Find a Lemonade instance running on this machine and save it as a profile.
38
+ lemonmatrix profile detect --save my-machine
39
+
40
+ # Or add one you already know the address of.
41
+ lemonmatrix profile add my-machine --host 192.168.1.42 --port 13305 --token $LEMONADE_API_KEY
42
+
43
+ lemonmatrix profile list
44
+ lemonmatrix profile show my-machine
45
+
46
+ # Run a sweep and write a schema-conformant result JSON under results/.
47
+ # OS isn't a flag -- it's derived from the profile's own discovered
48
+ # environment, since a different OS is a different profile, not a per-run
49
+ # setting.
50
+ lemonmatrix run --profile my-machine \
51
+ --model Llama-3.1-8B-Instruct-GGUF --model-class dense --quant Q4_K_M \
52
+ --context-length 4096 --engine igpu --backend llama.cpp-vulkan \
53
+ --power-state plugged
54
+
55
+ # Browse profiles and results, or launch new sweeps, from a local dashboard.
56
+ lemonmatrix dashboard
57
+ ```
58
+
59
+ `lemonmatrix profile detect --subnet 192.168.1.0/24` extends the scan to a LAN
60
+ range for the multi-machine fleet case. Lemonade has no
61
+ announce/broadcast mechanism, so this is a bounded port scan, not magic
62
+ discovery -- capped at 1024 hosts per scan.
63
+
64
+ ## Router cost runs
65
+
66
+ A `collection.router` that mixes local and cloud candidates answers one
67
+ question: how much of the cloud bill does local hardware take over? Give the
68
+ router a mixed prompt set and LemonMatrix records where each request went and
69
+ prices it:
70
+
71
+ ```bash
72
+ lemonmatrix run --profile my-machine --run-type router \
73
+ --model user.My-Router --context-length 4096 --power-state plugged \
74
+ --prompt-set router-mix --trials 10
75
+ ```
76
+
77
+ The result's `metrics.routing` block holds the share of requests per
78
+ candidate, the share that stayed local, the cost of the run, and the cost of
79
+ sending every request to the most expensive candidate instead. Prices are USD
80
+ per million tokens. They come from Lemonade's own `estimated_cost` when the
81
+ candidate carries cost metadata (cloud models get it from their provider), and
82
+ non-cloud candidates count as free. `--cost MODEL=IN,OUT` sets or overrides a
83
+ price, `--cost-baseline MODEL` picks the comparison model, and
84
+ `--prompts-file` takes your own prompts (one per line, or JSONL).
85
+
86
+ After the trials, each prompt the router sent elsewhere goes once to the
87
+ baseline model, and the baseline is priced on the tokens that model actually
88
+ wrote. This matters for reasoning models, which can write ten times the tokens
89
+ of a small local model for the same prompt. The extra requests run outside the
90
+ measured window; `--estimate-baseline` skips them and reuses the routed
91
+ model's token counts, and the result's `baseline_method` says which was used.
92
+
93
+ ## Submitting results
94
+
95
+ `lemonmatrix submit results/my-machine/<run_id>.json` opens a pull request
96
+ that adds the file to the public leaderboard
97
+ ([LemonMatrix/lemonmatrix.github.io](https://github.com/LemonMatrix/lemonmatrix.github.io)).
98
+ It validates the file against the same schemas the leaderboard's CI uses, forks
99
+ the repo (or reuses your fork), keeps the file's `results/<profile>/...` path,
100
+ pushes and opens the PR with the GitHub CLI. `--dry-run` shows the PR without
101
+ touching GitHub.
102
+
103
+ ## Importing other tools' results
104
+
105
+ `lemonmatrix import FILE...` reads results from
106
+ [lemonade_lab](https://github.com/skywalk1411/lemonade_lab) (as published in
107
+ amdaibenchmarks) and [LemonMetrics](https://github.com/lemonmetrics/lemonmetrics)
108
+ `report.json` files, which carry Ryzen AI NPU/hybrid rows and energy
109
+ estimates. Each file is normalized into `results/imported/<tool>/` and listed
110
+ with `lemonmatrix imported-results`. These numbers did not go through
111
+ LemonMatrix's validity checks, so they are marked `validated: false` and never
112
+ appear on the leaderboard. Host names, commands, URLs and raw power samples are
113
+ not copied. When several backends report the same number for one model, the
114
+ import warns that the backend switch may not have taken effect.
115
+
116
+ ## Dashboard
117
+
118
+ `lemonmatrix dashboard` starts a local Flask app (default
119
+ `http://127.0.0.1:5050`) with:
120
+
121
+ - A sortable, filterable leaderboard over every result under `results/`.
122
+ - Profile management: detect, add, and inspect environment fingerprints.
123
+ - A form to launch a new sweep against a saved profile (runs synchronously,
124
+ same as the CLI's `run` command).
125
+
126
+ It's a single-user local tool with no job queue -- submitting a run blocks the
127
+ page until the sweep finishes.
128
+
129
+ ## Development
130
+
131
+ ```bash
132
+ pytest tests/
133
+ ```
134
+
135
+ Tests run against a fake Lemonade server (`tests/conftest.py`) modeled on the
136
+ documented `/api/v1/*` response shapes, so they don't require real AMD hardware.
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "lemonmatrix"
7
+ version = "0.1.0"
8
+ description = "Benchmark Lemonade local AI servers and publish comparable, validated results."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Salah Eddine Bekhouche", email = "bekhouchesalah@gmail.com" }]
14
+ keywords = ["lemonade", "benchmark", "llm", "local-ai", "amd", "ryzen-ai", "radeon", "llama.cpp"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
26
+ "Topic :: System :: Benchmark",
27
+ ]
28
+ dependencies = [
29
+ "click>=8.0",
30
+ "requests>=2.28",
31
+ "jsonschema>=4.18",
32
+ "flask>=3.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://lemonmatrix.github.io"
37
+ Guide = "https://lemonmatrix.github.io/guide.html"
38
+ Source = "https://github.com/Bekhouche/LemonMatrix"
39
+ Issues = "https://github.com/Bekhouche/LemonMatrix/issues"
40
+
41
+ [project.optional-dependencies]
42
+ dev = ["pytest>=7.0"]
43
+
44
+ [project.scripts]
45
+ lemonmatrix = "lemonmatrix.cli:main"
46
+
47
+ [tool.setuptools.packages.find]
48
+ where = ["src"]
49
+
50
+ [tool.setuptools.package-data]
51
+ lemonmatrix = ["templates/*.html", "schema/*.json", "static/*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """LemonMatrix: a benchmarking control plane for Lemonade instances."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("lemonmatrix")
7
+ except PackageNotFoundError:
8
+ __version__ = "0+unknown"
@@ -0,0 +1,70 @@
1
+ """Looks up the installed engine build version for a run's --backend string.
2
+
3
+ Lemonade has no single "CUDA version" or "ROCm version" field (confirmed
4
+ against a real system-info response) -- what it has is a per-recipe,
5
+ per-backend entry under system_info["recipes"][recipe]["backends"][key],
6
+ each with its own "version" (e.g. llama.cpp's own build tag "b10397") and a
7
+ "state" of "installed" / "installable" / "unsupported". Only "installed"
8
+ means that version is what's actually running; "installable" just means it
9
+ could be downloaded, so it must not be reported as if it were active.
10
+
11
+ The mapping from a free-text --backend string (there is no enum for it in
12
+ the schema) to a (recipe, backend_key) pair is inherently a guess for
13
+ hand-typed strings -- BACKEND_ALIASES covers common display strings
14
+ ("llama.cpp-vulkan") confirmed against the real recipes tree. capabilities.py
15
+ instead generates canonical "<recipe_key>-<backend_key>" strings directly
16
+ from Lemonade's own keys (e.g. "llamacpp-vulkan", no dot) for the dashboard's
17
+ backend dropdown -- recipe keys can contain hyphens themselves (e.g.
18
+ "ryzenai-llm", "sd-cpp"), but backend keys never do, so splitting on the
19
+ *last* hyphen recovers both correctly. Unrecognized strings return None
20
+ rather than guessing further.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ BACKEND_ALIASES: dict[str, tuple[str, str]] = {
26
+ "llama.cpp-cpu": ("llamacpp", "cpu"),
27
+ "llama.cpp-vulkan": ("llamacpp", "vulkan"),
28
+ "llama.cpp-rocm": ("llamacpp", "rocm"),
29
+ "llama.cpp-cuda": ("llamacpp", "cuda"),
30
+ "llama.cpp-metal": ("llamacpp", "metal"),
31
+ "llama.cpp-system": ("llamacpp", "system"),
32
+ "fastflowlm-npu": ("flm", "npu"),
33
+ "ryzenai-npu": ("ryzenai-llm", "npu"),
34
+ }
35
+
36
+
37
+ def resolve_backend(system_info: dict, backend: str) -> tuple[str, str] | None:
38
+ """Split a --backend string into (recipe_key, backend_key), or None if
39
+ unrecognized. Used both to look up the installed engine version here and,
40
+ in bench.py, to actually tell Lemonade which backend to load (the
41
+ "<recipe>_backend" parameter on POST /api/v1/load) -- without this, a
42
+ load call has no backend selector at all and Lemonade silently falls
43
+ back to the recipe's configured default_backend, which may not be
44
+ installed on this host even when the one the user picked is.
45
+ """
46
+ if backend in BACKEND_ALIASES:
47
+ return BACKEND_ALIASES[backend]
48
+
49
+ # Canonical "<recipe_key>-<backend_key>" form: split on the last hyphen
50
+ # and confirm the recipe_key half actually exists, since backend keys
51
+ # never contain hyphens but some recipe keys do.
52
+ recipe_key, _, backend_key = backend.rpartition("-")
53
+ if recipe_key and recipe_key in (system_info.get("recipes") or {}):
54
+ return recipe_key, backend_key
55
+ return None
56
+
57
+
58
+ def lookup_backend_version(system_info: dict, backend: str) -> str | None:
59
+ """The installed engine build version for `backend`, or None if unknown
60
+ or not actually installed (state != "installed")."""
61
+ resolved = resolve_backend(system_info, backend)
62
+ if resolved is None:
63
+ return None
64
+ recipe_key, backend_key = resolved
65
+
66
+ recipe = (system_info.get("recipes") or {}).get(recipe_key) or {}
67
+ entry = (recipe.get("backends") or {}).get(backend_key) or {}
68
+ if entry.get("state") != "installed":
69
+ return None
70
+ return entry.get("version")