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

[Serve][AIR] Support mixed input and output type, with batching #25688

Merged
merged 7 commits into from
Jun 16, 2022

Conversation

simon-mo
Copy link
Contributor

Why are these changes needed?

For AIR Predictor interface conformance. The predictor support input any data batch type and output any type, not necessary matching input and output type. This PR refactored how model wrapper does batching and splitting to support that.

Related issue number

Checks

  • 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 :(

@simon-mo simon-mo marked this pull request as ready for review June 11, 2022 00:04
Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

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

Nice job!

python/ray/serve/model_wrappers.py Show resolved Hide resolved

# Check all input has the same dict keys.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Check all input has the same dict keys.
# Check that all inputs have the same dict keys.

batch_has_same_keys = input_keys.count(input_keys[0]) == batch_size
if not batch_has_same_keys:
raise ValueError(
f"The input batch contains dictionary of different keys: {input_keys}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f"The input batch contains dictionary of different keys: {input_keys}"
f"The input batch's dictionaries must each contain the same keys. Got different keys in some dictionaries: {input_keys}"

else:
raise ValueError(
"ModelWrapper only accepts numpy array or dataframe as input "
"ModelWrapper only accepts numpy array, dataframe, or dict of "
"array as input "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"array as input "
"arrays as input "

python/ray/serve/model_wrappers.py Show resolved Hide resolved
Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

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

Great job on the updates!

@simon-mo simon-mo merged commit d83773b into ray-project:master Jun 16, 2022
edoakes pushed a commit to edoakes/ray that referenced this pull request Jul 14, 2022
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.

None yet

3 participants