Contributing¶
Thank you for your interest in contributing to TurboQuantCPU! We welcome contributions from the community.
Getting Started¶
- Fork the repository on GitHub
- Clone your fork locally
- Create a new branch for your feature or fix
git clone https://github.com/2796gaurav/turboquantcpu.git
cd turboquantcpu
git checkout -b feature/your-feature-name
Development Setup¶
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Build C extensions
python setup.py build_ext --inplace
Code Style¶
- Follow PEP 8 for Python code
- Use type hints where applicable
- Add docstrings in Google style
- Keep functions focused and small
Testing¶
All contributions must include tests:
# Run all tests
pytest tests/ -v
# Run specific test
pytest tests/test_correctness.py::TestQJL::test_unbiasedness -v
# Run with coverage
pytest tests/ --cov=turboquantcpu --cov-report=html
Adding New Features¶
Adding a New Quantizer¶
- Create a new file in
turboquantcpu/ - Implement the quantizer class
- Add tests in
tests/ - Update documentation
Example structure:
# turboquantcpu/my_quantizer.py
from dataclasses import dataclass
import numpy as np
@dataclass
class MyQuantizerState:
"""State for my quantizer."""
data: np.ndarray
def memory_bytes(self) -> int:
return self.data.nbytes
class MyQuantizer:
"""My awesome quantizer."""
def __init__(self, head_dim: int, num_heads: int):
self.head_dim = head_dim
self.num_heads = num_heads
def compress(self, keys: np.ndarray) -> MyQuantizerState:
"""Compress keys."""
# Implementation
pass
def scores(self, query: np.ndarray, state: MyQuantizerState) -> np.ndarray:
"""Compute scores."""
# Implementation
pass
Adding C Kernels¶
- Add function to
turboquantcpu/_kernels/kernels.c - Add Python binding in
turboquantcpu/fwht.py - Update CPU detection if needed
Documentation¶
- Update README.md for user-facing changes
- Add docstrings to all public APIs
- Update docs/ for significant features
- Run
mkdocs serveto preview docs locally
Pull Request Process¶
- Update README.md with details of changes if applicable
- Add tests for new functionality
- Ensure all tests pass
- Update documentation
- Submit PR with clear description
Commit Messages¶
Follow conventional commits:
feat:New featurefix:Bug fixdocs:Documentation changestest:Test changesrefactor:Code refactoringperf:Performance improvements
Example:
feat: add PolarQuant algorithm
Implement PolarQuant for outlier-resistant quantization.
- Add polar transformation after FWHT
- Rayleigh quantization for radius
- Uniform quantization for angle
Questions?¶
- Open an issue for bugs
- Start a discussion for features
- Email: 2796gaurav@gmail.com
Code of Conduct¶
Be respectful and constructive in all interactions.