A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 15, 12:15 UTC
[Fix] Support passing args to logger (#17425)
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Aaron Pham committed
Apr 30, 2025 at 11:06 UTC
da4e7687b5d21d405bf229a74e055cc78cbcc06b
13 files changed
+75
-79
vllm/config.py
+6
-6
@@ -278,7 +278,7 @@ class ModelConfig:
278
max_model_len: int = None # type: ignore
279
"""Model context length (prompt and output). If unspecified, will be
280
automatically derived from the model config.
281
-
281
+
282
When passing via `--max-model-len`, supports k/m/g/K/M/G in human-readable
283
format. Examples:\n
284
- 1k -> 1000\n
@@ -518,11 +518,11 @@ class ModelConfig:
518
self.hf_text_config.sliding_window)
519
520
logger.warning_once(
521
- f"{self.hf_text_config.model_type} has interleaved "
522
- "attention, which is currently not supported by the "
523
- f"{backend} backend. Disabling sliding window and capping "
524
- "the max length to the sliding window size "
525
- f"({sliding_window_len_min}).")
521
+ "%s has interleaved attention, which is currently not supported by the %s backend. Disabling sliding window and capping the max length to the sliding window size (%d).", # noqa: E501
522
+ self.hf_text_config.model_type,
523
+ backend,
524
+ sliding_window_len_min,
525
+ )
526
self.disable_sliding_window = True
527
else:
528
# for a model with interleaved attention,
vllm/logger.py
+9
-8
@@ -5,6 +5,7 @@ import json
5
import logging
6
import os
7
import sys
8
+from collections.abc import Hashable
9
from functools import lru_cache, partial
10
from logging import Logger
11
from logging.config import dictConfig
@@ -52,15 +53,15 @@ DEFAULT_LOGGING_CONFIG = {
53
54
55
@lru_cache
55
-def _print_info_once(logger: Logger, msg: str) -> None:
56
+def _print_info_once(logger: Logger, msg: str, *args: Hashable) -> None:
57
# Set the stacklevel to 2 to print the original caller's line info
57
- logger.info(msg, stacklevel=2)
58
+ logger.info(msg, *args, stacklevel=2)
59
60
61
@lru_cache
61
-def _print_warning_once(logger: Logger, msg: str) -> None:
62
+def _print_warning_once(logger: Logger, msg: str, *args: Hashable) -> None:
63
# Set the stacklevel to 2 to print the original caller's line info
63
- logger.warning(msg, stacklevel=2)
64
+ logger.warning(msg, *args, stacklevel=2)
65
66
67
class _VllmLogger(Logger):
@@ -72,19 +73,19 @@ class _VllmLogger(Logger):
73
`intel_extension_for_pytorch.utils._logger`.
74
"""
75
75
- def info_once(self, msg: str) -> None:
76
+ def info_once(self, msg: str, *args: Hashable) -> None:
77
"""
78
As :meth:`info`, but subsequent calls with the same message
79
are silently dropped.
80
"""
80
- _print_info_once(self, msg)
81
+ _print_info_once(self, msg, *args)
82
82
- def warning_once(self, msg: str) -> None:
83
+ def warning_once(self, msg: str, *args: Hashable) -> None:
84
"""
85
As :meth:`warning`, but subsequent calls with the same message
86
are silently dropped.
87
"""
87
- _print_warning_once(self, msg)
88
+ _print_warning_once(self, msg, *args)
89
90
91
def _configure_vllm_root_logger() -> None:
vllm/lora/punica_wrapper/punica_selector.py
+1
-2
@@ -15,6 +15,5 @@ def get_punica_wrapper(*args, **kwargs) -> PunicaWrapperBase:
15
punica_wrapper = punica_wrapper_cls(*args, **kwargs)
16
assert punica_wrapper is not None, \
17
"the punica_wrapper_qualname(" + punica_wrapper_qualname + ") is wrong."
18
- logger.info_once("Using " + punica_wrapper_qualname.rsplit(".", 1)[1] +
19
- ".")
18
+ logger.info_once("Using %s.", punica_wrapper_qualname.rsplit(".", 1)[1])
19
return punica_wrapper
vllm/model_executor/custom_op.py
+3
-3
@@ -107,9 +107,9 @@ class CustomOp(nn.Module):
107
custom_ops = compilation_config.custom_ops
108
if not hasattr(cls, "name"):
109
logger.warning_once(
110
- f"Custom op {cls.__name__} was not registered, "
111
- f"which means it won't appear in the op registry. "
112
- f"It will be enabled/disabled based on the global settings.")
110
+ "Custom op %s was not registered, which means it won't appear in the op registry. It will be enabled/disabled based on the global settings.", # noqa: E501
111
+ cls.__name__,
112
+ )
113
return CustomOp.default_on()
114
115
enabled = f"+{cls.name}" in custom_ops
vllm/model_executor/guided_decoding/xgrammar_decoding.py
+3
-3
@@ -191,9 +191,9 @@ class GrammarConfig:
191
192
if model_with_warn is not None and any_whitespace:
193
logger.info_once(
194
- f"{model_with_warn} model detected, consider setting "
195
- "`disable_any_whitespace` to prevent runaway generation "
196
- "of whitespaces.")
194
+ "%s model detected, consider setting `disable_any_whitespace` to prevent runaway generation of whitespaces.", # noqa: E501
195
+ model_with_warn,
196
+ )
197
# Validate the schema and raise ValueError here if it is invalid.
198
# This is to avoid exceptions in model execution, which will crash
199
# the engine worker process.
vllm/model_executor/layers/quantization/awq_marlin.py
+3
-2
@@ -130,8 +130,9 @@ class AWQMarlinConfig(QuantizationConfig):
130
# Check if the layer is supported by AWQMarlin.
131
if not check_marlin_supports_layer(layer, self.group_size):
132
logger.warning_once(
133
- f"Layer '{prefix}' is not supported by AWQMarlin. "
134
- "Falling back to unoptimized AWQ kernels.")
133
+ "Layer '%s' is not supported by AWQMarlin. Falling back to unoptimized AWQ kernels.", # noqa: E501
134
+ prefix,
135
+ )
136
return AWQConfig.from_config(
137
self.full_config).get_quant_method(layer, prefix)
138
return AWQMarlinLinearMethod(self)
vllm/model_executor/model_loader/weight_utils.py
+11
-9
@@ -464,7 +464,7 @@ def fastsafetensors_weights_iterator(
464
hf_weights_files: List[str],
465
use_tqdm_on_load: bool,
466
) -> Generator[Tuple[str, torch.Tensor], None, None]:
467
- """Iterate over the weights in the model safetensor files
467
+ """Iterate over the weights in the model safetensor files
468
using fastsafetensor library."""
469
if torch.distributed.is_initialized():
470
pg = torch.distributed.group.WORLD
@@ -716,10 +716,10 @@ def maybe_remap_kv_scale_name(name: str, params_dict: dict) -> Optional[str]:
716
remapped_name = name.replace(".kv_scale", ".attn.k_scale")
717
if remapped_name not in params_dict:
718
logger.warning_once(
719
- f"Found kv_scale in the checkpoint (e.g. {name}), "
720
- "but not found the expected name in the model "
721
- f"(e.g. {remapped_name}). kv_scale is "
722
- "not loaded.")
719
+ "Found kv_scale in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). kv_scale is not loaded.", # noqa: E501
720
+ name,
721
+ remapped_name,
722
+ )
723
return None
724
return remapped_name
725
@@ -738,10 +738,12 @@ def maybe_remap_kv_scale_name(name: str, params_dict: dict) -> Optional[str]:
738
remapped_name = name.replace(scale_name, f".attn{scale_name}")
739
if remapped_name not in params_dict:
740
logger.warning_once(
741
- f"Found {scale_name} in the checkpoint (e.g. {name}), "
742
- "but not found the expected name in the model "
743
- f"(e.g. {remapped_name}). {scale_name} is "
744
- "not loaded.")
741
+ "Found %s in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). %s is not loaded.", # noqa: E501
742
+ scale_name,
743
+ name,
744
+ remapped_name,
745
+ scale_name,
746
+ )
747
return None
748
return remapped_name
749
vllm/model_executor/models/chameleon.py
+4
-4
@@ -1111,10 +1111,10 @@ class ChameleonForConditionalGeneration(nn.Module, SupportsMultiModal,
1111
".kv_scale", ".attn.kv_scale")
1112
if remapped_kv_scale_name not in params_dict:
1113
logger.warning_once(
1114
- "Found kv scale in the checkpoint (e.g. "
1115
- f"{name}), but not found the expected name in "
1116
- f"the model (e.g. {remapped_kv_scale_name}). "
1117
- "kv-scale is not loaded.")
1114
+ "Found kv scale in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). kv-scale is not loaded.", # noqa: E501
1115
+ name,
1116
+ remapped_kv_scale_name,
1117
+ )
1118
continue
1119
else:
1120
name = remapped_kv_scale_name
vllm/model_executor/models/olmoe.py
+4
-5
@@ -385,11 +385,10 @@ class OlmoeModel(nn.Module):
385
".kv_scale", ".attn.kv_scale")
386
if remapped_kv_scale_name not in params_dict:
387
logger.warning_once(
388
- "Found kv scale in the checkpoint "
389
- f"(e.g. {name}), but not found the expected "
390
- f"name in the model "
391
- f"(e.g. {remapped_kv_scale_name}). "
392
- "kv-scale is not loaded.")
388
+ "Found kv scale in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). kv-scale is not loaded.", # noqa: E501
389
+ name,
390
+ remapped_kv_scale_name,
391
+ )
392
continue
393
else:
394
name = remapped_kv_scale_name
vllm/model_executor/models/qwen2_moe.py
+4
-5
@@ -462,11 +462,10 @@ class Qwen2MoeModel(nn.Module):
462
".kv_scale", ".attn.kv_scale")
463
if remapped_kv_scale_name not in params_dict:
464
logger.warning_once(
465
- "Found kv scale in the checkpoint "
466
- f"(e.g. {name}), but not found the expected "
467
- f"name in the model "
468
- f"(e.g. {remapped_kv_scale_name}). "
469
- "kv-scale is not loaded.")
465
+ "Found kv_scale in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). kv_scale is not loaded.", # noqa: E501
466
+ name,
467
+ remapped_kv_scale_name,
468
+ )
469
continue
470
else:
471
name = remapped_kv_scale_name
vllm/model_executor/models/qwen3_moe.py
+4
-5
@@ -459,11 +459,10 @@ class Qwen3MoeModel(nn.Module):
459
".kv_scale", ".attn.kv_scale")
460
if remapped_kv_scale_name not in params_dict:
461
logger.warning_once(
462
- "Found kv scale in the checkpoint "
463
- f"(e.g. {name}), but not found the expected "
464
- f"name in the model "
465
- f"(e.g. {remapped_kv_scale_name}). "
466
- "kv-scale is not loaded.")
462
+ "Found kv scale in the checkpoint (e.g. %s), but not found the expected name in the model (e.g. %s). kv-scale is not loaded.", # noqa: E501
463
+ name,
464
+ remapped_kv_scale_name,
465
+ )
466
continue
467
else:
468
name = remapped_kv_scale_name
vllm/multimodal/profiling.py
+16
-22
@@ -215,17 +215,14 @@ class MultiModalProfiler(Generic[_I]):
215
elif total_len > seq_len and not envs.VLLM_USE_V1:
216
# `max_num_batched_tokens` is defined by `SchedulerConfig`
217
logger.warning_once(
218
- "The encoder sequence length used for profiling ("
219
- f"max_num_batched_tokens / max_num_seqs = {seq_len}) "
220
- " is too short "
221
- "to hold the multi-modal embeddings in the worst case "
222
- f"({total_len} tokens in total, out of which "
223
- f"{self._get_mm_num_tokens(mm_inputs)} are reserved for "
224
- "multi-modal embeddings). This may cause certain "
225
- "multi-modal inputs to fail during inference, even when "
226
- "the input text is short. To avoid this, you should "
227
- "increase `max_model_len`, reduce `max_num_seqs`, "
228
- "and/or reduce `mm_counts`.")
218
+ "The encoder sequence length used for profiling (max_num_batched_tokens / max_num_seqs = %d) " # noqa: E501
219
+ "is too short to hold the multi-modal embeddings in the worst case (%d tokens in total, out of which %s are reserved for multi-modal embeddings). " # noqa: E501
220
+ "This may cause certain multi-modal inputs to fail during inference, even when the input text is short. " # noqa: E501
221
+ "To avoid this, you should increase `max_model_len`, reduce `max_num_seqs`, and/or reduce `mm_counts`.", # noqa: E501
222
+ seq_len,
223
+ total_len,
224
+ str(self._get_mm_num_tokens(mm_inputs)),
225
+ )
226
227
return DummyEncoderData(encoder_prompt_token_ids)
228
@@ -243,17 +240,14 @@ class MultiModalProfiler(Generic[_I]):
240
if total_len > seq_len and not envs.VLLM_USE_V1:
241
# `max_num_batched_tokens` is defined by `SchedulerConfig`
242
logger.warning_once(
246
- "The sequence length used for profiling ("
247
- f"max_num_batched_tokens / max_num_seqs = {seq_len}) "
248
- "is too short "
249
- "to hold the multi-modal embeddings in the worst case "
250
- f"({total_len} tokens in total, out of which "
251
- f"{self._get_mm_num_tokens(mm_inputs)} are reserved for "
252
- "multi-modal embeddings). This may cause certain "
253
- "multi-modal inputs to fail during inference, even when "
254
- "the input text is short. To avoid this, you should "
255
- "increase `max_model_len`, reduce `max_num_seqs`, "
256
- "and/or reduce `mm_counts`.")
243
+ "The sequence length used for profiling (max_num_batched_tokens / max_num_seqs = %d) " # noqa: E501
244
+ "is too short to hold the multi-modal embeddings in the worst case (%d tokens in total, out of which %s are reserved for multi-modal embeddings). " # noqa: E501
245
+ "This may cause certain multi-modal inputs to fail during inference, even when the input text is short. " # noqa: E501
246
+ "To avoid this, you should increase `max_model_len`, reduce `max_num_seqs`, and/or reduce `mm_counts`.", # noqa: E501
247
+ seq_len,
248
+ total_len,
249
+ str(self._get_mm_num_tokens(mm_inputs)),
250
+ )
251
252
if total_len < seq_len:
253
prompt_token_ids.extend([0] * (seq_len - total_len))
vllm/multimodal/registry.py
+7
-5
@@ -100,7 +100,7 @@ class MultiModalRegistry:
100
model_config: "ModelConfig",
101
) -> Mapping[str, int]:
102
"""
103
- Get the maximum number of tokens per data item from each modality based
103
+ Get the maximum number of tokens per data item from each modality based
104
on underlying model configuration.
105
"""
106
if not model_config.is_multimodal_model:
@@ -126,11 +126,11 @@ class MultiModalRegistry:
126
) -> Mapping[str, int]:
127
"""
128
Get the maximum number of tokens per data item from each modality based
129
- on underlying model configuration, excluding modalities that user
129
+ on underlying model configuration, excluding modalities that user
130
explicitly disabled via `limit_mm_per_prompt`.
131
132
Note:
133
- This is currently directly used only in V1 for profiling the memory
133
+ This is currently directly used only in V1 for profiling the memory
134
usage of a model.
135
"""
136
mm_limits = self.get_mm_limits_per_prompt(model_config)
@@ -316,7 +316,9 @@ class MultiModalRegistry:
316
token_ids = dummy_data.prompt_token_ids
317
if len(token_ids) < seq_len:
318
logger.warning_once(
319
- f"Expected at least {seq_len} dummy encoder tokens for "
320
- f"profiling, but found {len(token_ids)} tokens instead.")
319
+ "Expected at least %d dummy encoder tokens for profiling, but found %d tokens instead.", # noqa: E501
320
+ seq_len,
321
+ len(token_ids),
322
+ )
323
324
return dummy_data