summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM. Yusuf Sarıgöz <yusufsarigoz@gmail.com>2023-08-25 09:26:05 +0300
committerGitHub <noreply@github.com>2023-08-25 09:26:05 +0300
commit87e3733f24a85d894cc16e1cbdfa1ea1e81a76f3 (patch)
tree8d43c8ff2bdcbf8e5152b0e21541dce56003fde8
parentb91ad7f46134d0d051dc516eb59a76f402de55c2 (diff)
gguf : make gguf pip-installable
* gitignore : add dist and rm pyproject.toml * gguf: prepare as Pip package * gguf: prepare as Pip package * gguf : fix line endings * requirements : add gguf * gguf : update readme with build notes * gguf : update readme with build notes * gguf : add notes for tests
-rw-r--r--.gitignore2
-rw-r--r--gguf-py/LICENSE21
-rw-r--r--gguf-py/README.md55
-rw-r--r--gguf-py/gguf/__init__.py1
-rw-r--r--[-rwxr-xr-x]gguf-py/gguf/gguf.py (renamed from gguf.py)0
-rw-r--r--gguf-py/pyproject.toml28
-rw-r--r--gguf-py/tests/test_gguf.py7
-rw-r--r--requirements.txt1
8 files changed, 114 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index f3121794..6cb7d9bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,6 +60,7 @@ compile_commands.json
CMakeSettings.json
__pycache__
+dist
zig-out/
zig-cache/
@@ -70,7 +71,6 @@ perf-*.txt
examples/jeopardy/results.txt
-pyproject.toml
poetry.lock
poetry.toml
diff --git a/gguf-py/LICENSE b/gguf-py/LICENSE
new file mode 100644
index 00000000..76f67efd
--- /dev/null
+++ b/gguf-py/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Georgi Gerganov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/gguf-py/README.md b/gguf-py/README.md
new file mode 100644
index 00000000..03ad306e
--- /dev/null
+++ b/gguf-py/README.md
@@ -0,0 +1,55 @@
+## gguf
+
+This is a Python package for writing binary files in the [GGUF](https://github.com/ggerganov/ggml/pull/302)
+(GGML Universal File) format.
+
+See [convert-llama-hf-to-gguf.py](https://github.com/ggerganov/llama.cpp/blob/master/convert-llama-hf-to-gguf.py)
+as an example for its usage.
+
+## Installation
+```sh
+pip install gguf
+```
+
+## Development
+Maintainers who participate in development of this package are advised to install it in editable mode:
+
+```sh
+cd /path/to/llama.cpp/gguf-py
+
+pip install --editable .
+```
+
+**Note**: This may require to upgrade your Pip installation, with a message saying that editable installation currently requires `setup.py`.
+In this case, upgrade Pip to the latest:
+
+```sh
+pip install --upgrade pip
+```
+
+## Publishing
+To publish the package, you need to have `twine` and `build` installed:
+
+```sh
+pip install build twine
+```
+
+Then, folow these steps to release a new version:
+
+1. Update the version in `pyproject.toml`.
+2. Build the package:
+
+```sh
+python -m build
+```
+
+3. Upload the generated distribution archives:
+
+```sh
+python -m twine upload dist/*
+```
+
+## TODO
+- [ ] Add tests
+- [ ] Include conversion scripts as command line entry points in this package.
+- Add CI workflow for releasing the package.
diff --git a/gguf-py/gguf/__init__.py b/gguf-py/gguf/__init__.py
new file mode 100644
index 00000000..718ea71e
--- /dev/null
+++ b/gguf-py/gguf/__init__.py
@@ -0,0 +1 @@
+from .gguf import GGUFWriter
diff --git a/gguf.py b/gguf-py/gguf/gguf.py
index f4db7001..f4db7001 100755..100644
--- a/gguf.py
+++ b/gguf-py/gguf/gguf.py
diff --git a/gguf-py/pyproject.toml b/gguf-py/pyproject.toml
new file mode 100644
index 00000000..a6bce946
--- /dev/null
+++ b/gguf-py/pyproject.toml
@@ -0,0 +1,28 @@
+[tool.poetry]
+name = "gguf"
+version = "0.2.0"
+description = "Write ML models in GGUF for GGML"
+authors = ["GGML <ggml@ggml.ai>"]
+packages = [
+ {include = "gguf"},
+]
+readme = "README.md"
+homepage = "https://ggml.ai"
+repository = "https://github.com/ggerganov/llama.cpp"
+keywords = ["ggml", "gguf", "llama.cpp"]
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+]
+
+[tool.poetry.dependencies]
+python = ">=3.8"
+numpy = ">=1.17"
+
+[tool.poetry.dev-dependencies]
+pytest = "^5.2"
+
+[build-system]
+requires = ["poetry-core>=1.0.0"]
+build-backend = "poetry.core.masonry.api"
diff --git a/gguf-py/tests/test_gguf.py b/gguf-py/tests/test_gguf.py
new file mode 100644
index 00000000..512531dd
--- /dev/null
+++ b/gguf-py/tests/test_gguf.py
@@ -0,0 +1,7 @@
+import gguf
+
+# TODO: add tests
+
+
+def test_write_gguf():
+ pass
diff --git a/requirements.txt b/requirements.txt
index 6c32cbd0..7dc51edb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
numpy==1.24
sentencepiece==0.1.98
+gguf>=0.1.0