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

[AIR] Add guide on how implement a custom predictors #31392

Merged
merged 11 commits into from
Jan 11, 2023

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Jan 3, 2023

Signed-off-by: Balaji Veeramani balaji@anyscale.com

Why are these changes needed?

Custom predictors allow users to port their models to do scalable batch inference with Ray, but there's no guide for doing this. This PR adds such a guide.

Related issue number

Closes #29789

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@bveeramani bveeramani requested a review from a team as a code owner January 3, 2023 07:41
@bveeramani bveeramani marked this pull request as draft January 3, 2023 07:41
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bveeramani! The content looks good to me, but I think we can do some restructuring to make this easier to read.

Instead of describing each method and then showing the examples at the end, I think it would be easier to follow by showing the examples directly in each method subsection.

So something like this:

We'll go through 2 examples of implementing custom predictors:

  • Implementing an MXNet Predictor. MXNet is ...
  • Implementing a statsmodel predictor. statsmodel is ...

Then walk through each step in the order that you would implement them

  1. from_checkpoint. Tab 1: MXNet. Tab 2: statsmodel
  2. __init__. Tab 1: MXNet. Tab 2: statsmodel.
  3. _predict_pandas/_predict_numpy. Tab 1: MXNet. Tab 2: statsmodel

Putting it all together. Tab 1: MXNet. Tab 2: statsmodel


# NOTE: This is to ensure the code runs. It shouldn't be part of the documentation.
dataset = ray.data.read_images("s3://air-example-data-2/imagenet-sample-images")
predictor.predict(dataset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to test these code snippets?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK they should already be tested

Copy link
Contributor

@ericl ericl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update this to describe how to create a basic checkpoint? For example, showing Checkpoint.from_dict({"arg": 123}) at least in the examples.

New users aren't familiar with checkpoints, so we should at least guide them on how to create/consume the most basic kind of checkpoint.

Also +1 on suggestions above.

bveeramani and others added 6 commits January 4, 2023 13:29
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com>
Signed-off-by: Balaji Veeramani <bveeramani@berkeley.edu>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@bveeramani bveeramani marked this pull request as ready for review January 7, 2023 00:20
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bveeramani, this looks great!

@amogkam
Copy link
Contributor

amogkam commented Jan 9, 2023

Looks like there are some errors with the doc code tests.

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@amogkam amogkam merged commit 30f8187 into ray-project:master Jan 11, 2023
AmeerHajAli pushed a commit that referenced this pull request Jan 12, 2023
Custom predictors allow users to port their models to do scalable batch inference with Ray, but there's no guide for doing this. This PR adds such a guide.

Signed-off-by: Balaji Veeramani <bveeramani@berkeley.edu>
Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[air/predictor] Add documentation for custom predictor
4 participants