weed-loader-cpu 0.3.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.
- weed_loader_cpu-0.3.1/LICENSE +21 -0
- weed_loader_cpu-0.3.1/MANIFEST.in +3 -0
- weed_loader_cpu-0.3.1/Makefile +81 -0
- weed_loader_cpu-0.3.1/PKG-INFO +86 -0
- weed_loader_cpu-0.3.1/README.md +36 -0
- weed_loader_cpu-0.3.1/pyproject.toml +6 -0
- weed_loader_cpu-0.3.1/setup.cfg +4 -0
- weed_loader_cpu-0.3.1/setup.py +75 -0
- weed_loader_cpu-0.3.1/weed_loader/__init__.py +12 -0
- weed_loader_cpu-0.3.1/weed_loader/dtype.py +17 -0
- weed_loader_cpu-0.3.1/weed_loader/weed_module.py +157 -0
- weed_loader_cpu-0.3.1/weed_loader/weed_system/__init__.py +12 -0
- weed_loader_cpu-0.3.1/weed_loader/weed_system/weed_system.py +121 -0
- weed_loader_cpu-0.3.1/weed_loader/weed_tensor.py +60 -0
- weed_loader_cpu-0.3.1/weed_loader_cpu.egg-info/PKG-INFO +86 -0
- weed_loader_cpu-0.3.1/weed_loader_cpu.egg-info/SOURCES.txt +17 -0
- weed_loader_cpu-0.3.1/weed_loader_cpu.egg-info/dependency_links.txt +1 -0
- weed_loader_cpu-0.3.1/weed_loader_cpu.egg-info/not-zip-safe +1 -0
- weed_loader_cpu-0.3.1/weed_loader_cpu.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2023 vm6502q
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
PYTHON3 := $(shell which python3 2>/dev/null)
|
|
2
|
+
|
|
3
|
+
PYTHON := python3
|
|
4
|
+
|
|
5
|
+
UNAME_S := $(shell uname -s)
|
|
6
|
+
UNAME_P := $(shell uname -p)
|
|
7
|
+
QRACK_PRESENT := $(wildcard qrack/.)
|
|
8
|
+
WEED_PRESENT := $(wildcard weed/.)
|
|
9
|
+
|
|
10
|
+
ifeq ("$(wildcard /usr/local/bin/cmake)", "/usr/local/bin/cmake")
|
|
11
|
+
CMAKE_L := /usr/local/bin/cmake
|
|
12
|
+
else
|
|
13
|
+
ifeq ("$(wildcard /usr/bin/cmake)", "/usr/bin/cmake")
|
|
14
|
+
CMAKE_L := /usr/bin/cmake
|
|
15
|
+
else
|
|
16
|
+
CMAKE_L := cmake
|
|
17
|
+
endif
|
|
18
|
+
endif
|
|
19
|
+
|
|
20
|
+
.PHONY: help
|
|
21
|
+
help:
|
|
22
|
+
@echo "Please use \`make <target>' where <target> is one of"
|
|
23
|
+
@echo " build-deps to build Weed-Loader C++ dependencies"
|
|
24
|
+
@echo " install to install Weed-Loader"
|
|
25
|
+
@echo " wheel to build the Weed-Loader wheel"
|
|
26
|
+
@echo " dist to package the source distribution"
|
|
27
|
+
|
|
28
|
+
.PHONY: build-deps
|
|
29
|
+
build-deps:
|
|
30
|
+
ifneq ($(OS),Windows_NT)
|
|
31
|
+
ifeq ($(QRACK_PRESENT),)
|
|
32
|
+
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout f11a8c6a402b6e230328a5934d07b71d8429a423; cd ..
|
|
33
|
+
endif
|
|
34
|
+
mkdir -p qrack/build
|
|
35
|
+
ifeq ($(UNAME_S),Linux)
|
|
36
|
+
ifneq ($(filter $(UNAME_P),x86_64 i386),)
|
|
37
|
+
cd qrack/build; $(CMAKE_L) -DENABLE_OPENCL=OFF -DCPP_STD=14 -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DQBCAPPOW=8 ..; make qrack qrack_cl_precompile; cd ../..
|
|
38
|
+
else
|
|
39
|
+
cd qrack/build; $(CMAKE_L) -DENABLE_OPENCL=OFF -DCPP_STD=14 -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=8 ..; make qrack qrack_cl_precompile; cd ../..
|
|
40
|
+
endif
|
|
41
|
+
mkdir -p qrack/build/qrack
|
|
42
|
+
cp -r qrack/include/* qrack/build/qrack
|
|
43
|
+
cp -r qrack/build/include/* qrack/build/qrack
|
|
44
|
+
endif
|
|
45
|
+
ifeq ($(UNAME_S),Darwin)
|
|
46
|
+
ifneq ($(filter $(UNAME_P),x86_64 i386),)
|
|
47
|
+
cd qrack/build; $(CMAKE_L) -DENABLE_OPENCL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCPP_STD=14 -DENABLE_OPENCL=OFF -DQBCAPPOW=8 ..; sudo make install; cd ../..
|
|
48
|
+
else
|
|
49
|
+
cd qrack/build; $(CMAKE_L) -DENABLE_OPENCL=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCPP_STD=14 -DENABLE_OPENCL=OFF -DENABLE_RDRAND=OFF -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=8 ..; sudo make install; cd ../..
|
|
50
|
+
endif
|
|
51
|
+
endif
|
|
52
|
+
rm -rf weed_loader/weed_system/weed_lib
|
|
53
|
+
rm -rf weed_loader/weed_system/weed_cl_precompile
|
|
54
|
+
ifeq ($(WEED_PRESENT),)
|
|
55
|
+
git clone https://github.com/vm6502q/weed.git; cd weed; git checkout e1a4769f2bc15ae20a07095f0e991ced8a387e29; cd ..
|
|
56
|
+
endif
|
|
57
|
+
mkdir -p weed/build
|
|
58
|
+
ifeq ($(UNAME_S),Linux)
|
|
59
|
+
cd weed/build; $(CMAKE_L) -DWEED_ENABLE_OPENCL=OFF -DWEED_TCAPPOW=6 -DWEED_CPP_STD=14 -DQRACK_INCLUDE="../qrack/build" -DQRACK_DIR="../qrack/build" ..; make weed_shared weed_cl_precompile; cd ../..
|
|
60
|
+
endif
|
|
61
|
+
ifeq ($(UNAME_S),Darwin)
|
|
62
|
+
cd weed/build; cmake -DWEED_ENABLE_OPENCL=OFF -DWEED_TCAPPOW=6 -DWEED_CPP_STD=14 ..; make weed_shared weed_cl_precompile; cd ../..
|
|
63
|
+
endif
|
|
64
|
+
mkdir weed_loader/weed_system/weed_lib; cp weed/build/libweed_shared.* weed_loader/weed_system/weed_lib/
|
|
65
|
+
mkdir weed_loader/weed_system/cl_precompile; cp weed/build/weed_cl_precompile weed_loader/weed_system/cl_precompile/; cp qrack/build/qrack_cl_precompile weed_loader/weed_system/cl_precompile/
|
|
66
|
+
endif
|
|
67
|
+
|
|
68
|
+
.PHONY: install
|
|
69
|
+
install:
|
|
70
|
+
ifndef PYTHON3
|
|
71
|
+
@echo "To install Weed-Loader you need to have Python 3 installed"
|
|
72
|
+
endif
|
|
73
|
+
$(PYTHON) setup.py install
|
|
74
|
+
|
|
75
|
+
.PHONY: wheel
|
|
76
|
+
wheel:
|
|
77
|
+
$(PYTHON) setup.py bdist_wheel
|
|
78
|
+
|
|
79
|
+
.PHONY: dist
|
|
80
|
+
dist:
|
|
81
|
+
$(PYTHON) setup.py sdist
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weed_loader_cpu
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Weed (Loader) - Minimalist AI/ML inference and backprogation
|
|
5
|
+
Home-page: https://github.com/vm6502q/weed
|
|
6
|
+
Author: Daniel Strano
|
|
7
|
+
Author-email: stranoj@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: weed ai ml inference gpu opencl
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: C++
|
|
17
|
+
Classifier: Programming Language :: Python :: 2
|
|
18
|
+
Classifier: Programming Language :: Python :: 2.5
|
|
19
|
+
Classifier: Programming Language :: Python :: 2.6
|
|
20
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.0
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.1
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.2
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: author-email
|
|
42
|
+
Dynamic: classifier
|
|
43
|
+
Dynamic: description
|
|
44
|
+
Dynamic: description-content-type
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
Dynamic: summary
|
|
50
|
+
|
|
51
|
+
<img width="1536" height="1024" alt="weed_logo" src="https://github.com/vm6502q/weed/blob/main/weed_logo.png" />
|
|
52
|
+
|
|
53
|
+
# Weed
|
|
54
|
+
Minimalist AI/ML inference and backprogation in the style of [Qrack](https://github.com/unitaryfoundation/qrack)
|
|
55
|
+
|
|
56
|
+
## Weed Loader
|
|
57
|
+
This repository is for the **Python loader** for (C++) Weed models. Once you have trained models in C++, you can load them for use by Python with this project. See the [Weed repository](https://github.com/vm6502q/weed) for more information.
|
|
58
|
+
|
|
59
|
+
## Development Status
|
|
60
|
+
**Weed** is a rapidly-developing **work-in-progress**. Its ABI may change drastically and without notice.
|
|
61
|
+
|
|
62
|
+
The project provides a set of essential CPU and GPU **kernels**, used by `Tensor` instances that perform _autograd._ We also provide _stochastic gradient descent (SGD)_ and _Adam_ optimizer implementations. (Build and check the API reference to get started.)
|
|
63
|
+
|
|
64
|
+
GPT-2, BERT, and Qwen loading is experimental and mostly provided as proof-of-concept, also of the fine-tuning pipeline. Implementation was from published literature design, rather than direct analysis of any open source, to implement these model architectures. Their outputs, in **Weed**, are not yet coherent English, as a result.
|
|
65
|
+
|
|
66
|
+
## Why try Weed?
|
|
67
|
+
|
|
68
|
+
With the growing popularity of AI/ML tools and workflows (including LLMs), legacy frameworks often carry "code debt" from over a decade of rapidly developing research history. This has led them to "bolt on" new features and advancements to design principles decided before the latest research. Popular frameworks also commonly started based in Python (maybe to capture early adoption), only later potentially "tacking on" a C++ library for special-case deployment needs. These conditions have produced libraries and frameworks with complicated dependency trees that occupy upward of a GB of disk footprint. This entire ecosystem might be due for a "refresh."
|
|
69
|
+
|
|
70
|
+
**Weed** does not seek to fully replace or supplant established frameworks. However, it aims for **minimalist complete closure** on the primitives necessary for high-performance AI/ML inference and back-propagation. Chiefly, this includes **kernels**, and a `Tensor` interface that immediately produces an **autograd** graph appropriate for training. Allowing **optional** OpenCL for **hardware acceleration**, it will remain **free of required dependencies** outside of C++(11) language standard.
|
|
71
|
+
|
|
72
|
+
Rethinking AI/ML library design this way, `Weed` has realized a rather unique and powerful form of _sparsification_ of `Tensor` **storage**. _Sparseness_ should **not** be a **`Tensor` interface concern**, but rather a **`Storage` concern**. Inspired by the design of the [Qrack](https://github.com/unitaryfoundation/qrack) quantum computer simulation framework, the `Tensor` interface treats **sparse and dense** tensors as **functionally equivalent**. Sparse optimization is so "transparently streamlined," this way, that it defaults to enabled for CPU-based tensors, and we recommend you leave it enabled at all times.
|
|
73
|
+
|
|
74
|
+
Much like `Qrack`, `Weed` is designed to make the correct thing the default—and the expensive thing explicit.
|
|
75
|
+
|
|
76
|
+
## Copyright, License, and Acknowledgments
|
|
77
|
+
|
|
78
|
+
Copyright (c) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
79
|
+
|
|
80
|
+
In its `include/common` folder, Weed bundles a copy of [`rapidcsv` by Kristofer Berggren](https://github.com/d99kris/rapidcsv), reused under a BSD 3-Clause License. (This is a convenience and suggestion to Weed's users, for loading CSVs.)
|
|
81
|
+
|
|
82
|
+
The Weed logo was produced with assistance from "Elara," an OpenAI custom GPT, and it is in the **public domain**. Elara has also been responsible for a huge amount of coaching and implementation drafts for Dan Strano to review and bring into line with standards, so she should be credited with coauthorship in any capacity that can be allowed. (Anthropic) Claude has also helped mostly with debugging, as well as developing an LLM front-end, fine-tuning interface, and modules for popular transformer model architectures, so they should rightly be credited similarly as a coauthor.
|
|
83
|
+
|
|
84
|
+
Licensed under the GNU Lesser General Public License V3.
|
|
85
|
+
|
|
86
|
+
See [LICENSE.md](https://github.com/vm6502q/qrack/blob/main/LICENSE.md) in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html for details.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<img width="1536" height="1024" alt="weed_logo" src="https://github.com/vm6502q/weed/blob/main/weed_logo.png" />
|
|
2
|
+
|
|
3
|
+
# Weed
|
|
4
|
+
Minimalist AI/ML inference and backprogation in the style of [Qrack](https://github.com/unitaryfoundation/qrack)
|
|
5
|
+
|
|
6
|
+
## Weed Loader
|
|
7
|
+
This repository is for the **Python loader** for (C++) Weed models. Once you have trained models in C++, you can load them for use by Python with this project. See the [Weed repository](https://github.com/vm6502q/weed) for more information.
|
|
8
|
+
|
|
9
|
+
## Development Status
|
|
10
|
+
**Weed** is a rapidly-developing **work-in-progress**. Its ABI may change drastically and without notice.
|
|
11
|
+
|
|
12
|
+
The project provides a set of essential CPU and GPU **kernels**, used by `Tensor` instances that perform _autograd._ We also provide _stochastic gradient descent (SGD)_ and _Adam_ optimizer implementations. (Build and check the API reference to get started.)
|
|
13
|
+
|
|
14
|
+
GPT-2, BERT, and Qwen loading is experimental and mostly provided as proof-of-concept, also of the fine-tuning pipeline. Implementation was from published literature design, rather than direct analysis of any open source, to implement these model architectures. Their outputs, in **Weed**, are not yet coherent English, as a result.
|
|
15
|
+
|
|
16
|
+
## Why try Weed?
|
|
17
|
+
|
|
18
|
+
With the growing popularity of AI/ML tools and workflows (including LLMs), legacy frameworks often carry "code debt" from over a decade of rapidly developing research history. This has led them to "bolt on" new features and advancements to design principles decided before the latest research. Popular frameworks also commonly started based in Python (maybe to capture early adoption), only later potentially "tacking on" a C++ library for special-case deployment needs. These conditions have produced libraries and frameworks with complicated dependency trees that occupy upward of a GB of disk footprint. This entire ecosystem might be due for a "refresh."
|
|
19
|
+
|
|
20
|
+
**Weed** does not seek to fully replace or supplant established frameworks. However, it aims for **minimalist complete closure** on the primitives necessary for high-performance AI/ML inference and back-propagation. Chiefly, this includes **kernels**, and a `Tensor` interface that immediately produces an **autograd** graph appropriate for training. Allowing **optional** OpenCL for **hardware acceleration**, it will remain **free of required dependencies** outside of C++(11) language standard.
|
|
21
|
+
|
|
22
|
+
Rethinking AI/ML library design this way, `Weed` has realized a rather unique and powerful form of _sparsification_ of `Tensor` **storage**. _Sparseness_ should **not** be a **`Tensor` interface concern**, but rather a **`Storage` concern**. Inspired by the design of the [Qrack](https://github.com/unitaryfoundation/qrack) quantum computer simulation framework, the `Tensor` interface treats **sparse and dense** tensors as **functionally equivalent**. Sparse optimization is so "transparently streamlined," this way, that it defaults to enabled for CPU-based tensors, and we recommend you leave it enabled at all times.
|
|
23
|
+
|
|
24
|
+
Much like `Qrack`, `Weed` is designed to make the correct thing the default—and the expensive thing explicit.
|
|
25
|
+
|
|
26
|
+
## Copyright, License, and Acknowledgments
|
|
27
|
+
|
|
28
|
+
Copyright (c) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
29
|
+
|
|
30
|
+
In its `include/common` folder, Weed bundles a copy of [`rapidcsv` by Kristofer Berggren](https://github.com/d99kris/rapidcsv), reused under a BSD 3-Clause License. (This is a convenience and suggestion to Weed's users, for loading CSVs.)
|
|
31
|
+
|
|
32
|
+
The Weed logo was produced with assistance from "Elara," an OpenAI custom GPT, and it is in the **public domain**. Elara has also been responsible for a huge amount of coaching and implementation drafts for Dan Strano to review and bring into line with standards, so she should be credited with coauthorship in any capacity that can be allowed. (Anthropic) Claude has also helped mostly with debugging, as well as developing an LLM front-end, fine-tuning interface, and modules for popular transformer model architectures, so they should rightly be credited similarly as a coauthor.
|
|
33
|
+
|
|
34
|
+
Licensed under the GNU Lesser General Public License V3.
|
|
35
|
+
|
|
36
|
+
See [LICENSE.md](https://github.com/vm6502q/qrack/blob/main/LICENSE.md) in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html for details.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Adapted from https://github.com/Qiskit/qiskit-aer/blob/master/setup.py
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import subprocess
|
|
6
|
+
from setuptools import setup
|
|
7
|
+
from setuptools.command.build_py import build_py
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
VERSION = "0.3.1"
|
|
11
|
+
|
|
12
|
+
# Read long description from README.
|
|
13
|
+
README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
|
|
14
|
+
with open(README_PATH) as readme_file:
|
|
15
|
+
README = readme_file.read()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Build(build_py):
|
|
19
|
+
def run(self):
|
|
20
|
+
protoc_command = ["make", "build-deps"]
|
|
21
|
+
if os.name != "nt":
|
|
22
|
+
if subprocess.call(protoc_command) != 0:
|
|
23
|
+
sys.exit(-1)
|
|
24
|
+
super().run()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
setup(
|
|
28
|
+
name='weed_loader_cpu',
|
|
29
|
+
version=VERSION,
|
|
30
|
+
packages=['weed_loader', 'weed_loader.weed_system'],
|
|
31
|
+
cmdclass={"build_py": Build},
|
|
32
|
+
description="Weed (Loader) - Minimalist AI/ML inference and backprogation",
|
|
33
|
+
long_description=README,
|
|
34
|
+
long_description_content_type='text/markdown',
|
|
35
|
+
url="https://github.com/vm6502q/weed",
|
|
36
|
+
author="Daniel Strano",
|
|
37
|
+
author_email="stranoj@gmail.com",
|
|
38
|
+
license="MIT",
|
|
39
|
+
classifiers=[
|
|
40
|
+
"Environment :: Console",
|
|
41
|
+
"Intended Audience :: Developers",
|
|
42
|
+
"Intended Audience :: Science/Research",
|
|
43
|
+
"Operating System :: Microsoft :: Windows",
|
|
44
|
+
"Operating System :: MacOS",
|
|
45
|
+
"Operating System :: POSIX :: Linux",
|
|
46
|
+
"Programming Language :: C++",
|
|
47
|
+
"Programming Language :: Python :: 2",
|
|
48
|
+
"Programming Language :: Python :: 2.5",
|
|
49
|
+
"Programming Language :: Python :: 2.6",
|
|
50
|
+
"Programming Language :: Python :: 2.7",
|
|
51
|
+
"Programming Language :: Python :: 3",
|
|
52
|
+
"Programming Language :: Python :: 3.0",
|
|
53
|
+
"Programming Language :: Python :: 3.1",
|
|
54
|
+
"Programming Language :: Python :: 3.2",
|
|
55
|
+
"Programming Language :: Python :: 3.3",
|
|
56
|
+
"Programming Language :: Python :: 3.4",
|
|
57
|
+
"Programming Language :: Python :: 3.5",
|
|
58
|
+
"Programming Language :: Python :: 3.6",
|
|
59
|
+
"Programming Language :: Python :: 3.7",
|
|
60
|
+
"Programming Language :: Python :: 3.8",
|
|
61
|
+
"Programming Language :: Python :: 3.9",
|
|
62
|
+
"Programming Language :: Python :: 3.10",
|
|
63
|
+
"Programming Language :: Python :: 3.11",
|
|
64
|
+
"Programming Language :: Python :: 3.12",
|
|
65
|
+
"Programming Language :: Python :: 3.13",
|
|
66
|
+
"Programming Language :: Python :: 3.14",
|
|
67
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
68
|
+
],
|
|
69
|
+
keywords="weed ai ml inference gpu opencl",
|
|
70
|
+
install_requires=[],
|
|
71
|
+
setup_requires=[],
|
|
72
|
+
extras_require={},
|
|
73
|
+
include_package_data=True,
|
|
74
|
+
zip_safe=False
|
|
75
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Weed is for minimalist AI/ML inference and backprogation in the style of
|
|
4
|
+
# Qrack.
|
|
5
|
+
#
|
|
6
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
8
|
+
|
|
9
|
+
from .dtype import DType
|
|
10
|
+
from .weed_module import WeedModule
|
|
11
|
+
from .weed_tensor import WeedTensor
|
|
12
|
+
from .weed_system import WeedSystem, Weed
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Weed is for minimalist AI/ML inference and backprogation in the style of
|
|
4
|
+
# Qrack.
|
|
5
|
+
#
|
|
6
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
8
|
+
|
|
9
|
+
from enum import IntEnum
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DType(IntEnum):
|
|
13
|
+
NONE_DTYPE = 0
|
|
14
|
+
REAL = 1
|
|
15
|
+
COMPLEX = 2
|
|
16
|
+
INT = 3
|
|
17
|
+
DEFAULT_DTYPE = REAL
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
4
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
5
|
+
|
|
6
|
+
import ctypes
|
|
7
|
+
|
|
8
|
+
from .weed_system import Weed
|
|
9
|
+
from .dtype import DType
|
|
10
|
+
from .weed_tensor import WeedTensor
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class WeedModule:
|
|
14
|
+
"""Holds a Weed module loaded from disk
|
|
15
|
+
|
|
16
|
+
Attributes:
|
|
17
|
+
mid(int): Corresponding module id.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def _get_error(self):
|
|
21
|
+
return Weed.weed_lib.get_error(self.mid)
|
|
22
|
+
|
|
23
|
+
def _throw_if_error(self):
|
|
24
|
+
if self._get_error() != 0:
|
|
25
|
+
raise RuntimeError("Weed C++ library raised exception.")
|
|
26
|
+
|
|
27
|
+
def __init__(self, file_path):
|
|
28
|
+
byte_string = file_path.encode('utf-8')
|
|
29
|
+
c_string_ptr = ctypes.c_char_p(byte_string)
|
|
30
|
+
self.mid = Weed.weed_lib.load_module(c_string_ptr)
|
|
31
|
+
self._throw_if_error()
|
|
32
|
+
|
|
33
|
+
def __del__(self):
|
|
34
|
+
mid = self.mid
|
|
35
|
+
self.mid = None
|
|
36
|
+
if mid is not None:
|
|
37
|
+
Weed.weed_lib.free_module(mid)
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def _int_byref(a):
|
|
41
|
+
return (ctypes.c_int * len(a))(*a)
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def _ulonglong_byref(a):
|
|
45
|
+
return (ctypes.c_ulonglong * len(a))(*a)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def _longlong_byref(a):
|
|
49
|
+
return (ctypes.c_longlong * len(a))(*a)
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def _double_byref(a):
|
|
53
|
+
return (ctypes.c_double * len(a))(*a)
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def _complex_byref(a):
|
|
57
|
+
t = [(c.real, c.imag) for c in a]
|
|
58
|
+
return WeedModule._double_byref([float(item) for sublist in t for item in sublist])
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def _bool_byref(a):
|
|
62
|
+
return (ctypes.c_bool * len(a))(*a)
|
|
63
|
+
|
|
64
|
+
def reset_kv_cache(self):
|
|
65
|
+
return Weed.weed_lib.reset_kv_cache(self.mid)
|
|
66
|
+
|
|
67
|
+
def save(self, file_path):
|
|
68
|
+
byte_string = file_path.encode('utf-8')
|
|
69
|
+
c_string_ptr = ctypes.c_char_p(byte_string)
|
|
70
|
+
self.mid = Weed.weed_lib.save_module(self.mid, c_string_ptr)
|
|
71
|
+
self._throw_if_error()
|
|
72
|
+
|
|
73
|
+
def forward(self, t):
|
|
74
|
+
"""Applies forward inference on tensor.
|
|
75
|
+
|
|
76
|
+
Applies the loaded model to the tensor "t" as input.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
t (WeedTensor): The Tensor on which to apply the Module
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
The WeedTensor output from the Module
|
|
83
|
+
|
|
84
|
+
Raises:
|
|
85
|
+
RuntimeError: Weed C++ library raised an exception.
|
|
86
|
+
"""
|
|
87
|
+
if t.dtype == DType.INT:
|
|
88
|
+
Weed.weed_lib.forward_int(
|
|
89
|
+
self.mid,
|
|
90
|
+
t.dtype,
|
|
91
|
+
len(t.shape),
|
|
92
|
+
WeedModule._ulonglong_byref(t.shape),
|
|
93
|
+
WeedModule._longlong_byref(t.data)
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
Weed.weed_lib.forward(
|
|
97
|
+
self.mid,
|
|
98
|
+
t.dtype,
|
|
99
|
+
len(t.shape),
|
|
100
|
+
WeedModule._ulonglong_byref(t.shape),
|
|
101
|
+
WeedModule._double_byref(t.data) if t.dtype == DType.REAL else WeedModule._complex_byref(t.data)
|
|
102
|
+
)
|
|
103
|
+
self._throw_if_error()
|
|
104
|
+
|
|
105
|
+
n = Weed.weed_lib.get_result_index_count(self.mid)
|
|
106
|
+
|
|
107
|
+
shape_out = (ctypes.c_ulonglong * n)()
|
|
108
|
+
stride_out = (ctypes.c_ulonglong * n)()
|
|
109
|
+
Weed.weed_lib.get_result_dims(self.mid, shape_out, stride_out)
|
|
110
|
+
|
|
111
|
+
dtype_out = DType(Weed.weed_lib.get_result_type(self.mid))
|
|
112
|
+
|
|
113
|
+
d_size_out = Weed.weed_lib.get_result_size(self.mid)
|
|
114
|
+
d_offset = Weed.weed_lib.get_result_offset(self.mid)
|
|
115
|
+
|
|
116
|
+
data_out = (ctypes.c_double * d_size_out)() if dtype_out == DType.REAL else (ctypes.c_double * (d_size_out << 1))()
|
|
117
|
+
Weed.weed_lib.get_result(self.mid, data_out)
|
|
118
|
+
|
|
119
|
+
self._throw_if_error()
|
|
120
|
+
|
|
121
|
+
shape_ptr = ctypes.cast(shape_out, ctypes.POINTER(ctypes.c_longlong))
|
|
122
|
+
stride_ptr = ctypes.cast(stride_out, ctypes.POINTER(ctypes.c_longlong))
|
|
123
|
+
double_ptr = ctypes.cast(data_out, ctypes.POINTER(ctypes.c_double))
|
|
124
|
+
|
|
125
|
+
if dtype_out == DType.REAL:
|
|
126
|
+
data = double_ptr[:d_size_out]
|
|
127
|
+
else:
|
|
128
|
+
data = []
|
|
129
|
+
for i in range(d_size_out):
|
|
130
|
+
j = i << 1
|
|
131
|
+
complex_num = complex(double_ptr[j], double_ptr[j + 1])
|
|
132
|
+
data.append(complex_num)
|
|
133
|
+
|
|
134
|
+
del double_ptr
|
|
135
|
+
del data_out
|
|
136
|
+
|
|
137
|
+
return WeedTensor(data, shape_ptr[:n], stride_ptr[:n], dtype_out, d_offset)
|
|
138
|
+
|
|
139
|
+
# Drafted by (Anthropic) Claude, improved by Dan Strano (iteratively)
|
|
140
|
+
def train_step(self, input_ids, target_ids, learning_rate):
|
|
141
|
+
"""
|
|
142
|
+
Single fine-tuning step.
|
|
143
|
+
input_ids: list[int] — token ids for input sequence
|
|
144
|
+
target_ids: list[int] — token ids for targets (typically input shifted by 1)
|
|
145
|
+
"""
|
|
146
|
+
seq_len = len(input_ids)
|
|
147
|
+
|
|
148
|
+
Weed.weed_lib.train_step(
|
|
149
|
+
self.mid,
|
|
150
|
+
1, # n: number of shape dims
|
|
151
|
+
WeedModule._ulonglong_byref([seq_len]), # shape: [seq_len]
|
|
152
|
+
WeedModule._longlong_byref(input_ids), # input_ids
|
|
153
|
+
len(target_ids), # n_target
|
|
154
|
+
WeedModule._longlong_byref(target_ids), # target_ids
|
|
155
|
+
ctypes.c_double(learning_rate) # learning_rate
|
|
156
|
+
)
|
|
157
|
+
self._throw_if_error()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Weed is for minimalist AI/ML inference and backprogation in the style of
|
|
4
|
+
# Qrack.
|
|
5
|
+
#
|
|
6
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
8
|
+
|
|
9
|
+
from .weed_system import WeedSystem
|
|
10
|
+
|
|
11
|
+
# Global entry-point for Weed shared library
|
|
12
|
+
Weed = WeedSystem()
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Weed is for minimalist AI/ML inference and backprogation in the style of
|
|
4
|
+
# Qrack.
|
|
5
|
+
#
|
|
6
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from ctypes import *
|
|
11
|
+
from sys import platform as _platform
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WeedSystem:
|
|
15
|
+
def __init__(self):
|
|
16
|
+
shared_lib_path = ""
|
|
17
|
+
if os.environ.get("WEED_SHARED_LIB_PATH") != None:
|
|
18
|
+
shared_lib_path = os.environ.get("WEED_SHARED_LIB_PATH")
|
|
19
|
+
elif _platform == "win32":
|
|
20
|
+
shared_lib_path = os.path.dirname(__file__) + "/weed_lib/weed_shared.dll"
|
|
21
|
+
elif _platform == "darwin":
|
|
22
|
+
shared_lib_path = os.path.dirname(__file__) + "/weed_lib/libweed_shared.dylib"
|
|
23
|
+
else:
|
|
24
|
+
shared_lib_path = os.path.dirname(__file__) + "/weed_lib/libweed_shared.so"
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
self.weed_lib = CDLL(shared_lib_path)
|
|
28
|
+
except Exception as e:
|
|
29
|
+
if _platform == "win32":
|
|
30
|
+
shared_lib_path = "C:/Program Files (x86)/Weed/bin/weed_shared.dll"
|
|
31
|
+
elif _platform == "darwin":
|
|
32
|
+
shared_lib_path = "/usr/local/lib/weed/libweed_shared.dylib"
|
|
33
|
+
else:
|
|
34
|
+
shared_lib_path = "/usr/local/lib/weed/libweed_shared.so"
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
self.weed_lib = CDLL(shared_lib_path)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
if _platform == "win32":
|
|
40
|
+
shared_lib_path = "C:/Program Files (x86)/Weed/bin/weed_shared.dll"
|
|
41
|
+
elif _platform == "darwin":
|
|
42
|
+
shared_lib_path = "/usr/lib/weed/libweed_shared.dylib"
|
|
43
|
+
else:
|
|
44
|
+
shared_lib_path = "/usr/lib/weed/libweed_shared.so"
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
self.weed_lib = CDLL(shared_lib_path)
|
|
48
|
+
except Exception as e:
|
|
49
|
+
print(
|
|
50
|
+
"IMPORTANT: Did you remember to install OpenCL, if your Weed version was built with OpenCL?"
|
|
51
|
+
)
|
|
52
|
+
raise e
|
|
53
|
+
|
|
54
|
+
self.weed_lib.get_error.restype = c_int
|
|
55
|
+
self.weed_lib.get_error.argtypes = [c_ulonglong]
|
|
56
|
+
|
|
57
|
+
self.weed_lib.load_module.restype = c_ulonglong
|
|
58
|
+
self.weed_lib.load_module.argtypes = [c_char_p]
|
|
59
|
+
|
|
60
|
+
self.weed_lib.save_module.restype = c_ulonglong
|
|
61
|
+
self.weed_lib.save_module.argtypes = [c_ulonglong, c_char_p]
|
|
62
|
+
|
|
63
|
+
self.weed_lib.free_module.restype = None
|
|
64
|
+
self.weed_lib.free_module.argtypes = [c_ulonglong]
|
|
65
|
+
|
|
66
|
+
self.weed_lib.forward.restype = None
|
|
67
|
+
self.weed_lib.forward.argtypes = [
|
|
68
|
+
c_ulonglong,
|
|
69
|
+
c_ulonglong,
|
|
70
|
+
c_ulonglong,
|
|
71
|
+
POINTER(c_ulonglong),
|
|
72
|
+
POINTER(c_double)
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
self.weed_lib.forward_int.restype = None
|
|
76
|
+
self.weed_lib.forward_int.argtypes = [
|
|
77
|
+
c_ulonglong,
|
|
78
|
+
c_ulonglong,
|
|
79
|
+
c_ulonglong,
|
|
80
|
+
POINTER(c_ulonglong),
|
|
81
|
+
POINTER(c_longlong)
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
self.weed_lib.get_result_index_count.restype = c_ulonglong
|
|
85
|
+
self.weed_lib.get_result_index_count.argtypes = [c_ulonglong]
|
|
86
|
+
|
|
87
|
+
self.weed_lib.get_result_dims.restype = None
|
|
88
|
+
self.weed_lib.get_result_dims.argtypes = [
|
|
89
|
+
c_ulonglong,
|
|
90
|
+
POINTER(c_ulonglong),
|
|
91
|
+
POINTER(c_ulonglong)
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
self.weed_lib.get_result_size.restype = c_ulonglong
|
|
95
|
+
self.weed_lib.get_result_size.argtypes = [c_ulonglong]
|
|
96
|
+
|
|
97
|
+
self.weed_lib.get_result_offset.restype = c_ulonglong
|
|
98
|
+
self.weed_lib.get_result_offset.argtypes = [c_ulonglong]
|
|
99
|
+
|
|
100
|
+
self.weed_lib.get_result_type.restype = c_ulonglong
|
|
101
|
+
self.weed_lib.get_result_type.argtypes = [c_ulonglong]
|
|
102
|
+
|
|
103
|
+
self.weed_lib.get_result.restype = None
|
|
104
|
+
self.weed_lib.get_result.argtypes = [
|
|
105
|
+
c_ulonglong,
|
|
106
|
+
POINTER(c_double)
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
self.weed_lib.train_step.restype = None
|
|
110
|
+
self.weed_lib.train_step.argtypes = [
|
|
111
|
+
c_ulonglong,
|
|
112
|
+
c_ulonglong,
|
|
113
|
+
POINTER(c_ulonglong),
|
|
114
|
+
POINTER(c_longlong),
|
|
115
|
+
c_ulonglong,
|
|
116
|
+
POINTER(c_longlong),
|
|
117
|
+
c_double
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
self.weed_lib.reset_kv_cache.restype = None
|
|
121
|
+
self.weed_lib.reset_kv_cache.argtypes = [c_ulonglong]
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
4
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
5
|
+
|
|
6
|
+
import ctypes
|
|
7
|
+
|
|
8
|
+
from .dtype import DType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class WeedTensor:
|
|
12
|
+
"""Container to hold tensor inputs and outputs
|
|
13
|
+
|
|
14
|
+
This is a "dumb" container that performs no math.
|
|
15
|
+
All it does is validate that (column-major) data
|
|
16
|
+
dimension matches "shape" and "stride."
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
offset(int): Offset into data storage
|
|
20
|
+
shape(List[int]): Shape of tensor indices
|
|
21
|
+
stride(List[int]): Stride of tensor storage
|
|
22
|
+
data(List): Real or complex data values
|
|
23
|
+
dtype(DType): Real or complex type of data
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, data, shape, stride=None, dtype=DType.REAL, offset=0):
|
|
27
|
+
if stride is None:
|
|
28
|
+
st = 1
|
|
29
|
+
stride = []
|
|
30
|
+
for i in range(len(stride)):
|
|
31
|
+
stride.append(st)
|
|
32
|
+
st *= shape[i]
|
|
33
|
+
else:
|
|
34
|
+
if len(shape) != len(stride):
|
|
35
|
+
raise ValueError("WeedTensor shape length must match stride length!")
|
|
36
|
+
st = 1
|
|
37
|
+
for i in range(len(stride)):
|
|
38
|
+
if stride[i] == 0:
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
if stride[i] != st:
|
|
42
|
+
raise ValueError("WeedTensor shape and stride must be contiguous!")
|
|
43
|
+
|
|
44
|
+
st *= shape[i]
|
|
45
|
+
|
|
46
|
+
sz = offset
|
|
47
|
+
for i in range(len(stride)):
|
|
48
|
+
sz += (shape[i] - 1) * stride[i]
|
|
49
|
+
|
|
50
|
+
if len(shape):
|
|
51
|
+
sz = sz + 1
|
|
52
|
+
|
|
53
|
+
if sz > len(data):
|
|
54
|
+
raise ValueError("WeedTensor shape and stride do not match data length!")
|
|
55
|
+
|
|
56
|
+
self.offset = offset
|
|
57
|
+
self.data = data
|
|
58
|
+
self.shape = shape
|
|
59
|
+
self.stride = stride
|
|
60
|
+
self.dtype = dtype
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weed_loader_cpu
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Weed (Loader) - Minimalist AI/ML inference and backprogation
|
|
5
|
+
Home-page: https://github.com/vm6502q/weed
|
|
6
|
+
Author: Daniel Strano
|
|
7
|
+
Author-email: stranoj@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: weed ai ml inference gpu opencl
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: C++
|
|
17
|
+
Classifier: Programming Language :: Python :: 2
|
|
18
|
+
Classifier: Programming Language :: Python :: 2.5
|
|
19
|
+
Classifier: Programming Language :: Python :: 2.6
|
|
20
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.0
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.1
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.2
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: author-email
|
|
42
|
+
Dynamic: classifier
|
|
43
|
+
Dynamic: description
|
|
44
|
+
Dynamic: description-content-type
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: license
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
Dynamic: summary
|
|
50
|
+
|
|
51
|
+
<img width="1536" height="1024" alt="weed_logo" src="https://github.com/vm6502q/weed/blob/main/weed_logo.png" />
|
|
52
|
+
|
|
53
|
+
# Weed
|
|
54
|
+
Minimalist AI/ML inference and backprogation in the style of [Qrack](https://github.com/unitaryfoundation/qrack)
|
|
55
|
+
|
|
56
|
+
## Weed Loader
|
|
57
|
+
This repository is for the **Python loader** for (C++) Weed models. Once you have trained models in C++, you can load them for use by Python with this project. See the [Weed repository](https://github.com/vm6502q/weed) for more information.
|
|
58
|
+
|
|
59
|
+
## Development Status
|
|
60
|
+
**Weed** is a rapidly-developing **work-in-progress**. Its ABI may change drastically and without notice.
|
|
61
|
+
|
|
62
|
+
The project provides a set of essential CPU and GPU **kernels**, used by `Tensor` instances that perform _autograd._ We also provide _stochastic gradient descent (SGD)_ and _Adam_ optimizer implementations. (Build and check the API reference to get started.)
|
|
63
|
+
|
|
64
|
+
GPT-2, BERT, and Qwen loading is experimental and mostly provided as proof-of-concept, also of the fine-tuning pipeline. Implementation was from published literature design, rather than direct analysis of any open source, to implement these model architectures. Their outputs, in **Weed**, are not yet coherent English, as a result.
|
|
65
|
+
|
|
66
|
+
## Why try Weed?
|
|
67
|
+
|
|
68
|
+
With the growing popularity of AI/ML tools and workflows (including LLMs), legacy frameworks often carry "code debt" from over a decade of rapidly developing research history. This has led them to "bolt on" new features and advancements to design principles decided before the latest research. Popular frameworks also commonly started based in Python (maybe to capture early adoption), only later potentially "tacking on" a C++ library for special-case deployment needs. These conditions have produced libraries and frameworks with complicated dependency trees that occupy upward of a GB of disk footprint. This entire ecosystem might be due for a "refresh."
|
|
69
|
+
|
|
70
|
+
**Weed** does not seek to fully replace or supplant established frameworks. However, it aims for **minimalist complete closure** on the primitives necessary for high-performance AI/ML inference and back-propagation. Chiefly, this includes **kernels**, and a `Tensor` interface that immediately produces an **autograd** graph appropriate for training. Allowing **optional** OpenCL for **hardware acceleration**, it will remain **free of required dependencies** outside of C++(11) language standard.
|
|
71
|
+
|
|
72
|
+
Rethinking AI/ML library design this way, `Weed` has realized a rather unique and powerful form of _sparsification_ of `Tensor` **storage**. _Sparseness_ should **not** be a **`Tensor` interface concern**, but rather a **`Storage` concern**. Inspired by the design of the [Qrack](https://github.com/unitaryfoundation/qrack) quantum computer simulation framework, the `Tensor` interface treats **sparse and dense** tensors as **functionally equivalent**. Sparse optimization is so "transparently streamlined," this way, that it defaults to enabled for CPU-based tensors, and we recommend you leave it enabled at all times.
|
|
73
|
+
|
|
74
|
+
Much like `Qrack`, `Weed` is designed to make the correct thing the default—and the expensive thing explicit.
|
|
75
|
+
|
|
76
|
+
## Copyright, License, and Acknowledgments
|
|
77
|
+
|
|
78
|
+
Copyright (c) Daniel Strano and the Qrack contributors 2017-2026. All rights reserved.
|
|
79
|
+
|
|
80
|
+
In its `include/common` folder, Weed bundles a copy of [`rapidcsv` by Kristofer Berggren](https://github.com/d99kris/rapidcsv), reused under a BSD 3-Clause License. (This is a convenience and suggestion to Weed's users, for loading CSVs.)
|
|
81
|
+
|
|
82
|
+
The Weed logo was produced with assistance from "Elara," an OpenAI custom GPT, and it is in the **public domain**. Elara has also been responsible for a huge amount of coaching and implementation drafts for Dan Strano to review and bring into line with standards, so she should be credited with coauthorship in any capacity that can be allowed. (Anthropic) Claude has also helped mostly with debugging, as well as developing an LLM front-end, fine-tuning interface, and modules for popular transformer model architectures, so they should rightly be credited similarly as a coauthor.
|
|
83
|
+
|
|
84
|
+
Licensed under the GNU Lesser General Public License V3.
|
|
85
|
+
|
|
86
|
+
See [LICENSE.md](https://github.com/vm6502q/qrack/blob/main/LICENSE.md) in the project root or https://www.gnu.org/licenses/lgpl-3.0.en.html for details.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
Makefile
|
|
4
|
+
README.md
|
|
5
|
+
pyproject.toml
|
|
6
|
+
setup.py
|
|
7
|
+
weed_loader/__init__.py
|
|
8
|
+
weed_loader/dtype.py
|
|
9
|
+
weed_loader/weed_module.py
|
|
10
|
+
weed_loader/weed_tensor.py
|
|
11
|
+
weed_loader/weed_system/__init__.py
|
|
12
|
+
weed_loader/weed_system/weed_system.py
|
|
13
|
+
weed_loader_cpu.egg-info/PKG-INFO
|
|
14
|
+
weed_loader_cpu.egg-info/SOURCES.txt
|
|
15
|
+
weed_loader_cpu.egg-info/dependency_links.txt
|
|
16
|
+
weed_loader_cpu.egg-info/not-zip-safe
|
|
17
|
+
weed_loader_cpu.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
weed_loader
|