-
Notifications
You must be signed in to change notification settings - Fork 2k
[None][feat] VeRL/TRTLLM prototype #9133
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,9 @@ | |
| from dataclasses import dataclass | ||
| from enum import Enum, EnumMeta | ||
| from pathlib import Path | ||
| from typing import (Any, ClassVar, Dict, List, Literal, Optional, Set, Tuple, | ||
| Type, TypeAlias, TypeVar, Union, get_args, get_origin) | ||
| from typing import (TYPE_CHECKING, Any, ClassVar, Dict, List, Literal, Optional, | ||
| Set, Tuple, Type, TypeAlias, TypeVar, Union, get_args, | ||
| get_origin) | ||
|
|
||
| import torch | ||
| import yaml | ||
|
|
@@ -19,6 +20,11 @@ | |
| from strenum import StrEnum | ||
| from transformers import PreTrainedTokenizerBase | ||
|
|
||
| try: | ||
| from ray.util.placement_group import PlacementGroup | ||
| except ImportError: | ||
| PlacementGroup = None | ||
|
|
||
| from tensorrt_llm.lora_helper import (LoraConfig, | ||
| get_default_trtllm_modules_to_hf_modules) | ||
|
|
||
|
|
@@ -1926,6 +1932,8 @@ def validate_dtype(cls, v, info): | |
| @field_validator("gpus_per_node", mode='before') | ||
| @classmethod | ||
| def validate_gpus_per_node(cls, v, info): | ||
| if os.getenv("RAY_LOCAL_WORLD_SIZE") is not None: | ||
|
Collaborator
Author
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. Note: According to Liwei, this is likely obsolete. |
||
| return info.data.get("tensor_parallel_size") | ||
| if v is None: | ||
| logger.warning( | ||
| f"Using default gpus_per_node: {torch.cuda.device_count()}") | ||
|
|
@@ -2701,6 +2709,26 @@ class TorchLlmArgs(BaseLlmArgs): | |
| "Allows users to extend the functions of the RayGPUWorker class.", | ||
| status="prototype") | ||
|
|
||
| # Ray placement group config. Namings TBD. | ||
| placement_groups: Optional[List[Any]] = Field( | ||
| default=None, | ||
| description="List of Ray placement groups, one per node. " | ||
| "Each element must be a ray.util.placement_group.PlacementGroup instance.", | ||
| exclude_from_json=True, | ||
| status="prototype") | ||
|
|
||
| placement_bundle_indices: Optional[List[List[int]]] = Field( | ||
| default=None, | ||
| description="List of bundle indices for each placement group. " | ||
| "Outer list corresponds to placement_groups, inner list contains bundle indices for that group. ", | ||
| status="prototype") | ||
|
|
||
| per_worker_gpu_share: Optional[float] = Field( | ||
| default=None, | ||
| description="GPU fraction per worker for colocation scenarios. " | ||
| "Example: 0.1 means 10 actors can share one GPU. Defaults to 1.0 (one actor per GPU).", | ||
| status="prototype") | ||
|
|
||
| enable_sleep: bool = Field( | ||
| default=False, | ||
| description= | ||
|
|
@@ -2945,6 +2973,44 @@ def validate_ray_worker_extension_cls(self) -> 'TorchLlmArgs': | |
| ) | ||
| return self | ||
|
|
||
| @model_validator(mode='after') | ||
| def validate_ray_placement_config(self) -> 'TorchLlmArgs': | ||
| has_pgs = self.placement_groups is not None | ||
| has_indices = self.placement_bundle_indices is not None | ||
|
|
||
| if (has_pgs or has_indices) and self.orchestrator_type != "ray": | ||
| raise ValueError( | ||
| "placement_groups is only supported with orchestrator_type='ray'" | ||
| ) | ||
|
|
||
| if has_pgs != has_indices: | ||
| raise ValueError( | ||
| "placement_groups and placement_bundle_indices must be provided together" | ||
| ) | ||
|
|
||
| if has_pgs: | ||
| if len(self.placement_groups) != len(self.placement_bundle_indices): | ||
| raise ValueError( | ||
| f"placement_groups length ({len(self.placement_groups)}) must equal " | ||
| f"placement_bundle_indices length ({len(self.placement_bundle_indices)})" | ||
| ) | ||
|
|
||
| if self.per_worker_gpu_share is not None: | ||
| if not (0 < self.per_worker_gpu_share <= 1.0): | ||
| raise ValueError( | ||
| f"per_worker_gpu_share must be between 0 and 1.0, " | ||
| f"got {self.per_worker_gpu_share}") | ||
|
|
||
| if has_pgs: | ||
| if PlacementGroup is not None: | ||
| for i, pg in enumerate(self.placement_groups): | ||
| if not isinstance(pg, PlacementGroup): | ||
| raise TypeError( | ||
| f"placement_groups[{i}] must be a Ray PlacementGroup, " | ||
| f"got {type(pg).__name__}") | ||
|
|
||
| return self | ||
|
|
||
| def get_executor_config( | ||
| self, | ||
| _hf_model_dir: Optional[Path] = None, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Notes from syncing w/ Liwei:
VeRL needs async init for TRTLLM's LLM(), but PYthon has a limitation where init must be sync. So Liwei separate the async part out here.