https://github.com/n3pdf/vegasflow
VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms
https://github.com/n3pdf/vegasflow
efficiency gpu-acceleration machine-learning monte-carlo monte-carlo-integration tensorflow
Last synced: 6 months ago
JSON representation
VegasFlow: accelerating Monte Carlo simulation across multiple hardware platforms
- Host: GitHub
- URL: https://github.com/n3pdf/vegasflow
- Owner: N3PDF
- License: apache-2.0
- Created: 2019-12-06T16:00:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-30T18:21:39.000Z (9 months ago)
- Last Synced: 2025-04-09T16:05:56.001Z (6 months ago)
- Topics: efficiency, gpu-acceleration, machine-learning, monte-carlo, monte-carlo-integration, tensorflow
- Language: Python
- Homepage: https://vegasflow.readthedocs.io
- Size: 8.55 MB
- Stars: 35
- Watchers: 7
- Forks: 9
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://zenodo.org/badge/latestdoi/226363558)
[](https://inspirehep.net/literature/1783000)[](https://github.com/N3PDF/vegasflow/actions?query=workflow%3A%22pytest%22)
[](https://vegasflow.readthedocs.io/en/latest/?badge=latest)# VegasFlow
VegasFlow is a Monte Carlo integration library written in Python and based on the [TensorFlow](https://www.tensorflow.org/) 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](https://vegasflow.readthedocs.io/en/latest).## Installation
[](https://anaconda.org/conda-forge/vegasflow)
[](https://aur.archlinux.org/packages/python-vegasflow/)The package can be installed with pip:
```bash
python3 -m pip install vegasflow
```as well as `conda`, from the `conda-forge` channel:
```bash
conda install vegasflow -c conda-forge
```If you prefer a manual installation you can clone the repository and run:
```bash
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:
```bash
python setup.py develop
```## Examples
A number of examples (basic integration, cuda, external tools integration) can be found in the [examples folder](https://github.com/N3PDF/vegasflow/tree/master/examples). A more detailed description can be found in the [documention](https://vegasflow.readthedocs.io/en/latest/examples.html).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:
```bash
pip install .[examples]
```### Minimal Working Example
```python
from vegasflow import vegas_wrapper
import tensorflow as tfdef 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](https://github.com/N3PDF/vegasflow/issues/new) 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:
- [https://doi.org/10.5281/zenodo.3691926](https://doi.org/10.5281/zenodo.3691926)
- [https://arxiv.org/abs/2002.12921](https://arxiv.org/abs/2002.12921)```bibtex
@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}
}
```