Contributing¶
Fast LiteLLM is maintained by Dipankar Sarkar at Neul Labs (me@dipankar.name). Contributions are welcome.
Prerequisites¶
- Python 3.8+ (3.12 recommended)
- Rust toolchain 1.70+ (
rustuprecommended) - uv for package management
- Git
Quick Setup¶
git clone https://github.com/neul-labs/fast-litellm.git
cd fast-litellm
# Run the setup script (installs uv if needed)
./scripts/setup_dev.sh
Manual Setup¶
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Create virtual environment
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
uv sync --all-extras
# Build Rust extensions (release build for performance)
uv run maturin develop --release
Development Workflow¶
-
Create a feature branch:
-
Rebuild after Rust changes:
-
Run tests:
-
Format and lint:
-
Commit using conventional commits:
Coding Standards¶
Rust¶
- Format with
cargo fmt - Lint with
cargo clippy -- -D warnings - Document public APIs with
///comments - Use
#[pyclass]and#[pymethods]for Python bindings
Python¶
- Format with
black(line length: 88) - Sort imports with
isort - Add type hints to public APIs
- Use Google-style docstrings
Testing¶
# Run all Python tests
uv run pytest tests/ -v
# Run a specific test file
uv run pytest tests/test_rust_acceleration.py -v
# Run Rust tests
cargo test
# Coverage
uv run pytest tests/ --cov=fast_litellm
# Benchmarks
python scripts/run_benchmarks.py --iterations 100
LiteLLM Integration Tests¶
# Setup LiteLLM for testing
./scripts/setup_litellm.sh
# Run LiteLLM tests with acceleration enabled
./scripts/run_litellm_tests.sh
# Compare performance with vs without acceleration
./scripts/compare_performance.py
Adding a New Rust Function¶
- Implement in
src/<module>.rs. - Export in
src/lib.rswith#[pyfunction](or#[pyclass]for types). - Register it inside the
#[pymodule]function. - Rebuild:
uv run maturin develop --release. - Add a Python wrapper in
fast_litellm/if needed. - Add tests in
tests/. - Run benchmarks to verify performance.
// src/lib.rs
#[pyfunction]
fn my_new_function(input: String) -> PyResult<String> {
Ok(format!("Processed: {}", input))
}
#[pymodule]
fn _rust(m: &Bound<'_, PyModule>) -> PyResult<()> {
// ... existing code ...
m.add_function(wrap_pyfunction!(my_new_function, m)?)?;
Ok(())
}
Pull Requests¶
Before opening a PR:
- Run the full test suite
- Ensure code is formatted (
cargo fmt,black,isort) - Run benchmarks; confirm no significant regressions
- Update documentation under
documentation/docs/when behaviour changes - Add tests for new functionality
Release Process¶
- Update version in
Cargo.toml(pyproject.tomlreads it dynamically via maturin). - Update
CHANGELOG.md. - Run the full benchmark suite and update
BENCHMARK.md. - Tag the release:
git tag v0.x.x && git push origin v0.x.x. - CI publishes to PyPI automatically.
Code of Conduct¶
Be respectful and constructive in all interactions.