# Contributing to torchrl We want to make contributing to this project as easy and transparent as possible. ## Installing the library Install the library as suggested in the README. For advanced features, it is preferable to install the nightly built of pytorch. TorchRL and TensorDict are being developed jointly. Stable releases are tied together such that you can safely install the latest version of both libraries. For TorchRL development, we recommend installing tensordict nightly ``` pip install tensordict-nightly ``` or the git version of the library: ``` pip install git+https://github.com/pytorch/tensordict ``` This command requires `pybind11[global]` and cmake to be installed. Once cloned, make sure you install torchrl in develop mode by running ``` python setup.py develop ``` in your shell. ### Local development with uv For a local development environment, you can also use [`uv`](https://docs.astral.sh/uv/). From the root of the cloned repository, run tests with ```shell uv run pytest test/test_tensordictmodules.py ``` `uv run` creates and manages a local virtual environment, installs TorchRL in editable mode, installs TensorDict from the PyTorch GitHub repository, and includes the `dev` dependency group by default. The `dev` group is intended to cover common low-friction development dependencies such as Gym, Gymnasium, Hydra, MuJoCo, pytest, TensorBoard, tqdm, and Weights & Biases. By default, the local `uv` configuration installs PyTorch nightly wheels from the CPU nightly index on all platforms. The PyTorch index is marked as explicit, so unrelated packages continue to resolve from PyPI instead of the PyTorch wheel index. On Linux machines where you want CUDA 13.0 nightly wheels, override the named PyTorch index used by the local configuration: ```shell uv run --index pytorch-nightly=https://download.pytorch.org/whl/nightly/cu130 pytest test/test_tensordictmodules.py ``` If the generation of this artifact in MacOs M1 doesn't work correctly or in the execution the message `(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))` appears, then try ``` ARCHFLAGS="-arch arm64" python setup.py develop ``` ## Formatting your code **Type annotation** TorchRL is not strongly-typed, i.e. we do not enforce type hints, neither do we check that the ones that are present are valid. We rely on type hints purely for documentary purposes. Although this might change in the future, there is currently no need for this to be enforced at the moment. **Linting** Before your PR is ready, you'll probably want your code to be checked. This can be done easily by installing ``` pip install pre-commit ``` and running ``` pre-commit run --all-files ``` from within the torchrl cloned directory. You can also install [pre-commit hooks](https://pre-commit.com/) (using `pre-commit install` ). You can disable the check by appending `-n` to your commit command: `git commit -m -n` ## Pull Requests We actively welcome your pull requests. 1. Fork the repo and create your branch from `main`. 2. If you've added code that should be tested, add tests. 3. If you've changed APIs, update the documentation. 4. Ensure the test suite and the documentation pass. 5. Make sure your code lints. 6. If you haven't already, complete the Contributor License Agreement ("CLA"). When submitting a PR, we encourage you to link it to the related issue (if any) and add some tags to it. The health of the CI is tracked on public dashboards: [CI timing](https://pytorch.github.io/rl/ci-timing/) (wall-clock trend of each workflow), [flaky tests](https://pytorch.github.io/rl/flaky/) and [benchmarks](https://pytorch.github.io/rl/dev/bench/). They can help you tell apart a slowdown or failure introduced by your PR from one that ships with `main`. ## Contributor License Agreement ("CLA") In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects. Complete your CLA here: ## Issues We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue. Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue. ## License By contributing to rl, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.