zenthrix 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zenthrix-0.1.0/.github/workflows/ci.yml +25 -0
- zenthrix-0.1.0/.github/workflows/release.yml +40 -0
- zenthrix-0.1.0/.gitignore +10 -0
- zenthrix-0.1.0/CONTRIBUTING.md +23 -0
- zenthrix-0.1.0/LICENSE +201 -0
- zenthrix-0.1.0/PKG-INFO +368 -0
- zenthrix-0.1.0/README.md +154 -0
- zenthrix-0.1.0/pyproject.toml +43 -0
- zenthrix-0.1.0/python/zenthrix/__init__.py +16 -0
- zenthrix-0.1.0/python/zenthrix/adapters/__init__.py +8 -0
- zenthrix-0.1.0/python/zenthrix/adapters/gguf_loader.py +14 -0
- zenthrix-0.1.0/python/zenthrix/adapters/onnx_loader.py +13 -0
- zenthrix-0.1.0/python/zenthrix/adapters/pytorch_loader.py +11 -0
- zenthrix-0.1.0/python/zenthrix/cli.py +80 -0
- zenthrix-0.1.0/python/zenthrix/config.py +12 -0
- zenthrix-0.1.0/python/zenthrix/engine.py +48 -0
- zenthrix-0.1.0/python/zenthrix/exceptions.py +14 -0
- zenthrix-0.1.0/python/zenthrix/validation.py +29 -0
- zenthrix-0.1.0/tests/test_cli.py +49 -0
- zenthrix-0.1.0/tests/test_engine.py +18 -0
- zenthrix-0.1.0/tests/test_validation.py +19 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: python -m pip install --upgrade pip
|
|
20
|
+
- run: python -m pip install pytest ruff mypy build
|
|
21
|
+
- run: python -m ruff check .
|
|
22
|
+
- run: python -m mypy python
|
|
23
|
+
- run: python -m pytest
|
|
24
|
+
- run: python -m build
|
|
25
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
- run: python -m pip install --upgrade pip build
|
|
21
|
+
- run: python -m build
|
|
22
|
+
- uses: softprops/action-gh-release@v2
|
|
23
|
+
with:
|
|
24
|
+
generate_release_notes: true
|
|
25
|
+
files: dist/*
|
|
26
|
+
|
|
27
|
+
publish-pypi:
|
|
28
|
+
needs: release
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
environment: pypi
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- run: python -m pip install --upgrade pip build
|
|
37
|
+
- run: python -m build
|
|
38
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
39
|
+
with:
|
|
40
|
+
print-hash: true
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Local setup
|
|
4
|
+
|
|
5
|
+
Use Python 3.10 or newer and install the development tools:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m venv .venv
|
|
9
|
+
python -m pip install --upgrade pip
|
|
10
|
+
python -m pip install pytest ruff mypy build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run the checks before opening a pull request:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m ruff check .
|
|
17
|
+
python -m mypy python
|
|
18
|
+
python -m pytest
|
|
19
|
+
python -m build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The public package validates model inputs and exposes the CLI/API boundary.
|
|
23
|
+
Compilation and inference require the separately distributed native engine.
|
zenthrix-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
zenthrix-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zenthrix
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Hardware-adaptive edge neural graph compiler frontend
|
|
5
|
+
Author: WithBrian Technologies
|
|
6
|
+
License: Apache License
|
|
7
|
+
Version 2.0, January 2004
|
|
8
|
+
http://www.apache.org/licenses/
|
|
9
|
+
|
|
10
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
11
|
+
|
|
12
|
+
1. Definitions.
|
|
13
|
+
|
|
14
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
15
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
16
|
+
|
|
17
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
18
|
+
the copyright owner that is granting the License.
|
|
19
|
+
|
|
20
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
21
|
+
other entities that control, are controlled by, or are under common
|
|
22
|
+
control with that entity. For the purposes of this definition,
|
|
23
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
24
|
+
direction or management of such entity, whether by contract or
|
|
25
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
26
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
27
|
+
|
|
28
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
29
|
+
exercising permissions granted by this License.
|
|
30
|
+
|
|
31
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
32
|
+
including but not limited to software source code, documentation
|
|
33
|
+
source, and configuration files.
|
|
34
|
+
|
|
35
|
+
"Object" form shall mean any form resulting from mechanical
|
|
36
|
+
transformation or translation of a Source form, including but
|
|
37
|
+
not limited to compiled object code, generated documentation,
|
|
38
|
+
and conversions to other media types.
|
|
39
|
+
|
|
40
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
41
|
+
Object form, made available under the License, as indicated by a
|
|
42
|
+
copyright notice that is included in or attached to the work
|
|
43
|
+
(an example is provided in the Appendix below).
|
|
44
|
+
|
|
45
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
46
|
+
form, that is based on (or derived from) the Work and for which the
|
|
47
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
48
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
49
|
+
of this License, Derivative Works shall not include works that remain
|
|
50
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
51
|
+
the Work and Derivative Works thereof.
|
|
52
|
+
|
|
53
|
+
"Contribution" shall mean any work of authorship, including
|
|
54
|
+
the original version of the Work and any modifications or additions
|
|
55
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
56
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
57
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
58
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
59
|
+
means any form of electronic, verbal, or written communication sent
|
|
60
|
+
to the Licensor or its representatives, including but not limited to
|
|
61
|
+
communication on electronic mailing lists, source code control systems,
|
|
62
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
63
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
64
|
+
excluding communication that is conspicuously marked or otherwise
|
|
65
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
66
|
+
|
|
67
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
68
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
69
|
+
subsequently incorporated within the Work.
|
|
70
|
+
|
|
71
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
75
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
76
|
+
Work and such Derivative Works in Source or Object form.
|
|
77
|
+
|
|
78
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
79
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
80
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
81
|
+
(except as stated in this section) patent license to make, have made,
|
|
82
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
83
|
+
where such license applies only to those patent claims licensable
|
|
84
|
+
by such Contributor that are necessarily infringed by their
|
|
85
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
86
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
87
|
+
institute patent litigation against any entity (including a
|
|
88
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
89
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
90
|
+
or contributory patent infringement, then any patent licenses
|
|
91
|
+
granted to You under this License for that Work shall terminate
|
|
92
|
+
as of the date such litigation is filed.
|
|
93
|
+
|
|
94
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
95
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
96
|
+
modifications, and in Source or Object form, provided that You
|
|
97
|
+
meet the following conditions:
|
|
98
|
+
|
|
99
|
+
(a) You must give any other recipients of the Work or
|
|
100
|
+
Derivative Works a copy of this License; and
|
|
101
|
+
|
|
102
|
+
(b) You must cause any modified files to carry prominent notices
|
|
103
|
+
stating that You changed the files; and
|
|
104
|
+
|
|
105
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
106
|
+
that You distribute, all copyright, patent, trademark, and
|
|
107
|
+
attribution notices from the Source form of the Work,
|
|
108
|
+
excluding those notices that do not pertain to any part of
|
|
109
|
+
the Derivative Works; and
|
|
110
|
+
|
|
111
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
112
|
+
distribution, then any Derivative Works that You distribute must
|
|
113
|
+
include a readable copy of the attribution notices contained
|
|
114
|
+
within such NOTICE file, excluding those notices that do not
|
|
115
|
+
pertain to any part of the Derivative Works, in at least one
|
|
116
|
+
of the following places: within a NOTICE text file distributed
|
|
117
|
+
as part of the Derivative Works; within the Source form or
|
|
118
|
+
documentation, if provided along with the Derivative Works; or,
|
|
119
|
+
within a display generated by the Derivative Works, if and
|
|
120
|
+
wherever such third-party notices normally appear. The contents
|
|
121
|
+
of the NOTICE file are for informational purposes only and
|
|
122
|
+
do not modify the License. You may add Your own attribution
|
|
123
|
+
notices within Derivative Works that You distribute, alongside
|
|
124
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
125
|
+
that such additional attribution notices cannot be construed
|
|
126
|
+
as modifying the License.
|
|
127
|
+
|
|
128
|
+
You may add Your own copyright statement to Your modifications and
|
|
129
|
+
may provide additional or different license terms and conditions
|
|
130
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
131
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
132
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
133
|
+
the conditions stated in this License.
|
|
134
|
+
|
|
135
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
136
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
137
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
138
|
+
this License, without any additional terms or conditions.
|
|
139
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
140
|
+
the terms of any separate license agreement you may have executed
|
|
141
|
+
with Licensor regarding such Contributions.
|
|
142
|
+
|
|
143
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
144
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
145
|
+
except as required for reasonable and customary use in describing the
|
|
146
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
147
|
+
|
|
148
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
149
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
150
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
152
|
+
implied, including, without limitation, any warranties or conditions
|
|
153
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
154
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
155
|
+
appropriateness of using or redistributing the Work and assume any
|
|
156
|
+
risks associated with Your exercise of permissions under this License.
|
|
157
|
+
|
|
158
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
159
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
160
|
+
unless required by applicable law (such as deliberate and grossly
|
|
161
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
162
|
+
liable to You for damages, including any direct, indirect, special,
|
|
163
|
+
incidental, or consequential damages of any character arising as a
|
|
164
|
+
result of this License or out of the use or inability to use the
|
|
165
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
166
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
167
|
+
other commercial damages or losses), even if such Contributor
|
|
168
|
+
has been advised of the possibility of such damages.
|
|
169
|
+
|
|
170
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
171
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
172
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
173
|
+
or other liability obligations and/or rights consistent with this
|
|
174
|
+
License. However, in accepting such obligations, You may act only
|
|
175
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
176
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
177
|
+
defend, and hold each Contributor harmless for any liability
|
|
178
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
179
|
+
of your accepting any such warranty or additional liability.
|
|
180
|
+
|
|
181
|
+
END OF TERMS AND CONDITIONS
|
|
182
|
+
|
|
183
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
184
|
+
|
|
185
|
+
To apply the Apache License to your work, attach the following
|
|
186
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
187
|
+
replaced with your own identifying information. (Don't include
|
|
188
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
189
|
+
comment syntax for the file format. We also recommend that a
|
|
190
|
+
file or class name and description of purpose be included on the
|
|
191
|
+
same "printed page" as the copyright notice for easier
|
|
192
|
+
identification within third-party archives.
|
|
193
|
+
|
|
194
|
+
Copyright [yyyy] [name of copyright owner]
|
|
195
|
+
|
|
196
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
+
you may not use this file except in compliance with the License.
|
|
198
|
+
You may obtain a copy of the License at
|
|
199
|
+
|
|
200
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
+
|
|
202
|
+
Unless required by applicable law or agreed to in writing, software
|
|
203
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
+
See the License for the specific language governing permissions and
|
|
206
|
+
limitations under the License.
|
|
207
|
+
License-File: LICENSE
|
|
208
|
+
Classifier: Development Status :: 3 - Alpha
|
|
209
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
210
|
+
Classifier: Programming Language :: Python :: 3
|
|
211
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
212
|
+
Requires-Python: >=3.10
|
|
213
|
+
Description-Content-Type: text/markdown
|
|
214
|
+
|
|
215
|
+
# Zenthrix
|
|
216
|
+
|
|
217
|
+
**Hardware-Adaptive Edge Neural Graph Compiler**
|
|
218
|
+
|
|
219
|
+
[](https://pypi.org/project/zenthrix/)
|
|
220
|
+
[](LICENSE)
|
|
221
|
+
[](.github/workflows/ci.yml)
|
|
222
|
+
|
|
223
|
+
Zenthrix is an edge-native model compiler frontend for compiling open-weight neural networks (LLMs, SLMs, and vision models) into zero-copy, memory-optimized binaries tailored for consumer edge silicon — Apple Silicon, Qualcomm Snapdragon NPU, and Arm Cortex/Ethos.
|
|
224
|
+
|
|
225
|
+
This repository is the public developer entry point: the PyPI package, CLI, and model-ingestion layer. The proprietary compilation engine itself lives in a separate private repository and is distributed as a precompiled binary. The v0.1.0 frontend validates inputs and exposes the integration boundary; compilation and inference require that separately provisioned engine.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Table of Contents
|
|
230
|
+
|
|
231
|
+
- [Key Features](#key-features)
|
|
232
|
+
- [Installation](#installation)
|
|
233
|
+
- [Quickstart](#quickstart)
|
|
234
|
+
- [Supported Target Architectures](#supported-target-architectures)
|
|
235
|
+
- [Repository Layout](#repository-layout)
|
|
236
|
+
- [Contributing](#contributing)
|
|
237
|
+
- [License](#license)
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Key Features
|
|
242
|
+
|
|
243
|
+
- **Direct Ingestion** — Native loaders for ONNX, PyTorch Export (AOTInductor), and GGUF architectures, with no intermediate format conversion required.
|
|
244
|
+
- **Unified Memory Tiling** — Schedules compute passes against unified memory architectures, reducing peak active RAM allocation by up to 40%.
|
|
245
|
+
- **Zero-Copy Runtime** — Emits standalone, relocatable `.zx` binaries that execute locally without a heavy Python runtime dependency.
|
|
246
|
+
- **Privacy-First Compilation** — Models compile entirely on-device; weights and computational graphs never leave the local environment.
|
|
247
|
+
|
|
248
|
+
## Installation
|
|
249
|
+
|
|
250
|
+
Install the precompiled command-line client and runtime via pip:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
pip install zenthrix
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### System Requirements
|
|
257
|
+
|
|
258
|
+
| Platform | Minimum Version |
|
|
259
|
+
|---|---|
|
|
260
|
+
| macOS | 14.0+ (Apple Silicon M1/M2/M3/M4) |
|
|
261
|
+
| Linux | Ubuntu 22.04+ (aarch64 / x86_64) |
|
|
262
|
+
| Android | NDK r25+ (for targeting Snapdragon platforms) |
|
|
263
|
+
|
|
264
|
+
## Quickstart
|
|
265
|
+
|
|
266
|
+
### 1. Compile a Model
|
|
267
|
+
|
|
268
|
+
Compilation requires the separately distributed native engine. Without it, the
|
|
269
|
+
CLI reports an actionable error rather than producing an invalid `.zx` file.
|
|
270
|
+
|
|
271
|
+
Compile an ONNX or GGUF model targeting local hardware execution:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
zenthrix compile \
|
|
275
|
+
--model meta-llama/Llama-3.2-1B-Instruct \
|
|
276
|
+
--format onnx \
|
|
277
|
+
--target auto \
|
|
278
|
+
--quantization int4 \
|
|
279
|
+
--output ./llama-3.2-1b.zx
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 2. Inspect Graph Optimizations
|
|
283
|
+
|
|
284
|
+
Analyze operator fusions and projected memory footprints prior to compilation:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
zenthrix inspect ./llama-3.2-1b.zx --memory-profile
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 3. Run Inference via CLI
|
|
291
|
+
|
|
292
|
+
Verify compiled throughput directly in your terminal:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
zenthrix run \
|
|
296
|
+
--model ./llama-3.2-1b.zx \
|
|
297
|
+
--prompt "Explain quantum decoherence in two sentences." \
|
|
298
|
+
--max-tokens 128
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### 4. Python API Usage
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
import zenthrix
|
|
305
|
+
|
|
306
|
+
# Load and initialize the compiled runtime
|
|
307
|
+
engine = zenthrix.Engine(model_path="./llama-3.2-1b.zx")
|
|
308
|
+
|
|
309
|
+
# Execute a deterministic inference pass
|
|
310
|
+
output = engine.generate(
|
|
311
|
+
prompt="Synthesize the primary risks of high inference latency.",
|
|
312
|
+
temperature=0.2,
|
|
313
|
+
max_tokens=256,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
print(output.text)
|
|
317
|
+
print(f"Time to First Token (TTFT): {output.ttft_ms} ms")
|
|
318
|
+
print(f"Throughput: {output.tokens_per_second} tokens/sec")
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Supported Target Architectures
|
|
322
|
+
|
|
323
|
+
| Silicon Target | Optimization Backend | Compute Units |
|
|
324
|
+
|---|---|---|
|
|
325
|
+
| Apple Silicon (M-Series / A-Series) | Metal MSL & AMX Matrix Intrinsics | GPU / Neural Engine |
|
|
326
|
+
| Qualcomm Snapdragon (8 Gen 2/3/4) | Hexagon HTP Architecture (C++) | NPU / HVX |
|
|
327
|
+
| Arm Neoverse / Cortex | Arm NEON / SVE2 Assembly | CPU Vector Extensions |
|
|
328
|
+
|
|
329
|
+
## Repository Layout
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
zenthrix/
|
|
333
|
+
├── .github/
|
|
334
|
+
│ ├── workflows/
|
|
335
|
+
│ │ ├── ci.yml
|
|
336
|
+
│ └── release.yml
|
|
337
|
+
├── python/
|
|
338
|
+
│ └── zenthrix/
|
|
339
|
+
│ ├── __init__.py
|
|
340
|
+
│ ├── cli.py
|
|
341
|
+
│ ├── config.py
|
|
342
|
+
│ ├── engine.py
|
|
343
|
+
│ ├── exceptions.py
|
|
344
|
+
│ ├── validation.py
|
|
345
|
+
│ ├── adapters/
|
|
346
|
+
│ │ ├── __init__.py
|
|
347
|
+
│ │ ├── gguf_loader.py
|
|
348
|
+
│ │ ├── onnx_loader.py
|
|
349
|
+
│ │ └── pytorch_loader.py
|
|
350
|
+
├── tests/
|
|
351
|
+
│ ├── test_cli.py
|
|
352
|
+
│ ├── test_engine.py
|
|
353
|
+
│ └── test_validation.py
|
|
354
|
+
├── .gitignore
|
|
355
|
+
├── CONTRIBUTING.md
|
|
356
|
+
├── LICENSE
|
|
357
|
+
└── pyproject.toml
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## Contributing
|
|
361
|
+
|
|
362
|
+
We welcome community contributions to adapters, loaders, and frontend parsers. All contributions require signing our Contributor License Agreement (CLA) during the pull request process.
|
|
363
|
+
|
|
364
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup instructions.
|
|
365
|
+
|
|
366
|
+
## License
|
|
367
|
+
|
|
368
|
+
The Zenthrix CLI and client adapters are distributed under the [Apache License 2.0](LICENSE). The underlying compilation engine dynamic binary is subject to the WithBrian Technologies Commercial EULA embedded in binary distributions.
|
zenthrix-0.1.0/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Zenthrix
|
|
2
|
+
|
|
3
|
+
**Hardware-Adaptive Edge Neural Graph Compiler**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/zenthrix/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](.github/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
Zenthrix is an edge-native model compiler frontend for compiling open-weight neural networks (LLMs, SLMs, and vision models) into zero-copy, memory-optimized binaries tailored for consumer edge silicon — Apple Silicon, Qualcomm Snapdragon NPU, and Arm Cortex/Ethos.
|
|
10
|
+
|
|
11
|
+
This repository is the public developer entry point: the PyPI package, CLI, and model-ingestion layer. The proprietary compilation engine itself lives in a separate private repository and is distributed as a precompiled binary. The v0.1.0 frontend validates inputs and exposes the integration boundary; compilation and inference require that separately provisioned engine.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [Key Features](#key-features)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Quickstart](#quickstart)
|
|
20
|
+
- [Supported Target Architectures](#supported-target-architectures)
|
|
21
|
+
- [Repository Layout](#repository-layout)
|
|
22
|
+
- [Contributing](#contributing)
|
|
23
|
+
- [License](#license)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Key Features
|
|
28
|
+
|
|
29
|
+
- **Direct Ingestion** — Native loaders for ONNX, PyTorch Export (AOTInductor), and GGUF architectures, with no intermediate format conversion required.
|
|
30
|
+
- **Unified Memory Tiling** — Schedules compute passes against unified memory architectures, reducing peak active RAM allocation by up to 40%.
|
|
31
|
+
- **Zero-Copy Runtime** — Emits standalone, relocatable `.zx` binaries that execute locally without a heavy Python runtime dependency.
|
|
32
|
+
- **Privacy-First Compilation** — Models compile entirely on-device; weights and computational graphs never leave the local environment.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install the precompiled command-line client and runtime via pip:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install zenthrix
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### System Requirements
|
|
43
|
+
|
|
44
|
+
| Platform | Minimum Version |
|
|
45
|
+
|---|---|
|
|
46
|
+
| macOS | 14.0+ (Apple Silicon M1/M2/M3/M4) |
|
|
47
|
+
| Linux | Ubuntu 22.04+ (aarch64 / x86_64) |
|
|
48
|
+
| Android | NDK r25+ (for targeting Snapdragon platforms) |
|
|
49
|
+
|
|
50
|
+
## Quickstart
|
|
51
|
+
|
|
52
|
+
### 1. Compile a Model
|
|
53
|
+
|
|
54
|
+
Compilation requires the separately distributed native engine. Without it, the
|
|
55
|
+
CLI reports an actionable error rather than producing an invalid `.zx` file.
|
|
56
|
+
|
|
57
|
+
Compile an ONNX or GGUF model targeting local hardware execution:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
zenthrix compile \
|
|
61
|
+
--model meta-llama/Llama-3.2-1B-Instruct \
|
|
62
|
+
--format onnx \
|
|
63
|
+
--target auto \
|
|
64
|
+
--quantization int4 \
|
|
65
|
+
--output ./llama-3.2-1b.zx
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Inspect Graph Optimizations
|
|
69
|
+
|
|
70
|
+
Analyze operator fusions and projected memory footprints prior to compilation:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
zenthrix inspect ./llama-3.2-1b.zx --memory-profile
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Run Inference via CLI
|
|
77
|
+
|
|
78
|
+
Verify compiled throughput directly in your terminal:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
zenthrix run \
|
|
82
|
+
--model ./llama-3.2-1b.zx \
|
|
83
|
+
--prompt "Explain quantum decoherence in two sentences." \
|
|
84
|
+
--max-tokens 128
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 4. Python API Usage
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
import zenthrix
|
|
91
|
+
|
|
92
|
+
# Load and initialize the compiled runtime
|
|
93
|
+
engine = zenthrix.Engine(model_path="./llama-3.2-1b.zx")
|
|
94
|
+
|
|
95
|
+
# Execute a deterministic inference pass
|
|
96
|
+
output = engine.generate(
|
|
97
|
+
prompt="Synthesize the primary risks of high inference latency.",
|
|
98
|
+
temperature=0.2,
|
|
99
|
+
max_tokens=256,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
print(output.text)
|
|
103
|
+
print(f"Time to First Token (TTFT): {output.ttft_ms} ms")
|
|
104
|
+
print(f"Throughput: {output.tokens_per_second} tokens/sec")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Supported Target Architectures
|
|
108
|
+
|
|
109
|
+
| Silicon Target | Optimization Backend | Compute Units |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| Apple Silicon (M-Series / A-Series) | Metal MSL & AMX Matrix Intrinsics | GPU / Neural Engine |
|
|
112
|
+
| Qualcomm Snapdragon (8 Gen 2/3/4) | Hexagon HTP Architecture (C++) | NPU / HVX |
|
|
113
|
+
| Arm Neoverse / Cortex | Arm NEON / SVE2 Assembly | CPU Vector Extensions |
|
|
114
|
+
|
|
115
|
+
## Repository Layout
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
zenthrix/
|
|
119
|
+
├── .github/
|
|
120
|
+
│ ├── workflows/
|
|
121
|
+
│ │ ├── ci.yml
|
|
122
|
+
│ └── release.yml
|
|
123
|
+
├── python/
|
|
124
|
+
│ └── zenthrix/
|
|
125
|
+
│ ├── __init__.py
|
|
126
|
+
│ ├── cli.py
|
|
127
|
+
│ ├── config.py
|
|
128
|
+
│ ├── engine.py
|
|
129
|
+
│ ├── exceptions.py
|
|
130
|
+
│ ├── validation.py
|
|
131
|
+
│ ├── adapters/
|
|
132
|
+
│ │ ├── __init__.py
|
|
133
|
+
│ │ ├── gguf_loader.py
|
|
134
|
+
│ │ ├── onnx_loader.py
|
|
135
|
+
│ │ └── pytorch_loader.py
|
|
136
|
+
├── tests/
|
|
137
|
+
│ ├── test_cli.py
|
|
138
|
+
│ ├── test_engine.py
|
|
139
|
+
│ └── test_validation.py
|
|
140
|
+
├── .gitignore
|
|
141
|
+
├── CONTRIBUTING.md
|
|
142
|
+
├── LICENSE
|
|
143
|
+
└── pyproject.toml
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Contributing
|
|
147
|
+
|
|
148
|
+
We welcome community contributions to adapters, loaders, and frontend parsers. All contributions require signing our Contributor License Agreement (CLA) during the pull request process.
|
|
149
|
+
|
|
150
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup instructions.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
The Zenthrix CLI and client adapters are distributed under the [Apache License 2.0](LICENSE). The underlying compilation engine dynamic binary is subject to the WithBrian Technologies Commercial EULA embedded in binary distributions.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zenthrix"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Hardware-adaptive edge neural graph compiler frontend"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "WithBrian Technologies" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"License :: OSI Approved :: Apache Software License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
]
|
|
19
|
+
dependencies = []
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
zenthrix = "zenthrix.cli:main"
|
|
23
|
+
|
|
24
|
+
[tool.hatch.build.targets.wheel]
|
|
25
|
+
packages = ["python/zenthrix"]
|
|
26
|
+
|
|
27
|
+
[tool.pytest.ini_options]
|
|
28
|
+
testpaths = ["tests"]
|
|
29
|
+
pythonpath = ["python"]
|
|
30
|
+
addopts = "-ra"
|
|
31
|
+
|
|
32
|
+
[tool.ruff]
|
|
33
|
+
line-length = 88
|
|
34
|
+
target-version = "py310"
|
|
35
|
+
|
|
36
|
+
[tool.ruff.lint]
|
|
37
|
+
select = ["E", "F", "I", "UP"]
|
|
38
|
+
|
|
39
|
+
[tool.mypy]
|
|
40
|
+
python_version = "3.10"
|
|
41
|
+
strict = true
|
|
42
|
+
mypy_path = "python"
|
|
43
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Public Python API for the Zenthrix compiler frontend."""
|
|
2
|
+
|
|
3
|
+
from .engine import Engine, InferenceResult
|
|
4
|
+
from .exceptions import EngineUnavailableError, InputValidationError, ZenthrixError
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.0"
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"Engine",
|
|
10
|
+
"EngineUnavailableError",
|
|
11
|
+
"InferenceResult",
|
|
12
|
+
"InputValidationError",
|
|
13
|
+
"ZenthrixError",
|
|
14
|
+
"__version__",
|
|
15
|
+
]
|
|
16
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""GGUF input validation."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from ..validation import validate_model_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def validate_gguf(path: str | Path) -> Path:
|
|
9
|
+
"""Validate a GGUF model path."""
|
|
10
|
+
model_path = validate_model_path(path)
|
|
11
|
+
if model_path.suffix.lower() != ".gguf":
|
|
12
|
+
raise ValueError(f"Expected a .gguf file, got: {model_path}")
|
|
13
|
+
return model_path
|
|
14
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""ONNX input validation."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from ..validation import validate_model_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def validate_onnx(path: str | Path) -> Path:
|
|
9
|
+
"""Validate an ONNX model path without importing optional ONNX tooling."""
|
|
10
|
+
model_path = validate_model_path(path)
|
|
11
|
+
if model_path.suffix.lower() != ".onnx":
|
|
12
|
+
raise ValueError(f"Expected an .onnx file, got: {model_path}")
|
|
13
|
+
return model_path
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""PyTorch Export/AOTInductor input validation."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from ..validation import validate_model_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def validate_pytorch_export(path: str | Path) -> Path:
|
|
9
|
+
"""Validate a PyTorch export artifact path."""
|
|
10
|
+
return validate_model_path(path)
|
|
11
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Command-line interface for the Zenthrix frontend."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from . import __version__
|
|
7
|
+
from .engine import Engine
|
|
8
|
+
from .exceptions import ZenthrixError
|
|
9
|
+
from .validation import validate_model_format, validate_model_path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
13
|
+
"""Build the command-line parser."""
|
|
14
|
+
parser = argparse.ArgumentParser(prog="zenthrix")
|
|
15
|
+
parser.add_argument("--version", action="version", version=__version__)
|
|
16
|
+
commands = parser.add_subparsers(dest="command", required=True)
|
|
17
|
+
|
|
18
|
+
compile_parser = commands.add_parser("compile", help="Compile a model")
|
|
19
|
+
compile_parser.add_argument("--model", required=True)
|
|
20
|
+
compile_parser.add_argument("--format", required=True, dest="model_format")
|
|
21
|
+
compile_parser.add_argument("--target", default="auto")
|
|
22
|
+
compile_parser.add_argument("--quantization")
|
|
23
|
+
compile_parser.add_argument("--output", required=True)
|
|
24
|
+
|
|
25
|
+
inspect_parser = commands.add_parser("inspect", help="Inspect a compiled model")
|
|
26
|
+
inspect_parser.add_argument("model")
|
|
27
|
+
inspect_parser.add_argument("--memory-profile", action="store_true")
|
|
28
|
+
|
|
29
|
+
run_parser = commands.add_parser("run", help="Run inference")
|
|
30
|
+
run_parser.add_argument("--model", required=True)
|
|
31
|
+
run_parser.add_argument("--prompt", required=True)
|
|
32
|
+
run_parser.add_argument("--max-tokens", type=int, default=128)
|
|
33
|
+
run_parser.add_argument("--temperature", type=float, default=0.2)
|
|
34
|
+
return parser
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _compile(args: argparse.Namespace) -> int:
|
|
38
|
+
validate_model_path(args.model)
|
|
39
|
+
validate_model_format(args.model_format)
|
|
40
|
+
raise ZenthrixError(
|
|
41
|
+
"The native compiler engine is not installed. "
|
|
42
|
+
"The public frontend cannot produce a .zx binary yet."
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _inspect(args: argparse.Namespace) -> int:
|
|
47
|
+
model_path = validate_model_path(args.model)
|
|
48
|
+
print(f"Model: {model_path}")
|
|
49
|
+
print("Memory profile: unavailable until the native engine is installed")
|
|
50
|
+
return 0
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _run(args: argparse.Namespace) -> int:
|
|
54
|
+
result = Engine(args.model).generate(
|
|
55
|
+
args.prompt,
|
|
56
|
+
temperature=args.temperature,
|
|
57
|
+
max_tokens=args.max_tokens,
|
|
58
|
+
)
|
|
59
|
+
print(result.text)
|
|
60
|
+
return 0
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main(argv: list[str] | None = None) -> int:
|
|
64
|
+
"""Run the CLI and return a process exit code."""
|
|
65
|
+
args = build_parser().parse_args(argv)
|
|
66
|
+
try:
|
|
67
|
+
if args.command == "compile":
|
|
68
|
+
return _compile(args)
|
|
69
|
+
if args.command == "inspect":
|
|
70
|
+
return _inspect(args)
|
|
71
|
+
if args.command == "run":
|
|
72
|
+
return _run(args)
|
|
73
|
+
except (ZenthrixError, ValueError) as error:
|
|
74
|
+
print(f"zenthrix: error: {error}", file=sys.stderr)
|
|
75
|
+
return 2
|
|
76
|
+
return 0
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Configuration types shared by the CLI and Python API."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True, slots=True)
|
|
7
|
+
class CompileConfig:
|
|
8
|
+
"""Options describing a compilation request."""
|
|
9
|
+
|
|
10
|
+
target: str = "auto"
|
|
11
|
+
quantization: str | None = None
|
|
12
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Public inference API and private-engine integration boundary."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .exceptions import EngineUnavailableError
|
|
7
|
+
from .validation import validate_model_path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class InferenceResult:
|
|
12
|
+
"""Result returned by a provisioned native runtime."""
|
|
13
|
+
|
|
14
|
+
text: str
|
|
15
|
+
ttft_ms: float
|
|
16
|
+
tokens_per_second: float
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Engine:
|
|
20
|
+
"""Handle a compiled model through the optional native engine.
|
|
21
|
+
|
|
22
|
+
The native engine is distributed separately from this public package. The
|
|
23
|
+
frontend validates the model path and reports a clear installation error
|
|
24
|
+
until that engine is provisioned.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, model_path: str | Path) -> None:
|
|
28
|
+
self.model_path = validate_model_path(model_path)
|
|
29
|
+
|
|
30
|
+
def generate(
|
|
31
|
+
self,
|
|
32
|
+
prompt: str,
|
|
33
|
+
*,
|
|
34
|
+
temperature: float = 0.2,
|
|
35
|
+
max_tokens: int = 256,
|
|
36
|
+
) -> InferenceResult:
|
|
37
|
+
"""Generate text using the optional native engine."""
|
|
38
|
+
if not prompt.strip():
|
|
39
|
+
raise ValueError("prompt must not be empty")
|
|
40
|
+
if temperature < 0:
|
|
41
|
+
raise ValueError("temperature must be non-negative")
|
|
42
|
+
if max_tokens < 1:
|
|
43
|
+
raise ValueError("max_tokens must be at least 1")
|
|
44
|
+
raise EngineUnavailableError(
|
|
45
|
+
"The Zenthrix native engine is not installed. "
|
|
46
|
+
"Install the platform runtime before calling Engine.generate()."
|
|
47
|
+
)
|
|
48
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Exceptions raised by the public Zenthrix frontend."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ZenthrixError(Exception):
|
|
5
|
+
"""Base class for expected Zenthrix errors."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InputValidationError(ZenthrixError, ValueError):
|
|
9
|
+
"""Raised when a user-provided path or option is invalid."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class EngineUnavailableError(ZenthrixError, RuntimeError):
|
|
13
|
+
"""Raised when the private native compilation engine is not installed."""
|
|
14
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Validation helpers for model inputs and compiler options."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from .exceptions import InputValidationError
|
|
6
|
+
|
|
7
|
+
SUPPORTED_FORMATS = frozenset({"onnx", "pytorch", "gguf"})
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def validate_model_path(path: str | Path) -> Path:
|
|
11
|
+
"""Return an existing regular model path or raise a useful error."""
|
|
12
|
+
model_path = Path(path)
|
|
13
|
+
if not model_path.exists():
|
|
14
|
+
raise InputValidationError(f"Model path does not exist: {model_path}")
|
|
15
|
+
if not model_path.is_file():
|
|
16
|
+
raise InputValidationError(f"Model path is not a file: {model_path}")
|
|
17
|
+
return model_path
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def validate_model_format(model_format: str) -> str:
|
|
21
|
+
"""Normalize and validate a supported model format."""
|
|
22
|
+
normalized = model_format.lower()
|
|
23
|
+
if normalized not in SUPPORTED_FORMATS:
|
|
24
|
+
supported = ", ".join(sorted(SUPPORTED_FORMATS))
|
|
25
|
+
raise InputValidationError(
|
|
26
|
+
f"Unsupported model format '{model_format}'. Expected one of: {supported}"
|
|
27
|
+
)
|
|
28
|
+
return normalized
|
|
29
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from zenthrix.cli import build_parser, main
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_parser_accepts_compile_options() -> None:
|
|
7
|
+
args = build_parser().parse_args(
|
|
8
|
+
[
|
|
9
|
+
"compile",
|
|
10
|
+
"--model",
|
|
11
|
+
"model.onnx",
|
|
12
|
+
"--format",
|
|
13
|
+
"onnx",
|
|
14
|
+
"--output",
|
|
15
|
+
"model.zx",
|
|
16
|
+
]
|
|
17
|
+
)
|
|
18
|
+
assert args.command == "compile"
|
|
19
|
+
assert args.model_format == "onnx"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_inspect_reports_existing_model(capsys, tmp_path: Path) -> None:
|
|
23
|
+
model = tmp_path / "model.zx"
|
|
24
|
+
model.write_bytes(b"placeholder")
|
|
25
|
+
|
|
26
|
+
assert main(["inspect", str(model), "--memory-profile"]) == 0
|
|
27
|
+
assert "Memory profile" in capsys.readouterr().out
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_compile_reports_missing_native_engine(tmp_path: Path, capsys) -> None:
|
|
31
|
+
model = tmp_path / "model.onnx"
|
|
32
|
+
model.write_bytes(b"placeholder")
|
|
33
|
+
|
|
34
|
+
assert (
|
|
35
|
+
main(
|
|
36
|
+
[
|
|
37
|
+
"compile",
|
|
38
|
+
"--model",
|
|
39
|
+
str(model),
|
|
40
|
+
"--format",
|
|
41
|
+
"onnx",
|
|
42
|
+
"--output",
|
|
43
|
+
str(tmp_path / "model.zx"),
|
|
44
|
+
]
|
|
45
|
+
)
|
|
46
|
+
== 2
|
|
47
|
+
)
|
|
48
|
+
assert "native compiler engine" in capsys.readouterr().err
|
|
49
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from zenthrix import Engine, EngineUnavailableError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_engine_validates_model_path(tmp_path: Path) -> None:
|
|
8
|
+
model = tmp_path / "model.zx"
|
|
9
|
+
model.write_bytes(b"placeholder")
|
|
10
|
+
assert Engine(model).model_path == model
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_engine_reports_missing_runtime(tmp_path: Path) -> None:
|
|
14
|
+
model = tmp_path / "model.zx"
|
|
15
|
+
model.write_bytes(b"placeholder")
|
|
16
|
+
|
|
17
|
+
with pytest.raises(EngineUnavailableError, match="native engine"):
|
|
18
|
+
Engine(model).generate("hello")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from zenthrix.exceptions import InputValidationError
|
|
5
|
+
from zenthrix.validation import validate_model_format, validate_model_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_validate_model_format_normalizes_case() -> None:
|
|
9
|
+
assert validate_model_format("ONNX") == "onnx"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_validate_model_format_rejects_unknown_format() -> None:
|
|
13
|
+
with pytest.raises(InputValidationError, match="Unsupported model format"):
|
|
14
|
+
validate_model_format("safetensors")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_validate_model_path_rejects_directory(tmp_path: Path) -> None:
|
|
18
|
+
with pytest.raises(InputValidationError, match="not a file"):
|
|
19
|
+
validate_model_path(tmp_path)
|