Skip to content

Conversation

ahao-anyscale
Copy link
Contributor

@ahao-anyscale ahao-anyscale commented Sep 3, 2025

Why are these changes needed?

importing ray.serve.llm requires the user to install gymnasium, which is not used by serve.llm. This requirement is due to the usage of the Deprecation utility from RLlib. The utility is copied over to llm._internal.

Related issue number

Closes #56185

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(
    • I ran import ray.serve.llm without having gymnasium installed and it did not error.

…when using serve.llm

Signed-off-by: ahao-anyscale <ahao@anyscale.com>
@ahao-anyscale ahao-anyscale marked this pull request as ready for review September 3, 2025 06:18
@ahao-anyscale ahao-anyscale requested review from a team as code owners September 3, 2025 06:18
Copy link
Contributor

@kouroshHakha kouroshHakha left a comment

Choose a reason for hiding this comment

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

just some nits.

@@ -1,5 +1,8 @@
from typing import TYPE_CHECKING, Any, Dict, Optional, Union

# Using Deprecated copied from ray.rllib.utils.deprecation since they are returning better messages.
# TODO: Ray core should inherit that.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We usually put the name here, so we can map back who wrote the todo (e.g. TODO (ahao))

@@ -1,5 +1,8 @@
from typing import TYPE_CHECKING, Any, Dict, Optional, Union

# Using Deprecated copied from ray.rllib.utils.deprecation since they are returning better messages.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Put this in the top of the deprecation.py

Signed-off-by: ahao-anyscale <ahao@anyscale.com>
@ray-gardener ray-gardener bot added serve Ray Serve Related Issue rllib RLlib related issues llm community-contribution Contributed by the community labels Sep 3, 2025
@kouroshHakha kouroshHakha enabled auto-merge (squash) September 3, 2025 07:09
@github-actions github-actions bot added the go add ONLY when ready to merge, run all tests label Sep 3, 2025
@@ -0,0 +1,136 @@
# Using Deprecated copied from ray.rllib.utils.deprecation since they are returning better messages.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move this module ray._common package

Copy link
Contributor

Choose a reason for hiding this comment

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

we have our own common on llm stuff. I dont know if all ray libraries want to use the same style. Putting it in ray._common requires more thinking that we are leaving as a future TODO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using Deprecated copied from ray.rllib.utils.deprecation

That makes it 2 libraries that use this module. Or did we make any changes specific to llm ?

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes it 2 libraries that use this module. Or did we make any changes specific to llm ?

No, but that's slower to land that way. Needs coordination with rllib (and potentially others) and we should not block this for PR as it has added unnecessary dependencies the way it was done so far. This is internal api anyways and is lightweight enough to maintain for now and we can reduce the tech debt later.

Copy link
Contributor

Choose a reason for hiding this comment

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

but that's slower to land that way. Needs coordination with rllib (and potentially others)

I disagree; it's not that big of a lift to just do it as part of this PR, but that's just my opinion. I am not going to block this PR. Let's atleast create a GH issue for a first time contributor to pick up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@abrarsheikh do you guys use a different style for serve? Where are the utilities for serve around deprecation?

@kouroshHakha kouroshHakha merged commit 39add1e into ray-project:master Sep 3, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Contributed by the community go add ONLY when ready to merge, run all tests llm rllib RLlib related issues serve Ray Serve Related Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Serve, LLM] implicit dependency on ray ray.rllib when importing ray.serve.llm
4 participants