Skip to content

Contributing to Tangent

Thanks for your interest in contributing! This repository is a maintained fork of Google's Tangent; development happens here via ordinary GitHub pull requests — there is no CLA.

Getting set up

git clone https://github.com/pedronahum/tangent.git
cd tangent
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt   # core deps + pytest + the autograd test oracle
pytest tests/                     # the core suite needs no optional backends

The suite must pass with no optional backends installed — backend-specific tests skip cleanly when their library is absent. To exercise a backend, install it (e.g. pip install jax) and rerun; tests/test_backend_coverage.py picks up every installed backend automatically.

Formatting and linting

CI enforces two ruff gates: ruff check . (lint) and ruff format --check . (formatting). Run both locally with:

make check      # exactly what CI runs: ruff check + ruff format --check
make fmt        # auto-format and auto-fix before committing

ruff is version-sensitive (formatter output can change between releases), so CI pins ruff==0.16.6; make install-dev installs that pinned version along with pre-commit. To catch the gates automatically on every commit, install the git hooks once:

make install-dev   # pip install -e ".[dev,test]"
make hooks         # pre-commit install

Scope and rules live in [tool.ruff] in pyproject.toml (the library and tests are formatted; docs/, examples/ and benchmarks/ keep their hand-laid layout), so the Makefile targets and the pre-commit hook stay in sync with CI.

Adding new derivatives

To add a derivative for a primitive operation:

Other functionality

If you've fixed a bug or built an enhancement, open a PR. For larger feature work, open a GitHub issue first to discuss the approach — the docs/ tree records design notes for several subsystems (checkpointing, optimizations, backend coverage) that are worth reading before touching those areas.