-
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
Is predict(..., pred_contrib=True) thread safe? #5482
Comments
Seems to be an issue related to the |
I found a bug in Predictor related to incorrect usage of omp_get_thread_num. LightGBM/src/application/predictor.hpp Line 94 in e0c34e7
When working in multi-threaded mode, different threads can return tid=0. So, different threads (predict_fun_ lambdas) can write to the same memory block. I think the same problem is in all 4 prediction types. |
Thanks @AndreyOrb . Are you interested in proposing a fix? We'd welcome it! It is probably worth looking at these other places, to see if they're safe: git grep omp_get_thread_num |
I have reviewed the issue carefully.
|
2) Fixed Boosting trees initialization microsoft#5482
Description
I'm using the model behind a gRCP prediction service. The service predicts one example at a time.
I can reproduce the bug locally like
The error is like
or
or
depending on different runs.
max_workers=1
, the error seems to go away.pred_contrib=True
, the error seems to go away, so it lookspredict
alone is thread-safe, consistent with Is the function "LGBM_BoosterPredictForMat" thread safe? #666Reproducible example
I can produce some diff error, but also related to threading using the following code:
The error is like
or
Environment info
LightGBM version or commit hash:
lightgbm==3.3.2
Command(s) you used to install LightGBM
I'm using lightgbm inside a monorepo with bazel, but I think under the hood it's equivalent to
python -m pip install lightgbm
Additional Comments
The text was updated successfully, but these errors were encountered: