Skip to content

Commit 16f9f79

Browse files
committed
Initial import of pqk
0 parents  commit 16f9f79

59 files changed

Lines changed: 16713 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test-linux:
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install system dependencies
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y libopenblas-dev gfortran
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.13"
27+
28+
- name: Create virtualenv
29+
run: |
30+
python -m venv .venv
31+
echo "VIRTUAL_ENV=$PWD/.venv" >> "$GITHUB_ENV"
32+
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
33+
34+
- name: Install Python tooling
35+
run: |
36+
python -m pip install --upgrade pip
37+
python -m pip install maturin numpy pyarrow pytest scikit-learn
38+
39+
- name: Build extension
40+
run: python -m maturin develop --release
41+
42+
- name: Run Rust tests
43+
run: cargo test --release
44+
45+
- name: Run Python tests
46+
run: pytest -q
47+
48+
- name: Verify static-wheel feature set compiles
49+
run: cargo check --no-default-features --features openblas-static
50+
51+
test-macos-arm64:
52+
runs-on: macos-14
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- name: Install system dependencies
57+
run: |
58+
brew install gcc
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: "3.13"
64+
65+
- name: Create virtualenv
66+
run: |
67+
python -m venv .venv
68+
echo "VIRTUAL_ENV=$PWD/.venv" >> "$GITHUB_ENV"
69+
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
70+
71+
- name: Install Python tooling
72+
run: |
73+
python -m pip install --upgrade pip
74+
python -m pip install maturin numpy pyarrow pytest scikit-learn
75+
76+
- name: Build extension
77+
run: python -m maturin develop --release --no-default-features --features python,openblas-static
78+
79+
- name: Run Rust tests
80+
run: cargo test --release --no-default-features --features openblas-static
81+
82+
- name: Run Python tests
83+
run: pytest -q
84+
85+
lint:
86+
runs-on: ubuntu-24.04
87+
steps:
88+
- uses: actions/checkout@v4
89+
- name: Rust format check
90+
run: cargo fmt --check

.github/workflows/release.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
jobs:
14+
linux-wheels:
15+
runs-on: ubuntu-24.04
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
target:
20+
- x86_64-unknown-linux-gnu
21+
- aarch64-unknown-linux-gnu
22+
python-version: ["3.10", "3.11", "3.12", "3.13"]
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
if: matrix.target == 'aarch64-unknown-linux-gnu'
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Build wheel
31+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380
32+
with:
33+
maturin-version: v1.13.1
34+
target: ${{ matrix.target }}
35+
manylinux: "2_28"
36+
args: --release --locked --compatibility pypi --out dist --features openblas-static -i python${{ matrix.python-version }}
37+
38+
- name: Upload wheel artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: wheels-linux-${{ matrix.target }}-py${{ matrix.python-version }}
42+
path: dist/*
43+
44+
macos-wheels:
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
include:
49+
- runner: macos-13
50+
target: x86_64-apple-darwin
51+
- runner: macos-14
52+
target: aarch64-apple-darwin
53+
python-version: ["3.10", "3.11", "3.12", "3.13"]
54+
runs-on: ${{ matrix.runner }}
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set up Python
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
63+
- name: Install build dependencies
64+
run: |
65+
brew install gcc
66+
python -m pip install --upgrade pip
67+
python -m pip install maturin delocate
68+
69+
- name: Build wheel
70+
run: |
71+
python -m maturin build \
72+
--release \
73+
--locked \
74+
--features openblas-static \
75+
--out dist \
76+
-i python
77+
78+
- name: Repair wheel
79+
run: |
80+
mkdir -p wheelhouse
81+
if [[ "${{ matrix.target }}" == x86_64-* ]]; then
82+
ARCHS=x86_64
83+
else
84+
ARCHS=arm64
85+
fi
86+
for wheel in dist/*.whl; do
87+
delocate-wheel --require-archs "$ARCHS" -w wheelhouse "$wheel"
88+
done
89+
90+
- name: Upload wheel artifact
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: wheels-macos-${{ matrix.target }}-py${{ matrix.python-version }}
94+
path: wheelhouse/*
95+
96+
sdist:
97+
runs-on: ubuntu-24.04
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Build sdist
101+
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380
102+
with:
103+
maturin-version: v1.13.1
104+
command: sdist
105+
args: --out dist
106+
- name: Upload sdist artifact
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: sdist
110+
path: dist/*
111+
112+
github-release:
113+
if: startsWith(github.ref, 'refs/tags/')
114+
needs: [linux-wheels, macos-wheels, sdist]
115+
runs-on: ubuntu-24.04
116+
steps:
117+
- uses: actions/download-artifact@v4
118+
with:
119+
path: artifacts
120+
121+
- name: Create GitHub release
122+
uses: softprops/action-gh-release@v2
123+
with:
124+
files: artifacts/**/*
125+
126+
publish-pypi:
127+
if: startsWith(github.ref, 'refs/tags/')
128+
needs: [linux-wheels, macos-wheels, sdist]
129+
runs-on: ubuntu-24.04
130+
environment:
131+
name: pypi
132+
url: https://pypi.org/p/pqk
133+
steps:
134+
- uses: actions/download-artifact@v4
135+
with:
136+
path: artifacts
137+
138+
- name: Collect distribution files
139+
run: |
140+
mkdir -p dist
141+
find artifacts -type f \( -name '*.whl' -o -name '*.tar.gz' \) -exec cp {} dist/ \;
142+
ls -lh dist
143+
144+
- name: Publish to PyPI
145+
uses: pypa/gh-action-pypi-publish@release/v1
146+
with:
147+
packages-dir: dist

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/target
2+
/.artifacts
3+
/.benchmarks
4+
/.venv
5+
/.pytest_cache
6+
/python/pqk/__pycache__
7+
**/__pycache__/
8+
*.pyc
9+
*.pyo
10+
*.so
11+
*.dylib
12+
*.egg-info/

CONTRIBUTING.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing
2+
3+
## Local development
4+
5+
```bash
6+
python -m pip install maturin
7+
python -m pip install -e .[dev]
8+
python -m maturin develop --release
9+
```
10+
11+
## Verification
12+
13+
```bash
14+
cargo test --release
15+
pytest -q
16+
cargo check --no-default-features --features openblas-static
17+
cargo bench --bench core_bench
18+
```
19+
20+
## Benchmark workflow
21+
22+
```bash
23+
python scripts/benchmark_suite.py \
24+
--output-dir .artifacts/benchmark-suite \
25+
--baseline-python .artifacts/pqk-baseline/.artifacts/venv-baseline313/bin/python \
26+
--original-python "$(which python)" \
27+
--enhanced-python "$(which python)" \
28+
--blas-threads 1 \
29+
--omp-threads 1 \
30+
--rayon-threads 24 \
31+
--rotation-batch-mib 32
32+
```
33+
34+
## Release workflow
35+
36+
1. Update benchmark artifacts if the public performance story changed.
37+
2. Ensure `README.md`, the notebook, and `benchmarks/results/*.json` agree with the current implementation.
38+
3. Tag the release as `vX.Y.Z`.
39+
4. Push the tag to trigger `.github/workflows/release.yml`.
40+
5. Verify the uploaded GitHub release artifacts and the published PyPI files.

0 commit comments

Comments
 (0)