nnopt port: Bonsai-27B-llama.cpp
Browse files- .gitattributes +17 -32
- LICENSE +177 -0
- LICENSE-llama.cpp +21 -0
- NOTICE +15 -0
- README.md +78 -0
- config.json +34 -0
- m2pro-gpu-q1_0/README.md +73 -0
- m2pro-gpu-q1_0/build.sh +52 -0
- m2pro-gpu-q1_0/deploy.sh +22 -0
- m2pro-gpu-q1_0/fetch.sh +33 -0
- m2pro-gpu-q1_0/nnopt-prismml-5ae2e169.patch +562 -0
- m2pro-gpu-q1_0/report.html +110 -0
- m2pro-gpu-q1_0/report/reproduce.sh +14 -0
- m2pro-gpu-q1_0/report/results.csv +81 -0
- m2pro-gpu-q1_0/report/results.json +1404 -0
- m2pro-gpu-q1_0/src/CMakeLists.txt +23 -0
- m2pro-gpu-q1_0/src/patches/0001-q1_0-lut-gemv.patch +549 -0
- m2pro-gpu-q1_0/src/run.sh +3 -0
- m2pro-gpu-q1_0/src/runner.cpp +335 -0
.gitattributes
CHANGED
|
@@ -1,35 +1,20 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.
|
| 31 |
-
*.
|
| 32 |
-
*.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.
|
| 35 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.gguf filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.so filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.bf16 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.f16 filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.f32 filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.tkb filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pdf filter=lfs diff=lfs merge=lfs -text
|
| 17 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
LICENSE-llama.cpp
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023-2026 The ggml authors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This software is copyright 2026-present Prism ML, Inc. It is available under the Apache 2.0 license.
|
| 2 |
+
If you publicly deploy or redistribute this software, we would appreciate attribution such as: "Created using Bonsai by Prism ML."
|
| 3 |
+
|
| 4 |
+
This software is built from Qwen3.6-27B, Copyright 2026 Alibaba Cloud, which is available under the Apache 2.0 License: https://huggingface.co/Qwen/Qwen3.6-27B/blob/main/LICENSE
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
This repository is a modified version of prism-ml/Bonsai-27B-gguf by Prism ML, revision f10afb355f104535e3e3e98cf7ab7795c72bd292.
|
| 9 |
+
|
| 10 |
+
Changes, made by nnopt (https://nnopt.dev):
|
| 11 |
+
- `m2pro-gpu-q1_0/` (nnopt job NN-53D464): fetched: fetch.sh downloads Bonsai-27B-Q1_0.gguf (original, unchanged). The runtime code (src/, build.sh, deploy.sh, run.sh) is new, written by nnopt's agents for this device.
|
| 12 |
+
|
| 13 |
+
The runner links llama.cpp (MIT, see LICENSE-llama.cpp).
|
| 14 |
+
|
| 15 |
+
Created using Bonsai by Prism ML.
|
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: prism-ml/Bonsai-27B-gguf
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
tags:
|
| 6 |
+
- on-device
|
| 7 |
+
- nnopt
|
| 8 |
+
- llama.cpp
|
| 9 |
+
- gguf
|
| 10 |
+
- metal
|
| 11 |
+
- macos
|
| 12 |
+
- apple-silicon
|
| 13 |
+
- gpu
|
| 14 |
+
- 1-bit
|
| 15 |
+
- mac-mini-m2-pro
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Bonsai-27B on Mac mini (M2 Pro) (PrismML llama.cpp Metal)
|
| 19 |
+
|
| 20 |
+
Ported, optimized and verified on a real Mac mini (M2 Pro) by [nnopt.dev](https://nnopt.dev) — AI agents that port and optimize models for the hardware you ship.
|
| 21 |
+
|
| 22 |
+
The model is [prism-ml/Bonsai-27B-gguf](https://huggingface.co/prism-ml/Bonsai-27B-gguf) by Prism ML, and it is theirs. The PrismML llama.cpp Metal port in this repository is nnopt's work: nnopt job NN-53D464.
|
| 23 |
+
|
| 24 |
+
Created using Bonsai by Prism ML.
|
| 25 |
+
|
| 26 |
+
| | |
|
| 27 |
+
|---|---|
|
| 28 |
+
| Device | Mac mini (M2 Pro), macOS |
|
| 29 |
+
| Chip | Apple M2 Pro |
|
| 30 |
+
| Processor | GPU (Apple M2 Pro, Metal), all layers |
|
| 31 |
+
| Runtime | PrismML llama.cpp fork 5ae2e169, Metal backend, with nnopt's patch |
|
| 32 |
+
| Precision | Q1_0 - 1.125-bit, as given |
|
| 33 |
+
| Modality | text -> text |
|
| 34 |
+
| Weights | fetched: fetch.sh downloads Bonsai-27B-Q1_0.gguf (original, unchanged) |
|
| 35 |
+
| nnopt job | NN-53D464 (optimize) |
|
| 36 |
+
| Folder | [`m2pro-gpu-q1_0/`](https://huggingface.co/nnopt-dev/Bonsai-27B-llama.cpp/tree/main/m2pro-gpu-q1_0) |
|
| 37 |
+
|
| 38 |
+
Run 2 of an optimize chain: NN-A8E243 (lookup-table Q1_0 GEMV, GDN rows mode) then NN-53D464 (repacked Q1_0 tile layout + packed-index LUT GEMV, fused decode conv-state step). The patch holds the result of both; NN-A8E243's LUT kernel was reworked in NN-53D464, its rows mode is in src/runner.cpp.
|
| 39 |
+
|
| 40 |
+
## Verified results
|
| 41 |
+
|
| 42 |
+
nnopt built the folder from a clean copy, deployed it to the device and checked it against the model's reference code on hidden inputs. The full report is `report.html` in the folder.
|
| 43 |
+
|
| 44 |
+
- Passed. Next-token agreement 100.0% (bar at least 98.0%)
|
| 45 |
+
- Speed target: decode 29.4 tokens/s (bar at least 19.0 tokens/s)
|
| 46 |
+
- Decode 29.4 tokens/s (was 15.9, 1.8x faster)
|
| 47 |
+
- Prefill 86.0 tokens/s (was 87.3, 1.0x slower)
|
| 48 |
+
- Time to first token 1.82 s (was 1.80 s)
|
| 49 |
+
- Load time 1.04 s (was 564 ms, 1.8x slower)
|
| 50 |
+
- Peak memory 4,532 MB (was 4,208 MB, 8% more)
|
| 51 |
+
|
| 52 |
+
## Use it
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
mkdir Bonsai-27B-llama.cpp && cd Bonsai-27B-llama.cpp
|
| 56 |
+
curl -fsSL https://huggingface.co/nnopt-dev/Bonsai-27B-llama.cpp/resolve/main/config.json -o config.json
|
| 57 |
+
hf download nnopt-dev/Bonsai-27B-llama.cpp --include "m2pro-gpu-q1_0/*" --local-dir .
|
| 58 |
+
cd m2pro-gpu-q1_0
|
| 59 |
+
bash fetch.sh
|
| 60 |
+
bash build.sh # copies the fork, applies src/patches/, builds bin/nnopt_runner (~30 s)
|
| 61 |
+
bash deploy.sh ~/bonsai27b
|
| 62 |
+
echo 'Explain quantum computing in simple terms.' > p.txt
|
| 63 |
+
sh ~/bonsai27b/run.sh --prompt-file p.txt --max-new-tokens 128 --out out.json --metrics m.json
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
Needs: macOS on Apple silicon with Xcode command line tools, CMake >= 3.14, rsync, patch, git, curl; ~4.6 GB free memory. `nnopt-prismml-5ae2e169.patch` is the same change as src/patches/ as a git diff.
|
| 67 |
+
|
| 68 |
+
`README.md` in the folder has every flag, the requirements and the known limits; `REPRO.md` (where present) reproduces the measurements.
|
| 69 |
+
|
| 70 |
+
## License
|
| 71 |
+
|
| 72 |
+
Apache 2.0, like prism-ml/Bonsai-27B-gguf: see LICENSE and NOTICE. The runner links llama.cpp (MIT, LICENSE-llama.cpp).
|
| 73 |
+
|
| 74 |
+
## Made with nnopt
|
| 75 |
+
|
| 76 |
+
[nnopt](https://nnopt.dev) is a platform where AI agents port, optimize and benchmark a model for a specific device. They write the runtime code on the real device, and a locked verification kit then checks the result against the model's own reference code before anything ships. Every number on this page comes from that check.
|
| 77 |
+
|
| 78 |
+
Want your model on your device? Start a job at [nnopt.dev](https://nnopt.dev).
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"nnopt_manifest": 1,
|
| 3 |
+
"repo": "nnopt-dev/Bonsai-27B-llama.cpp",
|
| 4 |
+
"model": {
|
| 5 |
+
"name": "Bonsai-27B",
|
| 6 |
+
"source_repo": "prism-ml/Bonsai-27B-gguf",
|
| 7 |
+
"source_revision": "f10afb355f104535e3e3e98cf7ab7795c72bd292",
|
| 8 |
+
"authors": "Prism ML",
|
| 9 |
+
"license": "apache-2.0"
|
| 10 |
+
},
|
| 11 |
+
"variants": [
|
| 12 |
+
{
|
| 13 |
+
"id": "m2pro-gpu-q1_0",
|
| 14 |
+
"device": "Mac mini (M2 Pro)",
|
| 15 |
+
"chip": "Apple M2 Pro",
|
| 16 |
+
"os": "macOS",
|
| 17 |
+
"processor": "GPU (Apple M2 Pro, Metal), all layers",
|
| 18 |
+
"runtime": "PrismML llama.cpp fork 5ae2e169, Metal backend, with nnopt's patch",
|
| 19 |
+
"runtime_version": "5ae2e169eac202d2f065606539c3ad6ab8b51333",
|
| 20 |
+
"precision": "Q1_0 - 1.125-bit, as given",
|
| 21 |
+
"weights": "fetched: fetch.sh downloads Bonsai-27B-Q1_0.gguf (original, unchanged)",
|
| 22 |
+
"nnopt_job": "NN-53D464",
|
| 23 |
+
"job_kind": "optimize",
|
| 24 |
+
"verified": {
|
| 25 |
+
"verdict": "Passed. Next-token agreement 100.0% (bar at least 98.0%); Speed target: decode 29.4 tokens/s (bar at least 19.0 tokens/s)",
|
| 26 |
+
"speed": "Decode 29.4 tokens/s (was 15.9, 1.8x faster); Prefill 86.0 tokens/s (was 87.3, 1.0x slower); Time to first token 1.82 s (was 1.80 s); Load time 1.04 s (was 564 ms, 1.8x slower); Peak memory 4,532 MB (was 4,208 MB, 8% more)"
|
| 27 |
+
},
|
| 28 |
+
"history": "Run 2 of an optimize chain: NN-A8E243 (lookup-table Q1_0 GEMV, GDN rows mode) then NN-53D464 (repacked Q1_0 tile layout + packed-index LUT GEMV, fused decode conv-state step). The patch holds the result of both; NN-A8E243's LUT kernel was reworked in NN-53D464, its rows mode is in src/runner.cpp.",
|
| 29 |
+
"fetch": "m2pro-gpu-q1_0/fetch.sh"
|
| 30 |
+
}
|
| 31 |
+
],
|
| 32 |
+
"license": "apache-2.0",
|
| 33 |
+
"made_by": "nnopt (https://nnopt.dev)"
|
| 34 |
+
}
|
m2pro-gpu-q1_0/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Bonsai-27B (Q1_0) on Mac mini M2 Pro: faster decode on the PrismML llama.cpp fork (Metal)
|
| 2 |
+
|
| 3 |
+
- **Model**: prism-ml/Bonsai-27B-gguf, `Bonsai-27B-Q1_0.gguf` (hybrid gated-delta-net + attention, 64 blocks).
|
| 4 |
+
- **Device**: Mac mini (M2 Pro), Apple GPU, macOS on Apple silicon.
|
| 5 |
+
- **Runtime**: the customer's PrismML llama.cpp fork (5ae2e169), Metal backend, with our patches
|
| 6 |
+
(`src/patches/0001-q1_0-lut-gemv.patch`) and a small C++ runner over `llama.h` (`src/runner.cpp`).
|
| 7 |
+
- **Precision**: Q1_0_g128 1-bit weights as published (reordered in memory at load), fp32 activations and
|
| 8 |
+
accumulation, f16 KV cache. **Processor**: GPU, all layers.
|
| 9 |
+
|
| 10 |
+
## Requirements
|
| 11 |
+
- macOS on Apple silicon (arm64), Xcode command line tools (`/usr/bin/clang`, `clang++`), CMake >= 3.14, rsync, patch.
|
| 12 |
+
- The customer's inputs folder (`inputs/reference_code` = the fork, `inputs/weights/Bonsai-27B-Q1_0.gguf`). build.sh
|
| 13 |
+
finds it via `$NNOPT_INPUTS_DIR`, or in `inputs/` or `work/inputs/` next to this folder or any parent folder.
|
| 14 |
+
|
| 15 |
+
## Build
|
| 16 |
+
bash build.sh # copies the fork to build/llama-src, applies src/patches, builds bin/nnopt_runner (~30 s)
|
| 17 |
+
|
| 18 |
+
## Deploy
|
| 19 |
+
bash deploy.sh DEST # DEST/run.sh, DEST/nnopt_runner, DEST/port.json, DEST/Bonsai-27B-Q1_0.gguf (APFS clone)
|
| 20 |
+
|
| 21 |
+
## Run
|
| 22 |
+
sh DEST/run.sh --prompt-file prompt.txt --max-new-tokens 128 [--ignore-eos] [--repeat R] --out out.json --metrics m.json
|
| 23 |
+
sh DEST/run.sh --score-tokens tokens.json --top-k 10 --out out.json --metrics m.json
|
| 24 |
+
|
| 25 |
+
Generation is greedy (argmax, ties to the lowest id), with the vocab's default special tokens and no chat template.
|
| 26 |
+
`out.json` = `{"prompt_tokens", "tokens", "text"}`; `m.json` holds load_ms and per-run total_ms, ttft_ms and token_ms.
|
| 27 |
+
|
| 28 |
+
## Check
|
| 29 |
+
nnopt-verify check --split public --bundle <work>/reference --port DEST --executor local
|
| 30 |
+
|
| 31 |
+
## Measured (this Mac)
|
| 32 |
+
| | starting version | this port |
|
| 33 |
+
|---|---|---|
|
| 34 |
+
| decode tok/s, kit bench (outside clock) | 15.85 | 27.48 |
|
| 35 |
+
| decode tok/s, kit sustained run (median) | - | 30.07 |
|
| 36 |
+
| decode ms/token, in-process (p000, 128 tokens) | ~63 | 33.1 |
|
| 37 |
+
| public check | - | all metrics 1.0 (1185 positions) |
|
| 38 |
+
|
| 39 |
+
Roofline: 54.6 tok/s (3.6 GB of weights per token at ~200 GB/s). Details, profile and what was tried: NOTES.md.
|
| 40 |
+
|
| 41 |
+
## Known limits
|
| 42 |
+
- Weights are read into Metal buffers (not mmapped) and repacked at load. Warm load takes ~1 s; the first launch
|
| 43 |
+
after a build takes ~18 s while Metal compiles the shaders.
|
| 44 |
+
- Speed work targets decode. Prefill uses the fork's kernels (adapted to the repacked layout, same speed).
|
| 45 |
+
- The repacked Q1_0 layout is internal to this build's Metal kernels. Do not mix these patched libraries with an
|
| 46 |
+
unpatched loader or mmap loading (the loader refuses mmap for Q1_0 Metal tensors).
|
| 47 |
+
|
| 48 |
+
## Verified by nnopt
|
| 49 |
+
|
| 50 |
+
**Passed** prism-ml/Bonsai-27B-gguf on Mac mini (M2 Pro) (2026-10-16). nnopt built this folder from a clean copy, deployed it to the device and ran it on hidden inputs; the full report is report.html.
|
| 51 |
+
|
| 52 |
+
| Check | Measured | Bar | Result |
|
| 53 |
+
|---|---|---|---|
|
| 54 |
+
| Speed target: decode | 29.4 tokens/s | at least 19.0 tokens/s | pass |
|
| 55 |
+
| Outputs match your reference code | Next-token agreement 100.0% | at least 98.0% (original precision) | pass |
|
| 56 |
+
| Runs on llama.cpp | src/runner.cpp:164: llama_model * model = llama_model_load_from_file(model_path.c_str(), mparams); | the runtime you asked for | pass |
|
| 57 |
+
|
| 58 |
+
| Speed | This port | Starting version | Change |
|
| 59 |
+
|---|---|---|---|
|
| 60 |
+
| Prefill, tokens/s | 86.0 | 87.3 | 1.0× slower |
|
| 61 |
+
| Decode, tokens/s | 29.4 | 15.9 | 1.9× faster |
|
| 62 |
+
| Time to first token | 1.82 s | 1.80 s | 1.0× slower |
|
| 63 |
+
| Load time | 1.04 s | 564 ms | 1.8× slower |
|
| 64 |
+
| Peak memory | 4,532 MB | 4,208 MB | 8% more |
|
| 65 |
+
|
| 66 |
+
| Measurement | Median |
|
| 67 |
+
|---|---|
|
| 68 |
+
| Prefill | 86.043 tokens/s |
|
| 69 |
+
| Decode | 29.3804 tokens/s |
|
| 70 |
+
| Time to first token | 1824.67 ms |
|
| 71 |
+
| Load time | 1037.93 ms |
|
| 72 |
+
| Peak memory | 4532.0 MB |
|
| 73 |
+
| Sustained speed after 11 min, % of start | 100.0 % |
|
m2pro-gpu-q1_0/build.sh
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Builds the customer's PrismML llama.cpp fork (Metal) with our speed patches (src/patches)
|
| 3 |
+
# plus a small contract runner over llama.h. Outputs stay in ./build and ./bin.
|
| 4 |
+
set -euo pipefail
|
| 5 |
+
cd "$(dirname "$0")"
|
| 6 |
+
ROOT="$(pwd)"
|
| 7 |
+
|
| 8 |
+
# Locate the customer's inputs (reference_code + weights).
|
| 9 |
+
find_inputs() {
|
| 10 |
+
local cands=("${NNOPT_INPUTS_DIR:-}")
|
| 11 |
+
# this folder and every ancestor: DIR/inputs and DIR/work/inputs (job layout)
|
| 12 |
+
local d="$ROOT"
|
| 13 |
+
while [ "$d" != "/" ]; do
|
| 14 |
+
cands+=("$d/inputs" "$d/work/inputs")
|
| 15 |
+
d="$(dirname "$d")"
|
| 16 |
+
done
|
| 17 |
+
for d in "${cands[@]}"; do
|
| 18 |
+
if [ -n "$d" ] && [ -f "$d/reference_code/include/llama.h" ]; then
|
| 19 |
+
(cd "$d" && pwd); return 0
|
| 20 |
+
fi
|
| 21 |
+
done
|
| 22 |
+
echo "build.sh: cannot find the inputs folder (set NNOPT_INPUTS_DIR)" >&2; exit 1
|
| 23 |
+
}
|
| 24 |
+
INPUTS="$(find_inputs)"
|
| 25 |
+
echo "inputs: $INPUTS"
|
| 26 |
+
|
| 27 |
+
# Apple toolchain explicitly (PATH may hold an Android NDK clang).
|
| 28 |
+
export CC=/usr/bin/clang CXX=/usr/bin/clang++
|
| 29 |
+
|
| 30 |
+
# Copy the fork (minus the parts this build never uses) and apply our patches (src/patches, in order).
|
| 31 |
+
# rsync --delete resets every file to the customer's version first, so the patches always apply cleanly.
|
| 32 |
+
LLAMA_SRC="$ROOT/build/llama-src"
|
| 33 |
+
mkdir -p "$LLAMA_SRC"
|
| 34 |
+
rsync -a --delete --exclude /.git --exclude /models --exclude /docs --exclude /tools --exclude /examples \
|
| 35 |
+
--exclude /media --exclude /app --exclude /benches "$INPUTS/reference_code/" "$LLAMA_SRC/"
|
| 36 |
+
for p in src/patches/*.patch; do
|
| 37 |
+
[ -f "$p" ] || continue
|
| 38 |
+
echo "applying $p"
|
| 39 |
+
patch -d "$LLAMA_SRC" -p1 --forward --quiet < "$p"
|
| 40 |
+
done
|
| 41 |
+
|
| 42 |
+
cmake -S src -B build/cmake \
|
| 43 |
+
-DCMAKE_BUILD_TYPE=Release \
|
| 44 |
+
-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
|
| 45 |
+
-DLLAMA_SRC="$LLAMA_SRC"
|
| 46 |
+
cmake --build build/cmake --target nnopt_runner -j "$(sysctl -n hw.ncpu)"
|
| 47 |
+
|
| 48 |
+
mkdir -p bin
|
| 49 |
+
cp build/cmake/nnopt_runner bin/nnopt_runner
|
| 50 |
+
echo "$INPUTS/weights/Bonsai-27B-Q1_0.gguf" > bin/model_path.txt
|
| 51 |
+
(cd "$INPUTS/reference_code" && git rev-parse HEAD 2>/dev/null || echo unknown) > bin/llama_commit.txt
|
| 52 |
+
echo "built bin/nnopt_runner"
|
m2pro-gpu-q1_0/deploy.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Installs the runner, run.sh, port.json and the GGUF weights into DEST (this Mac is the device).
|
| 3 |
+
set -euo pipefail
|
| 4 |
+
cd "$(dirname "$0")"
|
| 5 |
+
DEST="${1:?usage: deploy.sh DEST}"
|
| 6 |
+
[ -x bin/nnopt_runner ] || { echo "run build.sh first" >&2; exit 1; }
|
| 7 |
+
MODEL_SRC="$(cat bin/model_path.txt)"
|
| 8 |
+
[ -f "$MODEL_SRC" ] || { echo "weights not found: $MODEL_SRC" >&2; exit 1; }
|
| 9 |
+
mkdir -p "$DEST"
|
| 10 |
+
cp bin/nnopt_runner "$DEST/nnopt_runner"
|
| 11 |
+
cp src/run.sh "$DEST/run.sh"
|
| 12 |
+
# APFS clone when possible (instant, no extra space); plain copy otherwise.
|
| 13 |
+
if ! cmp -s "$MODEL_SRC" "$DEST/Bonsai-27B-Q1_0.gguf" 2>/dev/null; then
|
| 14 |
+
rm -f "$DEST/Bonsai-27B-Q1_0.gguf"
|
| 15 |
+
cp -c "$MODEL_SRC" "$DEST/Bonsai-27B-Q1_0.gguf" 2>/dev/null || cp "$MODEL_SRC" "$DEST/Bonsai-27B-Q1_0.gguf"
|
| 16 |
+
fi
|
| 17 |
+
cat > "$DEST/port.json" <<JSON
|
| 18 |
+
{"contract": 1, "model_type": "text_to_text",
|
| 19 |
+
"runtime": "PrismML llama.cpp fork $(cut -c1-8 bin/llama_commit.txt), Metal (all layers on GPU)",
|
| 20 |
+
"precision": "Q1_0_g128 weights (as published), f16 KV cache"}
|
| 21 |
+
JSON
|
| 22 |
+
echo "deployed to $DEST"
|
m2pro-gpu-q1_0/fetch.sh
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Run once after downloading this folder: bash fetch.sh
|
| 3 |
+
# Downloads the original GGUF and the PrismML llama.cpp fork; build.sh applies src/patches/.
|
| 4 |
+
set -euo pipefail
|
| 5 |
+
cd "$(dirname "$0")"
|
| 6 |
+
REPO=nnopt-dev/Bonsai-27B-llama.cpp
|
| 7 |
+
|
| 8 |
+
# The repository's manifest first (Hugging Face counts a download when config.json is requested).
|
| 9 |
+
curl -fsSL "https://huggingface.co/$REPO/resolve/main/config.json" -o ../config.json
|
| 10 |
+
|
| 11 |
+
sha256_of() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d" " -f1; else shasum -a 256 "$1" | cut -d" " -f1; fi; }
|
| 12 |
+
get() { # get URL FILE SHA256: download once, check the sha256
|
| 13 |
+
if [ -f "$2" ] && [ "$(sha256_of "$2")" = "$3" ]; then return 0; fi
|
| 14 |
+
mkdir -p "$(dirname "$2")"
|
| 15 |
+
curl -fL --retry 3 -o "$2.part" "$1"
|
| 16 |
+
[ "$(sha256_of "$2.part")" = "$3" ] || { echo "fetch.sh: sha256 mismatch for $1" >&2; rm -f "$2.part"; exit 1; }
|
| 17 |
+
mv "$2.part" "$2"
|
| 18 |
+
}
|
| 19 |
+
git_at() { # git_at URL COMMIT DIR: the exact commit, shallow
|
| 20 |
+
if [ "$(git -C "$3" rev-parse HEAD 2>/dev/null || true)" = "$2" ]; then return 0; fi
|
| 21 |
+
rm -rf "$3"; mkdir -p "$3"
|
| 22 |
+
git -C "$3" init -q && git -C "$3" remote add origin "$1"
|
| 23 |
+
git -C "$3" fetch -q --depth 1 origin "$2" && git -C "$3" -c advice.detachedHead=false checkout -q FETCH_HEAD
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
# The fork, unchanged, at 5ae2e169 (build.sh finds it in inputs/reference_code and copies it before patching).
|
| 27 |
+
git_at https://github.com/PrismML-Eng/llama.cpp 5ae2e169eac202d2f065606539c3ad6ab8b51333 inputs/reference_code
|
| 28 |
+
# The original weights, unchanged.
|
| 29 |
+
get "https://huggingface.co/prism-ml/Bonsai-27B-gguf/resolve/f10afb355f104535e3e3e98cf7ab7795c72bd292/Bonsai-27B-Q1_0.gguf" \
|
| 30 |
+
"inputs/weights/Bonsai-27B-Q1_0.gguf" 17ef842e47450caeb8eaa3ebfbbab5d2f2278b62b79be107985fb69a2f819aa0
|
| 31 |
+
mkdir -p bin
|
| 32 |
+
echo "$PWD/inputs/weights/Bonsai-27B-Q1_0.gguf" > bin/model_path.txt
|
| 33 |
+
echo "fetch.sh: done. Next: bash build.sh, then bash deploy.sh ~/bonsai27b"
|
m2pro-gpu-q1_0/nnopt-prismml-5ae2e169.patch
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ee5 100644
|
| 3 |
+
--- a/ggml/src/ggml-metal/ggml-metal-device.cpp
|
| 4 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-device.cpp
|
| 5 |
+
@@ -602,6 +602,17 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_dsv4_hc(ggml_met
|
| 6 |
+
return res;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
+ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_state_step(ggml_metal_library_t lib) {
|
| 10 |
+
+ const char * name = "kernel_conv_state_step_f32";
|
| 11 |
+
+
|
| 12 |
+
+ ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
| 13 |
+
+ if (!res.pipeline) {
|
| 14 |
+
+ res = ggml_metal_library_compile_pipeline(lib, name, name, nullptr);
|
| 15 |
+
+ }
|
| 16 |
+
+
|
| 17 |
+
+ return res;
|
| 18 |
+
+}
|
| 19 |
+
+
|
| 20 |
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv(ggml_metal_library_t lib, const ggml_tensor * op, bool silu) {
|
| 21 |
+
GGML_ASSERT(op->src[0]->type == GGML_TYPE_F32);
|
| 22 |
+
GGML_ASSERT(op->src[1]->type == GGML_TYPE_F32);
|
| 23 |
+
@@ -909,6 +920,16 @@ bool ggml_metal_ptq1_multicol_enabled(const ggml_tensor * op) {
|
| 24 |
+
op->src[1]->ne[1] >= 2 && op->src[1]->ne[1] <= 4;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
+bool ggml_metal_q1_0_lut_supported(const ggml_tensor * op) {
|
| 28 |
+
+ static const bool enabled = !getenv("NNOPT_Q1_LUT") || atoi(getenv("NNOPT_Q1_LUT")) != 0;
|
| 29 |
+
+ const ggml_tensor * src0 = op->src[0];
|
| 30 |
+
+ const ggml_tensor * src1 = op->src[1];
|
| 31 |
+
+ return enabled && src0->type == GGML_TYPE_Q1_0 && src1->type == GGML_TYPE_F32 &&
|
| 32 |
+
+ src0->ne[0] % 1024 == 0 && src0->ne[1] >= 512 && src1->ne[1] == 1 &&
|
| 33 |
+
+ src0->ne[2] == 1 && src0->ne[3] == 1 && src1->ne[2] == 1 && src1->ne[3] == 1 &&
|
| 34 |
+
+ src1->nb[0] == sizeof(float);
|
| 35 |
+
+}
|
| 36 |
+
+
|
| 37 |
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv(ggml_metal_library_t lib, const ggml_tensor * op) {
|
| 38 |
+
GGML_TENSOR_LOCALS( int32_t, ne0, op->src[0], ne);
|
| 39 |
+
GGML_TENSOR_LOCALS( int32_t, ne1, op->src[1], ne);
|
| 40 |
+
@@ -963,6 +984,16 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv(ggml_meta
|
| 41 |
+
nr1 = 2;
|
| 42 |
+
}
|
| 43 |
+
suffix = nr1 == 2 ? "_nr1_2" : nr1 == 3 ? "_nr1_3" : nr1 == 4 ? "_nr1_4" : "";
|
| 44 |
+
+ if (nr1 == 1 && ggml_metal_q1_0_lut_supported(op)) {
|
| 45 |
+
+ // lookup-table decode kernel, see kernel_mul_mv_q1_0_f32_lut
|
| 46 |
+
+ static const int lut_nr = getenv("NNOPT_Q1_LUT_NR") ? atoi(getenv("NNOPT_Q1_LUT_NR")) : 4;
|
| 47 |
+
+ static const int lut_nsg = getenv("NNOPT_Q1_LUT_NSG") ? atoi(getenv("NNOPT_Q1_LUT_NSG")) : 16;
|
| 48 |
+
+ nsg = lut_nsg;
|
| 49 |
+
+ nr0 = lut_nr;
|
| 50 |
+
+ smem = 16*(1024/4)*sizeof(float);
|
| 51 |
+
+ snprintf(ptq1_suffix, sizeof(ptq1_suffix), "_lut_%d", lut_nr);
|
| 52 |
+
+ suffix = ptq1_suffix;
|
| 53 |
+
+ }
|
| 54 |
+
} break;
|
| 55 |
+
case GGML_TYPE_Q2_0:
|
| 56 |
+
{
|
| 57 |
+
diff --git a/ggml/src/ggml-metal/ggml-metal-device.h b/ggml/src/ggml-metal/ggml-metal-device.h
|
| 58 |
+
index 5efc4c82f..5cd6c8858 100644
|
| 59 |
+
--- a/ggml/src/ggml-metal/ggml-metal-device.h
|
| 60 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-device.h
|
| 61 |
+
@@ -6,6 +6,7 @@
|
| 62 |
+
extern "C" {
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
+bool ggml_metal_q1_0_lut_supported(const struct ggml_tensor * op);
|
| 66 |
+
bool ggml_metal_ptq1_multicol_enabled(const struct ggml_tensor * op);
|
| 67 |
+
|
| 68 |
+
struct ggml_metal_buffer_id {
|
| 69 |
+
@@ -133,6 +134,7 @@ struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_tri
|
| 70 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_soft_max (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 71 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_lightning_indexer (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 72 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_dsv4_hc (ggml_metal_library_t lib, enum ggml_op op);
|
| 73 |
+
+struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_state_step (ggml_metal_library_t lib);
|
| 74 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv (ggml_metal_library_t lib, const struct ggml_tensor * op, bool silu);
|
| 75 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv_batched (ggml_metal_library_t lib, const struct ggml_tensor * op, int ssm_conv_bs, bool silu);
|
| 76 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 77 |
+
diff --git a/ggml/src/ggml-metal/ggml-metal-impl.h b/ggml/src/ggml-metal/ggml-metal-impl.h
|
| 78 |
+
index 6a68c7006..14e2e7f5d 100644
|
| 79 |
+
--- a/ggml/src/ggml-metal/ggml-metal-impl.h
|
| 80 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-impl.h
|
| 81 |
+
@@ -918,6 +918,18 @@ typedef struct {
|
| 82 |
+
uint64_t nb2;
|
| 83 |
+
} ggml_metal_kargs_ssm_conv;
|
| 84 |
+
|
| 85 |
+
+// decode conv-state step of the gated delta net, see ggml_metal_op_conv_state_step
|
| 86 |
+
+typedef struct {
|
| 87 |
+
+ int32_t nch; // channels
|
| 88 |
+
+ int32_t sA; // first element of the state slot copies, in the 4-wide conv input
|
| 89 |
+
+ int32_t sB;
|
| 90 |
+
+ int32_t silu;
|
| 91 |
+
+ uint64_t nb00; // state (concat src0) element (k, c) at c*nb01 + k*nb00
|
| 92 |
+
+ uint64_t nb01;
|
| 93 |
+
+ uint64_t nb11; // new input (concat src1) element (0, c) at c*nb11
|
| 94 |
+
+ uint64_t nb1; // conv input (concat dst) row stride
|
| 95 |
+
+} ggml_metal_kargs_conv_state_step;
|
| 96 |
+
+
|
| 97 |
+
typedef struct {
|
| 98 |
+
int64_t d_state;
|
| 99 |
+
int64_t d_inner;
|
| 100 |
+
diff --git a/ggml/src/ggml-metal/ggml-metal-ops.cpp b/ggml/src/ggml-metal/ggml-metal-ops.cpp
|
| 101 |
+
index dc2a9072c..9ffa82e9f 100644
|
| 102 |
+
--- a/ggml/src/ggml-metal/ggml-metal-ops.cpp
|
| 103 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-ops.cpp
|
| 104 |
+
@@ -566,9 +566,119 @@ int ggml_metal_op_encode(ggml_metal_op_t ctx, int idx) {
|
| 105 |
+
return res;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
+// Decode conv-state step of the gated delta net (src/models/delta-net-base.cpp build_conv_state, then
|
| 109 |
+
+// ggml_ssm_conv and ggml_silu in qwen35.cpp), for one token and one sequence:
|
| 110 |
+
+// conv_input = CONCAT(conv_states [3, C], x^T [1, C]) -> 2 x CPY(view of conv_input [3, C] at element s, state slot)
|
| 111 |
+
+// -> SSM_CONV(conv_input, kernel [4, C]) (-> SILU)
|
| 112 |
+
+// encoded as one thread-per-channel kernel instead of 4-5 dependent dispatches. Returns the number of fused nodes,
|
| 113 |
+
+// 0 when the pattern does not match (the generic kernels run).
|
| 114 |
+
+static int ggml_metal_op_conv_state_step(ggml_metal_op_t ctx, int idx) {
|
| 115 |
+
+ ggml_tensor * op = ctx->node(idx);
|
| 116 |
+
+
|
| 117 |
+
+ if (!ctx->use_fusion || idx + 4 > ctx->n_nodes()) {
|
| 118 |
+
+ return 0;
|
| 119 |
+
+ }
|
| 120 |
+
+
|
| 121 |
+
+ const ggml_tensor * s0 = op->src[0];
|
| 122 |
+
+ const ggml_tensor * s1 = op->src[1];
|
| 123 |
+
+ const int64_t nch = op->ne[1];
|
| 124 |
+
+
|
| 125 |
+
+ if (((const int32_t *) op->op_params)[0] != 0 || op->type != GGML_TYPE_F32 || s0->type != GGML_TYPE_F32 ||
|
| 126 |
+
+ s1->type != GGML_TYPE_F32 || !ggml_is_contiguous(op) ||
|
| 127 |
+
+ op->ne[0] != 4 || op->ne[2] != 1 || op->ne[3] != 1 ||
|
| 128 |
+
+ s0->ne[0] != 3 || s0->ne[1] != nch || s0->ne[2] != 1 || s0->ne[3] != 1 ||
|
| 129 |
+
+ s1->ne[0] != 1 || s1->ne[1] != nch || s1->ne[2] != 1 || s1->ne[3] != 1) {
|
| 130 |
+
+ return 0;
|
| 131 |
+
+ }
|
| 132 |
+
+
|
| 133 |
+
+ ggml_tensor * cpy[2] = { ctx->node(idx + 1), ctx->node(idx + 2) };
|
| 134 |
+
+ int32_t sidx[2];
|
| 135 |
+
+ for (int j = 0; j < 2; ++j) {
|
| 136 |
+
+ const ggml_tensor * v = cpy[j]->src[0];
|
| 137 |
+
+ const ggml_tensor * d = cpy[j]->src[1];
|
| 138 |
+
+ if (cpy[j]->op != GGML_OP_CPY || v->view_src != op || v->type != GGML_TYPE_F32 ||
|
| 139 |
+
+ d->type != GGML_TYPE_F32 || !ggml_is_contiguous(d) || ggml_nelements(d) != 3*nch ||
|
| 140 |
+
+ v->ne[0] != 3 || v->ne[1] != nch || v->ne[2] != 1 || v->ne[3] != 1 ||
|
| 141 |
+
+ v->nb[0] != sizeof(float) || v->nb[1] != op->nb[1] || cpy[j]->data != d->data) {
|
| 142 |
+
+ return 0;
|
| 143 |
+
+ }
|
| 144 |
+
+ const size_t offs = (const char *) v->data - (const char *) op->data;
|
| 145 |
+
+ if (offs % sizeof(float) != 0 || offs/sizeof(float) > 1) {
|
| 146 |
+
+ return 0;
|
| 147 |
+
+ }
|
| 148 |
+
+ sidx[j] = (int32_t) (offs/sizeof(float));
|
| 149 |
+
+ }
|
| 150 |
+
+
|
| 151 |
+
+ ggml_tensor * conv = ctx->node(idx + 3);
|
| 152 |
+
+ if (conv->op != GGML_OP_SSM_CONV || conv->src[0] != op || conv->type != GGML_TYPE_F32 ||
|
| 153 |
+
+ conv->src[1]->type != GGML_TYPE_F32 || !ggml_is_contiguous(conv->src[1]) ||
|
| 154 |
+
+ conv->src[1]->ne[0] != 4 || conv->src[1]->ne[1] != nch ||
|
| 155 |
+
+ conv->ne[0] != nch || conv->ne[1] != 1 || conv->ne[2] != 1 || !ggml_is_contiguous(conv)) {
|
| 156 |
+
+ return 0;
|
| 157 |
+
+ }
|
| 158 |
+
+
|
| 159 |
+
+ // conv followed by a silu that is its only consumer (as in ggml_metal_op_ssm_conv)
|
| 160 |
+
+ ggml_tensor * out = conv;
|
| 161 |
+
+ int n_fuse = 4;
|
| 162 |
+
+ {
|
| 163 |
+
+ static constexpr ggml_op ops[2] = { GGML_OP_SSM_CONV, GGML_OP_UNARY };
|
| 164 |
+
+ if (ctx->can_fuse(idx + 3, ops, 2)) {
|
| 165 |
+
+ ggml_tensor * un = ctx->node(idx + 4);
|
| 166 |
+
+ if (ggml_get_unary_op(un) == GGML_UNARY_OP_SILU && un->src[0] == conv &&
|
| 167 |
+
+ un->type == GGML_TYPE_F32 && ggml_is_contiguous(un) && ggml_are_same_shape(un, conv)) {
|
| 168 |
+
+ out = un;
|
| 169 |
+
+ n_fuse = 5;
|
| 170 |
+
+ }
|
| 171 |
+
+ }
|
| 172 |
+
+ }
|
| 173 |
+
+
|
| 174 |
+
+ for (int i = 1; i < n_fuse; ++i) {
|
| 175 |
+
+ if (!ggml_metal_op_concurrency_check(ctx, ctx->node(idx + i))) {
|
| 176 |
+
+ ggml_metal_op_concurrency_reset(ctx);
|
| 177 |
+
+ }
|
| 178 |
+
+ }
|
| 179 |
+
+
|
| 180 |
+
+ ggml_metal_kargs_conv_state_step args = {
|
| 181 |
+
+ /*.nch =*/ (int32_t) nch,
|
| 182 |
+
+ /*.sA =*/ sidx[0],
|
| 183 |
+
+ /*.sB =*/ sidx[1],
|
| 184 |
+
+ /*.silu =*/ n_fuse == 5 ? 1 : 0,
|
| 185 |
+
+ /*.nb00 =*/ s0->nb[0],
|
| 186 |
+
+ /*.nb01 =*/ s0->nb[1],
|
| 187 |
+
+ /*.nb11 =*/ s1->nb[1],
|
| 188 |
+
+ /*.nb1 =*/ op->nb[1],
|
| 189 |
+
+ };
|
| 190 |
+
+
|
| 191 |
+
+ ggml_metal_encoder_t enc = ctx->enc;
|
| 192 |
+
+
|
| 193 |
+
+ auto pipeline = ggml_metal_library_get_pipeline_conv_state_step(ctx->lib);
|
| 194 |
+
+
|
| 195 |
+
+ ggml_metal_encoder_set_pipeline(enc, pipeline);
|
| 196 |
+
+ ggml_metal_encoder_set_bytes (enc, &args, sizeof(args), 0);
|
| 197 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(s0), 1);
|
| 198 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(s1), 2);
|
| 199 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op), 3);
|
| 200 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(cpy[0]), 4);
|
| 201 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(cpy[1]), 5);
|
| 202 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(conv->src[1]), 6);
|
| 203 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(out), 7);
|
| 204 |
+
+
|
| 205 |
+
+ const int nth = 256;
|
| 206 |
+
+ ggml_metal_encoder_dispatch_threadgroups(enc, (nch + nth - 1)/nth, 1, 1, nth, 1, 1);
|
| 207 |
+
+
|
| 208 |
+
+ return n_fuse;
|
| 209 |
+
+}
|
| 210 |
+
+
|
| 211 |
+
int ggml_metal_op_concat(ggml_metal_op_t ctx, int idx) {
|
| 212 |
+
ggml_tensor * op = ctx->node(idx);
|
| 213 |
+
|
| 214 |
+
+ {
|
| 215 |
+
+ const int n_fuse = ggml_metal_op_conv_state_step(ctx, idx);
|
| 216 |
+
+ if (n_fuse > 0) {
|
| 217 |
+
+ return n_fuse;
|
| 218 |
+
+ }
|
| 219 |
+
+ }
|
| 220 |
+
+
|
| 221 |
+
ggml_metal_library_t lib = ctx->lib;
|
| 222 |
+
ggml_metal_encoder_t enc = ctx->enc;
|
| 223 |
+
|
| 224 |
+
diff --git a/ggml/src/ggml-metal/kernels/dequantize.h b/ggml/src/ggml-metal/kernels/dequantize.h
|
| 225 |
+
index 70e773a21..88856df43 100644
|
| 226 |
+
--- a/ggml/src/ggml-metal/kernels/dequantize.h
|
| 227 |
+
+++ b/ggml/src/ggml-metal/kernels/dequantize.h
|
| 228 |
+
@@ -45,10 +45,31 @@ void dequantize_bf16_t4(device const bfloat4 * src, short il, thread type4 & reg
|
| 229 |
+
}
|
| 230 |
+
#endif
|
| 231 |
+
|
| 232 |
+
+// Q1_0 weights in Metal buffers are stored repacked (llama-model-loader.cpp, q1_0_repack_tiles): each
|
| 233 |
+
+// 1024-weight tile of a row (8 blocks, 144 bytes) holds the 8 fp16 block scales (16 B), then the 8 x 16 B of
|
| 234 |
+
+// sign bits. Tiles start 16-byte aligned, so the address the original layout gives block i of a tile,
|
| 235 |
+
+// tile + 18*i, has (address & 15) == 2*i: every kernel keeps its block_q1_0 pointer arithmetic and finds
|
| 236 |
+
+// the block's scale and bits from that address.
|
| 237 |
+
+struct q1_0_loc {
|
| 238 |
+
+ half d;
|
| 239 |
+
+ device const uint8_t * qs;
|
| 240 |
+
+};
|
| 241 |
+
+
|
| 242 |
+
+static inline q1_0_loc q1_0_locate(device const block_q1_0 * xb) {
|
| 243 |
+
+ device const char * p = (device const char *) xb;
|
| 244 |
+
+ const short i = (short) ((((ulong) p) & 15) >> 1);
|
| 245 |
+
+ device const char * tile = p - 18*i;
|
| 246 |
+
+ q1_0_loc res;
|
| 247 |
+
+ res.d = ((device const half *) tile)[i];
|
| 248 |
+
+ res.qs = (device const uint8_t *) (tile + 16 + 16*i);
|
| 249 |
+
+ return res;
|
| 250 |
+
+}
|
| 251 |
+
+
|
| 252 |
+
template <typename type4x4>
|
| 253 |
+
void dequantize_q1_0(device const block_q1_0 * xb, short il, thread type4x4 & reg) {
|
| 254 |
+
- device const uint8_t * qs = xb->qs;
|
| 255 |
+
- const float d = xb->d;
|
| 256 |
+
+ const q1_0_loc blk = q1_0_locate(xb);
|
| 257 |
+
+ device const uint8_t * qs = blk.qs;
|
| 258 |
+
+ const float d = blk.d;
|
| 259 |
+
const float neg_d = -d;
|
| 260 |
+
|
| 261 |
+
const int byte_offset = il * 2; // il*16 bits = il*2 bytes
|
| 262 |
+
@@ -80,10 +101,11 @@ void dequantize_q1_0(device const block_q1_0 * xb, short il, thread type4x4 & re
|
| 263 |
+
|
| 264 |
+
template <typename type4>
|
| 265 |
+
void dequantize_q1_0_t4(device const block_q1_0 * xb, short il, thread type4 & reg) {
|
| 266 |
+
- const float d = xb->d;
|
| 267 |
+
+ const q1_0_loc blk = q1_0_locate(xb);
|
| 268 |
+
+ const float d = blk.d;
|
| 269 |
+
const float neg_d = -d;
|
| 270 |
+
const int base = il * 4;
|
| 271 |
+
- const uint8_t byte = xb->qs[base / 8];
|
| 272 |
+
+ const uint8_t byte = blk.qs[base / 8];
|
| 273 |
+
const int s = base % 8;
|
| 274 |
+
|
| 275 |
+
float4 reg_f;
|
| 276 |
+
diff --git a/ggml/src/ggml-metal/kernels/mul_mv.metal b/ggml/src/ggml-metal/kernels/mul_mv.metal
|
| 277 |
+
index d204fff39..1248901a4 100644
|
| 278 |
+
--- a/ggml/src/ggml-metal/kernels/mul_mv.metal
|
| 279 |
+
+++ b/ggml/src/ggml-metal/kernels/mul_mv.metal
|
| 280 |
+
@@ -2,7 +2,8 @@
|
| 281 |
+
#include "dequantize.h"
|
| 282 |
+
// Q1_0 dot product: dot = d * (2 * Σ(yl[i] where bit=1) - sumy)
|
| 283 |
+
inline float block_q_n_dot_y(device const block_q1_0 * qb_curr, float sumy, thread float * yl, int il) {
|
| 284 |
+
- device const uint8_t * qs = qb_curr->qs + il / 8;
|
| 285 |
+
+ const q1_0_loc blk = q1_0_locate(qb_curr);
|
| 286 |
+
+ device const uint8_t * qs = blk.qs + il / 8;
|
| 287 |
+
const uint8_t b0 = qs[0];
|
| 288 |
+
const uint8_t b1 = qs[1];
|
| 289 |
+
|
| 290 |
+
@@ -26,7 +27,7 @@ inline float block_q_n_dot_y(device const block_q1_0 * qb_curr, float sumy, thre
|
| 291 |
+
acc += select(0.0f, yl[14], bool(b1 & 0x40));
|
| 292 |
+
acc += select(0.0f, yl[15], bool(b1 & 0x80));
|
| 293 |
+
|
| 294 |
+
- return qb_curr->d * (2.0f * acc - sumy);
|
| 295 |
+
+ return blk.d * (2.0f * acc - sumy);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// Q2_0 dot: d * (sum_lo(y) + 2*sum_hi(y) - sumy) via per-bit conditional adds
|
| 299 |
+
@@ -430,6 +431,110 @@ kernel void kernel_mul_mv_q1_0_f32(
|
| 300 |
+
kernel_mul_mv_q1_0_f32_impl<N_R0_Q1_0, constant ggml_metal_kargs_mul_mv &>(args, src0, src1, dst, nullptr, tgpig, tiisg, sgitg);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
+// Q1_0 single-column mat-vec through a lookup table (decode, ne11 == 1), on the repacked layout
|
| 304 |
+
+// (see q1_0_locate in dequantize.h): a row's 1024-wide K tile is 16 B of block scales, then 128 B of bits.
|
| 305 |
+
+// The bit-select dot (block_q_n_dot_y) costs ~3 ALU ops per weight, which caps it well below the memory
|
| 306 |
+
+// bandwidth. Here the threadgroup first builds, for each group of 4 consecutive src1 values of the tile, the
|
| 307 |
+
+// 16 signed sums +-y0 +-y1 +-y2 +-y3 in threadgroup memory; then every 4 weight bits of every row cost one
|
| 308 |
+
+// table read and one add. Same math as block_q_n_dot_y: d*(2*sum(y where bit=1) - sum(y)) == d*sum(+-y), fp32.
|
| 309 |
+
+// Lane l of a row reads the tile's bits 32l..32l+31 (block l/4) with one coalesced 32-bit load: 8 nibbles,
|
| 310 |
+
+// groups g = 8l + j. Table layout tab[n*GT + pos], pos = (g%8)*32 + (g/8 + 4*(g%8))%32: both the build
|
| 311 |
+
+// (consecutive g) and the lookups (lane l reads g = 8l + j) hit 32 different banks.
|
| 312 |
+
+template<short NR>
|
| 313 |
+
+kernel void kernel_mul_mv_q1_0_f32_lut(
|
| 314 |
+
+ constant ggml_metal_kargs_mul_mv & args,
|
| 315 |
+
+ device const char * src0,
|
| 316 |
+
+ device const char * src1,
|
| 317 |
+
+ device char * dst,
|
| 318 |
+
+ threadgroup char * shmem [[threadgroup(0)]],
|
| 319 |
+
+ uint3 tgpig[[threadgroup_position_in_grid]],
|
| 320 |
+
+ ushort tiisg[[thread_index_in_simdgroup]],
|
| 321 |
+
+ ushort sgitg[[simdgroup_index_in_threadgroup]]) {
|
| 322 |
+
+ const short NSG = FC_mul_mv_nsg;
|
| 323 |
+
+
|
| 324 |
+
+ constexpr short KT = 1024;
|
| 325 |
+
+ constexpr short GT = KT/4; // groups of 4 per tile
|
| 326 |
+
+ constexpr short TB = 144; // bytes per row tile
|
| 327 |
+
+
|
| 328 |
+
+ threadgroup float * tab = (threadgroup float *) shmem;
|
| 329 |
+
+
|
| 330 |
+
+ const int r1 = tgpig.y;
|
| 331 |
+
+
|
| 332 |
+
+ const int first_row = (tgpig.x*NSG + sgitg)*NR;
|
| 333 |
+
+ const short tid = sgitg*N_SIMDWIDTH + tiisg;
|
| 334 |
+
+
|
| 335 |
+
+ device const float * y = (device const float *) (src1 + (uint64_t) r1*args.nb11);
|
| 336 |
+
+
|
| 337 |
+
+ device const char * ax[NR];
|
| 338 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 339 |
+
+ const int row = min(first_row + r, args.ne01 - 1);
|
| 340 |
+
+ ax[r] = src0 + (uint64_t) row*args.nb01;
|
| 341 |
+
+ }
|
| 342 |
+
+
|
| 343 |
+
+ float acc[NR] = { 0.f };
|
| 344 |
+
+
|
| 345 |
+
+ const int ntiles = args.ne00/KT;
|
| 346 |
+
+
|
| 347 |
+
+ // table offsets of the lane's groups j and j + 4, packed in the two 16-bit halves
|
| 348 |
+
+ uint offp[4];
|
| 349 |
+
+ FOR_UNROLL (short j = 0; j < 4; ++j) {
|
| 350 |
+
+ offp[j] = (uint) (j*32 + ((tiisg + 4*j) & 31)) | ((uint) ((j + 4)*32 + ((tiisg + 4*(j + 4)) & 31)) << 16);
|
| 351 |
+
+ }
|
| 352 |
+
+
|
| 353 |
+
+ for (int t = 0; t < ntiles; ++t) {
|
| 354 |
+
+ uint u [NR];
|
| 355 |
+
+ half dh[NR];
|
| 356 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 357 |
+
+ device const char * tb = ax[r] + t*TB;
|
| 358 |
+
+ dh[r] = ((device const half *) tb)[tiisg/4];
|
| 359 |
+
+ u [r] = ((device const uint *) (tb + 16))[tiisg];
|
| 360 |
+
+ }
|
| 361 |
+
+
|
| 362 |
+
+ threadgroup_barrier(mem_flags::mem_threadgroup);
|
| 363 |
+
+
|
| 364 |
+
+ for (short g = tid; g < GT; g += NSG*N_SIMDWIDTH) {
|
| 365 |
+
+ const float4 yv = ((device const float4 *) (y + t*KT))[g];
|
| 366 |
+
+ const float a[4] = { -yv[0] - yv[1], yv[0] - yv[1], -yv[0] + yv[1], yv[0] + yv[1] };
|
| 367 |
+
+ const float b[4] = { -yv[2] - yv[3], yv[2] - yv[3], -yv[2] + yv[3], yv[2] + yv[3] };
|
| 368 |
+
+ const short pos = (g%8)*32 + ((g/8 + 4*(g%8)) & 31);
|
| 369 |
+
+ FOR_UNROLL (short n = 0; n < 16; ++n) {
|
| 370 |
+
+ tab[n*GT + pos] = a[n%4] + b[n/4];
|
| 371 |
+
+ }
|
| 372 |
+
+ }
|
| 373 |
+
+
|
| 374 |
+
+ threadgroup_barrier(mem_flags::mem_threadgroup);
|
| 375 |
+
+
|
| 376 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 377 |
+
+ // two table indices per 32-bit op: nibbles j and j + 4 land in the two 16-bit halves as n*GT
|
| 378 |
+
+ const uint w = u[r];
|
| 379 |
+
+ const uint m = 0x0F000F00u;
|
| 380 |
+
+ const ushort2 x0 = as_type<ushort2>(((w << 8) & m) | offp[0]);
|
| 381 |
+
+ const ushort2 x1 = as_type<ushort2>(((w << 4) & m) | offp[1]);
|
| 382 |
+
+ const ushort2 x2 = as_type<ushort2>(((w ) & m) | offp[2]);
|
| 383 |
+
+ const ushort2 x3 = as_type<ushort2>(((w >> 4) & m) | offp[3]);
|
| 384 |
+
+ const float s = ((tab[x0[0]] + tab[x0[1]]) + (tab[x1[0]] + tab[x1[1]]))
|
| 385 |
+
+ + ((tab[x2[0]] + tab[x2[1]]) + (tab[x3[0]] + tab[x3[1]]));
|
| 386 |
+
+ acc[r] += (float) dh[r] * s;
|
| 387 |
+
+ }
|
| 388 |
+
+ }
|
| 389 |
+
+
|
| 390 |
+
+ device float * dst_f32 = (device float *) dst + (uint64_t) r1*args.ne0;
|
| 391 |
+
+
|
| 392 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 393 |
+
+ const float tot = simd_sum(acc[r]);
|
| 394 |
+
+
|
| 395 |
+
+ if (tiisg == 0 && first_row + r < args.ne01) {
|
| 396 |
+
+ dst_f32[first_row + r] = tot;
|
| 397 |
+
+ }
|
| 398 |
+
+ }
|
| 399 |
+
+}
|
| 400 |
+
+
|
| 401 |
+
+typedef decltype(kernel_mul_mv_q1_0_f32_lut<4>) kernel_mul_mv_q1_0_f32_lut_t;
|
| 402 |
+
+
|
| 403 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_2")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<2>;
|
| 404 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_4")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<4>;
|
| 405 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_8")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<8>;
|
| 406 |
+
+
|
| 407 |
+
// Q1_0 multi-column mat-vec: each q1_0 block is read once and dotted against nr1
|
| 408 |
+
// src1 columns (the spec-decode verify batch, ne11 = k+1 rows). tpb threads
|
| 409 |
+
// cooperate on one block, slice width SW = QK1_0/tpb. Register budget (M5 Pro):
|
| 410 |
+
@@ -506,14 +611,14 @@ void kernel_mul_mv_q1_0_f32_nc_impl(
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
FOR_UNROLL (short row = 0; row < nr0; row++) {
|
| 414 |
+
- device const block_q1_0 * qb = ax[row] + ib;
|
| 415 |
+
- device const uint8_t * qs = qb->qs + il/8;
|
| 416 |
+
+ const q1_0_loc blk = q1_0_locate(ax[row] + ib);
|
| 417 |
+
+ device const uint8_t * qs = blk.qs + il/8;
|
| 418 |
+
|
| 419 |
+
uint8_t b[SW/8];
|
| 420 |
+
FOR_UNROLL (short i = 0; i < SW/8; i++) {
|
| 421 |
+
b[i] = qs[i];
|
| 422 |
+
}
|
| 423 |
+
- const float d = qb->d;
|
| 424 |
+
+ const float d = blk.d;
|
| 425 |
+
|
| 426 |
+
FOR_UNROLL (short c = 0; c < nr1; c++) {
|
| 427 |
+
sumf[row][c] += q1_0_dot_y_sw<SW>(b, d, sumy[c], yl[c]);
|
| 428 |
+
@@ -681,8 +786,8 @@ void kernel_mul_mv_q1_0_f32_pc_impl(
|
| 429 |
+
int pcw[nr0];
|
| 430 |
+
|
| 431 |
+
FOR_UNROLL (short row = 0; row < nr0; row++) {
|
| 432 |
+
- device const block_q1_0 * qb = ax[row] + ib;
|
| 433 |
+
- device const uint8_t * qs = qb->qs; // 2-byte aligned: assemble from bytes
|
| 434 |
+
+ const q1_0_loc blk = q1_0_locate(ax[row] + ib);
|
| 435 |
+
+ device const uint8_t * qs = blk.qs; // 2-byte aligned: assemble from bytes
|
| 436 |
+
|
| 437 |
+
int pc = 0;
|
| 438 |
+
FOR_UNROLL (short j = 0; j < 4; j++) {
|
| 439 |
+
@@ -692,7 +797,7 @@ void kernel_mul_mv_q1_0_f32_pc_impl(
|
| 440 |
+
pc += popcount(wj);
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
- d [row] = qb->d;
|
| 444 |
+
+ d [row] = blk.d;
|
| 445 |
+
pcw[row] = pc;
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
diff --git a/ggml/src/ggml-metal/kernels/ssm.metal b/ggml/src/ggml-metal/kernels/ssm.metal
|
| 449 |
+
index b89be5454..8a4768412 100644
|
| 450 |
+
--- a/ggml/src/ggml-metal/kernels/ssm.metal
|
| 451 |
+
+++ b/ggml/src/ggml-metal/kernels/ssm.metal
|
| 452 |
+
@@ -66,6 +66,41 @@ kernel void kernel_ssm_conv_f32_f32_4(
|
| 453 |
+
x[0] = FC_ssm_conv_silu ? sumf / (1.0f + exp(-sumf)) : sumf;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
+// Decode (one token) conv-state step of the gated delta net in one thread per channel: the graph's
|
| 457 |
+
+// CONCAT(state[3], x) -> two CPYs of 3-wide windows into the state cache slots -> SSM_CONV (+ SILU).
|
| 458 |
+
+// Same math as kernel_ssm_conv_f32_f32_4: dot(conv input row, kernel row), then the same silu.
|
| 459 |
+
+kernel void kernel_conv_state_step_f32(
|
| 460 |
+
+ constant ggml_metal_kargs_conv_state_step & args,
|
| 461 |
+
+ device const char * src0,
|
| 462 |
+
+ device const char * src1,
|
| 463 |
+
+ device char * cin,
|
| 464 |
+
+ device float * dstA,
|
| 465 |
+
+ device float * dstB,
|
| 466 |
+
+ device const float4 * w,
|
| 467 |
+
+ device float * dst,
|
| 468 |
+
+ uint i[[thread_position_in_grid]]) {
|
| 469 |
+
+ if ((int) i >= args.nch) {
|
| 470 |
+
+ return;
|
| 471 |
+
+ }
|
| 472 |
+
+
|
| 473 |
+
+ device const char * s = src0 + i*args.nb01;
|
| 474 |
+
+ const float4 v = float4(*(device const float *) (s),
|
| 475 |
+
+ *(device const float *) (s + args.nb00),
|
| 476 |
+
+ *(device const float *) (s + 2*args.nb00),
|
| 477 |
+
+ *(device const float *) (src1 + i*args.nb11));
|
| 478 |
+
+
|
| 479 |
+
+ *(device float4 *) (cin + i*args.nb1) = v;
|
| 480 |
+
+
|
| 481 |
+
+ FOR_UNROLL (short k = 0; k < 3; ++k) {
|
| 482 |
+
+ dstA[3*i + k] = v[args.sA + k];
|
| 483 |
+
+ dstB[3*i + k] = v[args.sB + k];
|
| 484 |
+
+ }
|
| 485 |
+
+
|
| 486 |
+
+ const float sumf = dot(v, w[i]);
|
| 487 |
+
+
|
| 488 |
+
+ dst[i] = args.silu ? sumf / (1.0f + exp(-sumf)) : sumf;
|
| 489 |
+
+}
|
| 490 |
+
+
|
| 491 |
+
constant short FC_ssm_conv_bs [[function_constant(FC_SSM_CONV + 0)]];
|
| 492 |
+
|
| 493 |
+
// Batched version: each threadgroup processes multiple tokens for better efficiency
|
| 494 |
+
diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp
|
| 495 |
+
index 23d74c30a..ada919e6d 100644
|
| 496 |
+
--- a/src/llama-model-loader.cpp
|
| 497 |
+
+++ b/src/llama-model-loader.cpp
|
| 498 |
+
@@ -1440,6 +1440,36 @@ void llama_model_loader::load_data_for(struct ggml_tensor * cur) const {
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
+// Q1_0 weights in Metal buffers use the repacked layout the Metal kernels read (q1_0_locate in
|
| 503 |
+
+// ggml-metal kernels/dequantize.h): each 1024-weight tile of a row, 8 blocks of {fp16 d, 16 B bits} = 144 B,
|
| 504 |
+
+// is rewritten as the 8 scales (16 B) followed by the 8 x 16 B of bits. Same bytes, same size.
|
| 505 |
+
+static bool q1_0_metal_repack(const ggml_tensor * cur) {
|
| 506 |
+
+ if (cur->type != GGML_TYPE_Q1_0 || cur->buffer == nullptr) {
|
| 507 |
+
+ return false;
|
| 508 |
+
+ }
|
| 509 |
+
+ const char * name = ggml_backend_buft_name(ggml_backend_buffer_get_type(cur->buffer));
|
| 510 |
+
+ return strncmp(name, "MTL", 3) == 0;
|
| 511 |
+
+}
|
| 512 |
+
+
|
| 513 |
+
+static void q1_0_repack_tiles(void * data, const ggml_tensor * cur) {
|
| 514 |
+
+ constexpr size_t BS = 18; // block_q1_0: fp16 d, then 16 bytes of bits
|
| 515 |
+
+ constexpr size_t TB = 8*BS; // 144 bytes per 1024-weight tile
|
| 516 |
+
+ if (cur->ne[0] % 1024 != 0 || !ggml_is_contiguous(cur)) {
|
| 517 |
+
+ throw std::runtime_error(format("tensor '%s': the Metal Q1_0 kernels need ne0 %% 1024 == 0 and a contiguous tensor",
|
| 518 |
+
+ ggml_get_name(cur)));
|
| 519 |
+
+ }
|
| 520 |
+
+ const size_t ntiles = ggml_nbytes(cur)/TB;
|
| 521 |
+
+ uint8_t * p = (uint8_t *) data;
|
| 522 |
+
+ uint8_t tmp[TB];
|
| 523 |
+
+ for (size_t t = 0; t < ntiles; ++t, p += TB) {
|
| 524 |
+
+ memcpy(tmp, p, TB);
|
| 525 |
+
+ for (int i = 0; i < 8; ++i) {
|
| 526 |
+
+ memcpy(p + 2*i, tmp + i*BS, 2);
|
| 527 |
+
+ memcpy(p + 16 + 16*i, tmp + i*BS + 2, 16);
|
| 528 |
+
+ }
|
| 529 |
+
+ }
|
| 530 |
+
+}
|
| 531 |
+
+
|
| 532 |
+
bool llama_model_loader::load_all_data(
|
| 533 |
+
struct ggml_context * ctx,
|
| 534 |
+
llama_buf_map & bufs,
|
| 535 |
+
@@ -1585,6 +1615,11 @@ bool llama_model_loader::load_all_data(
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
GGML_ASSERT(buf_mmap || cur->data); // either we have a buffer to allocate the tensor in, or it is already allocated
|
| 539 |
+
+ if (q1_0_metal_repack(cur) || (buf_mmap && cur->type == GGML_TYPE_Q1_0 &&
|
| 540 |
+
+ strncmp(ggml_backend_buft_name(ggml_backend_buffer_get_type(buf_mmap)), "MTL", 3) == 0)) {
|
| 541 |
+
+ throw std::runtime_error(format("tensor '%s': Q1_0 weights on Metal need load_mode NONE, not mmap (repacked layout)",
|
| 542 |
+
+ ggml_get_name(cur)));
|
| 543 |
+
+ }
|
| 544 |
+
if (buf_mmap && cur->data == nullptr) {
|
| 545 |
+
ggml_backend_tensor_alloc(buf_mmap, cur, data);
|
| 546 |
+
if (lmlocks) {
|
| 547 |
+
@@ -1609,6 +1644,15 @@ bool llama_model_loader::load_all_data(
|
| 548 |
+
return std::make_pair(cur, ggml_validate_row_data(cur->type, cur->data, n_size));
|
| 549 |
+
}));
|
| 550 |
+
}
|
| 551 |
+
+ } else if (q1_0_metal_repack(cur)) {
|
| 552 |
+
+ read_buf.resize(n_size);
|
| 553 |
+
+ file->seek(weight->offs, SEEK_SET);
|
| 554 |
+
+ file->read_raw(read_buf.data(), n_size);
|
| 555 |
+
+ if (check_tensors && !ggml_validate_row_data(cur->type, read_buf.data(), n_size)) {
|
| 556 |
+
+ throw std::runtime_error(format("tensor '%s' has invalid data", ggml_get_name(cur)));
|
| 557 |
+
+ }
|
| 558 |
+
+ q1_0_repack_tiles(read_buf.data(), cur);
|
| 559 |
+
+ ggml_backend_tensor_set(cur, read_buf.data(), 0, n_size);
|
| 560 |
+
} else {
|
| 561 |
+
// If upload_backend is valid load the tensor in chunks to pinned memory and upload the buffers asynchronously to the GPU.
|
| 562 |
+
if (upload_backend) {
|
m2pro-gpu-q1_0/report.html
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
| 3 |
+
<title>nnopt report · prism-ml/Bonsai-27B-gguf</title>
|
| 4 |
+
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 5 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Condensed:wght@600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap">
|
| 6 |
+
<style>
|
| 7 |
+
:root {
|
| 8 |
+
--bg: #f3f5f2; --panel: #ffffff; --ink: #17201d; --ink-2: #33403b; --muted: #5a6762; --line: #cfd8d3;
|
| 9 |
+
--accent: #0b6e79; --accent-soft: #dcefee; --keep: #1d7a3e; --keep-soft: #dcf1e2; --stop: #b3261e;
|
| 10 |
+
--stop-soft: #f9dedb; --warn: #9a5b00; --warn-soft: #fbecd2; --grid: #e3e9e5;
|
| 11 |
+
--display: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
|
| 12 |
+
--body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
|
| 13 |
+
--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
|
| 14 |
+
color-scheme: light;
|
| 15 |
+
}
|
| 16 |
+
@media (prefers-color-scheme: dark) {
|
| 17 |
+
:root:not([data-theme="light"]) {
|
| 18 |
+
--bg: #111715; --panel: #18201d; --ink: #e4ebe7; --ink-2: #c3cec9; --muted: #9aa8a2; --line: #2c3833;
|
| 19 |
+
--accent: #4fc1cc; --accent-soft: #123236; --keep: #6fd394; --keep-soft: #143222; --stop: #ff8a80;
|
| 20 |
+
--stop-soft: #3d1715; --warn: #f0b45a; --warn-soft: #3a2a10; --grid: #222c28; color-scheme: dark;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
:root[data-theme="dark"] {
|
| 24 |
+
--bg: #111715; --panel: #18201d; --ink: #e4ebe7; --ink-2: #c3cec9; --muted: #9aa8a2; --line: #2c3833;
|
| 25 |
+
--accent: #4fc1cc; --accent-soft: #123236; --keep: #6fd394; --keep-soft: #143222; --stop: #ff8a80;
|
| 26 |
+
--stop-soft: #3d1715; --warn: #f0b45a; --warn-soft: #3a2a10; --grid: #222c28; color-scheme: dark;
|
| 27 |
+
}
|
| 28 |
+
* { box-sizing: border-box; }
|
| 29 |
+
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); }
|
| 30 |
+
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 20px 80px; display: grid; gap: 36px; }
|
| 31 |
+
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; }
|
| 32 |
+
h1 { font-size: clamp(28px, 4.5vw, 40px); font-weight: 700; letter-spacing: -0.01em; }
|
| 33 |
+
h2 { font-size: 22px; font-weight: 600; }
|
| 34 |
+
h3 { font-size: 16px; font-weight: 600; }
|
| 35 |
+
p { margin: 0; max-width: 72ch; }
|
| 36 |
+
code, .mono { font-family: var(--mono); font-size: 0.88em; }
|
| 37 |
+
.eyebrow { font: 500 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
|
| 38 |
+
.sub { color: var(--muted); font-size: 13px; }
|
| 39 |
+
section { display: grid; gap: 14px; min-width: 0; }
|
| 40 |
+
header { display: grid; gap: 10px; }
|
| 41 |
+
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
|
| 42 |
+
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 4px; min-width: 0; }
|
| 43 |
+
.tile .v { font: 700 26px/1.1 var(--display); font-variant-numeric: tabular-nums; }
|
| 44 |
+
.tile .k { font: 500 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
|
| 45 |
+
.tile.pass { border-color: var(--keep); background: var(--keep-soft); }
|
| 46 |
+
.tile.fail { border-color: var(--stop); background: var(--stop-soft); }
|
| 47 |
+
.tile.na { border-style: dashed; }
|
| 48 |
+
.badge { display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 var(--mono); padding: 4px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
|
| 49 |
+
.badge.pass { color: var(--keep); } .badge.fail { color: var(--stop); } .badge.skip { color: var(--muted); } .badge.warn { color: var(--warn); }
|
| 50 |
+
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; overflow-x: auto; }
|
| 51 |
+
table { border-collapse: collapse; width: 100%; font-size: 14px; }
|
| 52 |
+
th, td { text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
| 53 |
+
tr:last-child td { border-bottom: 0; }
|
| 54 |
+
th { font: 500 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
|
| 55 |
+
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
| 56 |
+
.flags { display: grid; gap: 6px; }
|
| 57 |
+
.flag { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 4px; font-size: 14px; }
|
| 58 |
+
.flag.bad { border-color: var(--stop); background: var(--stop-soft); }
|
| 59 |
+
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
|
| 60 |
+
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 8px; display: grid; gap: 6px; min-width: 0; }
|
| 61 |
+
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
|
| 62 |
+
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
|
| 63 |
+
.chart .pt { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
|
| 64 |
+
.chart .hit { fill: transparent; }
|
| 65 |
+
.chart .hit:hover + .pt, .chart .pt:hover { r: 5; }
|
| 66 |
+
.chart .gl { stroke: var(--grid); stroke-width: 1; }
|
| 67 |
+
.chart text { fill: var(--muted); font: 11px var(--mono); }
|
| 68 |
+
details { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
|
| 69 |
+
summary { cursor: pointer; font-weight: 500; }
|
| 70 |
+
pre { font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; margin: 10px 0 0; color: var(--ink-2); }
|
| 71 |
+
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
|
| 72 |
+
.kv dt { color: var(--muted); font: 500 12px/1.9 var(--mono); text-transform: uppercase; letter-spacing: .05em; }
|
| 73 |
+
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; word-break: break-all; }
|
| 74 |
+
footer { color: var(--muted); font-size: 12px; }
|
| 75 |
+
.figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
|
| 76 |
+
figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; min-width: 0; }
|
| 77 |
+
figure svg { width: 100%; height: auto; display: block; border-radius: 4px; }
|
| 78 |
+
figure .frame { fill: var(--grid); }
|
| 79 |
+
figcaption { font-size: 13px; color: var(--ink-2); display: grid; gap: 2px; }
|
| 80 |
+
.box { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
|
| 81 |
+
.box.ref { stroke: var(--ink); stroke-dasharray: 6 4; }
|
| 82 |
+
.box.ref.missed { stroke: var(--stop); stroke-width: 3; }
|
| 83 |
+
.box.port { stroke: var(--accent); }
|
| 84 |
+
.box.port.extra { stroke: var(--warn); stroke-width: 3; }
|
| 85 |
+
.box.borderline { stroke: var(--muted); stroke-width: 1; opacity: .7; }
|
| 86 |
+
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 12px var(--mono); color: var(--muted); }
|
| 87 |
+
.legend i { display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid; }
|
| 88 |
+
.vlm { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 12px; align-items: start; }
|
| 89 |
+
.vlm img { width: 100%; border-radius: 4px; display: block; }
|
| 90 |
+
.said { display: grid; gap: 6px; font-size: 14px; }
|
| 91 |
+
.said .who { font: 500 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
|
| 92 |
+
.said p { white-space: pre-wrap; word-break: break-word; }
|
| 93 |
+
mark { background: var(--stop-soft); color: var(--ink); border-bottom: 2px solid var(--stop); padding: 0 1px; }
|
| 94 |
+
@media (max-width: 560px) { .vlm { grid-template-columns: 1fr; } }
|
| 95 |
+
@media print { body { background: #fff; } .wrap { padding: 0; } }
|
| 96 |
+
</style></head><body><main class="wrap"><header><span class="eyebrow">nnopt verification report · Text to text</span>
|
| 97 |
+
<h1>prism-ml/Bonsai-27B-gguf on mac-mini-m2pro</h1>
|
| 98 |
+
<p class="sub">Job NN-53D464 · 2026-10-16 07:42 UTC ·
|
| 99 |
+
nnopt-verify 0.1.0 · reference bundle <span class="mono">b8e1d595699387ed</span></p>
|
| 100 |
+
</header><div class="tiles"><div class="tile pass"><span class="k">Correctness</span><span class="v">PASS</span><span class=sub>original precision policy</span></div><div class="tile pass"><span class="k">Speed target</span><span class="v">MET</span><span class=sub>Decode speed 29.38 tok/s vs 19.02 tok/s required</span></div><div class="tile pass"><span class="k">Runtime</span><span class="v">PASS</span><span class=sub>llama.cpp, as asked</span></div><div class="tile "><span class="k">Decode</span><span class="v">29.38 tok/s</span><span class=sub>warm, median</span></div><div class="tile "><span class="k">Peak memory</span><span class="v">4532 MB</span><span class=sub>process tree</span></div><div class="tile "><span class="k">Load time</span><span class="v">1038 ms</span></div></div><section><h2>Correctness</h2>
|
| 101 |
+
<p>The port ran on 20 inputs (6 hidden, generated fresh for this job and never shown to the
|
| 102 |
+
porting agent) and was compared with the reference outputs captured from your code. Thresholds are for the
|
| 103 |
+
<b>original</b> precision policy.</p>
|
| 104 |
+
<div class="panel"><table><thead><tr><th>Check</th><th>Value</th><th>Threshold</th><th>Result</th></tr></thead><tbody><tr><td>All cases ran<div class=sub>20/20 cases produced valid output</div></td><td class=num>1.00</td><td class=num>>= 1.00</td><td><span class="badge pass">✓ PASS</span></td></tr><tr><td>Tokenizer matches<div class=sub>prompt token ids identical</div></td><td class=num>1.00</td><td class=num>>= 1.00</td><td><span class="badge pass">✓ PASS</span></td></tr><tr><td>Next-token agreement (teacher-forced)<div class=sub>teacher-forced top-1 agreement over 1862 positions (0 near-ties forgiven)</div></td><td class=num>1.00</td><td class=num>>= 0.980</td><td><span class="badge pass">✓ PASS</span></td></tr><tr><td>Top-k overlap<div class=sub>mean top-10 overlap</div></td><td class=num>1.00</td><td class=num>>= 0.900</td><td><span class="badge pass">✓ PASS</span></td></tr><tr><td>Greedy continuation matched<div class=sub>mean matched prefix of 32 greedy tokens; 100% of prompts exact</div></td><td class=num>1.00</td><td class=num>>= 0.750</td><td><span class="badge pass">✓ PASS</span></td></tr></tbody></table></div><details><summary>Per-case results (20 cases)</summary><div class="panel" style="margin-top:10px"><table><thead><tr><th>Case</th><th>Split</th><th>Agreement</th><th>Top-k overlap</th><th>Greedy</th><th>Tokens</th></tr></thead><tbody><tr><td class=num>p000</td><td>public · builtin</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p001</td><td>public · builtin</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p002</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p003</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p004</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p005</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p006</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p007</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p008</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p009</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p010</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p011</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p012</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>p013</td><td>public · customer</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h000</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h001</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h002</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h003</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h004</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr><tr><td class=num>h005</td><td>hidden · generated</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>1.00</td><td class=num>yes</td></tr></tbody></table></div></details></section><section><h2>Runtime</h2>
|
| 105 |
+
<p>Asked for <b>Metal (llama.cpp fork)</b>. Clean build, the port's own code and build log: uses llama.cpp.</p>
|
| 106 |
+
<ul><li class="mono">src/runner.cpp:164: llama_model * model = llama_model_load_from_file(model_path.c_str(), mparams);</li><li class="mono">build log: [ 98%] Linking CXX static library libllama.a</li></ul></section><section><h2>Speed and memory</h2>
|
| 107 |
+
<p>2 warm-up runs, then 5 timed runs of 3 requests each (the first
|
| 108 |
+
request of each run is cold). Timed on the device's own clock.</p>
|
| 109 |
+
<div class="panel"><table><thead><tr><th>Metric (warm requests)</th><th>Median</th><th>p10</th><th>p90</th><th>n</th></tr></thead><tbody><tr><td>Decode speed</td><td class=num>29.38 tok/s</td><td class=num>26.49 tok/s</td><td class=num>29.99 tok/s</td><td class=num>10</td></tr><tr><td>Prefill speed</td><td class=num>86.04 tok/s</td><td class=num>86.01 tok/s</td><td class=num>86.38 tok/s</td><td class=num>10</td></tr><tr><td>Time to first token</td><td class=num>1825 ms</td><td class=num>1818 ms</td><td class=num>1825 ms</td><td class=num>10</td></tr><tr><td>End-to-end speed</td><td class=num>20.85 tok/s</td><td class=num>19.34 tok/s</td><td class=num>21.14 tok/s</td><td class=num>10</td></tr><tr><td>Request time</td><td class=num>6138 ms</td><td class=num>6054 ms</td><td class=num>6619 ms</td><td class=num>10</td></tr><tr><td>Time to first token (cold)</td><td class=num>1810 ms</td><td class=num>1810 ms</td><td class=num>1810 ms</td><td class=num>5</td></tr><tr><td>Load time</td><td class=num>1038 ms</td><td class=num>1032 ms</td><td class=num>1044 ms</td><td class=num>5</td></tr><tr><td>Process wall time</td><td class=num>20361 ms</td><td class=num>19901 ms</td><td class=num>20521 ms</td><td class=num>5</td></tr><tr><td>Peak RSS (process tree)</td><td class=num>4532 MB</td><td></td><td></td><td></td></tr><tr><td>Peak memory (self-reported)</td><td class=num>4530 MB</td><td></td><td></td><td></td></tr></tbody></table></div><p class="sub">External cross-check (paired --max-new-tokens N vs 1, 5 pairs, device clock): Decode speed: 27.60 tok/s. Graded values are capped by it.</p><p class="sub">Roofline: not computed (no environment specs or model facts were given).</p></section><section><h2>Sustained run</h2><p>The model ran continuously while the kit sampled temperature,
|
| 110 |
+
clocks and power.</p><div class="charts"><div class="chart"><h3>Decode speed over time</h3><svg viewBox="0 0 460 190" role="img" aria-label="Decode speed over time"><line class="gl" x1="46" x2="448" y1="164.0" y2="164.0"/><text x="40" y="168.0" text-anchor="end">30</text><line class="gl" x1="46" x2="448" y1="125.5" y2="125.5"/><text x="40" y="129.5" text-anchor="end">30</text><line class="gl" x1="46" x2="448" y1="87.0" y2="87.0"/><text x="40" y="91.0" text-anchor="end">30</text><line class="gl" x1="46" x2="448" y1="48.5" y2="48.5"/><text x="40" y="52.5" text-anchor="end">30</text><line class="gl" x1="46" x2="448" y1="10.0" y2="10.0"/><text x="40" y="14.0" text-anchor="end">30</text><text x="46.0" y="182" text-anchor="middle">32s</text><text x="146.5" y="182" text-anchor="middle">174s</text><text x="247.0" y="182" text-anchor="middle">317s</text><text x="347.5" y="182" text-anchor="middle">459s</text><text x="448.0" y="182" text-anchor="middle">602s</text><path class="ln" d="M46.0,106.7 L90.3,67.3 L134.7,67.3 L179.7,67.3 L224.8,106.7 L269.3,146.2 L314.2,146.2 L359.0,27.8 L403.2,146.2 L448.0,146.2"/><g><title>32 s: 30 tok/s</title><circle class="hit" cx="46.0" cy="106.7" r="10"/><circle class="pt" cx="46.0" cy="106.7" r="4"/></g><g><title>95 s: 30 tok/s</title><circle class="hit" cx="90.3" cy="67.3" r="10"/><circle class="pt" cx="90.3" cy="67.3" r="4"/></g><g><title>158 s: 30 tok/s</title><circle class="hit" cx="134.7" cy="67.3" r="10"/><circle class="pt" cx="134.7" cy="67.3" r="4"/></g><g><title>221 s: 30 tok/s</title><circle class="hit" cx="179.7" cy="67.3" r="10"/><circle class="pt" cx="179.7" cy="67.3" r="4"/></g><g><title>285 s: 30 tok/s</title><circle class="hit" cx="224.8" cy="106.7" r="10"/><circle class="pt" cx="224.8" cy="106.7" r="4"/></g><g><title>348 s: 30 tok/s</title><circle class="hit" cx="269.3" cy="146.2" r="10"/><circle class="pt" cx="269.3" cy="146.2" r="4"/></g><g><title>412 s: 30 tok/s</title><circle class="hit" cx="314.2" cy="146.2" r="10"/><circle class="pt" cx="314.2" cy="146.2" r="4"/></g><g><title>476 s: 30 tok/s</title><circle class="hit" cx="359.0" cy="27.8" r="10"/><circle class="pt" cx="359.0" cy="27.8" r="4"/></g><g><title>538 s: 30 tok/s</title><circle class="hit" cx="403.2" cy="146.2" r="10"/><circle class="pt" cx="403.2" cy="146.2" r="4"/></g><g><title>602 s: 30 tok/s</title><circle class="hit" cx="448.0" cy="146.2" r="10"/><circle class="pt" cx="448.0" cy="146.2" r="4"/></g></svg></div></div><dl class="kv"><dt>Duration</dt><dd>633.2 s</dd><dt>Runs</dt><dd>10</dd><dt>Sustained / initial speed</dt><dd>100.0%</dd><dt>Max temperature</dt><dd>–</dd><dt>GPU clock min / max</dt><dd>– / –</dd><dt>Mean power</dt><dd>–</dd><dt>Energy per token</dt><dd>–</dd></dl></section><section><h2>Environment and reproducibility</h2><dl class="kv"><dt>device</dt><dd>Mac mini (M2 Pro)</dd><dt>gpu</dt><dd>Apple M2 Pro GPU, 19 cores</dd><dt>name</dt><dd>Mac mini (M2 Pro)</dd><dt>executor</dt><dd>local</dd><dt>os</dt><dd>darwin</dd><dt>reference python</dt><dd>3.12.14</dd><dt>reference numpy</dt><dd>2.5.4</dd><dt>reference nnopt_verify</dt><dd>0.1.0</dd><dt>reference platform</dt><dd>macOS-27.0.1-arm64-arm-64bit</dd></dl><p class="sub">reproduce.sh re-runs the check and benchmark against the same frozen reference bundle; results.csv and results.json hold every number in this report.</p></section><footer>Generated by nnopt-verify 0.1.0. Correctness is graded on all inputs; speed figures are medians of warm requests unless marked cold.</footer></main></body></html>
|
m2pro-gpu-q1_0/report/reproduce.sh
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Reproduce the numbers in report.html with nnopt-verify 0.1.0.
|
| 3 |
+
# Needs: the frozen reference bundle, the port deployed on the device (./deploy.sh), and the device reachable.
|
| 4 |
+
# Connection: this machine.
|
| 5 |
+
set -e
|
| 6 |
+
BUNDLE=${BUNDLE:-./reference-bundle} # bundle digest b8e1d595699387ed56affd6be5a6b8698a0229f4007f8f68156d694d690355c3
|
| 7 |
+
PORT_DIR=${PORT_DIR:-/tmp/nnopt-device/port} # where deploy.sh put the port
|
| 8 |
+
OUT=${OUT:-./reproduced}
|
| 9 |
+
mkdir -p "$OUT"
|
| 10 |
+
|
| 11 |
+
nnopt-verify check --bundle "$BUNDLE" --port "$PORT_DIR" --executor local --precision original --split all --out "$OUT/check.json"
|
| 12 |
+
nnopt-verify bench --bundle "$BUNDLE" --port "$PORT_DIR" --executor local --warmup 2 --runs 5 --repeat 3 --max-new-tokens 128 --sustained-s 600.0 --env-specs '{"device": "Mac mini (M2 Pro)", "gpu": "Apple M2 Pro GPU, 19 cores", "name": "Mac mini (M2 Pro)"}' --out "$OUT/bench.json"
|
| 13 |
+
nnopt-verify grade --check "$OUT/check.json" --bench "$OUT/bench.json" --speed-target '{"metric": "tokens_per_s", "value": 19.02, "direction": "higher"}' --out "$OUT/grade.json"
|
| 14 |
+
nnopt-verify report --check "$OUT/check.json" --bench "$OUT/bench.json" --grade "$OUT/grade.json" --bundle "$BUNDLE" --out "$OUT/report"
|
m2pro-gpu-q1_0/report/results.csv
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
section,name,value,unit_or_op,threshold,passed
|
| 2 |
+
grade,correctness,True,,,True
|
| 3 |
+
grade,speed_target_met,True,,,True
|
| 4 |
+
check,cases_completed,1.0,>=,1.0,True
|
| 5 |
+
check,tokenizer_match,1.0,>=,1.0,True
|
| 6 |
+
check,next_token_agreement,1.0,>=,0.98,True
|
| 7 |
+
check,topk_overlap,1.0,>=,0.9,True
|
| 8 |
+
check,greedy_prefix,1.0,>=,0.75,True
|
| 9 |
+
check_metric,tokenizer_match,1.0,,,
|
| 10 |
+
check_metric,next_token_agreement,1.0,,,
|
| 11 |
+
check_metric,topk_overlap,1.0,,,
|
| 12 |
+
check_metric,greedy_prefix,1.0,,,
|
| 13 |
+
check_metric,greedy_exact,1.0,,,
|
| 14 |
+
check_metric,positions,1862,,,
|
| 15 |
+
check_metric,ties_forgiven,0,,,
|
| 16 |
+
check_metric,top_k,10,,,
|
| 17 |
+
bench,tokens_per_s.median,29.3804,tok/s,,
|
| 18 |
+
bench,tokens_per_s.p10,26.4903,tok/s,,
|
| 19 |
+
bench,tokens_per_s.p90,29.9945,tok/s,,
|
| 20 |
+
bench,tokens_per_s.min,26.3562,tok/s,,
|
| 21 |
+
bench,tokens_per_s.max,30.0148,tok/s,,
|
| 22 |
+
bench,tokens_per_s.n,10,tok/s,,
|
| 23 |
+
bench,prefill_tokens_per_s.median,86.043,tok/s,,
|
| 24 |
+
bench,prefill_tokens_per_s.p10,86.0103,tok/s,,
|
| 25 |
+
bench,prefill_tokens_per_s.p90,86.3823,tok/s,,
|
| 26 |
+
bench,prefill_tokens_per_s.min,86.0011,tok/s,,
|
| 27 |
+
bench,prefill_tokens_per_s.max,86.6422,tok/s,,
|
| 28 |
+
bench,prefill_tokens_per_s.n,10,tok/s,,
|
| 29 |
+
bench,ttft_ms.median,1824.67,ms,,
|
| 30 |
+
bench,ttft_ms.p10,1817.5,ms,,
|
| 31 |
+
bench,ttft_ms.p90,1825.36,ms,,
|
| 32 |
+
bench,ttft_ms.min,1812.05,ms,,
|
| 33 |
+
bench,ttft_ms.max,1825.56,ms,,
|
| 34 |
+
bench,ttft_ms.n,10,ms,,
|
| 35 |
+
bench,e2e_tokens_per_s.median,20.8546,tok/s,,
|
| 36 |
+
bench,e2e_tokens_per_s.p10,19.3377,tok/s,,
|
| 37 |
+
bench,e2e_tokens_per_s.p90,21.1426,tok/s,,
|
| 38 |
+
bench,e2e_tokens_per_s.min,19.267,tok/s,,
|
| 39 |
+
bench,e2e_tokens_per_s.max,21.1496,tok/s,,
|
| 40 |
+
bench,e2e_tokens_per_s.n,10,tok/s,,
|
| 41 |
+
bench,total_ms.median,6137.98,ms,,
|
| 42 |
+
bench,total_ms.p10,6054.13,ms,,
|
| 43 |
+
bench,total_ms.p90,6619.21,ms,,
|
| 44 |
+
bench,total_ms.min,6052.13,ms,,
|
| 45 |
+
bench,total_ms.max,6643.47,ms,,
|
| 46 |
+
bench,total_ms.n,10,ms,,
|
| 47 |
+
bench,cold_ttft_ms.median,1809.74,ms,,
|
| 48 |
+
bench,cold_ttft_ms.p10,1809.72,ms,,
|
| 49 |
+
bench,cold_ttft_ms.p90,1809.96,ms,,
|
| 50 |
+
bench,cold_ttft_ms.min,1809.71,ms,,
|
| 51 |
+
bench,cold_ttft_ms.max,1810.01,ms,,
|
| 52 |
+
bench,cold_ttft_ms.n,5,ms,,
|
| 53 |
+
bench,load_ms.median,1037.93,ms,,
|
| 54 |
+
bench,load_ms.p10,1031.94,ms,,
|
| 55 |
+
bench,load_ms.p90,1043.5,ms,,
|
| 56 |
+
bench,load_ms.min,1030.59,ms,,
|
| 57 |
+
bench,load_ms.max,1045.89,ms,,
|
| 58 |
+
bench,load_ms.n,5,ms,,
|
| 59 |
+
bench,wall_ms.median,20361.1,ms,,
|
| 60 |
+
bench,wall_ms.p10,19900.6,ms,,
|
| 61 |
+
bench,wall_ms.p90,20520.8,ms,,
|
| 62 |
+
bench,wall_ms.min,19874.6,ms,,
|
| 63 |
+
bench,wall_ms.max,20616.8,ms,,
|
| 64 |
+
bench,wall_ms.n,5,ms,,
|
| 65 |
+
bench,peak_rss_mb,4532.0,MB,,
|
| 66 |
+
bench,self_reported_peak_mem_mb,4530.1,MB,,
|
| 67 |
+
graded,tokens_per_s,29.3804,tok/s,,
|
| 68 |
+
graded,prefill_tokens_per_s,86.043,tok/s,,
|
| 69 |
+
graded,ttft_ms,1824.67,ms,,
|
| 70 |
+
graded,e2e_tokens_per_s,20.8546,tok/s,,
|
| 71 |
+
graded,total_ms,6137.98,ms,,
|
| 72 |
+
graded,cold_ttft_ms,1809.74,ms,,
|
| 73 |
+
graded,load_ms,1037.93,ms,,
|
| 74 |
+
graded,wall_ms,20361.1,ms,,
|
| 75 |
+
graded,peak_mem_mb,4532.0,MB,,
|
| 76 |
+
graded,time_to_first_token_ms,1824.67,ms,,
|
| 77 |
+
roofline,mem_bandwidth_gbps,,,,
|
| 78 |
+
roofline,peak_gflops,,,,
|
| 79 |
+
sustained,seconds,633.2,,,
|
| 80 |
+
sustained,iterations,10,,,
|
| 81 |
+
sustained,sustained_ratio,0.9995,,,
|
m2pro-gpu-q1_0/report/results.json
ADDED
|
@@ -0,0 +1,1404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"kit_version": "0.1.0",
|
| 3 |
+
"job": {
|
| 4 |
+
"job_id": "NN-53D464",
|
| 5 |
+
"kind": "optimize",
|
| 6 |
+
"model": "prism-ml/Bonsai-27B-gguf",
|
| 7 |
+
"environment": "mac-mini-m2pro",
|
| 8 |
+
"outcome": "passed",
|
| 9 |
+
"failure_reason": null,
|
| 10 |
+
"fingerprint": {
|
| 11 |
+
"name": "Mac mini (M2 Pro)",
|
| 12 |
+
"gpu": "Apple M2 Pro GPU, 19 cores"
|
| 13 |
+
},
|
| 14 |
+
"backend": {
|
| 15 |
+
"requested": "Metal (llama.cpp fork)",
|
| 16 |
+
"required": [
|
| 17 |
+
"llama.cpp"
|
| 18 |
+
],
|
| 19 |
+
"avoided": [],
|
| 20 |
+
"passed": true,
|
| 21 |
+
"reason": "uses llama.cpp",
|
| 22 |
+
"evidence": {
|
| 23 |
+
"llama.cpp": [
|
| 24 |
+
"src/runner.cpp:164: llama_model * model = llama_model_load_from_file(model_path.c_str(), mparams);",
|
| 25 |
+
"build log: [ 98%] Linking CXX static library libllama.a"
|
| 26 |
+
]
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"grade": {
|
| 31 |
+
"correctness": true,
|
| 32 |
+
"speed_target_met": true,
|
| 33 |
+
"details": {
|
| 34 |
+
"kit_version": "0.1.0",
|
| 35 |
+
"bundle_digest": "b8e1d595699387ed56affd6be5a6b8698a0229f4007f8f68156d694d690355c3",
|
| 36 |
+
"model_type": "text_to_text",
|
| 37 |
+
"precision": "original",
|
| 38 |
+
"split": "all",
|
| 39 |
+
"final": true,
|
| 40 |
+
"correctness": {
|
| 41 |
+
"passed": true,
|
| 42 |
+
"failed_checks": [],
|
| 43 |
+
"flags": [],
|
| 44 |
+
"metrics": {
|
| 45 |
+
"tokenizer_match": 1.0,
|
| 46 |
+
"next_token_agreement": 1.0,
|
| 47 |
+
"topk_overlap": 1.0,
|
| 48 |
+
"greedy_prefix": 1.0,
|
| 49 |
+
"greedy_exact": 1.0,
|
| 50 |
+
"positions": 1862,
|
| 51 |
+
"ties_forgiven": 0,
|
| 52 |
+
"top_k": 10
|
| 53 |
+
},
|
| 54 |
+
"errors": []
|
| 55 |
+
},
|
| 56 |
+
"benchmark": {
|
| 57 |
+
"tokens_per_s": 29.3804,
|
| 58 |
+
"prefill_tokens_per_s": 86.043,
|
| 59 |
+
"ttft_ms": 1824.67,
|
| 60 |
+
"load_ms": 1037.93,
|
| 61 |
+
"peak_mem_mb": 4532.0,
|
| 62 |
+
"flags": []
|
| 63 |
+
},
|
| 64 |
+
"speed": {
|
| 65 |
+
"metric": "tokens_per_s",
|
| 66 |
+
"higher_is_better": true,
|
| 67 |
+
"target": {
|
| 68 |
+
"metric": "tokens_per_s",
|
| 69 |
+
"value": 19.02,
|
| 70 |
+
"direction": "higher"
|
| 71 |
+
},
|
| 72 |
+
"measured": 29.3804,
|
| 73 |
+
"required": 19.02,
|
| 74 |
+
"ratio_to_required": 1.545,
|
| 75 |
+
"met": true
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"check": {
|
| 80 |
+
"kind": "check",
|
| 81 |
+
"model_type": "text_to_text",
|
| 82 |
+
"precision": "original",
|
| 83 |
+
"split": "all",
|
| 84 |
+
"bundle_digest": "b8e1d595699387ed56affd6be5a6b8698a0229f4007f8f68156d694d690355c3",
|
| 85 |
+
"port": {
|
| 86 |
+
"dir": "/tmp/nnopt-device/port",
|
| 87 |
+
"port_json": {
|
| 88 |
+
"contract": 1,
|
| 89 |
+
"model_type": "text_to_text",
|
| 90 |
+
"runtime": "PrismML llama.cpp fork 5ae2e169, Metal (all layers on GPU)",
|
| 91 |
+
"precision": "Q1_0_g128 weights (as published), f16 KV cache"
|
| 92 |
+
},
|
| 93 |
+
"tree_sha256": "00d98a077f021ba9bb6447fc53d0b91c7deb4073c0e3ef3221f863d1eb532037",
|
| 94 |
+
"external_sha256": {}
|
| 95 |
+
},
|
| 96 |
+
"executor": {
|
| 97 |
+
"executor": "local",
|
| 98 |
+
"os": "darwin"
|
| 99 |
+
},
|
| 100 |
+
"thresholds": {
|
| 101 |
+
"tokenizer_match_min": 1.0,
|
| 102 |
+
"next_token_agreement_min": 0.98,
|
| 103 |
+
"topk_overlap_min": 0.9,
|
| 104 |
+
"greedy_prefix_min": 0.75,
|
| 105 |
+
"tie_margin": 0.05
|
| 106 |
+
},
|
| 107 |
+
"checks": [
|
| 108 |
+
{
|
| 109 |
+
"name": "cases_completed",
|
| 110 |
+
"value": 1.0,
|
| 111 |
+
"op": ">=",
|
| 112 |
+
"threshold": 1.0,
|
| 113 |
+
"passed": true,
|
| 114 |
+
"detail": "20/20 cases produced valid output"
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"name": "tokenizer_match",
|
| 118 |
+
"value": 1.0,
|
| 119 |
+
"op": ">=",
|
| 120 |
+
"threshold": 1.0,
|
| 121 |
+
"passed": true,
|
| 122 |
+
"detail": "prompt token ids identical"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"name": "next_token_agreement",
|
| 126 |
+
"value": 1.0,
|
| 127 |
+
"op": ">=",
|
| 128 |
+
"threshold": 0.98,
|
| 129 |
+
"passed": true,
|
| 130 |
+
"detail": "teacher-forced top-1 agreement over 1862 positions (0 near-ties forgiven)"
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"name": "topk_overlap",
|
| 134 |
+
"value": 1.0,
|
| 135 |
+
"op": ">=",
|
| 136 |
+
"threshold": 0.9,
|
| 137 |
+
"passed": true,
|
| 138 |
+
"detail": "mean top-10 overlap"
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"name": "greedy_prefix",
|
| 142 |
+
"value": 1.0,
|
| 143 |
+
"op": ">=",
|
| 144 |
+
"threshold": 0.75,
|
| 145 |
+
"passed": true,
|
| 146 |
+
"detail": "mean matched prefix of 32 greedy tokens; 100% of prompts exact"
|
| 147 |
+
}
|
| 148 |
+
],
|
| 149 |
+
"metrics": {
|
| 150 |
+
"tokenizer_match": 1.0,
|
| 151 |
+
"next_token_agreement": 1.0,
|
| 152 |
+
"topk_overlap": 1.0,
|
| 153 |
+
"greedy_prefix": 1.0,
|
| 154 |
+
"greedy_exact": 1.0,
|
| 155 |
+
"positions": 1862,
|
| 156 |
+
"ties_forgiven": 0,
|
| 157 |
+
"top_k": 10
|
| 158 |
+
},
|
| 159 |
+
"cases": [
|
| 160 |
+
{
|
| 161 |
+
"id": "p000",
|
| 162 |
+
"split": "public",
|
| 163 |
+
"origin": "builtin",
|
| 164 |
+
"ref_tokens": 32,
|
| 165 |
+
"generate": {
|
| 166 |
+
"rc": 0,
|
| 167 |
+
"wall_ms": 18930.0,
|
| 168 |
+
"peak_rss_mb": 4532.0
|
| 169 |
+
},
|
| 170 |
+
"tokenizer_match": true,
|
| 171 |
+
"greedy_matched": 32,
|
| 172 |
+
"greedy_fraction": 1.0,
|
| 173 |
+
"port_text": " Paris.\n\n<think>\nHere's a thinking process:\n\n1. **Analyze User Input:**\n - Statement: \"The capital of France is",
|
| 174 |
+
"ref_text": " Paris.\n\n<think>\nHere's a thinking process:\n\n1. **Analyze User Input:**\n - Statement: \"The capital of France is",
|
| 175 |
+
"score": {
|
| 176 |
+
"rc": 0,
|
| 177 |
+
"wall_ms": 1926.0,
|
| 178 |
+
"peak_rss_mb": 4557.0
|
| 179 |
+
},
|
| 180 |
+
"positions": 37,
|
| 181 |
+
"agreement": 1.0,
|
| 182 |
+
"topk_overlap": 1.0,
|
| 183 |
+
"ties_forgiven": 0
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"id": "p001",
|
| 187 |
+
"split": "public",
|
| 188 |
+
"origin": "builtin",
|
| 189 |
+
"ref_tokens": 32,
|
| 190 |
+
"generate": {
|
| 191 |
+
"rc": 0,
|
| 192 |
+
"wall_ms": 2531.0,
|
| 193 |
+
"peak_rss_mb": 4526.0
|
| 194 |
+
},
|
| 195 |
+
"tokenizer_match": true,
|
| 196 |
+
"greedy_matched": 32,
|
| 197 |
+
"greedy_fraction": 1.0,
|
| 198 |
+
"port_text": " fibonacci(n - 1) + fibonacci(n - 2)\n\ndef main():\n n = int(input(\"Enter a number: \"))\n print",
|
| 199 |
+
"ref_text": " fibonacci(n - 1) + fibonacci(n - 2)\n\ndef main():\n n = int(input(\"Enter a number: \"))\n print",
|
| 200 |
+
"score": {
|
| 201 |
+
"rc": 0,
|
| 202 |
+
"wall_ms": 1926.0,
|
| 203 |
+
"peak_rss_mb": 4571.0
|
| 204 |
+
},
|
| 205 |
+
"positions": 51,
|
| 206 |
+
"agreement": 1.0,
|
| 207 |
+
"topk_overlap": 1.0,
|
| 208 |
+
"ties_forgiven": 0
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"id": "p002",
|
| 212 |
+
"split": "public",
|
| 213 |
+
"origin": "customer",
|
| 214 |
+
"ref_tokens": 32,
|
| 215 |
+
"generate": {
|
| 216 |
+
"rc": 0,
|
| 217 |
+
"wall_ms": 2638.0,
|
| 218 |
+
"peak_rss_mb": 4522.0
|
| 219 |
+
},
|
| 220 |
+
"tokenizer_match": true,
|
| 221 |
+
"greedy_matched": 32,
|
| 222 |
+
"greedy_fraction": 1.0,
|
| 223 |
+
"port_text": "\n\n<think>\nHere's a thinking process:\n\n1. **Understand User Request:**\n - **Topic:** Quantum computing\n - **Requirement",
|
| 224 |
+
"ref_text": "\n\n<think>\nHere's a thinking process:\n\n1. **Understand User Request:**\n - **Topic:** Quantum computing\n - **Requirement",
|
| 225 |
+
"score": {
|
| 226 |
+
"rc": 0,
|
| 227 |
+
"wall_ms": 1904.0,
|
| 228 |
+
"peak_rss_mb": 4561.0
|
| 229 |
+
},
|
| 230 |
+
"positions": 40,
|
| 231 |
+
"agreement": 1.0,
|
| 232 |
+
"topk_overlap": 1.0,
|
| 233 |
+
"ties_forgiven": 0
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"id": "p003",
|
| 237 |
+
"split": "public",
|
| 238 |
+
"origin": "customer",
|
| 239 |
+
"ref_tokens": 32,
|
| 240 |
+
"generate": {
|
| 241 |
+
"rc": 0,
|
| 242 |
+
"wall_ms": 3681.0,
|
| 243 |
+
"peak_rss_mb": 4527.0
|
| 244 |
+
},
|
| 245 |
+
"tokenizer_match": true,
|
| 246 |
+
"greedy_matched": 32,
|
| 247 |
+
"greedy_fraction": 1.0,
|
| 248 |
+
"port_text": " we cannot dedicate. The living cannot dedicate. The dead cannot be dedicated. We are merely the living, dedicating for the dead. We are the living,",
|
| 249 |
+
"ref_text": " we cannot dedicate. The living cannot dedicate. The dead cannot be dedicated. We are merely the living, dedicating for the dead. We are the living,",
|
| 250 |
+
"score": {
|
| 251 |
+
"rc": 0,
|
| 252 |
+
"wall_ms": 3074.0,
|
| 253 |
+
"peak_rss_mb": 4673.0
|
| 254 |
+
},
|
| 255 |
+
"positions": 154,
|
| 256 |
+
"agreement": 1.0,
|
| 257 |
+
"topk_overlap": 1.0,
|
| 258 |
+
"ties_forgiven": 0
|
| 259 |
+
},
|
| 260 |
+
{
|
| 261 |
+
"id": "p004",
|
| 262 |
+
"split": "public",
|
| 263 |
+
"origin": "customer",
|
| 264 |
+
"ref_tokens": 32,
|
| 265 |
+
"generate": {
|
| 266 |
+
"rc": 0,
|
| 267 |
+
"wall_ms": 3692.0,
|
| 268 |
+
"peak_rss_mb": 4529.0
|
| 269 |
+
},
|
| 270 |
+
"tokenizer_match": true,
|
| 271 |
+
"greedy_matched": 32,
|
| 272 |
+
"greedy_fraction": 1.0,
|
| 273 |
+
"port_text": " \"and I am sure you will be pleased to hear that it is let to a young man of good fortune, and of good character. I am sure you",
|
| 274 |
+
"ref_text": " \"and I am sure you will be pleased to hear that it is let to a young man of good fortune, and of good character. I am sure you",
|
| 275 |
+
"score": {
|
| 276 |
+
"rc": 0,
|
| 277 |
+
"wall_ms": 3064.0,
|
| 278 |
+
"peak_rss_mb": 4676.0
|
| 279 |
+
},
|
| 280 |
+
"positions": 156,
|
| 281 |
+
"agreement": 1.0,
|
| 282 |
+
"topk_overlap": 1.0,
|
| 283 |
+
"ties_forgiven": 0
|
| 284 |
+
},
|
| 285 |
+
{
|
| 286 |
+
"id": "p005",
|
| 287 |
+
"split": "public",
|
| 288 |
+
"origin": "customer",
|
| 289 |
+
"ref_tokens": 32,
|
| 290 |
+
"generate": {
|
| 291 |
+
"rc": 0,
|
| 292 |
+
"wall_ms": 3585.0,
|
| 293 |
+
"peak_rss_mb": 4526.0
|
| 294 |
+
},
|
| 295 |
+
"tokenizer_match": true,
|
| 296 |
+
"greedy_matched": 32,
|
| 297 |
+
"greedy_fraction": 1.0,
|
| 298 |
+
"port_text": " the biosphere by providing oxygen and organic carbon to the biosphere, and by forming the base of the food web.\nThe process of photosynthesis is divided",
|
| 299 |
+
"ref_text": " the biosphere by providing oxygen and organic carbon to the biosphere, and by forming the base of the food web.\nThe process of photosynthesis is divided",
|
| 300 |
+
"score": {
|
| 301 |
+
"rc": 0,
|
| 302 |
+
"wall_ms": 3095.0,
|
| 303 |
+
"peak_rss_mb": 4667.0
|
| 304 |
+
},
|
| 305 |
+
"positions": 148,
|
| 306 |
+
"agreement": 1.0,
|
| 307 |
+
"topk_overlap": 1.0,
|
| 308 |
+
"ties_forgiven": 0
|
| 309 |
+
},
|
| 310 |
+
{
|
| 311 |
+
"id": "p006",
|
| 312 |
+
"split": "public",
|
| 313 |
+
"origin": "customer",
|
| 314 |
+
"ref_tokens": 32,
|
| 315 |
+
"generate": {
|
| 316 |
+
"rc": 0,
|
| 317 |
+
"wall_ms": 3424.0,
|
| 318 |
+
"peak_rss_mb": 4525.0
|
| 319 |
+
},
|
| 320 |
+
"tokenizer_match": true,
|
| 321 |
+
"greedy_matched": 32,
|
| 322 |
+
"greedy_fraction": 1.0,
|
| 323 |
+
"port_text": " if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == ",
|
| 324 |
+
"ref_text": " if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == ",
|
| 325 |
+
"score": {
|
| 326 |
+
"rc": 0,
|
| 327 |
+
"wall_ms": 2710.0,
|
| 328 |
+
"peak_rss_mb": 4646.0
|
| 329 |
+
},
|
| 330 |
+
"positions": 122,
|
| 331 |
+
"agreement": 1.0,
|
| 332 |
+
"topk_overlap": 1.0,
|
| 333 |
+
"ties_forgiven": 0
|
| 334 |
+
},
|
| 335 |
+
{
|
| 336 |
+
"id": "p007",
|
| 337 |
+
"split": "public",
|
| 338 |
+
"origin": "customer",
|
| 339 |
+
"ref_tokens": 1,
|
| 340 |
+
"generate": {
|
| 341 |
+
"rc": 0,
|
| 342 |
+
"wall_ms": 1863.0,
|
| 343 |
+
"peak_rss_mb": 4524.0
|
| 344 |
+
},
|
| 345 |
+
"tokenizer_match": true,
|
| 346 |
+
"greedy_matched": 1,
|
| 347 |
+
"greedy_fraction": 1.0,
|
| 348 |
+
"port_text": "<|im_end|>",
|
| 349 |
+
"ref_text": "<|im_end|>",
|
| 350 |
+
"score": {
|
| 351 |
+
"rc": 0,
|
| 352 |
+
"wall_ms": 1925.0,
|
| 353 |
+
"peak_rss_mb": 4580.0
|
| 354 |
+
},
|
| 355 |
+
"positions": 60,
|
| 356 |
+
"agreement": 1.0,
|
| 357 |
+
"topk_overlap": 1.0,
|
| 358 |
+
"ties_forgiven": 0
|
| 359 |
+
},
|
| 360 |
+
{
|
| 361 |
+
"id": "p008",
|
| 362 |
+
"split": "public",
|
| 363 |
+
"origin": "customer",
|
| 364 |
+
"ref_tokens": 32,
|
| 365 |
+
"generate": {
|
| 366 |
+
"rc": 0,
|
| 367 |
+
"wall_ms": 2666.0,
|
| 368 |
+
"peak_rss_mb": 4523.0
|
| 369 |
+
},
|
| 370 |
+
"tokenizer_match": true,
|
| 371 |
+
"greedy_matched": 32,
|
| 372 |
+
"greedy_fraction": 1.0,
|
| 373 |
+
"port_text": "<think>\nThinking Process:\n\n1. **Deconstruct the request:**\n * Topic: Autumn leaves.\n * Form: Haiku",
|
| 374 |
+
"ref_text": "<think>\nThinking Process:\n\n1. **Deconstruct the request:**\n * Topic: Autumn leaves.\n * Form: Haiku",
|
| 375 |
+
"score": {
|
| 376 |
+
"rc": 0,
|
| 377 |
+
"wall_ms": 1966.0,
|
| 378 |
+
"peak_rss_mb": 4578.0
|
| 379 |
+
},
|
| 380 |
+
"positions": 58,
|
| 381 |
+
"agreement": 1.0,
|
| 382 |
+
"topk_overlap": 1.0,
|
| 383 |
+
"ties_forgiven": 0
|
| 384 |
+
},
|
| 385 |
+
{
|
| 386 |
+
"id": "p009",
|
| 387 |
+
"split": "public",
|
| 388 |
+
"origin": "customer",
|
| 389 |
+
"ref_tokens": 32,
|
| 390 |
+
"generate": {
|
| 391 |
+
"rc": 0,
|
| 392 |
+
"wall_ms": 3317.0,
|
| 393 |
+
"peak_rss_mb": 4526.0
|
| 394 |
+
},
|
| 395 |
+
"tokenizer_match": true,
|
| 396 |
+
"greedy_matched": 32,
|
| 397 |
+
"greedy_fraction": 1.0,
|
| 398 |
+
"port_text": " a profond\u00e9ment transform\u00e9 la France et le monde entier.\nLa R\u00e9volution fran\u00e7aise a profond\u00e9ment transform\u00e9 la France et le monde entier.\nLa R\u00e9",
|
| 399 |
+
"ref_text": " a profond\u00e9ment transform\u00e9 la France et le monde entier.\nLa R\u00e9volution fran\u00e7aise a profond\u00e9ment transform\u00e9 la France et le monde entier.\nLa R\u00e9",
|
| 400 |
+
"score": {
|
| 401 |
+
"rc": 0,
|
| 402 |
+
"wall_ms": 2668.0,
|
| 403 |
+
"peak_rss_mb": 4636.0
|
| 404 |
+
},
|
| 405 |
+
"positions": 116,
|
| 406 |
+
"agreement": 1.0,
|
| 407 |
+
"topk_overlap": 1.0,
|
| 408 |
+
"ties_forgiven": 0
|
| 409 |
+
},
|
| 410 |
+
{
|
| 411 |
+
"id": "p010",
|
| 412 |
+
"split": "public",
|
| 413 |
+
"origin": "customer",
|
| 414 |
+
"ref_tokens": 32,
|
| 415 |
+
"generate": {
|
| 416 |
+
"rc": 0,
|
| 417 |
+
"wall_ms": 2912.0,
|
| 418 |
+
"peak_rss_mb": 4524.0
|
| 419 |
+
},
|
| 420 |
+
"tokenizer_match": true,
|
| 421 |
+
"greedy_matched": 32,
|
| 422 |
+
"greedy_fraction": 1.0,
|
| 423 |
+
"port_text": " the same side always faces Earth. The Moon's orbit is inclined 5.1 degrees relative to Earth's equatorial plane. The Moon's orbit is also",
|
| 424 |
+
"ref_text": " the same side always faces Earth. The Moon's orbit is inclined 5.1 degrees relative to Earth's equatorial plane. The Moon's orbit is also",
|
| 425 |
+
"score": {
|
| 426 |
+
"rc": 0,
|
| 427 |
+
"wall_ms": 2313.0,
|
| 428 |
+
"peak_rss_mb": 4615.0
|
| 429 |
+
},
|
| 430 |
+
"positions": 96,
|
| 431 |
+
"agreement": 1.0,
|
| 432 |
+
"topk_overlap": 1.0,
|
| 433 |
+
"ties_forgiven": 0
|
| 434 |
+
},
|
| 435 |
+
{
|
| 436 |
+
"id": "p011",
|
| 437 |
+
"split": "public",
|
| 438 |
+
"origin": "customer",
|
| 439 |
+
"ref_tokens": 32,
|
| 440 |
+
"generate": {
|
| 441 |
+
"rc": 0,
|
| 442 |
+
"wall_ms": 2675.0,
|
| 443 |
+
"peak_rss_mb": 4522.0
|
| 444 |
+
},
|
| 445 |
+
"tokenizer_match": true,
|
| 446 |
+
"greedy_matched": 32,
|
| 447 |
+
"greedy_fraction": 1.0,
|
| 448 |
+
"port_text": " 1 large onion, diced\n2. 2 cloves garlic, minced\n3. 1 can (28 oz) whole peeled tomatoes\n4.",
|
| 449 |
+
"ref_text": " 1 large onion, diced\n2. 2 cloves garlic, minced\n3. 1 can (28 oz) whole peeled tomatoes\n4.",
|
| 450 |
+
"score": {
|
| 451 |
+
"rc": 0,
|
| 452 |
+
"wall_ms": 1911.0,
|
| 453 |
+
"peak_rss_mb": 4563.0
|
| 454 |
+
},
|
| 455 |
+
"positions": 42,
|
| 456 |
+
"agreement": 1.0,
|
| 457 |
+
"topk_overlap": 1.0,
|
| 458 |
+
"ties_forgiven": 0
|
| 459 |
+
},
|
| 460 |
+
{
|
| 461 |
+
"id": "p012",
|
| 462 |
+
"split": "public",
|
| 463 |
+
"origin": "customer",
|
| 464 |
+
"ref_tokens": 32,
|
| 465 |
+
"generate": {
|
| 466 |
+
"rc": 0,
|
| 467 |
+
"wall_ms": 3005.0,
|
| 468 |
+
"peak_rss_mb": 4527.0
|
| 469 |
+
},
|
| 470 |
+
"tokenizer_match": true,
|
| 471 |
+
"greedy_matched": 32,
|
| 472 |
+
"greedy_fraction": 1.0,
|
| 473 |
+
"port_text": "\u8f85\u4ee5\u5730\u5792\u3001\u58d5\u6c9f\u3001\u5173\u9698\u3001\u5821\u5792\u3001\u54e8\u53f0\u3001\u70ae\u53f0\u3001\u6697\u9053\u3001\u6697\u7a9f\u7b49\uff0c\u6784\u6210\u4e00\u4e2a\u7acb\u4f53\u9632\u5fa1\u4f53\u7cfb\u3002\u957f\u57ce",
|
| 474 |
+
"ref_text": "\u8f85\u4ee5\u5730\u5792\u3001\u58d5\u6c9f\u3001\u5173\u9698\u3001\u5821\u5792\u3001\u54e8\u53f0\u3001\u70ae\u53f0\u3001\u6697\u9053\u3001\u6697\u7a9f\u7b49\uff0c\u6784\u6210\u4e00\u4e2a\u7acb\u4f53\u9632\u5fa1\u4f53\u7cfb\u3002\u957f\u57ce",
|
| 475 |
+
"score": {
|
| 476 |
+
"rc": 0,
|
| 477 |
+
"wall_ms": 2282.0,
|
| 478 |
+
"peak_rss_mb": 4589.0
|
| 479 |
+
},
|
| 480 |
+
"positions": 69,
|
| 481 |
+
"agreement": 1.0,
|
| 482 |
+
"topk_overlap": 1.0,
|
| 483 |
+
"ties_forgiven": 0
|
| 484 |
+
},
|
| 485 |
+
{
|
| 486 |
+
"id": "p013",
|
| 487 |
+
"split": "public",
|
| 488 |
+
"origin": "customer",
|
| 489 |
+
"ref_tokens": 32,
|
| 490 |
+
"generate": {
|
| 491 |
+
"rc": 0,
|
| 492 |
+
"wall_ms": 2421.0,
|
| 493 |
+
"peak_rss_mb": 4522.0
|
| 494 |
+
},
|
| 495 |
+
"tokenizer_match": true,
|
| 496 |
+
"greedy_matched": 32,
|
| 497 |
+
"greedy_fraction": 1.0,
|
| 498 |
+
"port_text": ", there was a young girl named Lily who lived in a small village. She was curious and brave, and she loved to explore the world around her. One",
|
| 499 |
+
"ref_text": ", there was a young girl named Lily who lived in a small village. She was curious and brave, and she loved to explore the world around her. One",
|
| 500 |
+
"score": {
|
| 501 |
+
"rc": 0,
|
| 502 |
+
"wall_ms": 1906.0,
|
| 503 |
+
"peak_rss_mb": 4556.0
|
| 504 |
+
},
|
| 505 |
+
"positions": 36,
|
| 506 |
+
"agreement": 1.0,
|
| 507 |
+
"topk_overlap": 1.0,
|
| 508 |
+
"ties_forgiven": 0
|
| 509 |
+
},
|
| 510 |
+
{
|
| 511 |
+
"id": "h000",
|
| 512 |
+
"split": "hidden",
|
| 513 |
+
"origin": "generated",
|
| 514 |
+
"ref_tokens": 32,
|
| 515 |
+
"generate": {
|
| 516 |
+
"rc": 0,
|
| 517 |
+
"wall_ms": 2552.0,
|
| 518 |
+
"peak_rss_mb": 4523.0
|
| 519 |
+
},
|
| 520 |
+
"tokenizer_match": true,
|
| 521 |
+
"greedy_matched": 32,
|
| 522 |
+
"greedy_fraction": 1.0,
|
| 523 |
+
"port_text": " of the time were not aware of the fact that the bridge would be built on a fault line. The bridge was built with a length of 100",
|
| 524 |
+
"ref_text": " of the time were not aware of the fact that the bridge would be built on a fault line. The bridge was built with a length of 100",
|
| 525 |
+
"score": {
|
| 526 |
+
"rc": 0,
|
| 527 |
+
"wall_ms": 1940.0,
|
| 528 |
+
"peak_rss_mb": 4574.0
|
| 529 |
+
},
|
| 530 |
+
"positions": 53,
|
| 531 |
+
"agreement": 1.0,
|
| 532 |
+
"topk_overlap": 1.0,
|
| 533 |
+
"ties_forgiven": 0
|
| 534 |
+
},
|
| 535 |
+
{
|
| 536 |
+
"id": "h001",
|
| 537 |
+
"split": "hidden",
|
| 538 |
+
"origin": "generated",
|
| 539 |
+
"ref_tokens": 32,
|
| 540 |
+
"generate": {
|
| 541 |
+
"rc": 0,
|
| 542 |
+
"wall_ms": 2617.0,
|
| 543 |
+
"peak_rss_mb": 4525.0
|
| 544 |
+
},
|
| 545 |
+
"tokenizer_match": true,
|
| 546 |
+
"greedy_matched": 32,
|
| 547 |
+
"greedy_fraction": 1.0,
|
| 548 |
+
"port_text": " ses nombreux temples et ses rues pav\u00e9es. La ville est divis\u00e9e en deux parties : le centre-ville et les quartiers p\u00e9riph\u00e9riques. Le centre-ville",
|
| 549 |
+
"ref_text": " ses nombreux temples et ses rues pav\u00e9es. La ville est divis\u00e9e en deux parties : le centre-ville et les quartiers p\u00e9riph\u00e9riques. Le centre-ville",
|
| 550 |
+
"score": {
|
| 551 |
+
"rc": 0,
|
| 552 |
+
"wall_ms": 1920.0,
|
| 553 |
+
"peak_rss_mb": 4560.0
|
| 554 |
+
},
|
| 555 |
+
"positions": 40,
|
| 556 |
+
"agreement": 1.0,
|
| 557 |
+
"topk_overlap": 1.0,
|
| 558 |
+
"ties_forgiven": 0
|
| 559 |
+
},
|
| 560 |
+
{
|
| 561 |
+
"id": "h002",
|
| 562 |
+
"split": "hidden",
|
| 563 |
+
"origin": "generated",
|
| 564 |
+
"ref_tokens": 32,
|
| 565 |
+
"generate": {
|
| 566 |
+
"rc": 0,
|
| 567 |
+
"wall_ms": 2813.0,
|
| 568 |
+
"peak_rss_mb": 4523.0
|
| 569 |
+
},
|
| 570 |
+
"tokenizer_match": true,
|
| 571 |
+
"greedy_matched": 32,
|
| 572 |
+
"greedy_fraction": 1.0,
|
| 573 |
+
"port_text": " there exists a convex polygon with n sides such that the sum of the interior angles is equal to the sum of the exterior angles.\n\n<think>\nHere's a",
|
| 574 |
+
"ref_text": " there exists a convex polygon with n sides such that the sum of the interior angles is equal to the sum of the exterior angles.\n\n<think>\nHere's a",
|
| 575 |
+
"score": {
|
| 576 |
+
"rc": 0,
|
| 577 |
+
"wall_ms": 1903.0,
|
| 578 |
+
"peak_rss_mb": 4566.0
|
| 579 |
+
},
|
| 580 |
+
"positions": 45,
|
| 581 |
+
"agreement": 1.0,
|
| 582 |
+
"topk_overlap": 1.0,
|
| 583 |
+
"ties_forgiven": 0
|
| 584 |
+
},
|
| 585 |
+
{
|
| 586 |
+
"id": "h003",
|
| 587 |
+
"split": "hidden",
|
| 588 |
+
"origin": "generated",
|
| 589 |
+
"ref_tokens": 32,
|
| 590 |
+
"generate": {
|
| 591 |
+
"rc": 0,
|
| 592 |
+
"wall_ms": 3006.0,
|
| 593 |
+
"peak_rss_mb": 4524.0
|
| 594 |
+
},
|
| 595 |
+
"tokenizer_match": true,
|
| 596 |
+
"greedy_matched": 32,
|
| 597 |
+
"greedy_fraction": 1.0,
|
| 598 |
+
"port_text": " total += i;\n }\n printf(\"%d\\n\", total);\n return 0;\n}\n\n<think>\nHere's a thinking",
|
| 599 |
+
"ref_text": " total += i;\n }\n printf(\"%d\\n\", total);\n return 0;\n}\n\n<think>\nHere's a thinking",
|
| 600 |
+
"score": {
|
| 601 |
+
"rc": 0,
|
| 602 |
+
"wall_ms": 2349.0,
|
| 603 |
+
"peak_rss_mb": 4591.0
|
| 604 |
+
},
|
| 605 |
+
"positions": 70,
|
| 606 |
+
"agreement": 1.0,
|
| 607 |
+
"topk_overlap": 1.0,
|
| 608 |
+
"ties_forgiven": 0
|
| 609 |
+
},
|
| 610 |
+
{
|
| 611 |
+
"id": "h004",
|
| 612 |
+
"split": "hidden",
|
| 613 |
+
"origin": "generated",
|
| 614 |
+
"ref_tokens": 32,
|
| 615 |
+
"generate": {
|
| 616 |
+
"rc": 0,
|
| 617 |
+
"wall_ms": 2592.0,
|
| 618 |
+
"peak_rss_mb": 4522.0
|
| 619 |
+
},
|
| 620 |
+
"tokenizer_match": true,
|
| 621 |
+
"greedy_matched": 32,
|
| 622 |
+
"greedy_fraction": 1.0,
|
| 623 |
+
"port_text": ":\n1. It is the only province in Canada that is predominantly French-speaking.\n2. It is the only province in Canada that has a constitution that",
|
| 624 |
+
"ref_text": ":\n1. It is the only province in Canada that is predominantly French-speaking.\n2. It is the only province in Canada that has a constitution that",
|
| 625 |
+
"score": {
|
| 626 |
+
"rc": 0,
|
| 627 |
+
"wall_ms": 1907.0,
|
| 628 |
+
"peak_rss_mb": 4560.0
|
| 629 |
+
},
|
| 630 |
+
"positions": 40,
|
| 631 |
+
"agreement": 1.0,
|
| 632 |
+
"topk_overlap": 1.0,
|
| 633 |
+
"ties_forgiven": 0
|
| 634 |
+
},
|
| 635 |
+
{
|
| 636 |
+
"id": "h005",
|
| 637 |
+
"split": "hidden",
|
| 638 |
+
"origin": "generated",
|
| 639 |
+
"ref_tokens": 32,
|
| 640 |
+
"generate": {
|
| 641 |
+
"rc": 0,
|
| 642 |
+
"wall_ms": 6791.0,
|
| 643 |
+
"peak_rss_mb": 4539.0
|
| 644 |
+
},
|
| 645 |
+
"tokenizer_match": true,
|
| 646 |
+
"greedy_matched": 32,
|
| 647 |
+
"greedy_fraction": 1.0,
|
| 648 |
+
"port_text": " the text describes a series of observations and experiments related to fishing, photography, and mirror mechanics. The key elements include:\n\n1. **Fishing Observations",
|
| 649 |
+
"ref_text": " the text describes a series of observations and experiments related to fishing, photography, and mirror mechanics. The key elements include:\n\n1. **Fishing Observations",
|
| 650 |
+
"score": {
|
| 651 |
+
"rc": 0,
|
| 652 |
+
"wall_ms": 6535.0,
|
| 653 |
+
"peak_rss_mb": 4945.0
|
| 654 |
+
},
|
| 655 |
+
"positions": 429,
|
| 656 |
+
"agreement": 1.0,
|
| 657 |
+
"topk_overlap": 1.0,
|
| 658 |
+
"ties_forgiven": 0
|
| 659 |
+
}
|
| 660 |
+
],
|
| 661 |
+
"flags": [],
|
| 662 |
+
"errors": [],
|
| 663 |
+
"passed": true,
|
| 664 |
+
"started_at": "2026-10-16T07:26:42Z",
|
| 665 |
+
"seconds": 146.17
|
| 666 |
+
},
|
| 667 |
+
"bench": {
|
| 668 |
+
"kind": "bench",
|
| 669 |
+
"model_type": "text_to_text",
|
| 670 |
+
"bundle_digest": "b8e1d595699387ed56affd6be5a6b8698a0229f4007f8f68156d694d690355c3",
|
| 671 |
+
"case": "p000",
|
| 672 |
+
"port": {
|
| 673 |
+
"dir": "/tmp/nnopt-device/port",
|
| 674 |
+
"port_json": {
|
| 675 |
+
"contract": 1,
|
| 676 |
+
"model_type": "text_to_text",
|
| 677 |
+
"runtime": "PrismML llama.cpp fork 5ae2e169, Metal (all layers on GPU)",
|
| 678 |
+
"precision": "Q1_0_g128 weights (as published), f16 KV cache"
|
| 679 |
+
},
|
| 680 |
+
"tree_sha256": "00d98a077f021ba9bb6447fc53d0b91c7deb4073c0e3ef3221f863d1eb532037",
|
| 681 |
+
"external_sha256": {}
|
| 682 |
+
},
|
| 683 |
+
"executor": {
|
| 684 |
+
"executor": "local",
|
| 685 |
+
"os": "darwin"
|
| 686 |
+
},
|
| 687 |
+
"environment": {
|
| 688 |
+
"device": "Mac mini (M2 Pro)",
|
| 689 |
+
"gpu": "Apple M2 Pro GPU, 19 cores",
|
| 690 |
+
"name": "Mac mini (M2 Pro)"
|
| 691 |
+
},
|
| 692 |
+
"model_facts": {},
|
| 693 |
+
"config": {
|
| 694 |
+
"warmup": 2,
|
| 695 |
+
"runs": 5,
|
| 696 |
+
"repeat": 3,
|
| 697 |
+
"max_new_tokens": 128,
|
| 698 |
+
"external_check": true,
|
| 699 |
+
"sustained_s": 600.0,
|
| 700 |
+
"sustained_repeat": 10,
|
| 701 |
+
"sample_interval_s": 2.0,
|
| 702 |
+
"mem_interval_ms": 200,
|
| 703 |
+
"timeout_s": 1800.0,
|
| 704 |
+
"case": null,
|
| 705 |
+
"prompt_tokens": 128,
|
| 706 |
+
"batch": 1,
|
| 707 |
+
"external_min_s": 2.0,
|
| 708 |
+
"external_max_repeat": 500,
|
| 709 |
+
"resolution": null,
|
| 710 |
+
"seconds": 10.0,
|
| 711 |
+
"time_budget_s": 8980.1,
|
| 712 |
+
"adapt": true
|
| 713 |
+
},
|
| 714 |
+
"precision": "original",
|
| 715 |
+
"flags": [],
|
| 716 |
+
"errors": [],
|
| 717 |
+
"method": {
|
| 718 |
+
"warmup": 2,
|
| 719 |
+
"runs": 5,
|
| 720 |
+
"repeat": 3,
|
| 721 |
+
"adapted": false,
|
| 722 |
+
"first_run_s": 7.3,
|
| 723 |
+
"time_budget_s": 8980,
|
| 724 |
+
"estimate_s": 818
|
| 725 |
+
},
|
| 726 |
+
"started_at": "2026-10-16T07:29:08Z",
|
| 727 |
+
"inputs": {
|
| 728 |
+
"prompt_tokens_target": 128,
|
| 729 |
+
"prompt_tokens_estimate": 154,
|
| 730 |
+
"prompt_from": [
|
| 731 |
+
"p000",
|
| 732 |
+
"p001",
|
| 733 |
+
"p002",
|
| 734 |
+
"p003"
|
| 735 |
+
]
|
| 736 |
+
},
|
| 737 |
+
"timed_telemetry": {
|
| 738 |
+
"samples": 0
|
| 739 |
+
},
|
| 740 |
+
"runs": [
|
| 741 |
+
{
|
| 742 |
+
"wall_ms": 20616.8,
|
| 743 |
+
"load_ms": 1030.585,
|
| 744 |
+
"peak_rss_mb": 4529.0,
|
| 745 |
+
"peak_hwm_mb": null,
|
| 746 |
+
"self_peak_mem_mb": 4527.3,
|
| 747 |
+
"requests": [
|
| 748 |
+
{
|
| 749 |
+
"total_ms": 6600.802,
|
| 750 |
+
"ttft_ms": 1809.737,
|
| 751 |
+
"prompt_tokens": 157,
|
| 752 |
+
"new_tokens": 128,
|
| 753 |
+
"tokens_per_s": 26.507676268220116,
|
| 754 |
+
"prefill_tokens_per_s": 86.7529370289716,
|
| 755 |
+
"e2e_tokens_per_s": 19.39158302279026
|
| 756 |
+
},
|
| 757 |
+
{
|
| 758 |
+
"total_ms": 6195.819,
|
| 759 |
+
"ttft_ms": 1825.557,
|
| 760 |
+
"prompt_tokens": 157,
|
| 761 |
+
"new_tokens": 128,
|
| 762 |
+
"tokens_per_s": 29.06004262444677,
|
| 763 |
+
"prefill_tokens_per_s": 86.00114923828727,
|
| 764 |
+
"e2e_tokens_per_s": 20.659092849549026
|
| 765 |
+
},
|
| 766 |
+
{
|
| 767 |
+
"total_ms": 6616.514,
|
| 768 |
+
"ttft_ms": 1824.999,
|
| 769 |
+
"prompt_tokens": 157,
|
| 770 |
+
"new_tokens": 128,
|
| 771 |
+
"tokens_per_s": 26.505186772868285,
|
| 772 |
+
"prefill_tokens_per_s": 86.02744439859967,
|
| 773 |
+
"e2e_tokens_per_s": 19.34553452165294
|
| 774 |
+
}
|
| 775 |
+
]
|
| 776 |
+
},
|
| 777 |
+
{
|
| 778 |
+
"wall_ms": 19939.6,
|
| 779 |
+
"load_ms": 1045.894,
|
| 780 |
+
"peak_rss_mb": 4531.0,
|
| 781 |
+
"peak_hwm_mb": null,
|
| 782 |
+
"self_peak_mem_mb": 4529.9,
|
| 783 |
+
"requests": [
|
| 784 |
+
{
|
| 785 |
+
"total_ms": 6523.721,
|
| 786 |
+
"ttft_ms": 1810.005,
|
| 787 |
+
"prompt_tokens": 157,
|
| 788 |
+
"new_tokens": 128,
|
| 789 |
+
"tokens_per_s": 26.94264991781431,
|
| 790 |
+
"prefill_tokens_per_s": 86.74009187819922,
|
| 791 |
+
"e2e_tokens_per_s": 19.62070419627081
|
| 792 |
+
},
|
| 793 |
+
{
|
| 794 |
+
"total_ms": 6175.975,
|
| 795 |
+
"ttft_ms": 1818.109,
|
| 796 |
+
"prompt_tokens": 157,
|
| 797 |
+
"new_tokens": 128,
|
| 798 |
+
"tokens_per_s": 29.14270425019953,
|
| 799 |
+
"prefill_tokens_per_s": 86.35345845601117,
|
| 800 |
+
"e2e_tokens_per_s": 20.72547249624553
|
| 801 |
+
},
|
| 802 |
+
{
|
| 803 |
+
"total_ms": 6082.926,
|
| 804 |
+
"ttft_ms": 1824.754,
|
| 805 |
+
"prompt_tokens": 157,
|
| 806 |
+
"new_tokens": 128,
|
| 807 |
+
"tokens_per_s": 29.825004720335393,
|
| 808 |
+
"prefill_tokens_per_s": 86.03899484533258,
|
| 809 |
+
"e2e_tokens_per_s": 21.042504873477007
|
| 810 |
+
}
|
| 811 |
+
]
|
| 812 |
+
},
|
| 813 |
+
{
|
| 814 |
+
"wall_ms": 20361.1,
|
| 815 |
+
"load_ms": 1033.983,
|
| 816 |
+
"peak_rss_mb": 4529.0,
|
| 817 |
+
"peak_hwm_mb": null,
|
| 818 |
+
"self_peak_mem_mb": 4527.2,
|
| 819 |
+
"requests": [
|
| 820 |
+
{
|
| 821 |
+
"total_ms": 6548.573,
|
| 822 |
+
"ttft_ms": 1809.903,
|
| 823 |
+
"prompt_tokens": 157,
|
| 824 |
+
"new_tokens": 128,
|
| 825 |
+
"tokens_per_s": 26.800768992143364,
|
| 826 |
+
"prefill_tokens_per_s": 86.74498025584796,
|
| 827 |
+
"e2e_tokens_per_s": 19.546243128083017
|
| 828 |
+
},
|
| 829 |
+
{
|
| 830 |
+
"total_ms": 6643.473,
|
| 831 |
+
"ttft_ms": 1824.872,
|
| 832 |
+
"prompt_tokens": 157,
|
| 833 |
+
"new_tokens": 128,
|
| 834 |
+
"tokens_per_s": 26.356197576848555,
|
| 835 |
+
"prefill_tokens_per_s": 86.03343138587255,
|
| 836 |
+
"e2e_tokens_per_s": 19.267030964075566
|
| 837 |
+
},
|
| 838 |
+
{
|
| 839 |
+
"total_ms": 6054.358,
|
| 840 |
+
"ttft_ms": 1819.932,
|
| 841 |
+
"prompt_tokens": 157,
|
| 842 |
+
"new_tokens": 128,
|
| 843 |
+
"tokens_per_s": 29.992258691024475,
|
| 844 |
+
"prefill_tokens_per_s": 86.26695942485763,
|
| 845 |
+
"e2e_tokens_per_s": 21.141795711452804
|
| 846 |
+
}
|
| 847 |
+
]
|
| 848 |
+
},
|
| 849 |
+
{
|
| 850 |
+
"wall_ms": 20376.8,
|
| 851 |
+
"load_ms": 1039.908,
|
| 852 |
+
"peak_rss_mb": 4532.0,
|
| 853 |
+
"peak_hwm_mb": null,
|
| 854 |
+
"self_peak_mem_mb": 4530.1,
|
| 855 |
+
"requests": [
|
| 856 |
+
{
|
| 857 |
+
"total_ms": 6539.003,
|
| 858 |
+
"ttft_ms": 1809.708,
|
| 859 |
+
"prompt_tokens": 157,
|
| 860 |
+
"new_tokens": 128,
|
| 861 |
+
"tokens_per_s": 26.853896828174175,
|
| 862 |
+
"prefill_tokens_per_s": 86.75432721742955,
|
| 863 |
+
"e2e_tokens_per_s": 19.574849560399343
|
| 864 |
+
},
|
| 865 |
+
{
|
| 866 |
+
"total_ms": 6087.32,
|
| 867 |
+
"ttft_ms": 1825.341,
|
| 868 |
+
"prompt_tokens": 157,
|
| 869 |
+
"new_tokens": 128,
|
| 870 |
+
"tokens_per_s": 29.798363624034756,
|
| 871 |
+
"prefill_tokens_per_s": 86.01132610290352,
|
| 872 |
+
"e2e_tokens_per_s": 21.027315797428095
|
| 873 |
+
},
|
| 874 |
+
{
|
| 875 |
+
"total_ms": 6600.9,
|
| 876 |
+
"ttft_ms": 1824.583,
|
| 877 |
+
"prompt_tokens": 157,
|
| 878 |
+
"new_tokens": 128,
|
| 879 |
+
"tokens_per_s": 26.589524941497817,
|
| 880 |
+
"prefill_tokens_per_s": 86.04705842376039,
|
| 881 |
+
"e2e_tokens_per_s": 19.391295126422158
|
| 882 |
+
}
|
| 883 |
+
]
|
| 884 |
+
},
|
| 885 |
+
{
|
| 886 |
+
"wall_ms": 19874.6,
|
| 887 |
+
"load_ms": 1037.926,
|
| 888 |
+
"peak_rss_mb": 4529.0,
|
| 889 |
+
"peak_hwm_mb": null,
|
| 890 |
+
"self_peak_mem_mb": 4527.1,
|
| 891 |
+
"requests": [
|
| 892 |
+
{
|
| 893 |
+
"total_ms": 6556.858,
|
| 894 |
+
"ttft_ms": 1809.728,
|
| 895 |
+
"prompt_tokens": 157,
|
| 896 |
+
"new_tokens": 128,
|
| 897 |
+
"tokens_per_s": 26.753006553433337,
|
| 898 |
+
"prefill_tokens_per_s": 86.75336846200092,
|
| 899 |
+
"e2e_tokens_per_s": 19.521545227912515
|
| 900 |
+
},
|
| 901 |
+
{
|
| 902 |
+
"total_ms": 6052.126,
|
| 903 |
+
"ttft_ms": 1820.886,
|
| 904 |
+
"prompt_tokens": 157,
|
| 905 |
+
"new_tokens": 128,
|
| 906 |
+
"tokens_per_s": 30.014841984855504,
|
| 907 |
+
"prefill_tokens_per_s": 86.2217623728229,
|
| 908 |
+
"e2e_tokens_per_s": 21.149592721632033
|
| 909 |
+
},
|
| 910 |
+
{
|
| 911 |
+
"total_ms": 6099.979,
|
| 912 |
+
"ttft_ms": 1812.051,
|
| 913 |
+
"prompt_tokens": 157,
|
| 914 |
+
"new_tokens": 128,
|
| 915 |
+
"tokens_per_s": 29.61803463117851,
|
| 916 |
+
"prefill_tokens_per_s": 86.64215300783478,
|
| 917 |
+
"e2e_tokens_per_s": 20.983678796271263
|
| 918 |
+
}
|
| 919 |
+
]
|
| 920 |
+
}
|
| 921 |
+
],
|
| 922 |
+
"summary": {
|
| 923 |
+
"tokens_per_s": {
|
| 924 |
+
"n": 10,
|
| 925 |
+
"median": 29.3804,
|
| 926 |
+
"mean": 28.6902,
|
| 927 |
+
"min": 26.3562,
|
| 928 |
+
"max": 30.0148,
|
| 929 |
+
"p10": 26.4903,
|
| 930 |
+
"p90": 29.9945
|
| 931 |
+
},
|
| 932 |
+
"prefill_tokens_per_s": {
|
| 933 |
+
"n": 10,
|
| 934 |
+
"median": 86.043,
|
| 935 |
+
"mean": 86.1644,
|
| 936 |
+
"min": 86.0011,
|
| 937 |
+
"max": 86.6422,
|
| 938 |
+
"p10": 86.0103,
|
| 939 |
+
"p90": 86.3823
|
| 940 |
+
},
|
| 941 |
+
"ttft_ms": {
|
| 942 |
+
"n": 10,
|
| 943 |
+
"median": 1824.67,
|
| 944 |
+
"mean": 1822.11,
|
| 945 |
+
"min": 1812.05,
|
| 946 |
+
"max": 1825.56,
|
| 947 |
+
"p10": 1817.5,
|
| 948 |
+
"p90": 1825.36
|
| 949 |
+
},
|
| 950 |
+
"e2e_tokens_per_s": {
|
| 951 |
+
"n": 10,
|
| 952 |
+
"median": 20.8546,
|
| 953 |
+
"mean": 20.4733,
|
| 954 |
+
"min": 19.267,
|
| 955 |
+
"max": 21.1496,
|
| 956 |
+
"p10": 19.3377,
|
| 957 |
+
"p90": 21.1426
|
| 958 |
+
},
|
| 959 |
+
"total_ms": {
|
| 960 |
+
"n": 10,
|
| 961 |
+
"median": 6137.98,
|
| 962 |
+
"mean": 6260.94,
|
| 963 |
+
"min": 6052.13,
|
| 964 |
+
"max": 6643.47,
|
| 965 |
+
"p10": 6054.13,
|
| 966 |
+
"p90": 6619.21
|
| 967 |
+
},
|
| 968 |
+
"cold_ttft_ms": {
|
| 969 |
+
"n": 5,
|
| 970 |
+
"median": 1809.74,
|
| 971 |
+
"mean": 1809.82,
|
| 972 |
+
"min": 1809.71,
|
| 973 |
+
"max": 1810.01,
|
| 974 |
+
"p10": 1809.72,
|
| 975 |
+
"p90": 1809.96
|
| 976 |
+
},
|
| 977 |
+
"load_ms": {
|
| 978 |
+
"n": 5,
|
| 979 |
+
"median": 1037.93,
|
| 980 |
+
"mean": 1037.66,
|
| 981 |
+
"min": 1030.59,
|
| 982 |
+
"max": 1045.89,
|
| 983 |
+
"p10": 1031.94,
|
| 984 |
+
"p90": 1043.5
|
| 985 |
+
},
|
| 986 |
+
"wall_ms": {
|
| 987 |
+
"n": 5,
|
| 988 |
+
"median": 20361.1,
|
| 989 |
+
"mean": 20233.8,
|
| 990 |
+
"min": 19874.6,
|
| 991 |
+
"max": 20616.8,
|
| 992 |
+
"p10": 19900.6,
|
| 993 |
+
"p90": 20520.8
|
| 994 |
+
},
|
| 995 |
+
"peak_rss_mb": 4532.0,
|
| 996 |
+
"peak_hwm_mb": null,
|
| 997 |
+
"self_reported_peak_mem_mb": 4530.1
|
| 998 |
+
},
|
| 999 |
+
"external": {
|
| 1000 |
+
"available": true,
|
| 1001 |
+
"method": "paired --max-new-tokens N vs 1",
|
| 1002 |
+
"pairs": 5,
|
| 1003 |
+
"tokens_per_s": 27.6
|
| 1004 |
+
},
|
| 1005 |
+
"graded": {
|
| 1006 |
+
"tokens_per_s": 29.3804,
|
| 1007 |
+
"prefill_tokens_per_s": 86.043,
|
| 1008 |
+
"ttft_ms": 1824.67,
|
| 1009 |
+
"e2e_tokens_per_s": 20.8546,
|
| 1010 |
+
"total_ms": 6137.98,
|
| 1011 |
+
"cold_ttft_ms": 1809.74,
|
| 1012 |
+
"load_ms": 1037.93,
|
| 1013 |
+
"wall_ms": 20361.1,
|
| 1014 |
+
"peak_mem_mb": 4532.0,
|
| 1015 |
+
"time_to_first_token_ms": 1824.67
|
| 1016 |
+
},
|
| 1017 |
+
"sustained": {
|
| 1018 |
+
"seconds": 633.2,
|
| 1019 |
+
"iterations": 10,
|
| 1020 |
+
"failed_iterations": 0,
|
| 1021 |
+
"self_report_correction": null,
|
| 1022 |
+
"metric": "tokens_per_s",
|
| 1023 |
+
"series": [
|
| 1024 |
+
{
|
| 1025 |
+
"t_s": 31.64,
|
| 1026 |
+
"tokens_per_s": 29.97,
|
| 1027 |
+
"rc": 0
|
| 1028 |
+
},
|
| 1029 |
+
{
|
| 1030 |
+
"t_s": 94.56,
|
| 1031 |
+
"tokens_per_s": 29.98,
|
| 1032 |
+
"rc": 0
|
| 1033 |
+
},
|
| 1034 |
+
{
|
| 1035 |
+
"t_s": 157.5,
|
| 1036 |
+
"tokens_per_s": 29.98,
|
| 1037 |
+
"rc": 0
|
| 1038 |
+
},
|
| 1039 |
+
{
|
| 1040 |
+
"t_s": 221.4,
|
| 1041 |
+
"tokens_per_s": 29.98,
|
| 1042 |
+
"rc": 0
|
| 1043 |
+
},
|
| 1044 |
+
{
|
| 1045 |
+
"t_s": 285.3,
|
| 1046 |
+
"tokens_per_s": 29.97,
|
| 1047 |
+
"rc": 0
|
| 1048 |
+
},
|
| 1049 |
+
{
|
| 1050 |
+
"t_s": 348.5,
|
| 1051 |
+
"tokens_per_s": 29.96,
|
| 1052 |
+
"rc": 0
|
| 1053 |
+
},
|
| 1054 |
+
{
|
| 1055 |
+
"t_s": 412.2,
|
| 1056 |
+
"tokens_per_s": 29.96,
|
| 1057 |
+
"rc": 0
|
| 1058 |
+
},
|
| 1059 |
+
{
|
| 1060 |
+
"t_s": 475.7,
|
| 1061 |
+
"tokens_per_s": 29.99,
|
| 1062 |
+
"rc": 0
|
| 1063 |
+
},
|
| 1064 |
+
{
|
| 1065 |
+
"t_s": 538.4,
|
| 1066 |
+
"tokens_per_s": 29.96,
|
| 1067 |
+
"rc": 0
|
| 1068 |
+
},
|
| 1069 |
+
{
|
| 1070 |
+
"t_s": 602.0,
|
| 1071 |
+
"tokens_per_s": 29.96,
|
| 1072 |
+
"rc": 0
|
| 1073 |
+
}
|
| 1074 |
+
],
|
| 1075 |
+
"telemetry": [],
|
| 1076 |
+
"telemetry_summary": {
|
| 1077 |
+
"samples": 0
|
| 1078 |
+
},
|
| 1079 |
+
"first_window": 29.98,
|
| 1080 |
+
"last_window": 29.96,
|
| 1081 |
+
"window_s": 126.6,
|
| 1082 |
+
"sustained_ratio": 0.9995
|
| 1083 |
+
},
|
| 1084 |
+
"roofline": {
|
| 1085 |
+
"mem_bandwidth_gbps": null,
|
| 1086 |
+
"peak_gflops": null
|
| 1087 |
+
},
|
| 1088 |
+
"seconds": 800.36
|
| 1089 |
+
},
|
| 1090 |
+
"reference": {
|
| 1091 |
+
"format": "nnopt-reference-bundle",
|
| 1092 |
+
"version": 1,
|
| 1093 |
+
"job_id": "NN-53D464",
|
| 1094 |
+
"model_type": "text_to_text",
|
| 1095 |
+
"precision_policy": "original",
|
| 1096 |
+
"model": {
|
| 1097 |
+
"kind": "contract",
|
| 1098 |
+
"program": "/tmp/nnopt-device/port",
|
| 1099 |
+
"where": "device",
|
| 1100 |
+
"environment": "mac-mini-m2pro",
|
| 1101 |
+
"starting_version": "agent"
|
| 1102 |
+
},
|
| 1103 |
+
"runner": {
|
| 1104 |
+
"kind": "contract",
|
| 1105 |
+
"program": "/tmp/nnopt-device/port",
|
| 1106 |
+
"where": "device",
|
| 1107 |
+
"environment": "mac-mini-m2pro",
|
| 1108 |
+
"starting_version": "agent"
|
| 1109 |
+
},
|
| 1110 |
+
"params": {
|
| 1111 |
+
"max_new_tokens": 32,
|
| 1112 |
+
"top_k": 10,
|
| 1113 |
+
"long_words": 300
|
| 1114 |
+
},
|
| 1115 |
+
"tools": {
|
| 1116 |
+
"python": "3.12.14",
|
| 1117 |
+
"numpy": "2.5.4",
|
| 1118 |
+
"nnopt_verify": "0.1.0",
|
| 1119 |
+
"platform": "macOS-27.0.1-arm64-arm-64bit"
|
| 1120 |
+
},
|
| 1121 |
+
"created_at": "2026-10-16T05:07:31Z",
|
| 1122 |
+
"cases": [
|
| 1123 |
+
{
|
| 1124 |
+
"id": "p000",
|
| 1125 |
+
"split": "public",
|
| 1126 |
+
"origin": "builtin",
|
| 1127 |
+
"files": {
|
| 1128 |
+
"input": "inputs/p000.txt",
|
| 1129 |
+
"output": "outputs/p000.json"
|
| 1130 |
+
},
|
| 1131 |
+
"meta": {}
|
| 1132 |
+
},
|
| 1133 |
+
{
|
| 1134 |
+
"id": "p001",
|
| 1135 |
+
"split": "public",
|
| 1136 |
+
"origin": "builtin",
|
| 1137 |
+
"files": {
|
| 1138 |
+
"input": "inputs/p001.txt",
|
| 1139 |
+
"output": "outputs/p001.json"
|
| 1140 |
+
},
|
| 1141 |
+
"meta": {}
|
| 1142 |
+
},
|
| 1143 |
+
{
|
| 1144 |
+
"id": "p002",
|
| 1145 |
+
"split": "public",
|
| 1146 |
+
"origin": "customer",
|
| 1147 |
+
"files": {
|
| 1148 |
+
"input": "inputs/p002.txt",
|
| 1149 |
+
"input_meta": "inputs/p002.json",
|
| 1150 |
+
"output": "outputs/p002.json"
|
| 1151 |
+
},
|
| 1152 |
+
"meta": {
|
| 1153 |
+
"name": "found_model_card_quickstart"
|
| 1154 |
+
}
|
| 1155 |
+
},
|
| 1156 |
+
{
|
| 1157 |
+
"id": "p003",
|
| 1158 |
+
"split": "public",
|
| 1159 |
+
"origin": "customer",
|
| 1160 |
+
"files": {
|
| 1161 |
+
"input": "inputs/p003.txt",
|
| 1162 |
+
"input_meta": "inputs/p003.json",
|
| 1163 |
+
"output": "outputs/p003.json"
|
| 1164 |
+
},
|
| 1165 |
+
"meta": {
|
| 1166 |
+
"name": "found_gettysburg"
|
| 1167 |
+
}
|
| 1168 |
+
},
|
| 1169 |
+
{
|
| 1170 |
+
"id": "p004",
|
| 1171 |
+
"split": "public",
|
| 1172 |
+
"origin": "customer",
|
| 1173 |
+
"files": {
|
| 1174 |
+
"input": "inputs/p004.txt",
|
| 1175 |
+
"input_meta": "inputs/p004.json",
|
| 1176 |
+
"output": "outputs/p004.json"
|
| 1177 |
+
},
|
| 1178 |
+
"meta": {
|
| 1179 |
+
"name": "found_pride_prejudice"
|
| 1180 |
+
}
|
| 1181 |
+
},
|
| 1182 |
+
{
|
| 1183 |
+
"id": "p005",
|
| 1184 |
+
"split": "public",
|
| 1185 |
+
"origin": "customer",
|
| 1186 |
+
"files": {
|
| 1187 |
+
"input": "inputs/p005.txt",
|
| 1188 |
+
"input_meta": "inputs/p005.json",
|
| 1189 |
+
"output": "outputs/p005.json"
|
| 1190 |
+
},
|
| 1191 |
+
"meta": {
|
| 1192 |
+
"name": "found_wiki_photosynthesis"
|
| 1193 |
+
}
|
| 1194 |
+
},
|
| 1195 |
+
{
|
| 1196 |
+
"id": "p006",
|
| 1197 |
+
"split": "public",
|
| 1198 |
+
"origin": "customer",
|
| 1199 |
+
"files": {
|
| 1200 |
+
"input": "inputs/p006.txt",
|
| 1201 |
+
"input_meta": "inputs/p006.json",
|
| 1202 |
+
"output": "outputs/p006.json"
|
| 1203 |
+
},
|
| 1204 |
+
"meta": {
|
| 1205 |
+
"name": "found_python_code"
|
| 1206 |
+
}
|
| 1207 |
+
},
|
| 1208 |
+
{
|
| 1209 |
+
"id": "p007",
|
| 1210 |
+
"split": "public",
|
| 1211 |
+
"origin": "customer",
|
| 1212 |
+
"files": {
|
| 1213 |
+
"input": "inputs/p007.txt",
|
| 1214 |
+
"input_meta": "inputs/p007.json",
|
| 1215 |
+
"output": "outputs/p007.json"
|
| 1216 |
+
},
|
| 1217 |
+
"meta": {
|
| 1218 |
+
"name": "found_math_word_problem"
|
| 1219 |
+
}
|
| 1220 |
+
},
|
| 1221 |
+
{
|
| 1222 |
+
"id": "p008",
|
| 1223 |
+
"split": "public",
|
| 1224 |
+
"origin": "customer",
|
| 1225 |
+
"files": {
|
| 1226 |
+
"input": "inputs/p008.txt",
|
| 1227 |
+
"input_meta": "inputs/p008.json",
|
| 1228 |
+
"output": "outputs/p008.json"
|
| 1229 |
+
},
|
| 1230 |
+
"meta": {
|
| 1231 |
+
"name": "found_chat_template_qwen"
|
| 1232 |
+
}
|
| 1233 |
+
},
|
| 1234 |
+
{
|
| 1235 |
+
"id": "p009",
|
| 1236 |
+
"split": "public",
|
| 1237 |
+
"origin": "customer",
|
| 1238 |
+
"files": {
|
| 1239 |
+
"input": "inputs/p009.txt",
|
| 1240 |
+
"input_meta": "inputs/p009.json",
|
| 1241 |
+
"output": "outputs/p009.json"
|
| 1242 |
+
},
|
| 1243 |
+
"meta": {
|
| 1244 |
+
"name": "found_french_text"
|
| 1245 |
+
}
|
| 1246 |
+
},
|
| 1247 |
+
{
|
| 1248 |
+
"id": "p010",
|
| 1249 |
+
"split": "public",
|
| 1250 |
+
"origin": "customer",
|
| 1251 |
+
"files": {
|
| 1252 |
+
"input": "inputs/p010.txt",
|
| 1253 |
+
"input_meta": "inputs/p010.json",
|
| 1254 |
+
"output": "outputs/p010.json"
|
| 1255 |
+
},
|
| 1256 |
+
"meta": {
|
| 1257 |
+
"name": "found_wiki_moon"
|
| 1258 |
+
}
|
| 1259 |
+
},
|
| 1260 |
+
{
|
| 1261 |
+
"id": "p011",
|
| 1262 |
+
"split": "public",
|
| 1263 |
+
"origin": "customer",
|
| 1264 |
+
"files": {
|
| 1265 |
+
"input": "inputs/p011.txt",
|
| 1266 |
+
"input_meta": "inputs/p011.json",
|
| 1267 |
+
"output": "outputs/p011.json"
|
| 1268 |
+
},
|
| 1269 |
+
"meta": {
|
| 1270 |
+
"name": "found_recipe_list"
|
| 1271 |
+
}
|
| 1272 |
+
},
|
| 1273 |
+
{
|
| 1274 |
+
"id": "p012",
|
| 1275 |
+
"split": "public",
|
| 1276 |
+
"origin": "customer",
|
| 1277 |
+
"files": {
|
| 1278 |
+
"input": "inputs/p012.txt",
|
| 1279 |
+
"input_meta": "inputs/p012.json",
|
| 1280 |
+
"output": "outputs/p012.json"
|
| 1281 |
+
},
|
| 1282 |
+
"meta": {
|
| 1283 |
+
"name": "found_chinese_text"
|
| 1284 |
+
}
|
| 1285 |
+
},
|
| 1286 |
+
{
|
| 1287 |
+
"id": "p013",
|
| 1288 |
+
"split": "public",
|
| 1289 |
+
"origin": "customer",
|
| 1290 |
+
"files": {
|
| 1291 |
+
"input": "inputs/p013.txt",
|
| 1292 |
+
"input_meta": "inputs/p013.json",
|
| 1293 |
+
"output": "outputs/p013.json"
|
| 1294 |
+
},
|
| 1295 |
+
"meta": {
|
| 1296 |
+
"name": "found_short_prompt"
|
| 1297 |
+
}
|
| 1298 |
+
},
|
| 1299 |
+
{
|
| 1300 |
+
"id": "h000",
|
| 1301 |
+
"split": "hidden",
|
| 1302 |
+
"origin": "generated",
|
| 1303 |
+
"files": {
|
| 1304 |
+
"input": "inputs/h000.txt",
|
| 1305 |
+
"output": "outputs/h000.json"
|
| 1306 |
+
},
|
| 1307 |
+
"meta": {}
|
| 1308 |
+
},
|
| 1309 |
+
{
|
| 1310 |
+
"id": "h001",
|
| 1311 |
+
"split": "hidden",
|
| 1312 |
+
"origin": "generated",
|
| 1313 |
+
"files": {
|
| 1314 |
+
"input": "inputs/h001.txt",
|
| 1315 |
+
"output": "outputs/h001.json"
|
| 1316 |
+
},
|
| 1317 |
+
"meta": {}
|
| 1318 |
+
},
|
| 1319 |
+
{
|
| 1320 |
+
"id": "h002",
|
| 1321 |
+
"split": "hidden",
|
| 1322 |
+
"origin": "generated",
|
| 1323 |
+
"files": {
|
| 1324 |
+
"input": "inputs/h002.txt",
|
| 1325 |
+
"output": "outputs/h002.json"
|
| 1326 |
+
},
|
| 1327 |
+
"meta": {}
|
| 1328 |
+
},
|
| 1329 |
+
{
|
| 1330 |
+
"id": "h003",
|
| 1331 |
+
"split": "hidden",
|
| 1332 |
+
"origin": "generated",
|
| 1333 |
+
"files": {
|
| 1334 |
+
"input": "inputs/h003.txt",
|
| 1335 |
+
"output": "outputs/h003.json"
|
| 1336 |
+
},
|
| 1337 |
+
"meta": {}
|
| 1338 |
+
},
|
| 1339 |
+
{
|
| 1340 |
+
"id": "h004",
|
| 1341 |
+
"split": "hidden",
|
| 1342 |
+
"origin": "generated",
|
| 1343 |
+
"files": {
|
| 1344 |
+
"input": "inputs/h004.txt",
|
| 1345 |
+
"output": "outputs/h004.json"
|
| 1346 |
+
},
|
| 1347 |
+
"meta": {}
|
| 1348 |
+
},
|
| 1349 |
+
{
|
| 1350 |
+
"id": "h005",
|
| 1351 |
+
"split": "hidden",
|
| 1352 |
+
"origin": "generated",
|
| 1353 |
+
"files": {
|
| 1354 |
+
"input": "inputs/h005.txt",
|
| 1355 |
+
"output": "outputs/h005.json"
|
| 1356 |
+
},
|
| 1357 |
+
"meta": {}
|
| 1358 |
+
}
|
| 1359 |
+
],
|
| 1360 |
+
"splits": {
|
| 1361 |
+
"public": [
|
| 1362 |
+
"p000",
|
| 1363 |
+
"p001",
|
| 1364 |
+
"p002",
|
| 1365 |
+
"p003",
|
| 1366 |
+
"p004",
|
| 1367 |
+
"p005",
|
| 1368 |
+
"p006",
|
| 1369 |
+
"p007",
|
| 1370 |
+
"p008",
|
| 1371 |
+
"p009",
|
| 1372 |
+
"p010",
|
| 1373 |
+
"p011",
|
| 1374 |
+
"p012",
|
| 1375 |
+
"p013"
|
| 1376 |
+
],
|
| 1377 |
+
"hidden": [
|
| 1378 |
+
"h000",
|
| 1379 |
+
"h001",
|
| 1380 |
+
"h002",
|
| 1381 |
+
"h003",
|
| 1382 |
+
"h004",
|
| 1383 |
+
"h005"
|
| 1384 |
+
]
|
| 1385 |
+
},
|
| 1386 |
+
"notes": [],
|
| 1387 |
+
"determinism": {
|
| 1388 |
+
"generate_repeatable": true,
|
| 1389 |
+
"score_repeatable": true
|
| 1390 |
+
},
|
| 1391 |
+
"customer_expectations": [],
|
| 1392 |
+
"capture_plan": {
|
| 1393 |
+
"time_budget_s": 8722,
|
| 1394 |
+
"budget_share": 0.8,
|
| 1395 |
+
"hidden_floor": 3,
|
| 1396 |
+
"hidden_planned": 6,
|
| 1397 |
+
"hidden_captured": 6,
|
| 1398 |
+
"hidden_dropped": 0,
|
| 1399 |
+
"seconds_per_case": 13.7,
|
| 1400 |
+
"seconds": 123
|
| 1401 |
+
},
|
| 1402 |
+
"frozen_at": "2026-10-16T05:09:33Z"
|
| 1403 |
+
}
|
| 1404 |
+
}
|
m2pro-gpu-q1_0/src/CMakeLists.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cmake_minimum_required(VERSION 3.14)
|
| 2 |
+
project(nnopt_runner CXX C)
|
| 3 |
+
|
| 4 |
+
# LLAMA_SRC: the customer's PrismML llama.cpp fork, built unchanged.
|
| 5 |
+
if(NOT LLAMA_SRC)
|
| 6 |
+
message(FATAL_ERROR "set -DLLAMA_SRC=<path to the llama.cpp fork>")
|
| 7 |
+
endif()
|
| 8 |
+
|
| 9 |
+
set(LLAMA_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
| 10 |
+
set(LLAMA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
| 11 |
+
set(LLAMA_BUILD_SERVER OFF CACHE BOOL "" FORCE)
|
| 12 |
+
set(LLAMA_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
| 13 |
+
set(LLAMA_BUILD_COMMON OFF CACHE BOOL "" FORCE)
|
| 14 |
+
set(LLAMA_CURL OFF CACHE BOOL "" FORCE)
|
| 15 |
+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
| 16 |
+
set(GGML_METAL ON CACHE BOOL "" FORCE)
|
| 17 |
+
set(GGML_METAL_EMBED_LIBRARY ON CACHE BOOL "" FORCE)
|
| 18 |
+
|
| 19 |
+
add_subdirectory(${LLAMA_SRC} llama.cpp)
|
| 20 |
+
|
| 21 |
+
add_executable(nnopt_runner runner.cpp)
|
| 22 |
+
target_link_libraries(nnopt_runner PRIVATE llama)
|
| 23 |
+
target_compile_features(nnopt_runner PRIVATE cxx_std_17)
|
m2pro-gpu-q1_0/src/patches/0001-q1_0-lut-gemv.patch
ADDED
|
@@ -0,0 +1,549 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--- a/ggml/src/ggml-metal/ggml-metal-device.cpp 2026-10-15 23:29:33
|
| 2 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-device.cpp 2026-10-15 23:29:33
|
| 3 |
+
@@ -602,6 +602,17 @@
|
| 4 |
+
return res;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
+ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_state_step(ggml_metal_library_t lib) {
|
| 8 |
+
+ const char * name = "kernel_conv_state_step_f32";
|
| 9 |
+
+
|
| 10 |
+
+ ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
| 11 |
+
+ if (!res.pipeline) {
|
| 12 |
+
+ res = ggml_metal_library_compile_pipeline(lib, name, name, nullptr);
|
| 13 |
+
+ }
|
| 14 |
+
+
|
| 15 |
+
+ return res;
|
| 16 |
+
+}
|
| 17 |
+
+
|
| 18 |
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv(ggml_metal_library_t lib, const ggml_tensor * op, bool silu) {
|
| 19 |
+
GGML_ASSERT(op->src[0]->type == GGML_TYPE_F32);
|
| 20 |
+
GGML_ASSERT(op->src[1]->type == GGML_TYPE_F32);
|
| 21 |
+
@@ -909,6 +920,16 @@
|
| 22 |
+
op->src[1]->ne[1] >= 2 && op->src[1]->ne[1] <= 4;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
+bool ggml_metal_q1_0_lut_supported(const ggml_tensor * op) {
|
| 26 |
+
+ static const bool enabled = !getenv("NNOPT_Q1_LUT") || atoi(getenv("NNOPT_Q1_LUT")) != 0;
|
| 27 |
+
+ const ggml_tensor * src0 = op->src[0];
|
| 28 |
+
+ const ggml_tensor * src1 = op->src[1];
|
| 29 |
+
+ return enabled && src0->type == GGML_TYPE_Q1_0 && src1->type == GGML_TYPE_F32 &&
|
| 30 |
+
+ src0->ne[0] % 1024 == 0 && src0->ne[1] >= 512 && src1->ne[1] == 1 &&
|
| 31 |
+
+ src0->ne[2] == 1 && src0->ne[3] == 1 && src1->ne[2] == 1 && src1->ne[3] == 1 &&
|
| 32 |
+
+ src1->nb[0] == sizeof(float);
|
| 33 |
+
+}
|
| 34 |
+
+
|
| 35 |
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_mul_mv(ggml_metal_library_t lib, const ggml_tensor * op) {
|
| 36 |
+
GGML_TENSOR_LOCALS( int32_t, ne0, op->src[0], ne);
|
| 37 |
+
GGML_TENSOR_LOCALS( int32_t, ne1, op->src[1], ne);
|
| 38 |
+
@@ -963,6 +984,16 @@
|
| 39 |
+
nr1 = 2;
|
| 40 |
+
}
|
| 41 |
+
suffix = nr1 == 2 ? "_nr1_2" : nr1 == 3 ? "_nr1_3" : nr1 == 4 ? "_nr1_4" : "";
|
| 42 |
+
+ if (nr1 == 1 && ggml_metal_q1_0_lut_supported(op)) {
|
| 43 |
+
+ // lookup-table decode kernel, see kernel_mul_mv_q1_0_f32_lut
|
| 44 |
+
+ static const int lut_nr = getenv("NNOPT_Q1_LUT_NR") ? atoi(getenv("NNOPT_Q1_LUT_NR")) : 4;
|
| 45 |
+
+ static const int lut_nsg = getenv("NNOPT_Q1_LUT_NSG") ? atoi(getenv("NNOPT_Q1_LUT_NSG")) : 16;
|
| 46 |
+
+ nsg = lut_nsg;
|
| 47 |
+
+ nr0 = lut_nr;
|
| 48 |
+
+ smem = 16*(1024/4)*sizeof(float);
|
| 49 |
+
+ snprintf(ptq1_suffix, sizeof(ptq1_suffix), "_lut_%d", lut_nr);
|
| 50 |
+
+ suffix = ptq1_suffix;
|
| 51 |
+
+ }
|
| 52 |
+
} break;
|
| 53 |
+
case GGML_TYPE_Q2_0:
|
| 54 |
+
{
|
| 55 |
+
--- a/ggml/src/ggml-metal/ggml-metal-device.h 2026-10-15 23:29:33
|
| 56 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-device.h 2026-10-15 23:29:33
|
| 57 |
+
@@ -6,6 +6,7 @@
|
| 58 |
+
extern "C" {
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
+bool ggml_metal_q1_0_lut_supported(const struct ggml_tensor * op);
|
| 62 |
+
bool ggml_metal_ptq1_multicol_enabled(const struct ggml_tensor * op);
|
| 63 |
+
|
| 64 |
+
struct ggml_metal_buffer_id {
|
| 65 |
+
@@ -133,6 +134,7 @@
|
| 66 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_soft_max (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 67 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_lightning_indexer (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 68 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_dsv4_hc (ggml_metal_library_t lib, enum ggml_op op);
|
| 69 |
+
+struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_state_step (ggml_metal_library_t lib);
|
| 70 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv (ggml_metal_library_t lib, const struct ggml_tensor * op, bool silu);
|
| 71 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_conv_batched (ggml_metal_library_t lib, const struct ggml_tensor * op, int ssm_conv_bs, bool silu);
|
| 72 |
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_ssm_scan (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
| 73 |
+
--- a/ggml/src/ggml-metal/ggml-metal-impl.h 2026-10-15 23:29:33
|
| 74 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-impl.h 2026-10-15 23:29:33
|
| 75 |
+
@@ -917,6 +917,18 @@
|
| 76 |
+
uint64_t nb1;
|
| 77 |
+
uint64_t nb2;
|
| 78 |
+
} ggml_metal_kargs_ssm_conv;
|
| 79 |
+
+
|
| 80 |
+
+// decode conv-state step of the gated delta net, see ggml_metal_op_conv_state_step
|
| 81 |
+
+typedef struct {
|
| 82 |
+
+ int32_t nch; // channels
|
| 83 |
+
+ int32_t sA; // first element of the state slot copies, in the 4-wide conv input
|
| 84 |
+
+ int32_t sB;
|
| 85 |
+
+ int32_t silu;
|
| 86 |
+
+ uint64_t nb00; // state (concat src0) element (k, c) at c*nb01 + k*nb00
|
| 87 |
+
+ uint64_t nb01;
|
| 88 |
+
+ uint64_t nb11; // new input (concat src1) element (0, c) at c*nb11
|
| 89 |
+
+ uint64_t nb1; // conv input (concat dst) row stride
|
| 90 |
+
+} ggml_metal_kargs_conv_state_step;
|
| 91 |
+
|
| 92 |
+
typedef struct {
|
| 93 |
+
int64_t d_state;
|
| 94 |
+
--- a/ggml/src/ggml-metal/ggml-metal-ops.cpp 2026-10-15 23:29:33
|
| 95 |
+
+++ b/ggml/src/ggml-metal/ggml-metal-ops.cpp 2026-10-15 23:29:33
|
| 96 |
+
@@ -564,10 +564,120 @@
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
return res;
|
| 100 |
+
+}
|
| 101 |
+
+
|
| 102 |
+
+// Decode conv-state step of the gated delta net (src/models/delta-net-base.cpp build_conv_state, then
|
| 103 |
+
+// ggml_ssm_conv and ggml_silu in qwen35.cpp), for one token and one sequence:
|
| 104 |
+
+// conv_input = CONCAT(conv_states [3, C], x^T [1, C]) -> 2 x CPY(view of conv_input [3, C] at element s, state slot)
|
| 105 |
+
+// -> SSM_CONV(conv_input, kernel [4, C]) (-> SILU)
|
| 106 |
+
+// encoded as one thread-per-channel kernel instead of 4-5 dependent dispatches. Returns the number of fused nodes,
|
| 107 |
+
+// 0 when the pattern does not match (the generic kernels run).
|
| 108 |
+
+static int ggml_metal_op_conv_state_step(ggml_metal_op_t ctx, int idx) {
|
| 109 |
+
+ ggml_tensor * op = ctx->node(idx);
|
| 110 |
+
+
|
| 111 |
+
+ if (!ctx->use_fusion || idx + 4 > ctx->n_nodes()) {
|
| 112 |
+
+ return 0;
|
| 113 |
+
+ }
|
| 114 |
+
+
|
| 115 |
+
+ const ggml_tensor * s0 = op->src[0];
|
| 116 |
+
+ const ggml_tensor * s1 = op->src[1];
|
| 117 |
+
+ const int64_t nch = op->ne[1];
|
| 118 |
+
+
|
| 119 |
+
+ if (((const int32_t *) op->op_params)[0] != 0 || op->type != GGML_TYPE_F32 || s0->type != GGML_TYPE_F32 ||
|
| 120 |
+
+ s1->type != GGML_TYPE_F32 || !ggml_is_contiguous(op) ||
|
| 121 |
+
+ op->ne[0] != 4 || op->ne[2] != 1 || op->ne[3] != 1 ||
|
| 122 |
+
+ s0->ne[0] != 3 || s0->ne[1] != nch || s0->ne[2] != 1 || s0->ne[3] != 1 ||
|
| 123 |
+
+ s1->ne[0] != 1 || s1->ne[1] != nch || s1->ne[2] != 1 || s1->ne[3] != 1) {
|
| 124 |
+
+ return 0;
|
| 125 |
+
+ }
|
| 126 |
+
+
|
| 127 |
+
+ ggml_tensor * cpy[2] = { ctx->node(idx + 1), ctx->node(idx + 2) };
|
| 128 |
+
+ int32_t sidx[2];
|
| 129 |
+
+ for (int j = 0; j < 2; ++j) {
|
| 130 |
+
+ const ggml_tensor * v = cpy[j]->src[0];
|
| 131 |
+
+ const ggml_tensor * d = cpy[j]->src[1];
|
| 132 |
+
+ if (cpy[j]->op != GGML_OP_CPY || v->view_src != op || v->type != GGML_TYPE_F32 ||
|
| 133 |
+
+ d->type != GGML_TYPE_F32 || !ggml_is_contiguous(d) || ggml_nelements(d) != 3*nch ||
|
| 134 |
+
+ v->ne[0] != 3 || v->ne[1] != nch || v->ne[2] != 1 || v->ne[3] != 1 ||
|
| 135 |
+
+ v->nb[0] != sizeof(float) || v->nb[1] != op->nb[1] || cpy[j]->data != d->data) {
|
| 136 |
+
+ return 0;
|
| 137 |
+
+ }
|
| 138 |
+
+ const size_t offs = (const char *) v->data - (const char *) op->data;
|
| 139 |
+
+ if (offs % sizeof(float) != 0 || offs/sizeof(float) > 1) {
|
| 140 |
+
+ return 0;
|
| 141 |
+
+ }
|
| 142 |
+
+ sidx[j] = (int32_t) (offs/sizeof(float));
|
| 143 |
+
+ }
|
| 144 |
+
+
|
| 145 |
+
+ ggml_tensor * conv = ctx->node(idx + 3);
|
| 146 |
+
+ if (conv->op != GGML_OP_SSM_CONV || conv->src[0] != op || conv->type != GGML_TYPE_F32 ||
|
| 147 |
+
+ conv->src[1]->type != GGML_TYPE_F32 || !ggml_is_contiguous(conv->src[1]) ||
|
| 148 |
+
+ conv->src[1]->ne[0] != 4 || conv->src[1]->ne[1] != nch ||
|
| 149 |
+
+ conv->ne[0] != nch || conv->ne[1] != 1 || conv->ne[2] != 1 || !ggml_is_contiguous(conv)) {
|
| 150 |
+
+ return 0;
|
| 151 |
+
+ }
|
| 152 |
+
+
|
| 153 |
+
+ // conv followed by a silu that is its only consumer (as in ggml_metal_op_ssm_conv)
|
| 154 |
+
+ ggml_tensor * out = conv;
|
| 155 |
+
+ int n_fuse = 4;
|
| 156 |
+
+ {
|
| 157 |
+
+ static constexpr ggml_op ops[2] = { GGML_OP_SSM_CONV, GGML_OP_UNARY };
|
| 158 |
+
+ if (ctx->can_fuse(idx + 3, ops, 2)) {
|
| 159 |
+
+ ggml_tensor * un = ctx->node(idx + 4);
|
| 160 |
+
+ if (ggml_get_unary_op(un) == GGML_UNARY_OP_SILU && un->src[0] == conv &&
|
| 161 |
+
+ un->type == GGML_TYPE_F32 && ggml_is_contiguous(un) && ggml_are_same_shape(un, conv)) {
|
| 162 |
+
+ out = un;
|
| 163 |
+
+ n_fuse = 5;
|
| 164 |
+
+ }
|
| 165 |
+
+ }
|
| 166 |
+
+ }
|
| 167 |
+
+
|
| 168 |
+
+ for (int i = 1; i < n_fuse; ++i) {
|
| 169 |
+
+ if (!ggml_metal_op_concurrency_check(ctx, ctx->node(idx + i))) {
|
| 170 |
+
+ ggml_metal_op_concurrency_reset(ctx);
|
| 171 |
+
+ }
|
| 172 |
+
+ }
|
| 173 |
+
+
|
| 174 |
+
+ ggml_metal_kargs_conv_state_step args = {
|
| 175 |
+
+ /*.nch =*/ (int32_t) nch,
|
| 176 |
+
+ /*.sA =*/ sidx[0],
|
| 177 |
+
+ /*.sB =*/ sidx[1],
|
| 178 |
+
+ /*.silu =*/ n_fuse == 5 ? 1 : 0,
|
| 179 |
+
+ /*.nb00 =*/ s0->nb[0],
|
| 180 |
+
+ /*.nb01 =*/ s0->nb[1],
|
| 181 |
+
+ /*.nb11 =*/ s1->nb[1],
|
| 182 |
+
+ /*.nb1 =*/ op->nb[1],
|
| 183 |
+
+ };
|
| 184 |
+
+
|
| 185 |
+
+ ggml_metal_encoder_t enc = ctx->enc;
|
| 186 |
+
+
|
| 187 |
+
+ auto pipeline = ggml_metal_library_get_pipeline_conv_state_step(ctx->lib);
|
| 188 |
+
+
|
| 189 |
+
+ ggml_metal_encoder_set_pipeline(enc, pipeline);
|
| 190 |
+
+ ggml_metal_encoder_set_bytes (enc, &args, sizeof(args), 0);
|
| 191 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(s0), 1);
|
| 192 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(s1), 2);
|
| 193 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op), 3);
|
| 194 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(cpy[0]), 4);
|
| 195 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(cpy[1]), 5);
|
| 196 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(conv->src[1]), 6);
|
| 197 |
+
+ ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(out), 7);
|
| 198 |
+
+
|
| 199 |
+
+ const int nth = 256;
|
| 200 |
+
+ ggml_metal_encoder_dispatch_threadgroups(enc, (nch + nth - 1)/nth, 1, 1, nth, 1, 1);
|
| 201 |
+
+
|
| 202 |
+
+ return n_fuse;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
int ggml_metal_op_concat(ggml_metal_op_t ctx, int idx) {
|
| 206 |
+
ggml_tensor * op = ctx->node(idx);
|
| 207 |
+
+
|
| 208 |
+
+ {
|
| 209 |
+
+ const int n_fuse = ggml_metal_op_conv_state_step(ctx, idx);
|
| 210 |
+
+ if (n_fuse > 0) {
|
| 211 |
+
+ return n_fuse;
|
| 212 |
+
+ }
|
| 213 |
+
+ }
|
| 214 |
+
|
| 215 |
+
ggml_metal_library_t lib = ctx->lib;
|
| 216 |
+
ggml_metal_encoder_t enc = ctx->enc;
|
| 217 |
+
--- a/ggml/src/ggml-metal/kernels/dequantize.h 2026-10-15 23:29:33
|
| 218 |
+
+++ b/ggml/src/ggml-metal/kernels/dequantize.h 2026-10-15 23:29:33
|
| 219 |
+
@@ -44,11 +44,32 @@
|
| 220 |
+
reg = (type4)(*(src));
|
| 221 |
+
}
|
| 222 |
+
#endif
|
| 223 |
+
+
|
| 224 |
+
+// Q1_0 weights in Metal buffers are stored repacked (llama-model-loader.cpp, q1_0_repack_tiles): each
|
| 225 |
+
+// 1024-weight tile of a row (8 blocks, 144 bytes) holds the 8 fp16 block scales (16 B), then the 8 x 16 B of
|
| 226 |
+
+// sign bits. Tiles start 16-byte aligned, so the address the original layout gives block i of a tile,
|
| 227 |
+
+// tile + 18*i, has (address & 15) == 2*i: every kernel keeps its block_q1_0 pointer arithmetic and finds
|
| 228 |
+
+// the block's scale and bits from that address.
|
| 229 |
+
+struct q1_0_loc {
|
| 230 |
+
+ half d;
|
| 231 |
+
+ device const uint8_t * qs;
|
| 232 |
+
+};
|
| 233 |
+
+
|
| 234 |
+
+static inline q1_0_loc q1_0_locate(device const block_q1_0 * xb) {
|
| 235 |
+
+ device const char * p = (device const char *) xb;
|
| 236 |
+
+ const short i = (short) ((((ulong) p) & 15) >> 1);
|
| 237 |
+
+ device const char * tile = p - 18*i;
|
| 238 |
+
+ q1_0_loc res;
|
| 239 |
+
+ res.d = ((device const half *) tile)[i];
|
| 240 |
+
+ res.qs = (device const uint8_t *) (tile + 16 + 16*i);
|
| 241 |
+
+ return res;
|
| 242 |
+
+}
|
| 243 |
+
|
| 244 |
+
template <typename type4x4>
|
| 245 |
+
void dequantize_q1_0(device const block_q1_0 * xb, short il, thread type4x4 & reg) {
|
| 246 |
+
- device const uint8_t * qs = xb->qs;
|
| 247 |
+
- const float d = xb->d;
|
| 248 |
+
+ const q1_0_loc blk = q1_0_locate(xb);
|
| 249 |
+
+ device const uint8_t * qs = blk.qs;
|
| 250 |
+
+ const float d = blk.d;
|
| 251 |
+
const float neg_d = -d;
|
| 252 |
+
|
| 253 |
+
const int byte_offset = il * 2; // il*16 bits = il*2 bytes
|
| 254 |
+
@@ -80,10 +101,11 @@
|
| 255 |
+
|
| 256 |
+
template <typename type4>
|
| 257 |
+
void dequantize_q1_0_t4(device const block_q1_0 * xb, short il, thread type4 & reg) {
|
| 258 |
+
- const float d = xb->d;
|
| 259 |
+
+ const q1_0_loc blk = q1_0_locate(xb);
|
| 260 |
+
+ const float d = blk.d;
|
| 261 |
+
const float neg_d = -d;
|
| 262 |
+
const int base = il * 4;
|
| 263 |
+
- const uint8_t byte = xb->qs[base / 8];
|
| 264 |
+
+ const uint8_t byte = blk.qs[base / 8];
|
| 265 |
+
const int s = base % 8;
|
| 266 |
+
|
| 267 |
+
float4 reg_f;
|
| 268 |
+
--- a/ggml/src/ggml-metal/kernels/mul_mv.metal 2026-10-15 23:29:33
|
| 269 |
+
+++ b/ggml/src/ggml-metal/kernels/mul_mv.metal 2026-10-15 23:29:33
|
| 270 |
+
@@ -2,7 +2,8 @@
|
| 271 |
+
#include "dequantize.h"
|
| 272 |
+
// Q1_0 dot product: dot = d * (2 * Σ(yl[i] where bit=1) - sumy)
|
| 273 |
+
inline float block_q_n_dot_y(device const block_q1_0 * qb_curr, float sumy, thread float * yl, int il) {
|
| 274 |
+
- device const uint8_t * qs = qb_curr->qs + il / 8;
|
| 275 |
+
+ const q1_0_loc blk = q1_0_locate(qb_curr);
|
| 276 |
+
+ device const uint8_t * qs = blk.qs + il / 8;
|
| 277 |
+
const uint8_t b0 = qs[0];
|
| 278 |
+
const uint8_t b1 = qs[1];
|
| 279 |
+
|
| 280 |
+
@@ -26,7 +27,7 @@
|
| 281 |
+
acc += select(0.0f, yl[14], bool(b1 & 0x40));
|
| 282 |
+
acc += select(0.0f, yl[15], bool(b1 & 0x80));
|
| 283 |
+
|
| 284 |
+
- return qb_curr->d * (2.0f * acc - sumy);
|
| 285 |
+
+ return blk.d * (2.0f * acc - sumy);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
// Q2_0 dot: d * (sum_lo(y) + 2*sum_hi(y) - sumy) via per-bit conditional adds
|
| 289 |
+
@@ -429,7 +430,111 @@
|
| 290 |
+
ushort sgitg[[simdgroup_index_in_threadgroup]]) {
|
| 291 |
+
kernel_mul_mv_q1_0_f32_impl<N_R0_Q1_0, constant ggml_metal_kargs_mul_mv &>(args, src0, src1, dst, nullptr, tgpig, tiisg, sgitg);
|
| 292 |
+
}
|
| 293 |
+
+
|
| 294 |
+
+// Q1_0 single-column mat-vec through a lookup table (decode, ne11 == 1), on the repacked layout
|
| 295 |
+
+// (see q1_0_locate in dequantize.h): a row's 1024-wide K tile is 16 B of block scales, then 128 B of bits.
|
| 296 |
+
+// The bit-select dot (block_q_n_dot_y) costs ~3 ALU ops per weight, which caps it well below the memory
|
| 297 |
+
+// bandwidth. Here the threadgroup first builds, for each group of 4 consecutive src1 values of the tile, the
|
| 298 |
+
+// 16 signed sums +-y0 +-y1 +-y2 +-y3 in threadgroup memory; then every 4 weight bits of every row cost one
|
| 299 |
+
+// table read and one add. Same math as block_q_n_dot_y: d*(2*sum(y where bit=1) - sum(y)) == d*sum(+-y), fp32.
|
| 300 |
+
+// Lane l of a row reads the tile's bits 32l..32l+31 (block l/4) with one coalesced 32-bit load: 8 nibbles,
|
| 301 |
+
+// groups g = 8l + j. Table layout tab[n*GT + pos], pos = (g%8)*32 + (g/8 + 4*(g%8))%32: both the build
|
| 302 |
+
+// (consecutive g) and the lookups (lane l reads g = 8l + j) hit 32 different banks.
|
| 303 |
+
+template<short NR>
|
| 304 |
+
+kernel void kernel_mul_mv_q1_0_f32_lut(
|
| 305 |
+
+ constant ggml_metal_kargs_mul_mv & args,
|
| 306 |
+
+ device const char * src0,
|
| 307 |
+
+ device const char * src1,
|
| 308 |
+
+ device char * dst,
|
| 309 |
+
+ threadgroup char * shmem [[threadgroup(0)]],
|
| 310 |
+
+ uint3 tgpig[[threadgroup_position_in_grid]],
|
| 311 |
+
+ ushort tiisg[[thread_index_in_simdgroup]],
|
| 312 |
+
+ ushort sgitg[[simdgroup_index_in_threadgroup]]) {
|
| 313 |
+
+ const short NSG = FC_mul_mv_nsg;
|
| 314 |
+
+
|
| 315 |
+
+ constexpr short KT = 1024;
|
| 316 |
+
+ constexpr short GT = KT/4; // groups of 4 per tile
|
| 317 |
+
+ constexpr short TB = 144; // bytes per row tile
|
| 318 |
+
+
|
| 319 |
+
+ threadgroup float * tab = (threadgroup float *) shmem;
|
| 320 |
+
|
| 321 |
+
+ const int r1 = tgpig.y;
|
| 322 |
+
+
|
| 323 |
+
+ const int first_row = (tgpig.x*NSG + sgitg)*NR;
|
| 324 |
+
+ const short tid = sgitg*N_SIMDWIDTH + tiisg;
|
| 325 |
+
+
|
| 326 |
+
+ device const float * y = (device const float *) (src1 + (uint64_t) r1*args.nb11);
|
| 327 |
+
+
|
| 328 |
+
+ device const char * ax[NR];
|
| 329 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 330 |
+
+ const int row = min(first_row + r, args.ne01 - 1);
|
| 331 |
+
+ ax[r] = src0 + (uint64_t) row*args.nb01;
|
| 332 |
+
+ }
|
| 333 |
+
+
|
| 334 |
+
+ float acc[NR] = { 0.f };
|
| 335 |
+
+
|
| 336 |
+
+ const int ntiles = args.ne00/KT;
|
| 337 |
+
+
|
| 338 |
+
+ // table offsets of the lane's groups j and j + 4, packed in the two 16-bit halves
|
| 339 |
+
+ uint offp[4];
|
| 340 |
+
+ FOR_UNROLL (short j = 0; j < 4; ++j) {
|
| 341 |
+
+ offp[j] = (uint) (j*32 + ((tiisg + 4*j) & 31)) | ((uint) ((j + 4)*32 + ((tiisg + 4*(j + 4)) & 31)) << 16);
|
| 342 |
+
+ }
|
| 343 |
+
+
|
| 344 |
+
+ for (int t = 0; t < ntiles; ++t) {
|
| 345 |
+
+ uint u [NR];
|
| 346 |
+
+ half dh[NR];
|
| 347 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 348 |
+
+ device const char * tb = ax[r] + t*TB;
|
| 349 |
+
+ dh[r] = ((device const half *) tb)[tiisg/4];
|
| 350 |
+
+ u [r] = ((device const uint *) (tb + 16))[tiisg];
|
| 351 |
+
+ }
|
| 352 |
+
+
|
| 353 |
+
+ threadgroup_barrier(mem_flags::mem_threadgroup);
|
| 354 |
+
+
|
| 355 |
+
+ for (short g = tid; g < GT; g += NSG*N_SIMDWIDTH) {
|
| 356 |
+
+ const float4 yv = ((device const float4 *) (y + t*KT))[g];
|
| 357 |
+
+ const float a[4] = { -yv[0] - yv[1], yv[0] - yv[1], -yv[0] + yv[1], yv[0] + yv[1] };
|
| 358 |
+
+ const float b[4] = { -yv[2] - yv[3], yv[2] - yv[3], -yv[2] + yv[3], yv[2] + yv[3] };
|
| 359 |
+
+ const short pos = (g%8)*32 + ((g/8 + 4*(g%8)) & 31);
|
| 360 |
+
+ FOR_UNROLL (short n = 0; n < 16; ++n) {
|
| 361 |
+
+ tab[n*GT + pos] = a[n%4] + b[n/4];
|
| 362 |
+
+ }
|
| 363 |
+
+ }
|
| 364 |
+
+
|
| 365 |
+
+ threadgroup_barrier(mem_flags::mem_threadgroup);
|
| 366 |
+
+
|
| 367 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 368 |
+
+ // two table indices per 32-bit op: nibbles j and j + 4 land in the two 16-bit halves as n*GT
|
| 369 |
+
+ const uint w = u[r];
|
| 370 |
+
+ const uint m = 0x0F000F00u;
|
| 371 |
+
+ const ushort2 x0 = as_type<ushort2>(((w << 8) & m) | offp[0]);
|
| 372 |
+
+ const ushort2 x1 = as_type<ushort2>(((w << 4) & m) | offp[1]);
|
| 373 |
+
+ const ushort2 x2 = as_type<ushort2>(((w ) & m) | offp[2]);
|
| 374 |
+
+ const ushort2 x3 = as_type<ushort2>(((w >> 4) & m) | offp[3]);
|
| 375 |
+
+ const float s = ((tab[x0[0]] + tab[x0[1]]) + (tab[x1[0]] + tab[x1[1]]))
|
| 376 |
+
+ + ((tab[x2[0]] + tab[x2[1]]) + (tab[x3[0]] + tab[x3[1]]));
|
| 377 |
+
+ acc[r] += (float) dh[r] * s;
|
| 378 |
+
+ }
|
| 379 |
+
+ }
|
| 380 |
+
+
|
| 381 |
+
+ device float * dst_f32 = (device float *) dst + (uint64_t) r1*args.ne0;
|
| 382 |
+
+
|
| 383 |
+
+ FOR_UNROLL (short r = 0; r < NR; ++r) {
|
| 384 |
+
+ const float tot = simd_sum(acc[r]);
|
| 385 |
+
+
|
| 386 |
+
+ if (tiisg == 0 && first_row + r < args.ne01) {
|
| 387 |
+
+ dst_f32[first_row + r] = tot;
|
| 388 |
+
+ }
|
| 389 |
+
+ }
|
| 390 |
+
+}
|
| 391 |
+
+
|
| 392 |
+
+typedef decltype(kernel_mul_mv_q1_0_f32_lut<4>) kernel_mul_mv_q1_0_f32_lut_t;
|
| 393 |
+
+
|
| 394 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_2")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<2>;
|
| 395 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_4")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<4>;
|
| 396 |
+
+template [[host_name("kernel_mul_mv_q1_0_f32_lut_8")]] kernel kernel_mul_mv_q1_0_f32_lut_t kernel_mul_mv_q1_0_f32_lut<8>;
|
| 397 |
+
+
|
| 398 |
+
// Q1_0 multi-column mat-vec: each q1_0 block is read once and dotted against nr1
|
| 399 |
+
// src1 columns (the spec-decode verify batch, ne11 = k+1 rows). tpb threads
|
| 400 |
+
// cooperate on one block, slice width SW = QK1_0/tpb. Register budget (M5 Pro):
|
| 401 |
+
@@ -506,14 +611,14 @@
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
FOR_UNROLL (short row = 0; row < nr0; row++) {
|
| 405 |
+
- device const block_q1_0 * qb = ax[row] + ib;
|
| 406 |
+
- device const uint8_t * qs = qb->qs + il/8;
|
| 407 |
+
+ const q1_0_loc blk = q1_0_locate(ax[row] + ib);
|
| 408 |
+
+ device const uint8_t * qs = blk.qs + il/8;
|
| 409 |
+
|
| 410 |
+
uint8_t b[SW/8];
|
| 411 |
+
FOR_UNROLL (short i = 0; i < SW/8; i++) {
|
| 412 |
+
b[i] = qs[i];
|
| 413 |
+
}
|
| 414 |
+
- const float d = qb->d;
|
| 415 |
+
+ const float d = blk.d;
|
| 416 |
+
|
| 417 |
+
FOR_UNROLL (short c = 0; c < nr1; c++) {
|
| 418 |
+
sumf[row][c] += q1_0_dot_y_sw<SW>(b, d, sumy[c], yl[c]);
|
| 419 |
+
@@ -681,8 +786,8 @@
|
| 420 |
+
int pcw[nr0];
|
| 421 |
+
|
| 422 |
+
FOR_UNROLL (short row = 0; row < nr0; row++) {
|
| 423 |
+
- device const block_q1_0 * qb = ax[row] + ib;
|
| 424 |
+
- device const uint8_t * qs = qb->qs; // 2-byte aligned: assemble from bytes
|
| 425 |
+
+ const q1_0_loc blk = q1_0_locate(ax[row] + ib);
|
| 426 |
+
+ device const uint8_t * qs = blk.qs; // 2-byte aligned: assemble from bytes
|
| 427 |
+
|
| 428 |
+
int pc = 0;
|
| 429 |
+
FOR_UNROLL (short j = 0; j < 4; j++) {
|
| 430 |
+
@@ -692,7 +797,7 @@
|
| 431 |
+
pc += popcount(wj);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
- d [row] = qb->d;
|
| 435 |
+
+ d [row] = blk.d;
|
| 436 |
+
pcw[row] = pc;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
--- a/ggml/src/ggml-metal/kernels/ssm.metal 2026-10-15 23:29:33
|
| 440 |
+
+++ b/ggml/src/ggml-metal/kernels/ssm.metal 2026-10-15 23:29:33
|
| 441 |
+
@@ -66,6 +66,41 @@
|
| 442 |
+
x[0] = FC_ssm_conv_silu ? sumf / (1.0f + exp(-sumf)) : sumf;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
+// Decode (one token) conv-state step of the gated delta net in one thread per channel: the graph's
|
| 446 |
+
+// CONCAT(state[3], x) -> two CPYs of 3-wide windows into the state cache slots -> SSM_CONV (+ SILU).
|
| 447 |
+
+// Same math as kernel_ssm_conv_f32_f32_4: dot(conv input row, kernel row), then the same silu.
|
| 448 |
+
+kernel void kernel_conv_state_step_f32(
|
| 449 |
+
+ constant ggml_metal_kargs_conv_state_step & args,
|
| 450 |
+
+ device const char * src0,
|
| 451 |
+
+ device const char * src1,
|
| 452 |
+
+ device char * cin,
|
| 453 |
+
+ device float * dstA,
|
| 454 |
+
+ device float * dstB,
|
| 455 |
+
+ device const float4 * w,
|
| 456 |
+
+ device float * dst,
|
| 457 |
+
+ uint i[[thread_position_in_grid]]) {
|
| 458 |
+
+ if ((int) i >= args.nch) {
|
| 459 |
+
+ return;
|
| 460 |
+
+ }
|
| 461 |
+
+
|
| 462 |
+
+ device const char * s = src0 + i*args.nb01;
|
| 463 |
+
+ const float4 v = float4(*(device const float *) (s),
|
| 464 |
+
+ *(device const float *) (s + args.nb00),
|
| 465 |
+
+ *(device const float *) (s + 2*args.nb00),
|
| 466 |
+
+ *(device const float *) (src1 + i*args.nb11));
|
| 467 |
+
+
|
| 468 |
+
+ *(device float4 *) (cin + i*args.nb1) = v;
|
| 469 |
+
+
|
| 470 |
+
+ FOR_UNROLL (short k = 0; k < 3; ++k) {
|
| 471 |
+
+ dstA[3*i + k] = v[args.sA + k];
|
| 472 |
+
+ dstB[3*i + k] = v[args.sB + k];
|
| 473 |
+
+ }
|
| 474 |
+
+
|
| 475 |
+
+ const float sumf = dot(v, w[i]);
|
| 476 |
+
+
|
| 477 |
+
+ dst[i] = args.silu ? sumf / (1.0f + exp(-sumf)) : sumf;
|
| 478 |
+
+}
|
| 479 |
+
+
|
| 480 |
+
constant short FC_ssm_conv_bs [[function_constant(FC_SSM_CONV + 0)]];
|
| 481 |
+
|
| 482 |
+
// Batched version: each threadgroup processes multiple tokens for better efficiency
|
| 483 |
+
--- a/src/llama-model-loader.cpp 2026-10-15 23:29:33
|
| 484 |
+
+++ b/src/llama-model-loader.cpp 2026-10-15 23:29:33
|
| 485 |
+
@@ -1437,6 +1437,36 @@
|
| 486 |
+
|
| 487 |
+
if (check_tensors && !ggml_validate_row_data(cur->type, cur->data, ggml_nbytes(cur))) {
|
| 488 |
+
throw std::runtime_error(format("tensor '%s' has invalid data", ggml_get_name(cur)));
|
| 489 |
+
+ }
|
| 490 |
+
+}
|
| 491 |
+
+
|
| 492 |
+
+// Q1_0 weights in Metal buffers use the repacked layout the Metal kernels read (q1_0_locate in
|
| 493 |
+
+// ggml-metal kernels/dequantize.h): each 1024-weight tile of a row, 8 blocks of {fp16 d, 16 B bits} = 144 B,
|
| 494 |
+
+// is rewritten as the 8 scales (16 B) followed by the 8 x 16 B of bits. Same bytes, same size.
|
| 495 |
+
+static bool q1_0_metal_repack(const ggml_tensor * cur) {
|
| 496 |
+
+ if (cur->type != GGML_TYPE_Q1_0 || cur->buffer == nullptr) {
|
| 497 |
+
+ return false;
|
| 498 |
+
+ }
|
| 499 |
+
+ const char * name = ggml_backend_buft_name(ggml_backend_buffer_get_type(cur->buffer));
|
| 500 |
+
+ return strncmp(name, "MTL", 3) == 0;
|
| 501 |
+
+}
|
| 502 |
+
+
|
| 503 |
+
+static void q1_0_repack_tiles(void * data, const ggml_tensor * cur) {
|
| 504 |
+
+ constexpr size_t BS = 18; // block_q1_0: fp16 d, then 16 bytes of bits
|
| 505 |
+
+ constexpr size_t TB = 8*BS; // 144 bytes per 1024-weight tile
|
| 506 |
+
+ if (cur->ne[0] % 1024 != 0 || !ggml_is_contiguous(cur)) {
|
| 507 |
+
+ throw std::runtime_error(format("tensor '%s': the Metal Q1_0 kernels need ne0 %% 1024 == 0 and a contiguous tensor",
|
| 508 |
+
+ ggml_get_name(cur)));
|
| 509 |
+
+ }
|
| 510 |
+
+ const size_t ntiles = ggml_nbytes(cur)/TB;
|
| 511 |
+
+ uint8_t * p = (uint8_t *) data;
|
| 512 |
+
+ uint8_t tmp[TB];
|
| 513 |
+
+ for (size_t t = 0; t < ntiles; ++t, p += TB) {
|
| 514 |
+
+ memcpy(tmp, p, TB);
|
| 515 |
+
+ for (int i = 0; i < 8; ++i) {
|
| 516 |
+
+ memcpy(p + 2*i, tmp + i*BS, 2);
|
| 517 |
+
+ memcpy(p + 16 + 16*i, tmp + i*BS + 2, 16);
|
| 518 |
+
+ }
|
| 519 |
+
}
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
@@ -1585,6 +1615,11 @@
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
GGML_ASSERT(buf_mmap || cur->data); // either we have a buffer to allocate the tensor in, or it is already allocated
|
| 526 |
+
+ if (q1_0_metal_repack(cur) || (buf_mmap && cur->type == GGML_TYPE_Q1_0 &&
|
| 527 |
+
+ strncmp(ggml_backend_buft_name(ggml_backend_buffer_get_type(buf_mmap)), "MTL", 3) == 0)) {
|
| 528 |
+
+ throw std::runtime_error(format("tensor '%s': Q1_0 weights on Metal need load_mode NONE, not mmap (repacked layout)",
|
| 529 |
+
+ ggml_get_name(cur)));
|
| 530 |
+
+ }
|
| 531 |
+
if (buf_mmap && cur->data == nullptr) {
|
| 532 |
+
ggml_backend_tensor_alloc(buf_mmap, cur, data);
|
| 533 |
+
if (lmlocks) {
|
| 534 |
+
@@ -1609,6 +1644,15 @@
|
| 535 |
+
return std::make_pair(cur, ggml_validate_row_data(cur->type, cur->data, n_size));
|
| 536 |
+
}));
|
| 537 |
+
}
|
| 538 |
+
+ } else if (q1_0_metal_repack(cur)) {
|
| 539 |
+
+ read_buf.resize(n_size);
|
| 540 |
+
+ file->seek(weight->offs, SEEK_SET);
|
| 541 |
+
+ file->read_raw(read_buf.data(), n_size);
|
| 542 |
+
+ if (check_tensors && !ggml_validate_row_data(cur->type, read_buf.data(), n_size)) {
|
| 543 |
+
+ throw std::runtime_error(format("tensor '%s' has invalid data", ggml_get_name(cur)));
|
| 544 |
+
+ }
|
| 545 |
+
+ q1_0_repack_tiles(read_buf.data(), cur);
|
| 546 |
+
+ ggml_backend_tensor_set(cur, read_buf.data(), 0, n_size);
|
| 547 |
+
} else {
|
| 548 |
+
// If upload_backend is valid load the tensor in chunks to pinned memory and upload the buffers asynchronously to the GPU.
|
| 549 |
+
if (upload_backend) {
|
m2pro-gpu-q1_0/src/run.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# nnopt contract entry point (text_to_text): generate or score, see nnopt_runner.
|
| 2 |
+
cd "$(dirname "$0")" || exit 1
|
| 3 |
+
exec ./nnopt_runner --model ./Bonsai-27B-Q1_0.gguf "$@"
|
m2pro-gpu-q1_0/src/runner.cpp
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// nnopt contract runner (text_to_text) over the customer's PrismML llama.cpp fork.
|
| 2 |
+
// Runs the model the way llama-cli does on Metal (-ngl 99, n_batch 2048, n_ubatch 512,
|
| 3 |
+
// flash attention auto, f16 KV cache), with greedy decoding instead of sampling.
|
| 4 |
+
#include "llama.h"
|
| 5 |
+
|
| 6 |
+
#include <sys/resource.h>
|
| 7 |
+
#include <sys/sysctl.h>
|
| 8 |
+
|
| 9 |
+
#include <algorithm>
|
| 10 |
+
#include <chrono>
|
| 11 |
+
#include <cstdio>
|
| 12 |
+
#include <cstdlib>
|
| 13 |
+
#include <cstring>
|
| 14 |
+
#include <fstream>
|
| 15 |
+
#include <sstream>
|
| 16 |
+
#include <string>
|
| 17 |
+
#include <vector>
|
| 18 |
+
|
| 19 |
+
using clk = std::chrono::steady_clock;
|
| 20 |
+
static const clk::time_point t_start = clk::now();
|
| 21 |
+
|
| 22 |
+
static double ms_since(clk::time_point t) {
|
| 23 |
+
return std::chrono::duration<double, std::milli>(clk::now() - t).count();
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
static void die(const std::string & msg) {
|
| 27 |
+
fprintf(stderr, "nnopt_runner: %s\n", msg.c_str());
|
| 28 |
+
exit(1);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
static std::string read_file(const std::string & path) {
|
| 32 |
+
std::ifstream f(path, std::ios::binary);
|
| 33 |
+
if (!f) die("cannot read " + path);
|
| 34 |
+
std::stringstream ss;
|
| 35 |
+
ss << f.rdbuf();
|
| 36 |
+
return ss.str();
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
static void write_file(const std::string & path, const std::string & data) {
|
| 40 |
+
std::ofstream f(path, std::ios::binary | std::ios::trunc);
|
| 41 |
+
if (!f) die("cannot write " + path);
|
| 42 |
+
f << data;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// Replace invalid UTF-8 with U+FFFD (like Python's errors="replace") so the JSON stays valid.
|
| 46 |
+
static std::string sanitize_utf8(const std::string & s) {
|
| 47 |
+
std::string out;
|
| 48 |
+
size_t i = 0, n = s.size();
|
| 49 |
+
while (i < n) {
|
| 50 |
+
unsigned char c = s[i];
|
| 51 |
+
int len = c < 0x80 ? 1 : (c >> 5) == 0x6 ? 2 : (c >> 4) == 0xE ? 3 : (c >> 3) == 0x1E ? 4 : 0;
|
| 52 |
+
bool ok = len > 0 && i + len <= n;
|
| 53 |
+
for (int k = 1; ok && k < len; k++) ok = (((unsigned char) s[i + k]) & 0xC0) == 0x80;
|
| 54 |
+
if (ok) { out.append(s, i, len); i += len; }
|
| 55 |
+
else { out += "\xEF\xBF\xBD"; i += 1; }
|
| 56 |
+
}
|
| 57 |
+
return out;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
static std::string json_str(const std::string & s) {
|
| 61 |
+
std::string o = "\"";
|
| 62 |
+
for (unsigned char c : s) {
|
| 63 |
+
switch (c) {
|
| 64 |
+
case '"': o += "\\\""; break;
|
| 65 |
+
case '\\': o += "\\\\"; break;
|
| 66 |
+
case '\n': o += "\\n"; break;
|
| 67 |
+
case '\r': o += "\\r"; break;
|
| 68 |
+
case '\t': o += "\\t"; break;
|
| 69 |
+
default:
|
| 70 |
+
if (c < 0x20) { char b[8]; snprintf(b, sizeof b, "\\u%04x", c); o += b; }
|
| 71 |
+
else o += (char) c;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
return o + "\"";
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
template <typename T>
|
| 78 |
+
static std::string json_arr(const std::vector<T> & v, const char * fmt) {
|
| 79 |
+
std::string o = "[";
|
| 80 |
+
char b[64];
|
| 81 |
+
for (size_t i = 0; i < v.size(); i++) {
|
| 82 |
+
snprintf(b, sizeof b, fmt, v[i]);
|
| 83 |
+
if (i) o += ", ";
|
| 84 |
+
o += b;
|
| 85 |
+
}
|
| 86 |
+
return o + "]";
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// Parses {"tokens": [int, ...]}.
|
| 90 |
+
static std::vector<llama_token> parse_tokens_json(const std::string & s) {
|
| 91 |
+
size_t p = s.find("\"tokens\"");
|
| 92 |
+
if (p == std::string::npos) die("no \"tokens\" key in score input");
|
| 93 |
+
p = s.find('[', p);
|
| 94 |
+
size_t e = s.find(']', p);
|
| 95 |
+
if (p == std::string::npos || e == std::string::npos) die("malformed tokens array");
|
| 96 |
+
std::vector<llama_token> out;
|
| 97 |
+
const char * c = s.c_str() + p + 1;
|
| 98 |
+
const char * end = s.c_str() + e;
|
| 99 |
+
while (c < end) {
|
| 100 |
+
char * nx;
|
| 101 |
+
long v = strtol(c, &nx, 10);
|
| 102 |
+
if (nx == c) { c++; continue; }
|
| 103 |
+
out.push_back((llama_token) v);
|
| 104 |
+
c = nx;
|
| 105 |
+
}
|
| 106 |
+
return out;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
static int perf_cores() {
|
| 110 |
+
int n = 0; size_t sz = sizeof n;
|
| 111 |
+
if (sysctlbyname("hw.perflevel0.physicalcpu", &n, &sz, nullptr, 0) != 0 || n <= 0) n = 4;
|
| 112 |
+
return n;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
static double peak_mem_mb() {
|
| 116 |
+
struct rusage ru; getrusage(RUSAGE_SELF, &ru);
|
| 117 |
+
return ru.ru_maxrss / (1024.0 * 1024.0); // bytes on macOS
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// Greedy argmax, ties to the lowest id.
|
| 121 |
+
static llama_token argmax(const float * logits, int n_vocab) {
|
| 122 |
+
int best = 0;
|
| 123 |
+
for (int i = 1; i < n_vocab; i++) if (logits[i] > logits[best]) best = i;
|
| 124 |
+
return best;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
int main(int argc, char ** argv) {
|
| 128 |
+
std::string model_path, prompt_file, score_file, out_path, metrics_path;
|
| 129 |
+
int max_new = 128, repeat = 1, top_k = 0;
|
| 130 |
+
bool ignore_eos = false;
|
| 131 |
+
for (int i = 1; i < argc; i++) {
|
| 132 |
+
std::string a = argv[i];
|
| 133 |
+
auto next = [&]() -> std::string { if (i + 1 >= argc) die("missing value for " + a); return argv[++i]; };
|
| 134 |
+
if (a == "--model") model_path = next();
|
| 135 |
+
else if (a == "--prompt-file") prompt_file = next();
|
| 136 |
+
else if (a == "--max-new-tokens") max_new = std::stoi(next());
|
| 137 |
+
else if (a == "--ignore-eos") ignore_eos = true;
|
| 138 |
+
else if (a == "--repeat") repeat = std::max(1, std::stoi(next()));
|
| 139 |
+
else if (a == "--score-tokens") score_file = next();
|
| 140 |
+
else if (a == "--top-k") top_k = std::stoi(next());
|
| 141 |
+
else if (a == "--out") out_path = next();
|
| 142 |
+
else if (a == "--metrics") metrics_path = next();
|
| 143 |
+
else die("unknown argument " + a);
|
| 144 |
+
}
|
| 145 |
+
if (model_path.empty() || out_path.empty() || metrics_path.empty()) die("need --model, --out, --metrics");
|
| 146 |
+
const bool score = !score_file.empty();
|
| 147 |
+
if (!score && prompt_file.empty()) die("need --prompt-file or --score-tokens");
|
| 148 |
+
if (score && top_k <= 0) die("--score-tokens needs --top-k > 0");
|
| 149 |
+
if (score) repeat = 1;
|
| 150 |
+
|
| 151 |
+
// Inputs are read while loading.
|
| 152 |
+
std::string prompt_text;
|
| 153 |
+
std::vector<llama_token> score_tokens;
|
| 154 |
+
if (score) score_tokens = parse_tokens_json(read_file(score_file));
|
| 155 |
+
else prompt_text = read_file(prompt_file);
|
| 156 |
+
|
| 157 |
+
llama_backend_init();
|
| 158 |
+
|
| 159 |
+
llama_model_params mparams = llama_model_default_params();
|
| 160 |
+
mparams.n_gpu_layers = 999; // -ngl 99: every layer on the Metal GPU
|
| 161 |
+
// read the weights into Metal buffers (no mmap): the loader repacks the Q1_0 tensors into the tile layout
|
| 162 |
+
// the patched Metal kernels read (src/patches, q1_0_locate)
|
| 163 |
+
mparams.load_mode = LLAMA_LOAD_MODE_NONE;
|
| 164 |
+
llama_model * model = llama_model_load_from_file(model_path.c_str(), mparams);
|
| 165 |
+
if (!model) die("failed to load model " + model_path);
|
| 166 |
+
const llama_vocab * vocab = llama_model_get_vocab(model);
|
| 167 |
+
const int n_vocab = llama_vocab_n_tokens(vocab);
|
| 168 |
+
|
| 169 |
+
std::vector<llama_token> prompt;
|
| 170 |
+
if (!score) {
|
| 171 |
+
int n = -llama_tokenize(vocab, prompt_text.data(), (int32_t) prompt_text.size(), nullptr, 0, true, true);
|
| 172 |
+
prompt.resize(n);
|
| 173 |
+
if (llama_tokenize(vocab, prompt_text.data(), (int32_t) prompt_text.size(), prompt.data(), n, true, true) != n)
|
| 174 |
+
die("tokenize failed");
|
| 175 |
+
if (prompt.empty()) die("empty prompt");
|
| 176 |
+
} else {
|
| 177 |
+
if (score_tokens.empty()) die("empty score input");
|
| 178 |
+
for (llama_token t : score_tokens) if (t < 0 || t >= n_vocab) die("token id out of range");
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
// Context: 4096 by default (llama-cli's fit minimum), larger only if a request needs it.
|
| 182 |
+
const int need = score ? (int) score_tokens.size() : (int) prompt.size() + max_new;
|
| 183 |
+
int n_ctx = 4096;
|
| 184 |
+
if (need > n_ctx) n_ctx = ((need + 255) / 256) * 256;
|
| 185 |
+
if (n_ctx > (int) llama_model_n_ctx_train(model)) die("request longer than the model's context");
|
| 186 |
+
|
| 187 |
+
llama_context_params cparams = llama_context_default_params();
|
| 188 |
+
cparams.n_ctx = n_ctx;
|
| 189 |
+
cparams.n_batch = 2048;
|
| 190 |
+
cparams.n_ubatch = 512;
|
| 191 |
+
cparams.n_seq_max = 1;
|
| 192 |
+
cparams.n_threads = perf_cores();
|
| 193 |
+
cparams.n_threads_batch = perf_cores();
|
| 194 |
+
cparams.flash_attn_type = LLAMA_FLASH_ATTN_TYPE_AUTO;
|
| 195 |
+
cparams.type_k = GGML_TYPE_F16;
|
| 196 |
+
cparams.type_v = GGML_TYPE_F16;
|
| 197 |
+
cparams.no_perf = true;
|
| 198 |
+
// n_rs_seq 1: the fork's "rows mode" for the gated delta net, which reads and writes the recurrent state in
|
| 199 |
+
// the cache inside the fused GDN kernel instead of gathering and copying back 3 MB per layer each token
|
| 200 |
+
// (same math, identical outputs). NNOPT_RS_SEQ overrides it for A/B runs.
|
| 201 |
+
cparams.n_rs_seq = getenv("NNOPT_RS_SEQ") ? (uint32_t) atoi(getenv("NNOPT_RS_SEQ")) : 1;
|
| 202 |
+
llama_context * ctx = llama_init_from_model(model, cparams);
|
| 203 |
+
if (!ctx) die("failed to create context");
|
| 204 |
+
llama_memory_t mem = llama_get_memory(ctx);
|
| 205 |
+
const int n_batch = (int) llama_n_batch(ctx);
|
| 206 |
+
|
| 207 |
+
// Warm the Metal pipelines once so load_ms covers shader compilation (not timed as a request).
|
| 208 |
+
{
|
| 209 |
+
llama_token t0 = score ? score_tokens[0] : prompt[0];
|
| 210 |
+
llama_batch b = llama_batch_get_one(&t0, 1);
|
| 211 |
+
if (llama_decode(ctx, b) != 0) die("warmup decode failed");
|
| 212 |
+
llama_synchronize(ctx);
|
| 213 |
+
llama_memory_clear(mem, true);
|
| 214 |
+
}
|
| 215 |
+
const double load_ms = ms_since(t_start);
|
| 216 |
+
fprintf(stderr, "nnopt_runner: loaded in %.1f ms (n_ctx %d, n_vocab %d)\n", load_ms, n_ctx, n_vocab);
|
| 217 |
+
|
| 218 |
+
std::string runs_json;
|
| 219 |
+
std::string out_json;
|
| 220 |
+
|
| 221 |
+
if (score) {
|
| 222 |
+
const int L = (int) score_tokens.size();
|
| 223 |
+
clk::time_point t0 = clk::now();
|
| 224 |
+
llama_memory_clear(mem, true);
|
| 225 |
+
llama_batch batch = llama_batch_init(n_batch, 0, 1);
|
| 226 |
+
std::vector<std::vector<int>> top_ids(L);
|
| 227 |
+
std::vector<std::vector<float>> top_logits(L);
|
| 228 |
+
std::vector<int> idx(n_vocab);
|
| 229 |
+
for (int s = 0; s < L; s += n_batch) {
|
| 230 |
+
const int n = std::min(n_batch, L - s);
|
| 231 |
+
batch.n_tokens = n;
|
| 232 |
+
for (int j = 0; j < n; j++) {
|
| 233 |
+
batch.token[j] = score_tokens[s + j];
|
| 234 |
+
batch.pos[j] = s + j;
|
| 235 |
+
batch.n_seq_id[j] = 1;
|
| 236 |
+
batch.seq_id[j][0] = 0;
|
| 237 |
+
batch.logits[j] = 1;
|
| 238 |
+
}
|
| 239 |
+
if (llama_decode(ctx, batch) != 0) die("decode failed (score)");
|
| 240 |
+
for (int j = 0; j < n; j++) {
|
| 241 |
+
const float * lg = llama_get_logits_ith(ctx, j);
|
| 242 |
+
const int k = std::min(top_k, n_vocab);
|
| 243 |
+
for (int v = 0; v < n_vocab; v++) idx[v] = v;
|
| 244 |
+
std::partial_sort(idx.begin(), idx.begin() + k, idx.end(), [&](int a, int b) {
|
| 245 |
+
return lg[a] > lg[b] || (lg[a] == lg[b] && a < b);
|
| 246 |
+
});
|
| 247 |
+
for (int q = 0; q < k; q++) {
|
| 248 |
+
top_ids[s + j].push_back(idx[q]);
|
| 249 |
+
top_logits[s + j].push_back(lg[idx[q]]);
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
llama_batch_free(batch);
|
| 254 |
+
const double total = ms_since(t0);
|
| 255 |
+
std::string ids = "[", lgs = "[";
|
| 256 |
+
for (int i = 0; i < L; i++) {
|
| 257 |
+
if (i) { ids += ", "; lgs += ", "; }
|
| 258 |
+
ids += json_arr(top_ids[i], "%d");
|
| 259 |
+
lgs += json_arr(top_logits[i], "%.9g");
|
| 260 |
+
}
|
| 261 |
+
out_json = "{\"top_ids\": " + ids + "], \"top_logits\": " + lgs + "]}\n";
|
| 262 |
+
char b[128]; snprintf(b, sizeof b, "{\"total_ms\": %.3f}", total);
|
| 263 |
+
runs_json = b;
|
| 264 |
+
} else {
|
| 265 |
+
const int P = (int) prompt.size();
|
| 266 |
+
llama_batch batch = llama_batch_init(std::max(n_batch, 1), 0, 1);
|
| 267 |
+
std::vector<llama_token> gen;
|
| 268 |
+
for (int r = 0; r < repeat; r++) {
|
| 269 |
+
gen.clear();
|
| 270 |
+
std::vector<double> token_ms;
|
| 271 |
+
clk::time_point t0 = clk::now();
|
| 272 |
+
llama_memory_clear(mem, true);
|
| 273 |
+
// prefill: logits only for the last prompt token
|
| 274 |
+
for (int s = 0; s < P; s += n_batch) {
|
| 275 |
+
const int n = std::min(n_batch, P - s);
|
| 276 |
+
batch.n_tokens = n;
|
| 277 |
+
for (int j = 0; j < n; j++) {
|
| 278 |
+
batch.token[j] = prompt[s + j];
|
| 279 |
+
batch.pos[j] = s + j;
|
| 280 |
+
batch.n_seq_id[j] = 1;
|
| 281 |
+
batch.seq_id[j][0] = 0;
|
| 282 |
+
batch.logits[j] = (s + j == P - 1);
|
| 283 |
+
}
|
| 284 |
+
if (llama_decode(ctx, batch) != 0) die("decode failed (prefill)");
|
| 285 |
+
}
|
| 286 |
+
llama_token tok = argmax(llama_get_logits_ith(ctx, -1), n_vocab);
|
| 287 |
+
const double ttft = ms_since(t0);
|
| 288 |
+
token_ms.push_back(ttft);
|
| 289 |
+
gen.push_back(tok);
|
| 290 |
+
clk::time_point tp = clk::now();
|
| 291 |
+
while ((int) gen.size() < max_new && (ignore_eos || !llama_vocab_is_eog(vocab, tok))) {
|
| 292 |
+
batch.n_tokens = 1;
|
| 293 |
+
batch.token[0] = tok;
|
| 294 |
+
batch.pos[0] = P + (int) gen.size() - 1;
|
| 295 |
+
batch.n_seq_id[0] = 1;
|
| 296 |
+
batch.seq_id[0][0] = 0;
|
| 297 |
+
batch.logits[0] = 1;
|
| 298 |
+
if (llama_decode(ctx, batch) != 0) die("decode failed (generate)");
|
| 299 |
+
tok = argmax(llama_get_logits_ith(ctx, -1), n_vocab);
|
| 300 |
+
gen.push_back(tok);
|
| 301 |
+
token_ms.push_back(ms_since(tp));
|
| 302 |
+
tp = clk::now();
|
| 303 |
+
}
|
| 304 |
+
const double total = ms_since(t0);
|
| 305 |
+
char b[256];
|
| 306 |
+
snprintf(b, sizeof b, "{\"total_ms\": %.3f, \"ttft_ms\": %.3f, \"prompt_tokens\": %d, \"new_tokens\": %d, \"token_ms\": ",
|
| 307 |
+
total, ttft, P, (int) gen.size());
|
| 308 |
+
if (r) runs_json += ", ";
|
| 309 |
+
runs_json += std::string(b) + json_arr(token_ms, "%.3f") + "}";
|
| 310 |
+
fprintf(stderr, "nnopt_runner: run %d: ttft %.1f ms, %d tokens in %.1f ms\n", r, ttft, (int) gen.size(), total);
|
| 311 |
+
}
|
| 312 |
+
llama_batch_free(batch);
|
| 313 |
+
|
| 314 |
+
std::string text;
|
| 315 |
+
{
|
| 316 |
+
int n = llama_detokenize(vocab, gen.data(), (int32_t) gen.size(), nullptr, 0, false, true);
|
| 317 |
+
text.resize(n < 0 ? -n : n);
|
| 318 |
+
n = llama_detokenize(vocab, gen.data(), (int32_t) gen.size(), &text[0], (int32_t) text.size(), false, true);
|
| 319 |
+
if (n < 0) die("detokenize failed");
|
| 320 |
+
text.resize(n);
|
| 321 |
+
}
|
| 322 |
+
out_json = "{\"prompt_tokens\": " + json_arr(prompt, "%d") + ", \"tokens\": " + json_arr(gen, "%d") +
|
| 323 |
+
", \"text\": " + json_str(sanitize_utf8(text)) + "}\n";
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
write_file(out_path, out_json);
|
| 327 |
+
char b[128];
|
| 328 |
+
snprintf(b, sizeof b, "{\"load_ms\": %.3f, \"peak_mem_mb\": %.1f, \"runs\": [", load_ms, peak_mem_mb());
|
| 329 |
+
write_file(metrics_path, std::string(b) + runs_json + "]}\n");
|
| 330 |
+
|
| 331 |
+
llama_free(ctx);
|
| 332 |
+
llama_model_free(model);
|
| 333 |
+
llama_backend_free();
|
| 334 |
+
return 0;
|
| 335 |
+
}
|