Thank you for your interest in contributing to RustyGradients! This document provides guidelines for contributing.
- Rust 1.70+ (stable)
- Git
# Clone the repository
git clone https://github.com/Xzdes/RustyGradients.git
cd RustyGradients
# Build with default features
cargo build --features "cpu serialization"
# Run tests
cargo test --lib --features "cpu serialization"master- stable release branch- Feature branches:
feature/your-feature-name - Bug fixes:
fix/issue-description
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run tests:
cargo test --lib --features "cpu serialization" - Run clippy:
cargo clippy --features "cpu serialization" - Format code:
cargo fmt - Commit with a clear message
- Push and create a Pull Request
Follow conventional commits:
feat: add new activation function
fix: correct gradient calculation in matmul
docs: update README with CUDA examples
test: add tests for tokenization module
refactor: simplify backend trait
- Use
cargo fmtbefore committing - Run
cargo clippyand address warnings - Write documentation for public APIs
- Add tests for new functionality
- Use
///for public API documentation - Use
//!for module-level documentation - Include examples in doc comments when helpful
# Unit tests only (fastest)
cargo test --lib --features "cpu serialization"
# All tests including integration
cargo test --features "cpu serialization"
# Specific test
cargo test test_name --features "cpu serialization"- Place unit tests in the same file using
#[cfg(test)]module - Use descriptive test names:
test_matmul_2d_shapes - Test edge cases and error conditions
Available features:
| Feature | Description |
|---|---|
cpu |
CPU backend with rayon parallelization (default) |
cpu-blas |
BLAS acceleration for matrix operations |
cuda |
NVIDIA GPU support via cuBLAS |
metal-backend |
Apple Silicon GPU support |
serialization |
Safetensors model format |
tokenization |
BPE and HuggingFace tokenizers |
huggingface |
HuggingFace Hub integration |
src/
├── backend/ # Multi-backend abstraction (CPU, CUDA, Metal)
├── core/ # Autograd and computational graph
├── nn/ # Neural network layers
├── ops/ # Tensor operations
├── models/ # Model implementations (GPT)
├── serialization/ # Model save/load (Safetensors)
├── tokenization/ # Tokenizers (BPE, HuggingFace)
└── error.rs # Error types
- Ensure all tests pass
- Update documentation if needed
- Add entry to CHANGELOG (if applicable)
- Request review from maintainers
- Tests pass locally
- Code is formatted (
cargo fmt) - No clippy warnings (
cargo clippy) - Documentation updated (if needed)
- Commit messages follow convention
- CUDA Backend - Optimize custom kernels
- Metal Backend - Apple Silicon support
- Model Zoo - Add LLaMA, Mistral, BERT
- Documentation - Tutorials and examples
Look for issues labeled good first issue on GitHub.
- Open an issue on GitHub
- Check existing documentation in
/docs
By contributing, you agree that your contributions will be licensed under the MIT License.