Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/keep_gpu/single_gpu_controller/cuda_gpu_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ def _keep_loop(self) -> None:
raise RuntimeError("Failed to allocate matrix for GPU keeping")
while not self._stop_evt.is_set():
try:
self._run_mat_batch(matrix)
gpu_utilization = self._monitor_utilization(self.rank)
if gpu_utilization > self.busy_threshold:
logger.debug(
"rank %s: GPU busy (%d%%), sleeping longer",
self.rank,
gpu_utilization,
)
else:
self._run_mat_batch(matrix)
time.sleep(self.interval)
Comment on lines +175 to 183

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The log message at line 177, "sleeping longer", is misleading because time.sleep(self.interval) on line 183 is executed regardless of GPU utilization. To align the behavior with the log message, implement a longer sleep duration when the GPU is busy.

Suggested change
if gpu_utilization > self.busy_threshold:
logger.debug(
"rank %s: GPU busy (%d%%), sleeping longer",
self.rank,
gpu_utilization,
)
else:
self._run_mat_batch(matrix)
time.sleep(self.interval)
if gpu_utilization > self.busy_threshold:
logger.debug(
"rank %s: GPU busy (%d%%), sleeping longer",
self.rank,
gpu_utilization,
)
time.sleep(self.interval * 2) # sleep longer when GPU is busy
else:
self._run_mat_batch(matrix)
time.sleep(self.interval)

except RuntimeError as e:
# Handle OOM by clearing cache; then sleep and continue
Expand Down