fxbex 0.2.1__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.
- fxbex-0.2.1/LICENSE +201 -0
- fxbex-0.2.1/MANIFEST.in +9 -0
- fxbex-0.2.1/PKG-INFO +166 -0
- fxbex-0.2.1/README.md +146 -0
- fxbex-0.2.1/fxbex/__init__.py +5 -0
- fxbex-0.2.1/fxbex/__main__.py +2 -0
- fxbex-0.2.1/fxbex/cli.py +124 -0
- fxbex-0.2.1/fxbex/llm.py +52 -0
- fxbex-0.2.1/fxbex/package.py +258 -0
- fxbex-0.2.1/fxbex/replay.py +209 -0
- fxbex-0.2.1/fxbex/runtime.py +156 -0
- fxbex-0.2.1/fxbex/server.py +33 -0
- fxbex-0.2.1/fxbex/service.py +95 -0
- fxbex-0.2.1/fxbex/settings.py +27 -0
- fxbex-0.2.1/fxbex/ui.py +102 -0
- fxbex-0.2.1/fxbex/validation.py +114 -0
- fxbex-0.2.1/fxbex/worker.py +44 -0
- fxbex-0.2.1/fxbex.egg-info/PKG-INFO +166 -0
- fxbex-0.2.1/fxbex.egg-info/SOURCES.txt +22 -0
- fxbex-0.2.1/fxbex.egg-info/dependency_links.txt +1 -0
- fxbex-0.2.1/fxbex.egg-info/entry_points.txt +2 -0
- fxbex-0.2.1/fxbex.egg-info/top_level.txt +1 -0
- fxbex-0.2.1/pyproject.toml +30 -0
- fxbex-0.2.1/setup.cfg +4 -0
fxbex-0.2.1/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
|
+
https://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.
|
fxbex-0.2.1/MANIFEST.in
ADDED
fxbex-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fxbex
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Furiosa RNGD compiled artifact packaging and runtime CLI
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Keywords: furiosa,rngd,npu,compiled-artifacts
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# FXBEX
|
|
22
|
+
|
|
23
|
+
Linux CLI for packaging and running precompiled Furiosa RNGD artifacts.
|
|
24
|
+
`.fxbex` is an independent format, **not an official Furiosa FXB**.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
Python3.10+ is required. Install a compatible Furiosa SDK separately for NPU execution.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Once the first public PyPI release has completed:
|
|
32
|
+
python -m pip install fxbex
|
|
33
|
+
fxbex --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For local development from a checkout, use `python -m pip install -e .` instead.
|
|
37
|
+
|
|
38
|
+
To avoid changing any existing SDK dependencies:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
PYTHON=python3.10 bash scripts/install.sh
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This package does not install/upgrade Furiosa SDK, PyTorch or drivers. Build/inspect
|
|
45
|
+
and integrity-only validation use the Python standard library; NPU execution requires
|
|
46
|
+
the package's exact compatible SDK. Public PyPI installation is available only after
|
|
47
|
+
the first trusted publishing workflow has completed successfully.
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
fxbex build ./compiled_model -o model.fxbex
|
|
53
|
+
fxbex build ./compiled_model -o model-standalone.fxbex --standalone
|
|
54
|
+
fxbex inspect model.fxbex
|
|
55
|
+
fxbex validate model.fxbex
|
|
56
|
+
fxbex run model.fxbex
|
|
57
|
+
fxbex chat model.fxbex
|
|
58
|
+
fxbex serve model.fxbex --port 8000
|
|
59
|
+
fxbex doctor
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`run` starts chat for a chat adapter. For a tensor model, supply
|
|
63
|
+
`--input inputs.json -o result.json`. `chat` supports `/reset` and `/quit`.
|
|
64
|
+
`serve` binds localhost and supports non-streaming `/v1/chat/completions` for chat
|
|
65
|
+
adapters and `/predict` for tensor adapters. `fxbex ui --port 7861` is optional and
|
|
66
|
+
requires Gradio. Every command has `--help`.
|
|
67
|
+
|
|
68
|
+
`validate` checks checksums, external weights, SDK versions, installed adapter
|
|
69
|
+
contracts and RNGD detection; it **does not execute inference**. To inspect on a
|
|
70
|
+
machine without SDK/NPU use `fxbex validate model.fxbex --integrity-only`.
|
|
71
|
+
`--weights-dir /path/to/snapshot` relocates external weights, with hash validation.
|
|
72
|
+
|
|
73
|
+
The builder packages existing compiled artifacts; it does not compile an arbitrary
|
|
74
|
+
HF model. Kernel load fails on missing or mismatched artifacts, never silently
|
|
75
|
+
recompiles. Use only trusted packages and installed plugins.
|
|
76
|
+
|
|
77
|
+
## Model Forge integration
|
|
78
|
+
|
|
79
|
+
FXBEX core has no `compiler_engine` dependency. Generic `runnable_dag` packages
|
|
80
|
+
run directly. Model-specific code belongs to separately installed adapter plugins:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd /root/rngd-model-forge
|
|
84
|
+
bash tests/install_fxbex.sh /root/FXBEX
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This installs the `qwen35_replay` plugin via the `fxbex.adapters` Python entry point
|
|
88
|
+
and writes a shared NPU lock path in `~/.config/fxbex/config.json`, coordinating
|
|
89
|
+
with the existing Model Forge web workers. Model Forge's **FXBEX package** tab
|
|
90
|
+
calls this installed runtime in a subprocess; unloading releases the process.
|
|
91
|
+
|
|
92
|
+
A plugin class receives `(extracted_root, report_dir, ExitStack, weights_dir=None)`
|
|
93
|
+
and provides `chat` and/or `predict`; `preflight(root, weights_dir=None)` performs
|
|
94
|
+
static checks. Packages name an installed entry point, never an arbitrary import
|
|
95
|
+
or embedded Python program. Conflicting or missing entry points fail explicitly.
|
|
96
|
+
|
|
97
|
+
Default reports: `~/.cache/fxbex/runs`. Configure `reports_dir` and `npu_lock` in
|
|
98
|
+
`~/.config/fxbex/config.json`; `FXBEX_CONFIG` and `FXBEX_NPU_LOCK` can override paths.
|
|
99
|
+
The integration installer deliberately shares Model Forge's existing lock.
|
|
100
|
+
|
|
101
|
+
## Scope
|
|
102
|
+
|
|
103
|
+
Current built-in runtime supports fixed tensor DAGs on RNGD fusion8. Qwen's plugin
|
|
104
|
+
is text-only BF16 with512-token capacity. Previous verified Qwen package reload
|
|
105
|
+
used zero compiler calls; first load still takes about3minutes for weight preparation
|
|
106
|
+
and graph reconstruction. Other model adapters and automatic memory planning are
|
|
107
|
+
not implemented. Historical validation records in `docs/` predate this repository
|
|
108
|
+
split; current split validation is recorded separately.
|
|
109
|
+
|
|
110
|
+
Tests: `python3.10 -m unittest discover -s tests`.
|
|
111
|
+
|
|
112
|
+
## Reusable Gradio model page
|
|
113
|
+
|
|
114
|
+
Copy `examples/model_page.py`, set `PACKAGE = Path('fxbex/model.fxbex')`, then
|
|
115
|
+
run it on the SDK host. Keep delivery packages in your application's `fxbex/`
|
|
116
|
+
folder: `fxbex build ./compiled_model -o fxbex/model.fxbex`.
|
|
117
|
+
The page lists saved packages, copies uploaded packages there without replacing
|
|
118
|
+
existing files, provides Load/Unload, measures request wall time, and displays a
|
|
119
|
+
Python load/run/release example with the selected filename below the controls.
|
|
120
|
+
Use `mode='chat'` or `mode='predict'`; an agent can supply `controls(run)` for
|
|
121
|
+
image/upscale-specific inputs and outputs without rewriting the lifecycle shell.
|
|
122
|
+
That callback calls `run('predict', named_inputs)` and receives `(result, timing)`.
|
|
123
|
+
Input conversion and output rendering must match a validated model adapter;
|
|
124
|
+
the template does not add model support. Existing Model Forge embeds this same
|
|
125
|
+
shell with its coordinated service. Packages remain excluded from Git.
|
|
126
|
+
|
|
127
|
+
## Python LLM API
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from fxbex import LLM
|
|
131
|
+
|
|
132
|
+
package = '/root/rngd-model-forge/fxbex/RedHatAI--Qwen3.5-9B-FP8-dynamic__text-bf16__fusion8__ctx512__sdk2026.4.0.fxbex'
|
|
133
|
+
with LLM('RedHatAI/Qwen3.5-9B-FP8-dynamic', fxbex=package) as llm:
|
|
134
|
+
print(llm.generate('What is 2+2? Reply briefly.')['text'])
|
|
135
|
+
print(llm.converse('What is 2+2?')['text'])
|
|
136
|
+
print(llm.converse('Multiply that answer by 3.')['text'])
|
|
137
|
+
llm.reset()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`fxb=package` is an alias for `fxbex=package`; supply exactly one. `LLM(fxbex=package)`
|
|
141
|
+
reads model identity from the package. Explicit model names must match; naming
|
|
142
|
+
Qwen3-8B does not turn a Qwen3.5-9B package into that model. `chat(messages)` accepts
|
|
143
|
+
explicit message history. Results are dictionaries containing `text` and available
|
|
144
|
+
runtime metrics. Without a `with` block, call `llm.close()` (or `unload()`). Model
|
|
145
|
+
execution runs in a persistent subprocess; closing releases its NPU allocations.
|
|
146
|
+
|
|
147
|
+
This API accepts FXBEX content even if the filename ends in `.fxb`, but **official
|
|
148
|
+
Furiosa FXB content is not supported by this loader**; use `furiosa_llm.LLM` for it.
|
|
149
|
+
The compatible SDK, original weights and model adapter plugin are still required.
|
|
150
|
+
No model download, automatic compilation, or CPU fallback is introduced.
|
|
151
|
+
|
|
152
|
+
### Wheel installation
|
|
153
|
+
|
|
154
|
+
Build with `python -m pip wheel --no-deps --no-build-isolation . -w dist`, then:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python -m pip install dist/fxbex-0.2.1-py3-none-any.whl
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`pip install fxbex` is available only after the first successful PyPI publication.
|
|
161
|
+
GitHub remains private. Publishing a wheel to PyPI exposes its source publicly;
|
|
162
|
+
PyPI authentication and explicit release approval are required separately.
|
|
163
|
+
|
|
164
|
+
Release preparation and keyless GitHub OIDC authentication: [docs/PYPI_RELEASE.md](docs/PYPI_RELEASE.md).
|
|
165
|
+
The Python core is Apache-2.0 licensed; Furiosa SDK and model assets are not bundled.
|
|
166
|
+
Actual NPU testing of the new LLM wrapper is deferred; its API unit tests pass.
|
fxbex-0.2.1/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# FXBEX
|
|
2
|
+
|
|
3
|
+
Linux CLI for packaging and running precompiled Furiosa RNGD artifacts.
|
|
4
|
+
`.fxbex` is an independent format, **not an official Furiosa FXB**.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
Python3.10+ is required. Install a compatible Furiosa SDK separately for NPU execution.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# Once the first public PyPI release has completed:
|
|
12
|
+
python -m pip install fxbex
|
|
13
|
+
fxbex --help
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For local development from a checkout, use `python -m pip install -e .` instead.
|
|
17
|
+
|
|
18
|
+
To avoid changing any existing SDK dependencies:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
PYTHON=python3.10 bash scripts/install.sh
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This package does not install/upgrade Furiosa SDK, PyTorch or drivers. Build/inspect
|
|
25
|
+
and integrity-only validation use the Python standard library; NPU execution requires
|
|
26
|
+
the package's exact compatible SDK. Public PyPI installation is available only after
|
|
27
|
+
the first trusted publishing workflow has completed successfully.
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
fxbex build ./compiled_model -o model.fxbex
|
|
33
|
+
fxbex build ./compiled_model -o model-standalone.fxbex --standalone
|
|
34
|
+
fxbex inspect model.fxbex
|
|
35
|
+
fxbex validate model.fxbex
|
|
36
|
+
fxbex run model.fxbex
|
|
37
|
+
fxbex chat model.fxbex
|
|
38
|
+
fxbex serve model.fxbex --port 8000
|
|
39
|
+
fxbex doctor
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`run` starts chat for a chat adapter. For a tensor model, supply
|
|
43
|
+
`--input inputs.json -o result.json`. `chat` supports `/reset` and `/quit`.
|
|
44
|
+
`serve` binds localhost and supports non-streaming `/v1/chat/completions` for chat
|
|
45
|
+
adapters and `/predict` for tensor adapters. `fxbex ui --port 7861` is optional and
|
|
46
|
+
requires Gradio. Every command has `--help`.
|
|
47
|
+
|
|
48
|
+
`validate` checks checksums, external weights, SDK versions, installed adapter
|
|
49
|
+
contracts and RNGD detection; it **does not execute inference**. To inspect on a
|
|
50
|
+
machine without SDK/NPU use `fxbex validate model.fxbex --integrity-only`.
|
|
51
|
+
`--weights-dir /path/to/snapshot` relocates external weights, with hash validation.
|
|
52
|
+
|
|
53
|
+
The builder packages existing compiled artifacts; it does not compile an arbitrary
|
|
54
|
+
HF model. Kernel load fails on missing or mismatched artifacts, never silently
|
|
55
|
+
recompiles. Use only trusted packages and installed plugins.
|
|
56
|
+
|
|
57
|
+
## Model Forge integration
|
|
58
|
+
|
|
59
|
+
FXBEX core has no `compiler_engine` dependency. Generic `runnable_dag` packages
|
|
60
|
+
run directly. Model-specific code belongs to separately installed adapter plugins:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cd /root/rngd-model-forge
|
|
64
|
+
bash tests/install_fxbex.sh /root/FXBEX
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This installs the `qwen35_replay` plugin via the `fxbex.adapters` Python entry point
|
|
68
|
+
and writes a shared NPU lock path in `~/.config/fxbex/config.json`, coordinating
|
|
69
|
+
with the existing Model Forge web workers. Model Forge's **FXBEX package** tab
|
|
70
|
+
calls this installed runtime in a subprocess; unloading releases the process.
|
|
71
|
+
|
|
72
|
+
A plugin class receives `(extracted_root, report_dir, ExitStack, weights_dir=None)`
|
|
73
|
+
and provides `chat` and/or `predict`; `preflight(root, weights_dir=None)` performs
|
|
74
|
+
static checks. Packages name an installed entry point, never an arbitrary import
|
|
75
|
+
or embedded Python program. Conflicting or missing entry points fail explicitly.
|
|
76
|
+
|
|
77
|
+
Default reports: `~/.cache/fxbex/runs`. Configure `reports_dir` and `npu_lock` in
|
|
78
|
+
`~/.config/fxbex/config.json`; `FXBEX_CONFIG` and `FXBEX_NPU_LOCK` can override paths.
|
|
79
|
+
The integration installer deliberately shares Model Forge's existing lock.
|
|
80
|
+
|
|
81
|
+
## Scope
|
|
82
|
+
|
|
83
|
+
Current built-in runtime supports fixed tensor DAGs on RNGD fusion8. Qwen's plugin
|
|
84
|
+
is text-only BF16 with512-token capacity. Previous verified Qwen package reload
|
|
85
|
+
used zero compiler calls; first load still takes about3minutes for weight preparation
|
|
86
|
+
and graph reconstruction. Other model adapters and automatic memory planning are
|
|
87
|
+
not implemented. Historical validation records in `docs/` predate this repository
|
|
88
|
+
split; current split validation is recorded separately.
|
|
89
|
+
|
|
90
|
+
Tests: `python3.10 -m unittest discover -s tests`.
|
|
91
|
+
|
|
92
|
+
## Reusable Gradio model page
|
|
93
|
+
|
|
94
|
+
Copy `examples/model_page.py`, set `PACKAGE = Path('fxbex/model.fxbex')`, then
|
|
95
|
+
run it on the SDK host. Keep delivery packages in your application's `fxbex/`
|
|
96
|
+
folder: `fxbex build ./compiled_model -o fxbex/model.fxbex`.
|
|
97
|
+
The page lists saved packages, copies uploaded packages there without replacing
|
|
98
|
+
existing files, provides Load/Unload, measures request wall time, and displays a
|
|
99
|
+
Python load/run/release example with the selected filename below the controls.
|
|
100
|
+
Use `mode='chat'` or `mode='predict'`; an agent can supply `controls(run)` for
|
|
101
|
+
image/upscale-specific inputs and outputs without rewriting the lifecycle shell.
|
|
102
|
+
That callback calls `run('predict', named_inputs)` and receives `(result, timing)`.
|
|
103
|
+
Input conversion and output rendering must match a validated model adapter;
|
|
104
|
+
the template does not add model support. Existing Model Forge embeds this same
|
|
105
|
+
shell with its coordinated service. Packages remain excluded from Git.
|
|
106
|
+
|
|
107
|
+
## Python LLM API
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from fxbex import LLM
|
|
111
|
+
|
|
112
|
+
package = '/root/rngd-model-forge/fxbex/RedHatAI--Qwen3.5-9B-FP8-dynamic__text-bf16__fusion8__ctx512__sdk2026.4.0.fxbex'
|
|
113
|
+
with LLM('RedHatAI/Qwen3.5-9B-FP8-dynamic', fxbex=package) as llm:
|
|
114
|
+
print(llm.generate('What is 2+2? Reply briefly.')['text'])
|
|
115
|
+
print(llm.converse('What is 2+2?')['text'])
|
|
116
|
+
print(llm.converse('Multiply that answer by 3.')['text'])
|
|
117
|
+
llm.reset()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`fxb=package` is an alias for `fxbex=package`; supply exactly one. `LLM(fxbex=package)`
|
|
121
|
+
reads model identity from the package. Explicit model names must match; naming
|
|
122
|
+
Qwen3-8B does not turn a Qwen3.5-9B package into that model. `chat(messages)` accepts
|
|
123
|
+
explicit message history. Results are dictionaries containing `text` and available
|
|
124
|
+
runtime metrics. Without a `with` block, call `llm.close()` (or `unload()`). Model
|
|
125
|
+
execution runs in a persistent subprocess; closing releases its NPU allocations.
|
|
126
|
+
|
|
127
|
+
This API accepts FXBEX content even if the filename ends in `.fxb`, but **official
|
|
128
|
+
Furiosa FXB content is not supported by this loader**; use `furiosa_llm.LLM` for it.
|
|
129
|
+
The compatible SDK, original weights and model adapter plugin are still required.
|
|
130
|
+
No model download, automatic compilation, or CPU fallback is introduced.
|
|
131
|
+
|
|
132
|
+
### Wheel installation
|
|
133
|
+
|
|
134
|
+
Build with `python -m pip wheel --no-deps --no-build-isolation . -w dist`, then:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
python -m pip install dist/fxbex-0.2.1-py3-none-any.whl
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`pip install fxbex` is available only after the first successful PyPI publication.
|
|
141
|
+
GitHub remains private. Publishing a wheel to PyPI exposes its source publicly;
|
|
142
|
+
PyPI authentication and explicit release approval are required separately.
|
|
143
|
+
|
|
144
|
+
Release preparation and keyless GitHub OIDC authentication: [docs/PYPI_RELEASE.md](docs/PYPI_RELEASE.md).
|
|
145
|
+
The Python core is Apache-2.0 licensed; Furiosa SDK and model assets are not bundled.
|
|
146
|
+
Actual NPU testing of the new LLM wrapper is deferred; its API unit tests pass.
|
fxbex-0.2.1/fxbex/cli.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""CLI for local FXB_EX packages; SDK is imported only for runtime operations."""
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import sys
|
|
6
|
+
from .package import build, inspect
|
|
7
|
+
from .validation import validate
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _main(argv=None):
|
|
11
|
+
parser = argparse.ArgumentParser(
|
|
12
|
+
prog='fxbex', description='Build, inspect and run compiled FXB_EX model packages.',
|
|
13
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
14
|
+
epilog="""Examples:
|
|
15
|
+
fxbex build ./compiled_model -o model.fxbex
|
|
16
|
+
fxbex inspect model.fxbex
|
|
17
|
+
fxbex validate model.fxbex --integrity-only
|
|
18
|
+
fxbex validate model.fxbex --weights-dir ./weights
|
|
19
|
+
fxbex run model.fxbex --input inputs.json -o result.json
|
|
20
|
+
fxbex chat model.fxbex
|
|
21
|
+
fxbex serve model.fxbex --port 8000
|
|
22
|
+
fxbex doctor
|
|
23
|
+
|
|
24
|
+
Validation checks static readiness; it does not run inference or prove NPU execution.
|
|
25
|
+
Model-specific exporters and capture commands belong to their adapter plugins.""")
|
|
26
|
+
sub = parser.add_subparsers(dest='action', required=True)
|
|
27
|
+
p = sub.add_parser('build', help='Pack a compiled directory with checksums (no compilation)')
|
|
28
|
+
p.add_argument('source', help='Compiled directory containing manifest and required JSON configurations')
|
|
29
|
+
p.add_argument('-o', '--output', required=True, help='New .fxbex file; existing files are never overwritten')
|
|
30
|
+
p.add_argument('--standalone', action='store_true', help='Copy referenced external weights into the archive')
|
|
31
|
+
p = sub.add_parser('inspect', help='Verify integrity and display the manifest; no SDK needed')
|
|
32
|
+
p.add_argument('package', help='Path to a .fxbex archive')
|
|
33
|
+
p = sub.add_parser('validate', help='Check integrity, SDK, adapter, weights and device availability without inference')
|
|
34
|
+
p.add_argument('package', help='Path to a .fxbex archive')
|
|
35
|
+
p.add_argument('--integrity-only', action='store_true', help='Verify archive only; skip SDK, weights and device checks')
|
|
36
|
+
p.add_argument('--weights-dir', help='Override the external checkpoint/weights directory')
|
|
37
|
+
sub.add_parser('doctor', help='Report installed SDK versions and RNGD device status')
|
|
38
|
+
p = sub.add_parser('ui', help='Launch the local package interface')
|
|
39
|
+
p.add_argument('--port', type=int, default=7861, help='HTTP port (default: 7861)')
|
|
40
|
+
for name, help_text in (
|
|
41
|
+
('run', 'Run JSON inputs or start interactive chat for a chat adapter'),
|
|
42
|
+
('chat', 'Chat interactively, or process a messages JSON file'),
|
|
43
|
+
('predict', 'Run a tensor DAG with named JSON inputs'),
|
|
44
|
+
('serve', 'Serve the loaded package over local HTTP'),
|
|
45
|
+
):
|
|
46
|
+
p = sub.add_parser(name, help=help_text, description=help_text)
|
|
47
|
+
p.add_argument('package', help='Path to a .fxbex archive')
|
|
48
|
+
p.add_argument('--report-dir', help='Directory for runtime logs and evidence')
|
|
49
|
+
p.add_argument('--weights-dir', help='Override external checkpoint/weights directory')
|
|
50
|
+
if name != 'serve':
|
|
51
|
+
p.add_argument('--input', help='JSON file: named tensors for predict, or {"messages": [...]} for chat')
|
|
52
|
+
p.add_argument('-o', '--output', help='Write response JSON to this file')
|
|
53
|
+
p.add_argument('--max-new-tokens', type=int, default=32, help='Chat token limit (default: 32)')
|
|
54
|
+
else:
|
|
55
|
+
p.add_argument('--port', type=int, default=8000, help='HTTP port (default: 8000)')
|
|
56
|
+
args=parser.parse_args(argv)
|
|
57
|
+
if args.action=='build':result={'package':str(build(args.source,args.output,standalone=args.standalone))}
|
|
58
|
+
elif args.action == 'inspect':
|
|
59
|
+
m=inspect(args.package)
|
|
60
|
+
result={'model':m['model'],'runtime':m['runtime'],'compatibility':m['compatibility'],
|
|
61
|
+
'standalone':m['standalone'],'files':len(m['files']),
|
|
62
|
+
'artifact_bytes':sum(x['size'] for x in m['files'].values()),'integrity_verified':True}
|
|
63
|
+
elif args.action == 'validate':
|
|
64
|
+
result = validate(args.package, integrity_only=args.integrity_only, weights_dir=args.weights_dir)
|
|
65
|
+
elif args.action=='doctor':
|
|
66
|
+
from .runtime import doctor
|
|
67
|
+
result=doctor()
|
|
68
|
+
elif args.action=='ui':
|
|
69
|
+
from .ui import launch
|
|
70
|
+
launch(args.port);return
|
|
71
|
+
else:
|
|
72
|
+
from .runtime import Session
|
|
73
|
+
# SDK/compiler diagnostics may print; keep JSON results on stdout.
|
|
74
|
+
import contextlib
|
|
75
|
+
if args.action == 'predict' and not args.input:
|
|
76
|
+
raise ValueError('--input JSON file is required for tensor prediction')
|
|
77
|
+
session=Session(args.package,report_dir=args.report_dir,weights_dir=args.weights_dir)
|
|
78
|
+
log_path=session.report_dir/'runtime.log'
|
|
79
|
+
print(f'Loading package; diagnostics: {log_path}',file=sys.stderr,flush=True)
|
|
80
|
+
with log_path.open('w') as log, contextlib.redirect_stdout(log), contextlib.redirect_stderr(log):
|
|
81
|
+
session.__enter__()
|
|
82
|
+
print(f'NPU package ready; reports: {session.report_dir}',file=sys.stderr,flush=True)
|
|
83
|
+
try:
|
|
84
|
+
if args.action=='serve':
|
|
85
|
+
from .server import serve
|
|
86
|
+
serve(session,args.port);return
|
|
87
|
+
if args.action=='predict' or (args.action=='run' and session.manifest['runtime']['adapter']=='runnable_dag'):
|
|
88
|
+
if not args.input:raise ValueError('--input JSON file is required for tensor prediction')
|
|
89
|
+
result=session.predict(json.loads(Path(args.input).read_text()))
|
|
90
|
+
elif args.input:
|
|
91
|
+
data=json.loads(Path(args.input).read_text())
|
|
92
|
+
result=session.chat(data['messages'],data.get('max_new_tokens',args.max_new_tokens))
|
|
93
|
+
else:
|
|
94
|
+
messages=[]
|
|
95
|
+
print('FXB_EX chat: /reset clears history, /quit unloads.',flush=True)
|
|
96
|
+
while True:
|
|
97
|
+
try:prompt=input('you> ')
|
|
98
|
+
except EOFError:break
|
|
99
|
+
if prompt.strip()=='/quit':break
|
|
100
|
+
if prompt.strip()=='/reset':messages=[];continue
|
|
101
|
+
if not prompt.strip():continue
|
|
102
|
+
candidate=messages+[{'role':'user','content':prompt}]
|
|
103
|
+
result=session.chat(candidate,args.max_new_tokens)
|
|
104
|
+
messages=candidate+[{'role':'assistant','content':result['text']}]
|
|
105
|
+
print(result['text'],flush=True)
|
|
106
|
+
return
|
|
107
|
+
finally:session.__exit__(None,None,None)
|
|
108
|
+
if args.output:Path(args.output).write_text(json.dumps(result,ensure_ascii=False,indent=2))
|
|
109
|
+
result['report_dir']=str(session.report_dir)
|
|
110
|
+
print(json.dumps(result,ensure_ascii=False,indent=2))
|
|
111
|
+
return 0 if result.get('valid', True) else 1
|
|
112
|
+
|
|
113
|
+
def main(argv=None):
|
|
114
|
+
try:
|
|
115
|
+
return _main(argv) or 0
|
|
116
|
+
except Exception as exc:
|
|
117
|
+
print(f'fxbex: {exc}', file=sys.stderr)
|
|
118
|
+
return 1
|
|
119
|
+
except KeyboardInterrupt:
|
|
120
|
+
return 130
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == '__main__':
|
|
124
|
+
sys.exit(main())
|