Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustments to setup.py and README for torch Sobol #55

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ matrix:
- name: "GPyTorch + PyTorch stable (Python 3.6)"
python: "3.6"
install:
- pip install -q cython numpy
# TODO: Remove when locked to upcoming GPyTorch release 0.3.2
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@8f0d338d42222689f0106f5f29e62ef4777a392f
# TODO: Remove once GPyTorch 0.3.2 is released and marked a dep. of botorch
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@32911e3b51901917c0f14101972581c1295b5edb
# TODO: Remove once PyTorch 1.1 is released and marked a dep. of botorch
- pip install -q torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- pip install -q -e .[test]
script:
- pytest -ra --cov=. --cov-report term-missing
Expand All @@ -22,19 +23,21 @@ matrix:
python: "3.7"
dist: xenial
install:
- pip install -q cython numpy
# TODO: Remove when locked to upcoming GPyTorch release 0.3.2
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@8f0d338d42222689f0106f5f29e62ef4777a392f
# TODO: Remove once GPyTorch 0.3.2 is released and marked a dep. of botorch
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@32911e3b51901917c0f14101972581c1295b5edb
# TODO: Remove once PyTorch 1.1 is released and marked a dep. of botorch
- pip install -q torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- pip install -q -e .[test]
script:
- pytest -ra --cov=. --cov-report term-missing
# Latest versions
- name: "GPyTorch + PyTorch latest"
python: "3.6"
install:
- pip install -q cython numpy
- pip install -q torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html;
# TODO: Fix gpytorch installation to work with torch nightly in pip,
# so we don't have to reinstall torch nightly after installing stable
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git
- pip install -q torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- pip install -q -e .[test]
script:
- pytest -ra --cov=. --cov-report term-missing
Expand All @@ -57,9 +60,10 @@ matrix:
- name: "Docs: Sphinx (Python 3.6)"
python: "3.6"
install:
- pip install -q cython numpy
# TODO: Remove when locked to upcoming GPyTorch release 0.3.2
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@8f0d338d42222689f0106f5f29e62ef4777a392f
# TODO: Remove once GPyTorch 0.3.2 is released and marked a dep. of botorch
- pip install -q git+https://github.com/cornellius-gp/gpytorch.git@32911e3b51901917c0f14101972581c1295b5edb
# TODO: Remove once PyTorch 1.1 is released and marked a dep. of botorch
- pip install -q torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
- pip install -q -e .[dev]
script:
# warnings treated as errors
Expand Down
24 changes: 18 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Contributing to botorch
We want to make contributing to botorch is as easy and transparent as possible.
# Contributing to BoTorch
We want to make contributing to BoTorch is as easy and transparent as possible.


## Development installation

To get the development installation with all the necessary dependencies for
linting, testing, and building the documentation, run the following:
```bash
git clone https://github.com/facebookexternal/botorch.git
cd botorch
pip install -e .[dev]
```


## Our Development Process

#### Code Style

