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

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

wants to merge 3 commits into from

Conversation

Balandat
Copy link
Contributor

Summary:
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.

Differential Revision: D14946543

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 16, 2019
@eytan
Copy link
Contributor

eytan commented Apr 16, 2019 via email

@Balandat
Copy link
Contributor Author

Balandat commented Apr 16, 2019

I don’t want to require external testers of the software to install PyTorch off master, but rather use conda.

The PyTorch nightlies are available on conda. So the setup will require running
conda install pytorch-nightly -c pytorch instead of
conda install pytorch -c pytorch

Are you worried about them having to install a different version of pytorch if they already have one set up?

@Balandat
Copy link
Contributor Author

Hmm good thing I exported this. Looks like we're getting failures that we are not seeing internally (D14601706).

My suspicion is that the pytorch nightlies we get from pip don't contain/properly build the ATen SobolEngine. This all runs fine when using the nightlies from conda locally on my Mac.

@eytan
Copy link
Contributor

eytan commented Apr 16, 2019 via email

@Balandat
Copy link
Contributor Author

We'll need to figure out what the issues are with the nightlies in travis first anyway.

@Balandat
Copy link
Contributor Author

@soumith, any idea why we're running into the following on travis when using the pytorch nightlies from pip (this is on linux):

AttributeError: module 'torch' has no attribute '_sobol_engine_initialize_state_'

Things run fine using the pytorch nightlies from conda on my Mac (pip installs on my Mac fail b/c of a MKL linking issues). Things also run fine internally (D14601706).

@Balandat
Copy link
Contributor Author

Travis log for a recent failed run: https://travis-ci.com/facebookexternal/botorch/jobs/194077151

@soumith
Copy link
Member

soumith commented Apr 18, 2019

i cant see the log. it says cant find project. Can you paste the failure?

@Balandat
Copy link
Contributor Author

https://phabricator.internmc.facebook.com/P62627525$1044-1045

Excerpt:


self = SobolEngine(dimension=1, scramble=True, seed=6627), dimension = 1
scramble = True, seed = 6627

�[1m    def __init__(self, dimension, scramble=False, seed=None):�[0m
�[1m        if dimension > self.MAXDIM or dimension < 1:�[0m
�[1m            raise ValueError("Supported range of dimensionality "�[0m
�[1m                             "for SobolEngine is [1, {}]".format(self.MAXDIM))�[0m
�[1m    �[0m
�[1m        self.seed = seed�[0m
�[1m        self.scramble = scramble�[0m
�[1m        self.dimension = dimension�[0m
�[1m    �[0m
�[1m        self.sobolstate = torch.zeros(dimension, self.MAXBIT, dtype=torch.long)�[0m
�[1m>       torch._sobol_engine_initialize_state_(self.sobolstate, self.dimension)�[0m
�[1m�[31mE       AttributeError: module 'torch' has no attribute '_sobol_engine_initialize_state_'�[0m

�[1m�[31m../../../virtualenv/python3.6.3/lib/python3.6/site-packages/torch/quasirandom.py�[0m:54: AttributeError

@Balandat
Copy link
Contributor Author

Upon further digging, it seems that this failure may be caused by gpytorch's pip install re-installing the latest pytorch version over the nightlies. This should not happen.

@Balandat
Copy link
Contributor Author

Fixed gpytorch setup.py upstream: cornellius-gp/gpytorch#663, will peg to that commit once merged into master.

@Balandat
Copy link
Contributor Author

Argh I don't know why this is still failing...

@Balandat
Copy link
Contributor Author

OK so even with the upstream change to the gpytorch setup we still get the following:

Screen Shot 2019-04-24 at 9 23 10 AM

I think the reason is that the pip install actually calls the package torch-nightly and not torch as conda does.

I tried working around this upstream by doing some parsing in setup.py of the sorts

torch_min = "1.0.1"
# if recent dev version of PyTorch is installed, no need to install stable
try:
    import torch
    if torch.__version__ >= torch_min:
        install_requires = []
    else:
        install_requires = ["torch" + ">=" + torch_min]
except ImportError:
    install_requires = ["torch" + ">=" + torch_min]

Unfortunately. there is a bug in pip 19.0.1 that shows up in conjunction with having a pyproject.toml file (which gpytorch does) that always results in setup.py not being able to import torch: pypa/pip#6163.

I think for now I'll just re-install the nightlies after installing gpytorch in .travis.yml, and then just put the req. "torch>=1.1` upon release.

Summary:
This diff
- uses the native torch SobolEngine introduced in D9330179
- moves the cython implementation to `experimental/balandat/qmc` (would like to
  upstream this to scipy at a later point)
- ports the NormalQMCEngine and MultivariateNormalQMCEngine over to torch
- updates tests accordingly
- restructures the botorch TARGET files (these were really funky so that we
  could use the Cython SobolEngine - this is not necessary anymore). Note that
  this changes the target from `//pytorch/botorch/botorch:botorch` to
  `//pytorch/botorch:botorch`.

This has been a long time coming, hard to believe it's finally here...

Differential Revision: D14601706

fbshipit-source-id: 2b1e52adbf6a9af79aa5a4cc7c184831d233bfb0
Summary:
This uses regexp parsing to get the version from setup.py so we have a single source.
Pull Request resolved: #45

Differential Revision: D14892769

fbshipit-source-id: 6475006d4f93ec0cf0fbcc641db91bc71ebf6e2a
Summary:
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: 9dbbb3bad205663274ec30f960dea44e390688b7
facebook-github-bot pushed a commit that referenced this pull request Apr 25, 2019
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
Balandat added a commit that referenced this pull request Apr 26, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants