-
Notifications
You must be signed in to change notification settings - Fork 485
update GpuMemoryMonitor to DeviceMemoryMonitor for all HW #1526
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
fdd28c4
e2c4a03
5bb122e
9f25626
b6553a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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. Nit:
Contributor
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. Got it, I have updated cuda to current_platform_omni.
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. Thanks. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |
| from vllm.platforms import current_platform | ||
| from vllm.utils.torch_utils import cuda_device_count_stateless | ||
|
|
||
| from vllm_omni.platforms import current_omni_platform | ||
|
|
||
| _P = ParamSpec("_P") | ||
|
|
||
| if current_platform.is_rocm(): | ||
|
|
@@ -504,8 +506,8 @@ def wrapper(f: Callable[_P, None]) -> Callable[_P, None]: | |
| return wrapper | ||
|
|
||
|
|
||
| class GPUMemoryMonitor: | ||
| """Poll global device memory usage via CUDA APIs.""" | ||
| class DeviceMemoryMonitor: | ||
|
Collaborator
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. Suggestion: Consider making base class GPU-specific Since the base
This would make the design more robust. |
||
| """Poll global device memory usage.""" | ||
|
|
||
| def __init__(self, device_index: int, interval: float = 0.05): | ||
| self.device_index = device_index | ||
|
|
@@ -518,8 +520,8 @@ def start(self) -> None: | |
| def monitor_loop() -> None: | ||
| while not self._stop_event.is_set(): | ||
| try: | ||
| with torch.cuda.device(self.device_index): | ||
| free_bytes, total_bytes = torch.cuda.mem_get_info() | ||
| with current_omni_platform.device(self.device_index): | ||
| free_bytes, total_bytes = current_omni_platform.mem_get_info() | ||
| used_mb = (total_bytes - free_bytes) / (1024**2) | ||
| self._peak_used_mb = max(self._peak_used_mb, used_mb) | ||
| except Exception: | ||
|
|
@@ -537,8 +539,8 @@ def stop(self) -> None: | |
|
|
||
| @property | ||
| def peak_used_mb(self) -> float: | ||
| fallback_alloc = torch.cuda.max_memory_allocated(device=self.device_index) / (1024**2) | ||
| fallback_reserved = torch.cuda.max_memory_reserved(device=self.device_index) / (1024**2) | ||
| fallback_alloc = current_omni_platform.max_memory_allocated(device=self.device_index) / (1024**2) | ||
| fallback_reserved = current_omni_platform.max_memory_reserved(device=self.device_index) / (1024**2) | ||
| return max(self._peak_used_mb, fallback_alloc, fallback_reserved) | ||
|
|
||
| def __del__(self): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.