Monte Carlo integration with Tensorflow
Project description
VegasFlow
VegasFlow is a Monte Carlo integration library written in Python and based on the TensorFlow framework. It is developed with a focus on speed and efficiency, enabling researchers to perform very expensive calculation as quick and easy as possible.
Some of the key features of VegasFlow are:
-
Integrates efficiently high dimensional functions on single (multi-threading) and multi CPU, single and multi GPU, many GPUs or clusters.
-
Compatible with Python, C, C++ or Fortran.
-
Implementation of different Monte Carlo algorithms.
Documentation
The documentation for VegasFlow is available at vegasflow.readthedocs.io.
Installation
The package can be installed with pip:
python3 -m pip install vegasflow
as well as conda
, from the conda-forge
channel:
conda install vegasflow -c conda-forge
If you prefer a manual installation you can clone the repository and run:
git clone https://github.com/N3PDF/vegasflow.git
cd vegasflow
python setup.py install
or if you are planning to extend or develop the code just use:
python setup.py develop
Examples
A number of examples (basic integration, cuda, external tools integration) can be found in the examples folder. A more detailed description can be found in the documention.
Below you can find a minimal workflow for using the examples provided with VegasFlow:
Firstly, one can install any extra dependencies required by the examples using:
pip install .[examples]
Minimal Working Example
from vegasflow import vegas_wrapper
import tensorflow as tf
def integrand(x, **kwargs):
""" Function:
x_{1} * x_{2} ... * x_{n}
x: array of dimension (events, n)
"""
return tf.reduce_prod(x, axis=1)
dimensions = 8
iterations = 5
events_per_iteration = int(1e5)
vegas_wrapper(integrand, dimensions, iterations, events_per_iteration, compilable=True)
Please feel free to open an issue if you would like some specific example or find any problems at all with the code or the documentation.
Citation policy
If you use the package please cite the following paper and zenodo references:
@article{Carrazza:2020rdn,
author = "Carrazza, Stefano and Cruz-Martinez, Juan M.",
title = "{VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms}",
eprint = "2002.12921",
archivePrefix = "arXiv",
primaryClass = "physics.comp-ph",
reportNumber = "TIF-UNIMI-2020-8",
doi = "10.1016/j.cpc.2020.107376",
journal = "Comput. Phys. Commun.",
volume = "254",
pages = "107376",
year = "2020"
}
@software{vegasflow_package,
author = {Juan Cruz-Martinez and
Stefano Carrazza},
title = {N3PDF/vegasflow: vegasflow v1.0},
month = feb,
year = 2020,
publisher = {Zenodo},
version = {v1.0},
doi = {10.5281/zenodo.3691926},
url = {https://doi.org/10.5281/zenodo.3691926}
}
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
Built Distribution
File details
Details for the file vegasflow-1.2.2.tar.gz
.
File metadata
- Download URL: vegasflow-1.2.2.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 136018be250466236584a24dcc91504f274ed3a92bffdb1e836653f7df801be6 |
|
MD5 | 6c17b59330c50afff824f1c40573e19c |
|
BLAKE2b-256 | 4193f6d2faaa65482fb5948805fbfa0add33a1907344fdb58b3f1683505cc298 |
File details
Details for the file vegasflow-1.2.2-py3-none-any.whl
.
File metadata
- Download URL: vegasflow-1.2.2-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c18f9cd30af0fb76b02a8959c7339e37d9e8842b74abae53fc6b52621bc6a92c |
|
MD5 | 609cfac3255c70277e0d184614ed5309 |
|
BLAKE2b-256 | ff069e322927552a42abc1a6f86bbcfc7aca2bc79691b951ae276fe4599042ab |