botorch uses the [black](https://github.com/ambv/black) code formatter to
BoTorch uses the [black](https://github.com/ambv/black) code formatter to
enforce a common code style across the code base. black is installed easily via
pip using `pip install black`, and run locally by calling
```bash
Expand All @@ -20,7 +32,7 @@ Travis will fail on your PR if it does not adhere to the black formatting style.


#### Type Hints
botorch is fully typed using python 3.6+
BoTorch is fully typed using python 3.6+
[type hints](https://www.python.org/dev/peps/pep-0484/).
We expect any contributions to also use proper type annotations. While we
currently do not enforce full consistency of these in Travis (type checkers can
Expand All @@ -40,7 +52,7 @@ python -m unittest

#### Documentation

botorch's website is also open source, and is part of this very repository (the
BoTorch's website is also open source, and is part of this very repository (the
code can be found in the [website](../website/) folder).
It is built using [Docusaurus](https://docusaurus.io/), and consists of three
main elements:
Expand Down Expand Up @@ -89,5 +101,5 @@ outlined on that page and do not file a public issue.


## License
By contributing to botorch, you agree that your contributions will be licensed
By contributing to BoTorch, you agree that your contributions will be licensed
under the LICENSE file in the root directory of this source tree.
93 changes: 66 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,91 @@
<img width="300" src="./botorch_logo_lockup.svg" alt="BoTorch Logo" />
<a href="https://botorch.org">
<img width="300" src="./botorch_logo_lockup.svg" alt="BoTorch Logo" />
</a>

[![Build Status](
https://travis-ci.com/facebookexternal/botorch.svg?token=esFvpzSw7sLSsfe1PAr1&branch=master
)](https://travis-ci.com/facebookexternal/botorch)


BoTorch is a library for Bayesian Optimization in PyTorch.
BoTorch is a library for Bayesian Optimization built on PyTorch.

It is currently an alpha version under active development - be warned!
*BoTorch is currently in alpha and under active development - be warned*!


## Installation
### Why BoTorch
BoTorch
* Provides a modular and easily extensible interface for composing Bayesian
optimization primitives, including probabilistic models, acquisition functions,
and optimizers.
* Harnesses the power of PyTorch, including auto-differentiation, native support
for highly parallelized modern hardware (e.g. GPUs) using device-agnostic code,
and a dynamic computation graph.
* Supports Monte Carlo-based acquisition functions via the
[reparameterization trick](https://arxiv.org/abs/1312.6114), which makes it
straightforward to implement new ideas without having to impose restrictive
assumptions about the underlying model.
* Enables seamless integration with deep and/or convolutional architectures in PyTorch.
* Has first-class support for state-of-the art probabilistic models in
[GPyTorch](http://www.gpytorch.ai/), including support for multi-task Gaussian
Processes (GPs) deep kernel learning, deep GPs, and approximate inference.

##### Setup Requirements (TODO: Remove once we can use torch Sobol)

The following are required to run the setup:
### Target Audience

- Python >= 3.6
- numpy
- cython
The primary audience for hands-on use of BoTorch are researchers and
sophisticated practitioners in Bayesian Optimization and AI.

We recommend using BoTorch as a low-level API for implementing new algorithms
for [Ax](https://github.com/facebook/Ax). Ax has been designed to be
an easy-to-use platform for end-users, which at the same time is flexible enough
for Bayesian Optimization researchers to plug into for handling of feature
transformations, (meta-)data management, storage, etc.

We recommend that end-users who are not actively doing research on Bayesian
Optimization simply use Ax.

##### Installation Requirements

- PyTorch >= 1.0.1
- gpytorch >= 0.3.0
## Installation

#### Installation Requirements

- Python >= 3.6
- PyTorch nightly (**TODO:** peg to PyTorch 1.1 once released)
- gpytorch >= 0.3.1 (**TODO:** peg to GPyTorch 0.3.2 once released)
- scipy

**Important:**
You will want to have you PyTorch build link against **MKL** (the non-optimized
version of botorch can be up to an order of magnitude slower). Setting this up
manually can be tricky - to make sure this works please use the Anaconda
installation instructions on https://pytorch.org/.
**Important note for MacOS users:**
* You will want to make sure your PyTorch build is linked against MKL (the
non-optimized version of BoTorch can be up to an order of magnitude slower in
some settings). Setting this up manually on MacOS can be tricky - to ensure
this works properly please follow the
[PyTorch installation instructions](https://pytorch.org/get-started/locally/).
* If you need CUDA on MacOS, you will need to build PyTorch from source. Please
consult the PyTorch installation instructions above.


### Install botorch
#### Installing BoTorch

To run the botorch setup, you'll need cython (**TODO:** Remove)
The latest release of BoTorch is easily installed using either pip or conda:
```bash
pip install cython
pip install botorch
```

We recommend installing botorch using pip via ssh:
**TODO: Conda install**


If you'd like to try our bleeding edge features (and don't mind running into an
occasional bug here or there), you can install the latest master from GitHub
(this will also require installing the current GPyTorch master)::
```bash
pip install git+https://github.com/cornellius-gp/gpytorch.git
pip install git+https://github.com/facebookexternal/botorch.git
```


#### Installing BoTorch from the private repo **TODO: REMOVE**

BoTorch is easily installed using pip:
```bash
pip install git+ssh://[email protected]/facebookexternal/botorch.git
```
Expand All @@ -63,14 +107,9 @@ To customize the installation, you can also run the following instead:



## Installation using conda

**TODO: conda install is unsupported until the repo is public**


## Contributing
See the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.


## License
botorch is MIT licensed, as found in the LICENSE file.
BoTorch is MIT licensed, as found in the LICENSE file.
8 changes: 8 additions & 0 deletions botorch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/usr/bin/env python3

import os
import re

from . import acquisition, exceptions, models, optim, posteriors, test_functions
from .cross_validation import batch_cross_validation
from .fit import fit_gpytorch_model
from .gen import gen_candidates_scipy, gen_candidates_torch, get_best_candidates
from .utils import manual_seed


# get version string from setup.py
with open(os.path.join(os.path.dirname(__file__), os.pardir, "setup.py"), "r") as f:
__version__ = re.search(r"version=['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)


__all__ = [
"acquisition",
"batch_cross_validation",
Expand Down
2 changes: 1 addition & 1 deletion botorch/acquisition/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import torch
from torch import Tensor
from torch.nn import Module
from torch.quasirandom import SobolEngine

from ..exceptions import UnsupportedError
from ..posteriors import Posterior
from ..qmc.sobol import SobolEngine
from ..utils.sampling import draw_sobol_normal_samples, manual_seed


Expand Down
3 changes: 2 additions & 1 deletion botorch/qmc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#! /usr/bin/env python3

from torch.quasirandom import SobolEngine

from .normal import MultivariateNormalQMCEngine, NormalQMCEngine
from .sobol import SobolEngine


__all__ = ["MultivariateNormalQMCEngine", "NormalQMCEngine", "SobolEngine"]
Loading