Giter Club home page Giter Club logo

Comments (4)

hcho3 avatar hcho3 commented on July 28, 2024 1

@EdisonIsCoding As shown in https://treelite.readthedocs.io/en/latest/treelite-runtime-api.html#treelite.runtime.Predictor.predict, TreelitePredictorPredictBatch function is currently not thread safe. The reason is that it uses a dedicated thread pool to parallelize batch prediction. Consider using TreelitePredictorPredictInst instead.

from treelite.

EdisonIsCoding avatar EdisonIsCoding commented on July 28, 2024

Hi,

I'm developing a service recently which will allow others to do prediction via my service. And internally, I'm using a treelite predictor and calling into TreelitePredictorPredictBatch to make a prediction. So I'm wandering that whether this API is thread safe, since the request will come from different threads? Thanks for any help in advance!!

from treelite.

EdisonIsCoding avatar EdisonIsCoding commented on July 28, 2024

@hcho3 Thanks for your timely response! But in the case when the batch only have one row, it looks like TreelitePredictorPredictBatch also works fine, since I ran a stress test with 30 threads and each thread called TreelitePredictorPredictBatch API ~3k times with only one row in the batch (where I should call TreelitePredictorPredictInst in stead), the server did get the right prediction and didn't get into any problem. Is that true?

from treelite.

hcho3 avatar hcho3 commented on July 28, 2024

I'll have to come back to the stability of batch prediction API. I suppose that TreelitePredictorPredictBatch can work in your use case, but I won't provide any guarantees.

from treelite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.