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

Extending the Ray Serve integration to allow attributes for Serve deployments #2918

Merged

Conversation

zoltan-fedor
Copy link
Contributor

@zoltan-fedor zoltan-fedor commented Jul 28, 2022

Related Issue(s): closes #2917

We should be able to set Ray Serve attributes for the nodes of pipelines, like amount of GPU to use, max_concurrent_queries, etc.

Now this is possible from the pipeline yaml file for each node of the pipeline.

Proposed changes:

  • Extending the Ray Serve integration to allow attributes to be provided for the Serve deployments. Attributes like GPU usage (incl partial GPU usage), num_concurrent_queries and so on. See full list of attributes for the ray.serve.deployment() method in the Ray Serve API documentation

Pre-flight checklist

…loyments

This closes deepset-ai#2917

We should be able to set Ray Serve attributes for the nodes of pipelines, like amount of GPU to use, max_concurrent_queries, etc.

Now this is possible from the pipeline yaml file for each node of the pipeline.
Python 3.8 was generating a different schema than Python 3.7 is creating in the CI. You MUST use Python 3.7 to generate the schemas, otherwise the CIs will fail.
@sjrl sjrl added journey:advanced type:feature New feature or request labels Jul 29, 2022
@ZanSara ZanSara requested review from dmigo and ZanSara July 29, 2022 08:51
@ZanSara
Copy link
Contributor

ZanSara commented Jul 29, 2022

Hey @zoltan-fedor! Thank you for this PR. I will review it shortly 🙂

Copy link
Contributor

@ZanSara ZanSara left a comment

Choose a reason for hiding this comment

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

There are a couple of catches here.

The core issue is that you added the deployment_kwargs block to the general pipeline schema, without restricting it to Ray pipelines. This needs two actions to be fixed:

  1. We need a pipeline test that verifies that Ray attributes cannot be added to base pipelines. It could be something as simple as adding the following test in tests/pipelines/test_pipeline.yaml.py, approx line 996:
def test_load_yaml_ray_args_in_pipeline(tmp_path):
    with pytest.raises(PipelineConfigError) as e:
      pipeline = Pipeline.load_from_yaml(
          SAMPLES_PATH / "pipeline" / "ray.haystack-pipeline.yml", pipeline_name="ray_query_pipeline",
      )
  1. We need to restrict this argument to Ray pipelines. This is rather easy, you just need to add deployment_kwargs alongside replicas in this part of the schema:
    "oneOf": [
    {
    "not": {"required": ["extras"]},
    "properties": {
    "pipelines": {
    "title": "Pipelines",
    "items": {"properties": {"nodes": {"items": {"not": {"required": ["replicas"]}}}}},
    }
    },
    },

I hope it's all clear! Let me know if there's any question 🙂


One last thing: how about renaming the new param to serve_deployment_kwargs? Just to clarify it's related to Ray Serve. Otherwise deployment_kwargs sounds very generic.

This was generated by the JSON generator, but based on @ZanSara's instructions, I am removing it.
@zoltan-fedor
Copy link
Contributor Author

zoltan-fedor commented Jul 29, 2022

HI @ZanSara ,
As requested, I have renamed deployment_kwargs to serve_deployment_kwargs.

I have also added serve_deployment_kwargs to :

"oneOf": [ 
     { 
         "not": {"required": ["extras"]}, 
         "properties": { 
             "pipelines": { 
                 "title": "Pipelines", 
                 "items": {"properties": {"nodes": {"items": {"not": {"required": ["replicas", "serve_deployment_kwargs"]}}}}}, 
             } 
         }, 
     }, 

But that will not make the exception tested in the test to be thrown, so this test will fail:

def test_load_yaml_ray_args_in_pipeline(tmp_path):
    with pytest.raises(PipelineConfigError) as e:
      pipeline = Pipeline.load_from_yaml(
          SAMPLES_PATH / "pipeline" / "ray.haystack-pipeline.yml", pipeline_name="ray_query_pipeline",
      )

Any recommendations?

@ZanSara
Copy link
Contributor

ZanSara commented Jul 29, 2022

You're right about the test! We should add a check in the pipeline loading for the extras: ray. I'm going to add a comment about where I'd like to see this check added, hold on

@ZanSara
Copy link
Contributor

ZanSara commented Jul 29, 2022

Ok that's not very easy to explain 😅 I'll add a commit myself to do that 👍

@zoltan-fedor
Copy link
Contributor Author

Let me finish the removal of the replicas

@zoltan-fedor
Copy link
Contributor Author

I have made the replicas change by moving it below the new serve_deployment_kwargs, but I don't think I am allowed to add the breaking label to this PR. Would you mind adding that?

@ZanSara
Copy link
Contributor

ZanSara commented Jul 29, 2022

Let me finish the removal of the replicas

Sorry! I haven't seen this. I'm done anyway, I'll be back in a while to see how the tests look like.

…-fedor/haystack into feature-ray-serve-deployment-args
@zoltan-fedor zoltan-fedor requested a review from ZanSara July 29, 2022 16:23
Copy link
Contributor

@ZanSara ZanSara left a comment

Choose a reason for hiding this comment

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

Great work, thanks for it! 😊 I have no remarks.

@ZanSara ZanSara merged commit 7b97bbb into deepset-ai:master Aug 3, 2022
@zoltan-fedor zoltan-fedor deleted the feature-ray-serve-deployment-args branch August 3, 2022 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Ray Serve integration should allow settings like GPU use, concurrent queries, etc
4 participants