Skip to content

Commit 1c490dd

Browse files
gpleissBalandat
andauthored
LazyTensor -> LinearOperator (#2027)
* Bump version, require linear_operator * [WIP] Replace LazyTensor with LinearOperator, fix gpytorch/lazy test suite failures * [WIP] fix gpytorch/variational test suite failures * [WIP] fix gpytorch/functions test suite failures * [WIP] specify linear_operator commit in setup.py * [WIP] Remove lazy docs * [WIP] Update CI requirements * [WIP] Pipe eval_cg_tolerance to linear_operator.utils.linear_cg * [WIP] Use linear_operator errors (fix variational fantasy test failures) * [WIP] fix remaining test suite bugs * [WIP] Use linear_operator functions * [WIP] Add linear_operator dependency, bump Python to 3.8 * [WIP] remove unused utilities * [WIP] Move Cholesky to LinearOperator * Fix rebase issues * Fix new failing test, consolodate requirements, fix docs typo. * Fix import in IdentityLT test * Bump linear operator version * Fix cuda issue in polya gamma notebook * Shorten LinearOperator and Tensor imports in gpytorch/__init__.py * Remove deprecation warnings after linear_operator migration (#2102) * Remove tests of deprecated items that were moved to linear_operator * Run test suite * Replace all LazyTensors with LinearOperators * Update .diag, .evaluate, .add_diag, .inv_matmul calls, solve ConstantMean deprecation warnings * Rename *_lazy_tensor arguments, use linear_operator interpolation utils * Resolve solve_triangular warnings * Resolve eigh warnings * Resolve meshgrid warnings * Update gpytorch/kernels/multi_device_kernel.py Co-authored-by: Max Balandat <Balandat@users.noreply.github.com> * Update gpytorch/likelihoods/multitask_gaussian_likelihood.py Co-authored-by: Max Balandat <Balandat@users.noreply.github.com> * Consistent import * Add tests for deprecated LazyTensor import * Fix doc issues * Fix doc issues * Remove extra testing requirements Co-authored-by: Max Balandat <Balandat@users.noreply.github.com> Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
1 parent 58e7926 commit 1c490dd

File tree

222 files changed

+1973
-16831
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+1973
-16831
lines changed

.conda/meta.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ build:
1313

1414
requirements:
1515
host:
16-
- python>=3.7
16+
- python>=3.8
1717

1818
run:
19-
- pytorch>=1.10
20-
- numpy
19+
- pytorch>=1.11
2120
- scikit-learn
22-
- scipy
21+
- linear_operator>=0.1.1
2322

2423
test:
2524
imports:

.github/workflows/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Python
2020
uses: actions/setup-python@v2
2121
with:
22-
python-version: "3.7"
22+
python-version: "3.8"
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
@@ -40,7 +40,7 @@ jobs:
4040
- uses: conda-incubator/setup-miniconda@v2
4141
with:
4242
auto-update-conda: false
43-
python-version: "3.7"
43+
python-version: "3.8"
4444
- name: Install dependencies
4545
run: |
4646
conda install -y anaconda-client conda-build

.github/workflows/run_test_suite.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Python
1919
uses: actions/setup-python@v2
2020
with:
21-
python-version: "3.7"
21+
python-version: "3.8"
2222
- name: Install dependencies
2323
run: |
2424
pip install flake8==4.0.1 flake8-print==4.0.0 pre-commit
@@ -43,13 +43,13 @@ jobs:
4343
- name: Set up Python
4444
uses: actions/setup-python@v2
4545
with:
46-
python-version: "3.7"
46+
python-version: "3.8"
4747
- name: Install dependencies
4848
run: |
4949
if [[ ${{ matrix.pytorch-version }} = "master" ]]; then
5050
pip install --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html;
5151
else
52-
pip install torch==1.10+cpu -f https://download.pytorch.org/whl/torch_stable.html;
52+
pip install torch==1.11+cpu -f https://download.pytorch.org/whl/torch_stable.html;
5353
fi
5454
if [[ ${{ matrix.extras }} == "with-extras" ]]; then
5555
pip install "pyro-ppl>=1.8";
@@ -67,9 +67,10 @@ jobs:
6767
- name: Set up Python
6868
uses: actions/setup-python@v2
6969
with:
70-
python-version: "3.7"
70+
python-version: "3.8"
7171
- name: Install dependencies
7272
run: |
73+
pip install torch==1.11+cpu -f https://download.pytorch.org/whl/torch_stable.html
7374
pip install pytest nbval jupyter tqdm matplotlib torchvision scipy
7475
pip install -r requirements.txt
7576
python setup.py build develop

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sphinx:
1616

1717
# Optionally set the version of Python and requirements required to build your docs
1818
python:
19-
version: 3.7
19+
version: 3.8
2020
install:
2121
- requirements: requirements.txt
2222
- requirements: docs/requirements.txt

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
GPyTorch is a Gaussian process library implemented using PyTorch. GPyTorch is designed for creating scalable, flexible, and modular Gaussian process models with ease.
88

9-
Internally, GPyTorch differs from many existing approaches to GP inference by performing all inference operations using modern numerical linear algebra techniques like preconditioned conjugate gradients. Implementing a scalable GP method is as simple as providing a matrix multiplication routine with the kernel matrix and its derivative via our `LazyTensor` interface, or by composing many of our already existing `LazyTensors`. This allows not only for easy implementation of popular scalable GP techniques, but often also for significantly improved utilization of GPU computing compared to solvers based on the Cholesky decomposition.
9+
Internally, GPyTorch differs from many existing approaches to GP inference by performing all inference operations using modern numerical linear algebra techniques like preconditioned conjugate gradients. Implementing a scalable GP method is as simple as providing a matrix multiplication routine with the kernel matrix and its derivative via our `LinearOperator` interface, or by composing many of our already existing `LinearOperators`. This allows not only for easy implementation of popular scalable GP techniques, but often also for significantly improved utilization of GPU computing compared to solvers based on the Cholesky decomposition.
1010

1111
GPyTorch provides (1) significant GPU acceleration (through MVM based inference); (2) state-of-the-art implementations of the latest algorithmic advances for scalability and flexibility ([SKI/KISS-GP](http://proceedings.mlr.press/v37/wilson15.pdf), [stochastic Lanczos expansions](https://arxiv.org/abs/1711.03481), [LOVE](https://arxiv.org/pdf/1803.06058.pdf), [SKIP](https://arxiv.org/pdf/1802.08903.pdf), [stochastic variational](https://arxiv.org/pdf/1611.00336.pdf) [deep kernel learning](http://proceedings.mlr.press/v51/wilson16.pdf), ...); (3) easy integration with deep learning frameworks.
1212

@@ -17,8 +17,8 @@ See our numerous [**examples and tutorials**](https://gpytorch.readthedocs.io/en
1717
## Installation
1818

1919
**Requirements**:
20-
- Python >= 3.7
21-
- PyTorch >= 1.10
20+
- Python >= 3.8
21+
- PyTorch >= 1.11
2222

2323
Install GPyTorch using pip or conda:
2424

docs/source/distributions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ For the most part, GpyTorch relies on torch's distribution library.
99
However, we offer two custom distributions.
1010

1111
We implement a custom :obj:`~gpytorch.distributions.MultivariateNormal` that accepts
12-
:obj:`~gpytorch.lazy.LazyTensor` objects for covariance matrices. This allows us to use custom
12+
:obj:`~linear_operator.operators.LinearOperator` objects for covariance matrices. This allows us to use custom
1313
linear algebra operations, which makes this more efficient than PyTorch's MVN implementation.
1414

1515
In addition, we implement a :obj:`~gpytorch.distributions.MultitaskMultivariateNormal` which

docs/source/functions.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@ Functions
1212

1313
.. automodule:: gpytorch
1414

15-
.. autofunction:: add_diag
15+
.. autofunction:: add_diagonal
1616

1717
.. autofunction:: add_jitter
1818

1919
.. autofunction:: dsmm
2020

21-
.. autofunction:: inv_matmul
21+
.. autofunction:: diagonalization
2222

2323
.. autofunction:: inv_quad
2424

2525
.. autofunction:: inv_quad_logdet
2626

27-
.. autofunction:: matmul
28-
29-
.. autofunction:: logdet
30-
31-
.. autofunction:: log_normal_cdf
32-
3327
.. autofunction:: pivoted_cholesky
3428

3529
.. autofunction:: root_decomposition
3630

3731
.. autofunction:: root_inv_decomposition
32+
33+
.. autofunction:: solve
34+
35+
.. autofunction:: sqrt_inv_matmul

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ GPyTorch's documentation
5050
:caption: Advanced Package Reference
5151

5252
module
53-
lazy
5453
functions
5554
utils
5655

docs/source/lazy.rst

Lines changed: 0 additions & 130 deletions
This file was deleted.

docs/source/utils.rst

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,31 @@ gpytorch.utils
55
===================================
66

77
.. currentmodule:: gpytorch.utils
8-
9-
10-
Utilities
11-
----------------
12-
138
.. automodule:: gpytorch.utils
149
:members:
1510

16-
Lanczos Utilities
17-
~~~~~~~~~~~~~~~~~
11+
Grid Utilities
12+
----------------------
1813

19-
.. automodule:: gpytorch.utils.lanczos
14+
.. automodule:: gpytorch.utils.grid
2015
:members:
2116

22-
Permutation Utilities
23-
~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
Interpolation Utilities
18+
---------------------------------
2419

25-
.. automodule:: gpytorch.utils.permutation
20+
.. automodule:: gpytorch.utils.interpolation
2621
:members:
2722

2823
Quadrature Utilities
29-
~~~~~~~~~~~~~~~~~~~~
24+
----------------------------
3025

3126
.. automodule:: gpytorch.utils.quadrature
3227
:members:
3328

34-
Sparse Utilities
35-
~~~~~~~~~~~~~~~~~
29+
Transform Utilities
30+
--------------------------
3631

37-
.. automodule:: gpytorch.utils.sparse
38-
:members:
39-
40-
Grid Utilities
41-
~~~~~~~~~~~~~~~~~
42-
43-
.. automodule:: gpytorch.utils.grid
32+
.. automodule:: gpytorch.utils.transforms
4433
:members:
4534

4635
Nearest Neighbors Utilities

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: gpytorch
22
channels:
33
- pytorch
4+
- gpytorch
45
dependencies:
56
- pytorch
6-
- numpy
77
- scikit-learn
8-
- scipy
8+
- linear_operator>0.1.1

examples/00_Basic_Usage/Implementing_a_custom_Kernel.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"\n",
9797
"To implement a custom kernel, we derive one from GPyTorch's [kernel class](https://docs.gpytorch.ai/en/latest/kernels.html) and implement the `forward()` method. The base class provides many useful routines. For example, `__call__()` is implemented, so that the kernel may be called directly, without resorting to the `forward()` routine. Among other things, the `Kernel` class provides a method `covar_dist()`, which may be used to calculate the Euclidian distance between point pairs conveniently.\n",
9898
"\n",
99-
"The `forward()` method represents the kernel function and should return a `torch.tensor` or a `gpytorch.lazy.LazyTensor`, when called on two `torch.tensor`s:"
99+
"The `forward()` method represents the kernel function and should return a `torch.tensor` or a `linear_operator.operators.LinearOperator`, when called on two `torch.tensor`s:"
100100
]
101101
},
102102
{

examples/04_Variational_and_Approximate_GPs/PolyaGamma_Binary_Classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
}
129129
],
130130
"source": [
131-
"plt.plot(train_x.squeeze(-1), train_y, 'o')"
131+
"plt.plot(train_x.squeeze(-1).cpu(), train_y.cpu(), 'o')"
132132
]
133133
},
134134
{
@@ -1755,7 +1755,7 @@
17551755
"# push training data points through model\n",
17561756
"train_mean_f = model(train_x).loc.data.cpu()\n",
17571757
"# plot training data with y being -1/1 valued\n",
1758-
"plt.plot(train_x.squeeze(-1), train_y.mul(2.).sub(1.), 'o')\n",
1758+
"plt.plot(train_x.squeeze(-1).cpu(), train_y.mul(2.).sub(1.).cpu(), 'o')\n",
17591759
"# plot mean gaussian process posterior mean evaluated at training data\n",
17601760
"plt.plot(train_x.squeeze(-1).cpu(), train_mean_f.cpu(), 'x')"
17611761
]

examples/08_Advanced_Usage/Simple_GP_Regression_Derivative_Information_2d.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"metadata": {},
7272
"outputs": [],
7373
"source": [
74-
"xv, yv = torch.meshgrid([torch.linspace(0, 1, 10), torch.linspace(0, 1, 10)])\n",
74+
"xv, yv = torch.meshgrid(torch.linspace(0, 1, 10), torch.linspace(0, 1, 10), indexing=\"ij\")\n",
7575
"train_x = torch.cat((\n",
7676
" xv.contiguous().view(xv.numel(), 1), \n",
7777
" yv.contiguous().view(yv.numel(), 1)),\n",
@@ -301,7 +301,7 @@
301301
"\n",
302302
"# Test points\n",
303303
"n1, n2 = 50, 50\n",
304-
"xv, yv = torch.meshgrid([torch.linspace(0, 1, n1), torch.linspace(0, 1, n2)])\n",
304+
"xv, yv = torch.meshgrid(torch.linspace(0, 1, n1), torch.linspace(0, 1, n2), indexing=\"ij\")\n",
305305
"f, dfx, dfy = franke(xv, yv)\n",
306306
"\n",
307307
"# Make predictions\n",

0 commit comments

Comments
 (0)