Contributing to TurboQuant¶
Thanks for considering a contribution. This document captures the few conventions that keep the project pleasant to work in.
Setup¶
git clone https://github.com/Ademo93/turboquant
cd turboquant
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev,onnx,viz]"
pre-commit install
Running checks¶
The full GPU/slow suite is opt-in:
Adding a new quantization method¶
- Drop a module under
src/turboquant/quantization/your_method.pywith a single public functionquantize_your_method(model, **kw) -> nn.Module. - Register it in
src/turboquant/quantization/__init__.py(_REGISTRY). - Add it to the
Methodliteral type. - Write a unit test in
tests/test_quantization.py(use thetiny_mlpfixture). - Document it in
docs/quantization.md. - If the backend depends on a heavy library, add a
[project.optional-dependencies]entry inpyproject.tomland useimportlib.import_modulelazily.
Coding style¶
- Keep modules short and readable. The goal is that each algorithm doubles as a reference for how the method works.
- Cite the original paper in the module docstring.
- Prefer explicit kwargs over
**kwdicts in public APIs. - No top-level imports of optional heavy dependencies (bitsandbytes, auto-gptq, tensorrt). Defer them inside functions.
Pull request checklist¶
- [ ] Tests pass:
pytest -m "not slow and not gpu" - [ ] Lint passes:
ruff check src tests && ruff format --check src tests - [ ] New public APIs documented under
docs/ - [ ] If adding a backend, it degrades cleanly when its optional dependency
is missing (raises
ImportErrorwith install instructions)