Skip to main content

Package providing torch-based numerical integration methods.

Project description

torchquad

Documentation Status


Logo

High-performance numerical integration on the GPU with PyTorch
Explore the docs »

View Example notebook · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

This project allows utilizing GPUs for efficient numerical integration with PyTorch.

Built With

Getting Started

This is a brief example of setting up torchquad.

Prerequisites

We recommend using conda, especially if you want to utilize the GPU. It will automatically set up CUDA and the cudatoolkit for you in that case. Note that torchquad also works on the CPU. However, it is optimized for GPU usage.

  • conda, which will take care of all requirements for you. For a detailed list of required packages, please refer to the conda environment file.

Installation

  1. Get miniconda or similar
  2. Clone the repo
    git clone https://github.com/esa/torchquad.git
    
  3. Setup the environment. This will create a conda environment called torchquad
    conda env create -f environment.yml
    

Alternatively you can use

pip install torchquad

Usage

This is a brief example how torchquad can be used to compute a simple integral. For a more thorough introduction please refer to the example notebook.

The full documentation can be found on readthedocs.

# To avoid copying things to GPU memory, 
# ideally allocate everything in torch on the GPU
# and avoid non-torch function calls
import torch 
from torchquad import MonteCarlo

# The function we want to integrate, in this example f(x,y) = sin(x) + e^y
def some_function(x):
    return torch.sin(x[0]) + torch.exp(x[1])

# Declare an integrator, here we use the simple, stochastic Monte Carlo integration method
mc = MonteCarlo()

# Compute the function integral by sampling 10000 points over domain 
integral_value = mc.integrate(some_function,dim=2,N=10000,integration_domain = [[0,1],[-1,1]])

You can find all available integrators here:

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

The project is open to community contributions. Feel free to open an issue or write us an email if you would like to discuss a problem or idea first.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GPL-3.0 License. See LICENSE for more information.

Contact

Created by ESA's Advanced Concepts Team

  • Pablo Gómez - pablo.gomez at esa.int
  • Gabriele Meoni - gabriele.meoni at esa.int
  • Håvard Hem Toftevaag - havard.hem.toftevaag at esa.int

Project Link: https://github.com/esa/torchquad

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchquad-0.1.1.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

torchquad-0.1.1-py3-none-any.whl (26.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page