Skip to content
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

Inplace Predict Java API (xgboost4j) #5951

Closed
viswanathk opened this issue Jul 28, 2020 · 9 comments · Fixed by #9167
Closed

Inplace Predict Java API (xgboost4j) #5951

viswanathk opened this issue Jul 28, 2020 · 9 comments · Fixed by #9167

Comments

@viswanathk
Copy link

Hello.

I see that in the changelog for 1.1.0, a new API was added for thread safe prediction (inplace_predict). The current predict method exposed through xgboost4j is not thread safe, and hence marked as synchronized in the method.

Given that the inplace_predict can now do threadsafe prediction, what are the plans of adding this to the Java API? We use this library in a multithreaded Java application, and this can help boost performance.

Thanks,
Viswanath.

@trivialfis
Copy link
Member

trivialfis commented Jul 28, 2020

Would you like to open a PR for it? Inplace prediction means XGBoost has to digest external data directly. I'm not familiar with the ecosystem of Java so I don't know what data types to support.

@trivialfis
Copy link
Member

Also after #5853 normal predict function should also be thread safe in xgboost native code.

@viswanathk
Copy link
Author

viswanathk commented Jul 28, 2020

Good to know about #5853, but looks like it might take a while before we see it in release, and inplace_predict already does the job. Do you think it will be faster to add the Java wrapper to the inplace, than #5853 waiting for to make it release?

Would you like to open a PR for it? Inplace prediction means XGBoost has to digest external data directly. I'm not familiar with the ecosystem of Java so I don't know what data types to support.

I will go over the required changes - although I am not sure on where the gotchas can potentially be.

@trivialfis
Copy link
Member

trivialfis commented Jul 28, 2020

It's a blocking PR for the next release and we are now squashing the next release, so I would say pretty soon.

I will go over the required changes

I can help with issues in C++. @CodingCat expressed interest in inplace prediction before. So maybe @CodingCat can provide some suggestions on related topics around JVM bindings.

@dozaza
Copy link

dozaza commented Aug 14, 2020

Hi guys,

I'm working an online XGBoost prediction service, and want to use Java Multi thread for better performance.

As C++ code has resolved thread safe feature, simply removing "synchronize" key word in Java "predict" method, could enable multi-thread prediction in Java Environment?

@trivialfis
Copy link
Member

The C API is thread safe now. You need to check whether JAVA layer has additional states.

@viswanathk
Copy link
Author

Java layer doesn't seem to maintain any state that get's updated on the predict flow. Raised the PR #6021

Who's the maintainer / reviewer for the Java package?

@fangpings
Copy link

Any update on this issue?

@sihanwang94
Copy link

Need this feature +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants