Contributing
Grilly is open source under the MIT license. Contributions are welcome.
Getting Started
- Fork the repository
- Clone and install in development mode:
git clone https://github.com/YOUR_USERNAME/grilly.git
cd grilly
pip install -e ".[dev]"
- Build the C++ backend (see Installation)
Development Workflow
- Create a feature branch from
main - Write code and tests
- Run linting and tests
- Submit a pull request
Code Style
- Line length: 100 characters
- Formatter: Black (
black . --check) - Linter: Ruff (
ruff check .) - Import sorting: isort with Black profile (
isort . --check-only) - Type checking: mypy (
mypy .) - Target Python: 3.12
# Run all checks
ruff check .
black . --check
isort . --check-only
mypy .
Testing
# All tests (requires Vulkan)
uv run pytest tests/ -v
# CPU-only tests (no GPU needed)
uv run pytest tests/ -m "not gpu" -v
# With coverage
uv run pytest tests/ --cov=. --cov-report=term
# Single test
pytest tests/test_snn.py -k "test_lif"
GPU tests auto-skip when Vulkan is unavailable. The gpu_backend fixture in tests/conftest.py handles this.
Adding a New Layer
- Create the GLSL shader in
shaders/(forward + backward) - Compile to SPIR-V:
glslc shader.glsl -o spv/shader.spv - Add the backend dispatch in
backend/(bridge function or VulkanCompute method) - Create the
nn.Modulesubclass innn/ - Add functional API wrapper in
functional/ - Write tests in
tests/ - Export from
nn/__init__.pyandfunctional/__init__.py
File Organization Rules
- Maximum 1000 lines per file
- Proper OOP -- no God classes
- Always edit existing files rather than creating duplicates
- Each
nn.Modulein its own file (or grouped by category)
Pull Request Checklist
- [ ] Tests pass:
uv run pytest tests/ -v - [ ] Linting passes:
ruff check . - [ ] New features have tests
- [ ] New public API is exported from
__init__.py - [ ] Shaders compiled to SPIR-V and included
Reporting Issues
File issues at github.com/grillcheese-ai/grilly/issues. Include:
- Grilly version (
python -c "import grilly; print(grilly.__version__)") - GPU model and driver version (
vulkaninfo --summary) - OS and Python version
- Minimal reproduction steps