TPESampler RSS grows unbounded with trial count in long-running studies (follow-up to #3050)
Follow-up to #3050. That issue was closed as a generic "memory grows with n_trials" report without confirming the cause is in TPESampler itself rather than the user's objective function. We reproduced it isolated from any objective-function cost.
Reproduction: TPESampler(multivariate=True, constant_liar=True), ~36-parameter search space, JournalStorage, several parallel workers. Replacing the real objective with a trivial return random.random() still produces the same near-linear RSS growth with trial count, OOMing once enough trials accumulate. gc_after_trial=True slows but doesn't stop it — the retained history is referenced, not garbage.
This points to TPESampler retaining full trial history in memory to refit its KDE models on every sampling call, with no bound on study length.
Is there a supported way to cap this? — e.g. windowing to the most recent N trials for KDE fitting, or periodic sampler state rotation — short of restarting the study with a fresh sampler? Happy to share the minimal reproduction script.
Source: optuna/optuna