Skip to content

Commit

Permalink
[Lint] Refactor logging to remove f-string usage for compliance
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Mansy <[email protected]>
  • Loading branch information
Ahmed14z committed Nov 4, 2024
1 parent b963eed commit 4bab492
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions vllm/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,31 +253,31 @@ def determine_num_available_blocks(self) -> Tuple[int, int]:
return num_gpu_blocks, num_cpu_blocks

def _assert_memory_footprint_increased_during_profiling(self):
# NOTE(woosuk): Here we assume that the other processes using the same
# GPU did not change their memory usage during the profiling.
# NOTE(woosuk): Here we assume that the other processes using the same
# GPU did not change their memory usage during the profiling.
free_gpu_memory, total_memory = torch.cuda.mem_get_info()
memory_diff = self.init_gpu_memory - free_gpu_memory

# If we've loaded model weights but memory shows no change,
# we're likely in a restricted environment
model_loaded = hasattr(self.model_runner, 'model')
memory_is_static = memory_diff == 0

is_restricted_env = model_loaded and memory_is_static

if is_restricted_env:
logger.info(
"Detected restricted GPU environment. "
"Model is loaded but memory reports static usage. "
f"Free memory: {free_gpu_memory / (1024**3):.2f}GB, "
f"Total memory: {total_memory / (1024**3):.2f}GB"
)

logger.info("Detected restricted GPU environment. "
"Model is loaded but memory reports static usage. "
"Free memory: {:.2f}GB, Total memory: {:.2f}GB".format(
free_gpu_memory / (1024**3),
total_memory / (1024**3)))

Check failure on line 273 in vllm/worker/worker.py

View workflow job for this annotation

GitHub Actions / ruff (3.8)

Ruff (G001)

vllm/worker/worker.py:269:25: G001 Logging statement uses `str.format`

Check failure on line 273 in vllm/worker/worker.py

View workflow job for this annotation

GitHub Actions / ruff (3.9)

Ruff (G001)

vllm/worker/worker.py:269:25: G001 Logging statement uses `str.format`

Check failure on line 273 in vllm/worker/worker.py

View workflow job for this annotation

GitHub Actions / ruff (3.10)

Ruff (G001)

vllm/worker/worker.py:269:25: G001 Logging statement uses `str.format`

assert memory_diff > 0 or is_restricted_env, (
"Error in memory profiling. "
"Error in memory profiling."
f"Initial free memory {self.init_gpu_memory}, current free memory"
f" {free_gpu_memory}. This happens when the GPU memory was "
"not properly cleaned up before initializing the vLLM instance.")

def initialize_cache(self, num_gpu_blocks: int,
num_cpu_blocks: int) -> None:
"""Allocate GPU and CPU KV cache with the specified number of blocks.
Expand Down

0 comments on commit 4bab492

Please sign in to comment.