Skip to content

Commit b5d8e9a

Browse files
authored
Merge pull request #4 from PrimeIntellect-ai/update-python-src
Update python src
2 parents cd06add + ee020f0 commit b5d8e9a

File tree

10 files changed

+78
-41
lines changed

10 files changed

+78
-41
lines changed

.github/workflows/cmake-multi-platform.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ jobs:
7373
shell: bash
7474
run: |
7575
. .venv/bin/activate
76-
cd ${{ github.workspace }}/python/src
76+
cd ${{ github.workspace }}/python/
7777
pip wheel --verbose -w dist .
7878
7979
- name: Install Python wheel
8080
if: runner.os != 'windows'
8181
shell: bash
8282
run: |
8383
. .venv/bin/activate
84-
pip install ${{ github.workspace }}/python/src/dist/*.whl
84+
pip install ${{ github.workspace }}/python/dist/*.whl
8585
8686
- name: Install Pytest
8787
if: runner.os != 'windows'
File renamed without changes.

python/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Fast Quant
2+
3+
Fast Quant is a Python package that provides a fast and efficient way to quantize and dequantize data. It is designed to be used in conjunction with the Fast Quant library.
4+
5+
## Installation
6+
7+
```bash
8+
git clone <>
9+
cd python
10+
pip install .
11+
```
12+
13+
## Development
14+
15+
clone the repository
16+
```bash
17+
git clone <>
18+
cd python
19+
```
20+
21+
install the package with the tests dependency
22+
```bash
23+
pip install -e .[dev]
24+
```
25+
26+
install pre-commit hooks
27+
```bash
28+
pre-commit install
29+
```
30+
31+
run the tests
32+
```bash
33+
pytest tests
34+
```
35+
File renamed without changes.

python/pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "fast-quant"
7+
version = "0.1.0"
8+
authors = [
9+
{name = "Mario Sieg", email = "[email protected]"},
10+
]
11+
description = "Multithreaded SIMD int8 and int4 quantization kernels."
12+
dependencies = ["cffi"]
13+
14+
[project.optional-dependencies]
15+
dev = ["pytest","torch","numpy","pre-commit","ruff"]
16+
17+
[tool.ruff]
18+
line-length = 120
19+
target-version = "py38"
20+
21+
[tool.ruff.lint]
22+
ignore = ["F403"]
23+
select = ["ANN"]
24+
25+
[tool.ruff.format]
26+
quote-style = "single"
27+
28+
[tool.ruff.lint.per-file-ignores]
29+
"setup.py" = ["ANN"]
Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from setuptools.command.build_ext import build_ext
99

1010
CMAKE_ROOT: str = os.path.abspath(
11-
os.path.join(os.path.dirname(__file__), '..', '..')
12-
) # Root directory of the CMake project
11+
os.path.join(os.path.dirname(__file__), "..") # Go up one directory to find CMakeLists.txt
12+
)
1313
NUM_JOBS: int = max(multiprocessing.cpu_count() - 1, 1) # Use all but one core
1414

1515

@@ -41,10 +41,13 @@ def run(self):
4141
self.build_extension(ext)
4242

4343
def build_extension(self, ext):
44-
if not os.path.exists(self.build_temp):
45-
os.makedirs(self.build_temp)
44+
if os.path.exists(self.build_temp):
45+
import shutil
46+
shutil.rmtree(self.build_temp)
47+
os.makedirs(self.build_temp)
48+
4649
cmake_args = [
47-
f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={os.path.abspath(os.path.join(self.build_lib, "quant"))}',
50+
f'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={os.path.abspath(os.path.join(self.build_lib, "src", "quant"))}',
4851
'-DCMAKE_BUILD_TYPE=Release',
4952
]
5053
build_args = [
@@ -62,32 +65,16 @@ def build_extension(self, ext):
6265
['cmake', '--build', '.'] + build_args, cwd=self.build_temp
6366
)
6467
)
65-
66-
67-
# Setup dependencies from requirements.txt
68-
lib_folder = os.path.dirname(os.path.realpath(__file__))
69-
requirement_path = f'{lib_folder}/requirements.txt'
70-
install_requires = []
71-
if os.path.isfile(requirement_path):
72-
with open(requirement_path) as f:
73-
install_requires = f.read().splitlines()
74-
68+
7569
setup(
76-
name='fast-quant',
77-
version='0.1.0',
78-
author='Mario Sieg',
79-
author_email='[email protected]',
80-
description='Multithreaded SIMD int8 and int4 quantization kernels.',
81-
long_description='Multithreaded SIMD int8 and int4 quantization kernels.',
82-
packages=['quant'],
70+
packages=['src.quant'],
8371
package_data={
84-
'quant': ['*.dylib', '*.so', '*.dll'],
72+
'src.quant': ['*.dylib', '*.so', '*.dll'],
8573
},
8674
include_package_data=True,
8775
ext_modules=[CMakeBuildExtension('quant', root_dir=CMAKE_ROOT)],
8876
cmdclass={
8977
'build_ext': CMakeBuildExecutor,
9078
},
91-
zip_safe=False,
92-
install_requires=install_requires,
79+
zip_safe=False
9380
)

python/src/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/src/ruff.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

python/test/requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)