Skip to content

Development Setup

Quick Start

If you're just getting started with TorchEBM development, this guide will help you set up your environment properly.

Prerequisites

Before setting up the TorchEBM development environment, make sure you have the following:

Setting Up Your Environment

1. Fork and Clone the Repository

  1. Navigate to TorchEBM repository
  2. Click the Fork button in the top-right corner
  3. Clone your fork to your local machine:
    git clone https://github.com/YOUR-USERNAME/torchebm.git
    cd torchebm
    
gh repo fork soran-ghaderi/torchebm --clone=true
cd torchebm

2. Set Up Virtual Environment

It's recommended to use a virtual environment to manage dependencies:

python -m venv venv
# Activate on Windows
venv\Scripts\activate
# Activate on macOS/Linux
source venv/bin/activate
conda create -n torchebm python=3.9
conda activate torchebm

3. Install Development Dependencies

pip install -e ".[dev]"

This will install TorchEBM in development mode along with all development dependencies.

Development Workflow

1. Create a Branch

git checkout -b feature/your-feature-name

2. Make Changes

Make your changes to the codebase.

3. Run Tests

pytest

4. Commit Changes

Follow our commit conventions.

git commit -m "feat: add new feature"

5. Push Changes and Create a Pull Request

git push origin feature/your-feature-name

Then go to GitHub and create a pull request.

Documentation Development

To preview documentation locally:

pip install -e ".[docs]"
mkdocs serve

This will start a local server at http://127.0.0.1:8000/.

Common Issues

Missing CUDA?

If you're developing CUDA extensions, ensure you have the right CUDA toolkit installed:

pip install torch==1.12.0+cu116 -f https://download.pytorch.org/whl/cu116/torch_stable.html

Next Steps

  • Code Style


    Learn about our coding standards.

    Code Style

  • Testing Guide


    Learn how to write effective tests.

    Testing Guide

  • API Design


    Understand our API design principles.

    API Design