-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LGBM_BoosterPredictForCSRSingleRowFastInit
behavior differs from documentation
#4980
Comments
@AlbertoEAF Could you please take a look? |
Hello, I'm not available this month and probably not the next either. I believe @david-cortes is likely right. If I recall correctly, there might be some Predict operations that still have some internal coupling with the Booster itself, as that's the way the prediction functions of old (which the Fast ones reuse) are implemented. Doing predictions with certain changed parameters can modify the Booster itself, thus afecting posterior calls to Predict functions of any kind, including the Fast variants. This being the case it won't be a trivial fix. Maybe as a first step we should document to what side-effects Fast and FastInit prediction functions are susceptible to first. We should state in their docs that currently, prediction functions of any kind (fast & non-fast) can modify the Booster itself, indirectly affecting posterior use of the Fast methods that one assumes depend only on their init params (as they should). We must first review which parameters do this though. Note: In particular, and by design, to minimize calls at every FastPredict call, threading parameters are only set in FastInit and assume no one is using other threading parameter values other than those set in the FastInit call. I know it's not the best design, but as long as it's documented, this gives a better performance, and in case one wants to reset OpenMP's parallel processing settings he can call the FastInit again. Maybe this approach of having a FastInitReset or FastInitUpdate to modify the FastConfigHandle settings / force them again can be used as a stop-gap instead of having to modify all the internal Predict+Booster machinery in LGBM which has some coupling and will take some time to refactor. I also don't know yet if it's viable to refactor LGBM to fix this without sacrificing performance for the non-Fast methods, which should never be an option in my view. |
No problem! Thank you very much for your detailed input! |
Once this gets sorted out, the R docs need to be updated to reflect the correct behavior: #5312 (comment) |
Calling C function
LGBM_BoosterPredictForCSRSingleRowFastInit
has undocumented side effects in the booster object that it takes as input. According to the documentation, this function should produce aFastConfigHandle
object which is to then be passed to the prediction functionLGBM_BoosterPredictForCSRSingleRowFast
, but additionally:BoosterHandle
input that it is passed, changing its behavior also in calls toLGBM_BoosterPredictForCSRSingleRow
(which do not use the producedFastConfigHandle
).BoosterHandle
but with different parameters (such asstart_iteration
) will in the second call produce an object which still has the configuration from the earlier object.LGBM_BoosterPredictForCSRSingleRow
with a differentpredict_type
will affect the configuration from theFastConfigHandle
object in further calls toLGBM_BoosterPredictForCSRSingleRowFast
, even thoughFastConfigHandle
is not passed toLGBM_BoosterPredictForCSRSingleRow
.The text was updated successfully, but these errors were encountered: