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

[core] clean up executor class hierarchy between v1 and v0 #12171

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

youkaichao
Copy link
Member

@youkaichao youkaichao commented Jan 17, 2025

This is a followup work of #11256 . After that PR, the executor hierarchy becomes quite messy:

  • v1 and v0 share the same ray executor
  • v1's multiprocessing executor and uniproc executor does not inherit any class from v0's executor base class

This makes adding new functions quite confusing. For example, #11960 adds some new functions like get_kv_cache_spec , but forgot to add it in the ray executor (which lives in v0 folder).

I'd like to clean up the hierarchy in this PR. The basic functionality of executor lives in v0 folder. v1 executors mainly inherit and extend new functions (interfaces). They can just delegate the function to collective_rpc .

After this PR, if we want to add a new interface in v1, we just need to touch vllm.v1.executor.abstract.Executor . If we want to add a new interface in both v0 and v1, we just need to touch vllm.executor.executor_base.ExecutorBase .

It is also possible to design the functions so that we don't even need UniprocExecutorV1 etc. But right now, the signature of execute_model conflicts. So I leave it as-is now.

Signed-off-by: youkaichao <[email protected]>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@youkaichao
Copy link
Member Author

youkaichao commented Jan 17, 2025

Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

Great simplification to the executor code! But I remembered that one coding convention of v1 is that we should make the dependency between v0 code and v1 code simple and can achieve it via some code duplication. Correct me if it is wrong. @WoosukKwon

class Executor(ABC):
"""Abstract class for executors."""
class Executor(ExecutorBase):
"""Abstract class for v1 executors, mainly define some new methods."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

A more clear comment: "Abstract class for v1 executors, mainly define some methods for v1. Define methods shared by v0 and v1 in ExecutorBase" And how to add an interface to only v0?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in dc2a886

Copy link
Member Author

Choose a reason for hiding this comment

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

how to add an interface to only v0

we don't introduce new features that only work for v0.

self.collective_rpc("profile", args=(is_start, ))


class UniprocExecutorV1(UniProcExecutor, Executor):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems that we don't have xxxV1 class in v1 code now. Will this be better? from vllm.executor.uniproc_executor import UniProcExecutor as UniProcExecutorV0

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good, added in 21a4b0e

Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
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.

2 participants