Thank you for your interest in contributing! This guide covers setup, deveopment workflow and testing processes in TGM. We also invite you to join the TGL slack group, where you can connect with the community and ask questions.
TGM requires Python 3.10.
We use uv to manage dependencies and provide a reproducible environment. If you don't have uv installed:
pip install uvNote
uv creates an isolated environment in .venv based on the lockfile uv.lock.
Most commands can be run by simply prepending uv run to the respective command:
- Instead of running
python <command>, you will runuv run python <command> - Instead of running
pytest, you will runuv run pytest
uv automatically resolves package versions while respecting existing dependencies.
Add or remove a core dependency:
uv add <package>
uv remove <package>Important
This updates pyproject.toml and uv.lock automatically, which should be committed.
Core dependencies should be kept to an absolute minimum. To add optional dependencies, uv has the notion of dependency groups. For instance, the dev group is the set of dependencies required for TGM development, but is not necessarily shipped to end-users of the library.
Add or remove a group dependency:
uv add --group <group> <package>
uv remove --group <group> <package>Tip
Any package on PyPI can be added, making uv a drop in replacement for pip. For complex use cases such as non-python dependencies, or installing specific package versions, consult the uv documentation.
Sometimes you may want to activate .venv manually (e.g., for IDE integration):
. .venv/bin/activate # bashNote: after doing so, you will have direct access to all executables (e.g. Python) as usual.
# Clone the repo
git clone https://github.com/tgm-team/tgm.git
cd tgm
# Install core dependencies
uv syncTGM includes pre-commit hooks for formatting, linting, static type analysis, and more.
The hooks can be installed by issuing:
uv run pre-commit installTip
Hooks can be bypassed with the --no-verify flag, but using them is strongly recommended.
The TGM test suite is organized into:
test/unit: unit teststest/integration: integration teststest/performance: performance tests
Run the entire (unit) test suite with
./scripts/run_unit_tests.shIntegration tests run periodicaly on our CI cluster to validate example correctness, latency, throughput and GPU usage.
To trigger manually:
./scripts/triger_integration_tests.shImportant
You will need to setup an auth key for permission to trigger remote jobs on our CI. Contact Jacob Chmura for details. At minimum, run examples locally to ensure nothing breaks.
Performance tests also run on our CI cluster to stress test various aspect of our core library. They can be triggered similar to our integration tests, assuming you have the permissions:
./scripts/trigger_perf_tests.shTo build (and serve) the documentation locally:
./scripts/build_docs.sh- Start by writing a new example akin to our previous examples, outside of TGM core.
- Next, add the example into our integration test harness. Request the minimal amount of resources needed.
- Once the harness is setup, we'll report some performance and efficiency numbers, to confirm the implementation is correct.
- If you have reusable components (hooks, layers, etc.) that are broadly useful, they may be migrated to TGM core. Note each addition must include unit tests and a justification for inclusion.
Before opening a Pull Request, please first open a new issue describing the feature you’d like to add or the bug you’d like to fix. Assign yourself to the issue so others know you’re working on it, and feel free to tag a core library developer if you’d like early feedback on your proposed approach.
Once you are ready to contribute code:
- Fork the repository and create a feature branch.
- Implement your changes and ensure that all tests pass locally
- Open a pull request referencing the related issue.
TGM uses Github Actions for continuous integration. Each PR will automatically be built and validated against the TGM guidelines. Please ensure all the automatic checks pass and then tag members of the core team for review and further discussion.