You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add "pre_dispatch" parameter to HalvingGridSearchCV #23108
In base GridSearchCV it is possible to set a pre_dispatch parameter, so that RAM usage by new jobs is limited.
I would like to do the same thing for the newer and arguably better versions of gridsearch.
Describe your proposed solution
Add the pre_dispatch parameter that already exists in scikit to the new grid searches.
Describe alternatives you've considered, if relevant
If you one that would be great because currently I am running into heavy issues with catboost which only accepts n_jobs=1 when running on gpu :)
One option is to add a parallel_kwargs parameter that would pass the kwars down to joblib.Parallel.
Another options is to make the parallel_backend context manager work:
fromjoblibimportParallel, delayed, parallel_backendfrommathimportsqrt# This does not workwithparallel_backend("loky", pre_dispatch="2*n_jobs"):
parallel=Parallel()
out=parallel(delayed(sqrt)(i**2) foriinrange(10))
print(out)
I don't understand why pre_dispatch would fundamentally change memory usage anyway: the memory mapping of the training data should prevent large data copies.
@nilslacroix have you tried to hard-code a different value of pre_dispatch in your local copy of scikit-learn in the source code of HalvingGridSearchCV to see if it actually fix your problem?
If so, which values help, and which value make the execution crash and what it the error message you get?
We could implement @thomasjpfan's suggestion but that will make joblib even more complex so I would like to make sure that it is actually useful before considering a pull request.
I am also running into issues with this. HalvingGridSearchCV causes a memory explosion when working with large datasets on HPC clusters with many cores available and therefore using high n_jobs. Having the pre_dispatch parameter available here would help.
I don't understand why pre_dispatch would fundamentally change memory usage anyway: the memory mapping of the training data should prevent large data copies.
Activity
thomasjpfan commentedon Apr 14, 2022
We have resisted adding
kwargsfrom joblib.Parallel into estimators and removed it recently: #18030 (comment)One option is to add a
parallel_kwargsparameter that would pass the kwars down tojoblib.Parallel.Another options is to make the
parallel_backendcontext manager work:@lesteve @ogrisel What do you think?
ogrisel commentedon Jun 30, 2022
I don't understand why
pre_dispatchwould fundamentally change memory usage anyway: the memory mapping of the training data should prevent large data copies.ogrisel commentedon Jun 30, 2022
@nilslacroix have you tried to hard-code a different value of
pre_dispatchin your local copy of scikit-learn in the source code ofHalvingGridSearchCVto see if it actually fix your problem?If so, which values help, and which value make the execution crash and what it the error message you get?
ogrisel commentedon Jun 30, 2022
We could implement @thomasjpfan's suggestion but that will make joblib even more complex so I would like to make sure that it is actually useful before considering a pull request.
thomasjpfan commentedon Aug 26, 2022
I am closing this issue because there was no response to #23108 (comment).
smith558 commentedon Apr 2, 2023
I am also running into issues with this.
HalvingGridSearchCVcauses a memory explosion when working with large datasets on HPC clusters with many cores available and therefore using highn_jobs. Having thepre_dispatchparameter available here would help.smith558 commentedon Apr 2, 2023
This discussion seems to suggest otherwise and seems to suggest that data replication occurs when using
n_jobs.https://datascience.stackexchange.com/questions/34416/scikit-learn-n-jobs-parameter-on-cpu-usage-memory
smith558 commentedon Apr 2, 2023
Additionally, this makes the API inconsistent as the
GridSearchCVmakes this parameter available whilst theHalvingGridSearchCVdoesn't.