Package providing torch-based numerical integration methods.
Project description
torchquad
High-performance numerical integration on the GPU with PyTorch
Explore the docs »
View Example notebook
·
Report Bug
·
Request Feature
Table of Contents
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
- Get miniconda or similar
- Clone the repo
git clone https://github.com/esa/torchquad.git
- 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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1322f46be91d1639d01416adcca6dc59b6e34b9b27082a68b191d4aa8eb3adc4 |
|
MD5 | ba3b3da8e68f0720e4192fa02b59b4a3 |
|
BLAKE2b-256 | f19d2beb2a9f75caba59dafe2380fff3d45d0d1c21ef3527cdae26afcd4a81f3 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c0fb223469736a110e443b9ed5ffe47786d275de557aa5bbae2015d11388689 |
|
MD5 | 8c8d5b6fb5a4af078fb8191dab72d40c |
|
BLAKE2b-256 | f4acbc28d573e90202aec10a826b44ac6536bf338ed9b26cba040098daa09d06 |