-
Notifications
You must be signed in to change notification settings - Fork 321
[skyrl] Pass through profiler_config to vLLM engine #1622
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -345,6 +345,9 @@ class AsyncVLLMInferenceEngine(BaseVLLMInferenceEngine): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def __init__(self, *args, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| super().__init__(*args, **kwargs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._weight_loader = VLLMWeightLoader(self.llm, is_async=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # vLLM raises if profile() is called without profiler_config; gate on it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._profile_enabled = self.llm.vllm_config.profiler_config.profiler is not None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._profile_counter = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _create_engine(self, *args, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| openai_kwargs = pop_openai_kwargs(kwargs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -489,17 +492,30 @@ async def generate(self, input_batch: InferenceEngineInput) -> InferenceEngineOu | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Generate responses using vLLM's async engine.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt_token_ids, sampling_params = self._preprocess_prompts(input_batch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for prompt in prompt_token_ids: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Schedule the collection of outputs for each prompt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Avoid duplicate request_ids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request_id = str(uuid4().hex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task = asyncio.create_task(self._collect_outputs(prompt, request_id, sampling_params)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks.append(task) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = await asyncio.gather(*tasks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if self._profile_enabled: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.llm.start_profile(profile_prefix=f"sample_{self._profile_counter}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._profile_counter += 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for prompt in prompt_token_ids: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Schedule the collection of outputs for each prompt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Avoid duplicate request_ids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request_id = str(uuid4().hex) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| task = asyncio.create_task(self._collect_outputs(prompt, request_id, sampling_params)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks.append(task) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputs = await asyncio.gather(*tasks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finally: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if self._profile_enabled: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.llm.stop_profile() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+495
to
+509
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._postprocess_outputs(outputs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def start_profile(self, profile_prefix: Optional[str] = None) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.llm.start_profile(profile_prefix=profile_prefix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def stop_profile(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.llm.stop_profile() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def wake_up(self, *args: Any, **kwargs: Any): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await self.llm.wake_up(tags=kwargs.get("tags", None)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
AsyncVLLMInferenceEngineis an asynchronous engine, multiplegeneratecalls can run concurrently. Because vLLM's profiler is global, concurrent profiling attempts will conflict. We should initialize a lock here to serialize profiling in thegeneratemethod.