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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file torchquad-0.1.1.tar.gz.

File metadata

  • Download URL: torchquad-0.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for torchquad-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1322f46be91d1639d01416adcca6dc59b6e34b9b27082a68b191d4aa8eb3adc4
MD5 ba3b3da8e68f0720e4192fa02b59b4a3
BLAKE2b-256 f19d2beb2a9f75caba59dafe2380fff3d45d0d1c21ef3527cdae26afcd4a81f3

See more details on using hashes here.

File details

Details for the file torchquad-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: torchquad-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for torchquad-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c0fb223469736a110e443b9ed5ffe47786d275de557aa5bbae2015d11388689
MD5 8c8d5b6fb5a4af078fb8191dab72d40c
BLAKE2b-256 f4acbc28d573e90202aec10a826b44ac6536bf338ed9b26cba040098daa09d06

See more details on using hashes here.

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