stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.61k stars 369 forks source link

Modify the opitimization lines earch to not return a point with non-finite gradient #3306

Open avehtari opened 3 months ago

avehtari commented 3 months ago

There are some reports (e.g. https://discourse.mc-stan.org/t/disabling-line-search/36062) optimization returning a point that has finite log density but infinite gradient. The current line search does not check that the gradient is finite. The line search could modified so that when the gradient is non-finite the corresponding log density value is considered to be -Inf and then line search would more likely keep out of problematic areas (I did this in GPstuff software many years ago)

Garren-H commented 3 months ago

To add to this I have also been experiencing problems where if I start at a point close to the a mode, bfgs and lbfgs results in an error (newton is not feasible due to the dimensionality of the problem). I am using a cluster to perform inference and sometimes my take weeks to run. The cluster has a max walltime of about 5 days (which can not be changed due to capacity reasons). I hence resort to running a fixed number of iterations, saving the final iteration and starting a new job from the previous point which frequently results an error "line search could not make progress". I have been using cmdstan 2.34, have not updated to the latest version.