Skip to content

Commit

Permalink
Adjustments to setup.py and README for torch Sobol (#20)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook/Ax#20

Pull Request resolved: #55

Using the torch native SobolEngine makes things a lot simpler for botorch.
ax still uses the cython SobolEngine for a lot of things outside torch land.

Reviewed By: danielrjiang

Differential Revision: D14946543

fbshipit-source-id: b2b0ea09a5ea7dc29ecb2a24e7ecdc279d168943
  • Loading branch information
Balandat authored and facebook-github-bot committed Apr 25, 2019
1 parent bd78f68 commit b28317c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 65 deletions.
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.
21 changes: 0 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys

from setuptools import find_packages, setup
from setuptools.extension import Extension


REQUIRED_MAJOR = 3
Expand Down Expand Up @@ -35,20 +34,6 @@ def missing(package_name):
)


# check for numpy (required for building Sobol cython)
try:
import numpy
except ImportError:
missing("numpy")


# check for Cython itself
try:
from Cython.Build import cythonize
except ImportError:
missing("cython")


# error out if setup dependencies not met
if fatals:
sys.exit(
Expand All @@ -57,10 +42,6 @@ def missing(package_name):
)


# TODO: Use torch Sobol once torch 1.1 is released
EXTENSIONS = [Extension("botorch.qmc.sobol", ["botorch/qmc/sobol.pyx"])]


TEST_REQUIRES = ["pytest>=3.6", "pytest-cov"]

DEV_REQUIRES = TEST_REQUIRES + ["black", "flake8", "sphinx", "sphinx-autodoc-typehints"]
Expand All @@ -83,9 +64,7 @@ def missing(package_name):
python_requires=">=3.6",
setup_requires=["cython", "numpy"],
install_requires=["torch>=1.0.1", "gpytorch>=0.3.1", "scipy"],
include_dirs=[numpy.get_include()],
packages=find_packages(),
ext_modules=cythonize(EXTENSIONS),
extras_require={
"dev": DEV_REQUIRES,
"test": TEST_REQUIRES,
Expand Down

0 comments on commit b28317c

Please sign in to comment.