Open gpleiss opened 1 year ago
After the training (for i in range(50):
) the model mode is switched to model.eval()
. Then after activating the with ...verbose_linalg():
context, it is switched back to model.train()
just to be switched back again to model.eval()
. Is there a reason to do this?
I tried without switching back and forth, but it seems to still work.
...
with gpytorch.settings.verbose_linalg():
#model.train() ##### commented this line
#model.eval() ##### commented this line
start_time = time.time()
with gpytorch.settings.fast_computations(solves=False):
preds = model.likelihood(model(test_x))
print(time.time() - start_time)
model.train()
model.eval()
start_time = time.time()
with gpytorch.settings.fast_pred_var():
preds = model.likelihood(model(test_x))
print(time.time() - start_time)
Edit: I tested it using GPyTorch v1.11
it is switched back to model.train() just to be switched back again to model.eval(). Is there a reason to do this?
Did you check the timing if you don't do that? I assume this is done to clear the caches to have an apples-to-apples comparison.
I did, using 3 runs each. Without switching back and forth it is approx. 5% faster, when not specifying the contexts (with gpytorch.settings...)
. When specifying the contexts, the runtime seemed to vary up- and downwards, so I would say no significance here.
For comparison of runtimes it seems reasonable. But my question aimed for technical necessity, e.g. would I also be required to do it in production runs to ensure correctness of results, etc. Rereading my question that was not very clear, sorry for that.
See #2078.
Cholesky seems to be outperforming CG now, even when N=4000. It seems like dimensionality is an important factor (low dimensionality tends to have worse condition numbers.)
(Also note that we seem to be running Cholesky twice (once for predictive mean, once for solves). However, this issue should disappear with the prediction strategy refactor that @JonathanWenger is working on.