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 16, 03:15 UTC
[Misc] Move `print_*_once` from utils to logger (#11298)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk> Signed-off-by: Maxime Fournioux <55544262+mfournioux@users.noreply.github.com> Co-authored-by: Maxime Fournioux <55544262+mfournioux@users.noreply.github.com>
Cyrus Leung committed
Jan 9, 2025 at 12:48 UTC
d848800e884f581eeed9f154d6c2aeb38eac24de
21 files changed
+129
-72
.github/workflows/lint-and-deploy.yaml
+1
@@ -64,6 +64,7 @@ jobs:
64
run: |
65
export AWS_ACCESS_KEY_ID=minioadmin
66
export AWS_SECRET_ACCESS_KEY=minioadmin
67
+ sleep 30 && kubectl -n ns-vllm logs -f "$(kubectl -n ns-vllm get pods | awk '/deployment/ {print $1;exit}')" &
68
helm install --wait --wait-for-jobs --timeout 5m0s --debug --create-namespace --namespace=ns-vllm test-vllm examples/online_serving/chart-helm -f examples/online_serving/chart-helm/values.yaml --set secrets.s3endpoint=http://minio:9000 --set secrets.s3bucketname=testbucket --set secrets.s3accesskeyid=$AWS_ACCESS_KEY_ID --set secrets.s3accesskey=$AWS_SECRET_ACCESS_KEY --set resources.requests.cpu=1 --set resources.requests.memory=4Gi --set resources.limits.cpu=2 --set resources.limits.memory=5Gi --set image.env[0].name=VLLM_CPU_KVCACHE_SPACE --set image.env[1].name=VLLM_LOGGING_LEVEL --set-string image.env[0].value="1" --set-string image.env[1].value="DEBUG" --set-string extraInit.s3modelpath="opt-125m/" --set-string 'resources.limits.nvidia\.com/gpu=0' --set-string 'resources.requests.nvidia\.com/gpu=0' --set-string image.repository="vllm-cpu-env"
69
70
- name: curl test
vllm/attention/backends/torch_sdpa.py
+6
-3
@@ -13,9 +13,12 @@ from vllm.attention.backends.abstract import (AttentionBackend, AttentionImpl,
13
from vllm.attention.backends.utils import CommonAttentionState
14
from vllm.attention.ops.ipex_attn import PagedAttention
15
from vllm.attention.ops.paged_attn import PagedAttentionMetadata
16
-from vllm.utils import make_tensor_with_pad, print_warning_once
16
+from vllm.logger import init_logger
17
+from vllm.utils import make_tensor_with_pad
18
from vllm.worker.cpu_model_runner import ModelInputForCPUBuilder
19
20
+logger = init_logger(__name__)
21
+
22
23
class TorchSDPABackend(AttentionBackend):
24
@@ -396,8 +399,8 @@ class TorchSDPABackendImpl(AttentionImpl[TorchSDPAMetadata]):
399
raise ValueError(
400
"Torch SPDA does not support block-sparse attention.")
401
if logits_soft_cap is not None:
399
- print_warning_once("Torch SPDA does not support logits soft cap. "
400
- "Outputs may be slightly off.")
402
+ logger.warning_once("Torch SPDA does not support logits soft cap. "
403
+ "Outputs may be slightly off.")
404
self.num_heads = num_heads
405
self.head_size = head_size
406
self.scale = float(scale)
vllm/attention/backends/xformers.py
+5
-3
@@ -17,7 +17,9 @@ from vllm.attention.backends.utils import (
17
is_all_cross_attn_metadata_set, is_all_encoder_attn_metadata_set)
18
from vllm.attention.ops.paged_attn import (PagedAttention,
19
PagedAttentionMetadata)
20
-from vllm.utils import print_warning_once
20
+from vllm.logger import init_logger
21
+
22
+logger = init_logger(__name__)
23
24
25
class XFormersBackend(AttentionBackend):
@@ -385,8 +387,8 @@ class XFormersImpl(AttentionImpl[XFormersMetadata]):
387
raise ValueError(
388
"XFormers does not support block-sparse attention.")
389
if logits_soft_cap is not None:
388
- print_warning_once("XFormers does not support logits soft cap. "
389
- "Outputs may be slightly off.")
390
+ logger.warning_once("XFormers does not support logits soft cap. "
391
+ "Outputs may be slightly off.")
392
self.num_heads = num_heads
393
self.head_size = head_size
394
self.scale = float(scale)
vllm/config.py
+4
-5
@@ -32,8 +32,7 @@ from vllm.transformers_utils.config import (
32
from vllm.transformers_utils.s3_utils import S3Model
33
from vllm.transformers_utils.utils import is_s3
34
from vllm.utils import (GiB_bytes, LayerBlockType, cuda_device_count_stateless,
35
- get_cpu_memory, print_warning_once, random_uuid,
36
- resolve_obj_by_qualname)
35
+ get_cpu_memory, random_uuid, resolve_obj_by_qualname)
36
37
if TYPE_CHECKING:
38
from ray.util.placement_group import PlacementGroup
@@ -314,7 +313,7 @@ class ModelConfig:
313
sliding_window_len_min = get_min_sliding_window(
314
self.hf_text_config.sliding_window)
315
317
- print_warning_once(
316
+ logger.warning_once(
317
f"{self.hf_text_config.model_type} has interleaved "
318
"attention, which is currently not supported by the "
319
"XFORMERS backend. Disabling sliding window and capping "
@@ -2758,7 +2757,7 @@ class CompilationConfig(BaseModel):
2757
2758
def model_post_init(self, __context: Any) -> None:
2759
if not self.enable_reshape and self.enable_fusion:
2761
- print_warning_once(
2760
+ logger.warning_once(
2761
"Fusion enabled but reshape elimination disabled."
2762
"RMSNorm + quant (fp8) fusion might not work")
2763
@@ -3151,7 +3150,7 @@ class VllmConfig:
3150
self.scheduler_config.chunked_prefill_enabled and \
3151
self.model_config.dtype == torch.float32 and \
3152
current_platform.get_device_capability() == (7, 5):
3154
- print_warning_once(
3153
+ logger.warning_once(
3154
"Turing devices tensor cores do not support float32 matmul. "
3155
"To workaround this limitation, vLLM will set 'ieee' input "
3156
"precision for chunked prefill triton kernels.")
vllm/entrypoints/chat_utils.py
+3
-4
@@ -35,7 +35,6 @@ from vllm.logger import init_logger
35
from vllm.multimodal import MultiModalDataDict
36
from vllm.multimodal.utils import MediaConnector
37
from vllm.transformers_utils.tokenizer import AnyTokenizer, MistralTokenizer
38
-from vllm.utils import print_warning_once
38
39
logger = init_logger(__name__)
40
@@ -985,14 +984,14 @@ def apply_mistral_chat_template(
984
**kwargs: Any,
985
) -> List[int]:
986
if chat_template is not None:
988
- print_warning_once(
987
+ logger.warning_once(
988
"'chat_template' cannot be overridden for mistral tokenizer.")
989
if "add_generation_prompt" in kwargs:
991
- print_warning_once(
990
+ logger.warning_once(
991
"'add_generation_prompt' is not supported for mistral tokenizer, "
992
"so it will be ignored.")
993
if "continue_final_message" in kwargs:
995
- print_warning_once(
994
+ logger.warning_once(
995
"'continue_final_message' is not supported for mistral tokenizer, "
996
"so it will be ignored.")
997
vllm/inputs/preprocess.py
+11
-9
@@ -10,7 +10,6 @@ from vllm.multimodal import MULTIMODAL_REGISTRY, MultiModalRegistry
10
from vllm.multimodal.inputs import MultiModalDataDict, MultiModalInputsV2
11
from vllm.prompt_adapter.request import PromptAdapterRequest
12
from vllm.transformers_utils.tokenizer_group import BaseTokenizerGroup
13
-from vllm.utils import print_info_once, print_warning_once
13
14
from .data import (DecoderOnlyInputs, EncoderDecoderInputs, ProcessorInputs,
15
PromptType, SingletonInputs, SingletonPrompt, token_inputs)
@@ -68,21 +67,24 @@ class InputPreprocessor:
67
'''
68
69
if not self.model_config.is_encoder_decoder:
71
- print_warning_once("Using None for decoder start token id because "
72
- "this is not an encoder/decoder model.")
70
+ logger.warning_once(
71
+ "Using None for decoder start token id because "
72
+ "this is not an encoder/decoder model.")
73
return None
74
75
if (self.model_config is None or self.model_config.hf_config is None):
76
- print_warning_once("Using None for decoder start token id because "
77
- "model config is not available.")
76
+ logger.warning_once(
77
+ "Using None for decoder start token id because "
78
+ "model config is not available.")
79
return None
80
81
dec_start_token_id = getattr(self.model_config.hf_config,
82
'decoder_start_token_id', None)
83
if dec_start_token_id is None:
83
- print_warning_once("Falling back on <BOS> for decoder start token "
84
- "id because decoder start token id is not "
85
- "available.")
84
+ logger.warning_once(
85
+ "Falling back on <BOS> for decoder start token "
86
+ "id because decoder start token id is not "
87
+ "available.")
88
dec_start_token_id = self.get_bos_token_id()
89
90
return dec_start_token_id
@@ -231,7 +233,7 @@ class InputPreprocessor:
233
# updated to use the new multi-modal processor
234
can_process_multimodal = self.mm_registry.has_processor(model_config)
235
if not can_process_multimodal:
234
- print_info_once(
236
+ logger.info_once(
237
"Your model uses the legacy input pipeline instead of the new "
238
"multi-modal processor. Please note that the legacy pipeline "
239
"will be removed in a future release. For more details, see: "
vllm/inputs/registry.py
+2
-2
@@ -12,7 +12,7 @@ from vllm.logger import init_logger
12
from vllm.transformers_utils.processor import cached_get_processor
13
from vllm.transformers_utils.tokenizer import AnyTokenizer
14
from vllm.utils import (ClassRegistry, get_allowed_kwarg_only_overrides,
15
- print_warning_once, resolve_mm_processor_kwargs)
15
+ resolve_mm_processor_kwargs)
16
17
from .data import ProcessorInputs, SingletonInputs
18
from .parse import is_encoder_decoder_inputs
@@ -352,7 +352,7 @@ class InputRegistry:
352
num_tokens = dummy_data.seq_data.prompt_token_ids
353
if len(num_tokens) < seq_len:
354
if is_encoder_data:
355
- print_warning_once(
355
+ logger.warning_once(
356
f"Expected at least {seq_len} dummy encoder tokens for "
357
f"profiling, but found {len(num_tokens)} tokens instead.")
358
else:
vllm/logger.py
+52
-5
@@ -4,11 +4,12 @@ import json
4
import logging
5
import os
6
import sys
7
-from functools import partial
7
+from functools import lru_cache, partial
8
from logging import Logger
9
from logging.config import dictConfig
10
from os import path
11
-from typing import Dict, Optional
11
+from types import MethodType
12
+from typing import Any, Optional, cast
13
14
import vllm.envs as envs
15
@@ -49,8 +50,44 @@ DEFAULT_LOGGING_CONFIG = {
50
}
51
52
53
+@lru_cache
54
+def _print_info_once(logger: Logger, msg: str) -> None:
55
+ # Set the stacklevel to 2 to print the original caller's line info
56
+ logger.info(msg, stacklevel=2)
57
+
58
+
59
+@lru_cache
60
+def _print_warning_once(logger: Logger, msg: str) -> None:
61
+ # Set the stacklevel to 2 to print the original caller's line info
62
+ logger.warning(msg, stacklevel=2)
63
+
64
+
65
+class _VllmLogger(Logger):
66
+ """
67
+ Note:
68
+ This class is just to provide type information.
69
+ We actually patch the methods directly on the :class:`logging.Logger`
70
+ instance to avoid conflicting with other libraries such as
71
+ `intel_extension_for_pytorch.utils._logger`.
72
+ """
73
+
74
+ def info_once(self, msg: str) -> None:
75
+ """
76
+ As :meth:`info`, but subsequent calls with the same message
77
+ are silently dropped.
78
+ """
79
+ _print_info_once(self, msg)
80
+
81
+ def warning_once(self, msg: str) -> None:
82
+ """
83
+ As :meth:`warning`, but subsequent calls with the same message
84
+ are silently dropped.
85
+ """
86
+ _print_warning_once(self, msg)
87
+
88
+
89
def _configure_vllm_root_logger() -> None:
53
- logging_config: Dict = {}
90
+ logging_config = dict[str, Any]()
91
92
if not VLLM_CONFIGURE_LOGGING and VLLM_LOGGING_CONFIG_PATH:
93
raise RuntimeError(
@@ -84,12 +121,22 @@ def _configure_vllm_root_logger() -> None:
121
dictConfig(logging_config)
122
123
87
-def init_logger(name: str) -> Logger:
124
+def init_logger(name: str) -> _VllmLogger:
125
"""The main purpose of this function is to ensure that loggers are
126
retrieved in such a way that we can be sure the root vllm logger has
127
already been configured."""
128
92
- return logging.getLogger(name)
129
+ logger = logging.getLogger(name)
130
+
131
+ methods_to_patch = {
132
+ "info_once": _print_info_once,
133
+ "warning_once": _print_warning_once,
134
+ }
135
+
136
+ for method_name, method in methods_to_patch.items():
137
+ setattr(logger, method_name, MethodType(method, logger))
138
+
139
+ return cast(_VllmLogger, logger)
140
141
142
# The root logger is initialized when the module is imported.
vllm/lora/peft_helper.py
+4
-2
@@ -4,7 +4,9 @@ import math
4
from dataclasses import MISSING, dataclass, field, fields
5
from typing import Literal, Optional, Union
6
7
-from vllm.utils import print_info_once
7
+from vllm.logger import init_logger
8
+
9
+logger = init_logger(__name__)
10
11
12
@dataclass
@@ -42,7 +44,7 @@ class PEFTHelper:
44
def __post_init__(self):
45
self._validate_features()
46
if self.use_rslora:
45
- print_info_once("Loading LoRA weights trained with rsLoRA.")
47
+ logger.info_once("Loading LoRA weights trained with rsLoRA.")
48
self.vllm_lora_scaling_factor = self.lora_alpha / math.sqrt(self.r)
49
else:
50
self.vllm_lora_scaling_factor = self.lora_alpha / self.r
vllm/lora/punica_wrapper/punica_selector.py
+5
-3
@@ -1,19 +1,21 @@
1
+from vllm.logger import init_logger
2
from vllm.platforms import current_platform
2
-from vllm.utils import print_info_once
3
4
from .punica_base import PunicaWrapperBase
5
6
+logger = init_logger(__name__)
7
+
8
9
def get_punica_wrapper(*args, **kwargs) -> PunicaWrapperBase:
10
if current_platform.is_cuda_alike():
11
# Lazy import to avoid ImportError
12
from vllm.lora.punica_wrapper.punica_gpu import PunicaWrapperGPU
11
- print_info_once("Using PunicaWrapperGPU.")
13
+ logger.info_once("Using PunicaWrapperGPU.")
14
return PunicaWrapperGPU(*args, **kwargs)
15
elif current_platform.is_hpu():
16
# Lazy import to avoid ImportError
17
from vllm.lora.punica_wrapper.punica_hpu import PunicaWrapperHPU
16
- print_info_once("Using PunicaWrapperHPU.")
18
+ logger.info_once("Using PunicaWrapperHPU.")
19
return PunicaWrapperHPU(*args, **kwargs)
20
else:
21
raise NotImplementedError
vllm/model_executor/custom_op.py
+1
-2
@@ -5,7 +5,6 @@ import torch.nn as nn
5
from vllm.config import get_current_vllm_config
6
from vllm.logger import init_logger
7
from vllm.platforms import current_platform
8
-from vllm.utils import print_warning_once
8
9
logger = init_logger(__name__)
10
@@ -91,7 +90,7 @@ class CustomOp(nn.Module):
90
compilation_config = get_current_vllm_config().compilation_config
91
custom_ops = compilation_config.custom_ops
92
if not hasattr(cls, "name"):
94
- print_warning_once(
93
+ logger.warning_once(
94
f"Custom op {cls.__name__} was not registered, "
95
f"which means it won't appear in the op registry. "
96
f"It will be enabled/disabled based on the global settings.")
vllm/model_executor/layers/quantization/compressed_tensors/compressed_tensors_moe.py
+5
-3
@@ -8,6 +8,7 @@ from compressed_tensors.quantization import QuantizationStrategy
8
9
import vllm.model_executor.layers.fused_moe # noqa
10
from vllm import _custom_ops as ops
11
+from vllm.logger import init_logger
12
from vllm.model_executor.layers.fused_moe import (FusedMoE, FusedMoEMethodBase,
13
FusedMoeWeightScaleSupported)
14
from vllm.model_executor.layers.quantization.compressed_tensors.schemes import (
@@ -16,7 +17,8 @@ from vllm.model_executor.layers.quantization.utils.w8a8_utils import (
17
all_close_1d, normalize_e4m3fn_to_e4m3fnuz, per_tensor_dequantize)
18
from vllm.model_executor.utils import set_weight_attrs
19
from vllm.platforms import current_platform
19
-from vllm.utils import print_warning_once
20
+
21
+logger = init_logger(__name__)
22
23
24
class GPTQMarlinState(Enum):
@@ -142,10 +144,10 @@ class CompressedTensorsW8A8Fp8MoEMethod(CompressedTensorsMoEMethod):
144
"activation scales are None.")
145
if (not all_close_1d(layer.w13_input_scale)
146
or not all_close_1d(layer.w2_input_scale)):
145
- print_warning_once(
147
+ logger.warning_once(
148
"Found input_scales that are not equal for "
149
"fp8 MoE layer. Using the maximum across experts "
148
- "for each layer. ")
150
+ "for each layer.")
151
layer.w13_input_scale = torch.nn.Parameter(
152
layer.w13_input_scale.max(), requires_grad=False)
153
layer.w2_input_scale = torch.nn.Parameter(
vllm/model_executor/layers/quantization/fp8.py
+2
-3
@@ -28,7 +28,6 @@ from vllm.model_executor.parameter import (BlockQuantScaleParameter,
28
PerTensorScaleParameter)
29
from vllm.model_executor.utils import set_weight_attrs
30
from vllm.platforms import current_platform
31
-from vllm.utils import print_warning_once
31
32
ACTIVATION_SCHEMES = ["static", "dynamic"]
33
@@ -539,10 +538,10 @@ class Fp8MoEMethod(FusedMoEMethodBase):
538
"activation scales are None.")
539
if (not all_close_1d(layer.w13_input_scale)
540
or not all_close_1d(layer.w2_input_scale)):
542
- print_warning_once(
541
+ logger.warning_once(
542
"Found input_scales that are not equal for "
543
"fp8 MoE layer. Using the maximum across experts "
545
- "for each layer. ")
544
+ "for each layer.")
545
layer.w13_input_scale = torch.nn.Parameter(
546
layer.w13_input_scale.max(), requires_grad=False)
547
layer.w2_input_scale = torch.nn.Parameter(
vllm/model_executor/layers/quantization/kv_cache.py
+4
-2
@@ -1,8 +1,10 @@
1
import torch
2
3
+from vllm.logger import init_logger
4
from vllm.model_executor.layers.quantization.base_config import (
5
QuantizationConfig, QuantizeMethodBase)
5
-from vllm.utils import print_warning_once
6
+
7
+logger = init_logger(__name__)
8
9
10
class BaseKVCacheMethod(QuantizeMethodBase):
@@ -67,7 +69,7 @@ class BaseKVCacheMethod(QuantizeMethodBase):
69
layer._v_scale = v_scale
70
if (layer._k_scale == 1.0 and layer._v_scale == 1.0
71
and "e5m2" not in layer.kv_cache_dtype):
70
- print_warning_once(
72
+ logger.warning_once(
73
"Using KV cache scaling factor 1.0 for fp8_e4m3. This "
74
"may cause accuracy issues. Please make sure k/v_scale "
75
"scaling factors are available in the fp8 checkpoint.")
vllm/model_executor/layers/quantization/utils/marlin_utils_fp8.py
+4
-2
@@ -3,11 +3,13 @@ from typing import Optional
3
import torch
4
5
import vllm._custom_ops as ops
6
+from vllm.logger import init_logger
7
from vllm.platforms import current_platform
7
-from vllm.utils import print_warning_once
8
9
from .marlin_utils import marlin_make_workspace, marlin_permute_scales
10
11
+logger = init_logger(__name__)
12
+
13
14
def is_fp8_marlin_supported():
15
return current_platform.has_device_capability(80)
@@ -47,7 +49,7 @@ def apply_fp8_marlin_linear(
49
50
def prepare_fp8_layer_for_marlin(layer: torch.nn.Module,
51
strategy: str = "tensor") -> None:
50
- print_warning_once(
52
+ logger.warning_once(
53
"Your GPU does not have native support for FP8 computation but "
54
"FP8 quantization is being used. Weight-only FP8 compression will "
55
"be used leveraging the Marlin kernel. This may degrade "
vllm/model_executor/model_loader/weight_utils.py
+4
-4
@@ -25,7 +25,7 @@ from vllm.model_executor.layers.quantization import (QuantizationConfig,
25
get_quantization_config)
26
from vllm.model_executor.layers.quantization.schema import QuantParamSchema
27
from vllm.platforms import current_platform
28
-from vllm.utils import PlaceholderModule, print_warning_once
28
+from vllm.utils import PlaceholderModule
29
30
try:
31
from runai_model_streamer import SafetensorsStreamer
@@ -673,7 +673,7 @@ def maybe_remap_kv_scale_name(name: str, params_dict: dict) -> Optional[str]:
673
None: If the remapped name is not found in params_dict.
674
"""
675
if name.endswith(".kv_scale"):
676
- print_warning_once(
676
+ logger.warning_once(
677
"DEPRECATED. Found kv_scale in the checkpoint. "
678
"This format is deprecated in favor of separate k_scale and "
679
"v_scale tensors and will be removed in a future release. "
@@ -682,7 +682,7 @@ def maybe_remap_kv_scale_name(name: str, params_dict: dict) -> Optional[str]:
682
# NOTE: we remap the deprecated kv_scale to k_scale
683
remapped_name = name.replace(".kv_scale", ".attn.k_scale")
684
if remapped_name not in params_dict:
685
- print_warning_once(
685
+ logger.warning_once(
686
f"Found kv_scale in the checkpoint (e.g. {name}), "
687
"but not found the expected name in the model "
688
f"(e.g. {remapped_name}). kv_scale is "
@@ -695,7 +695,7 @@ def maybe_remap_kv_scale_name(name: str, params_dict: dict) -> Optional[str]:
695
if name.endswith(scale_name):
696
remapped_name = name.replace(scale_name, f".attn{scale_name}")
697
if remapped_name not in params_dict:
698
- print_warning_once(
698
+ logger.warning_once(
699
f"Found {scale_name} in the checkpoint (e.g. {name}), "
700
"but not found the expected name in the model "
701
f"(e.g. {remapped_name}). {scale_name} is "
vllm/model_executor/models/chameleon.py
+4
-2
@@ -11,6 +11,7 @@ from transformers import (BatchFeature, ChameleonConfig, ChameleonProcessor,
11
from vllm.attention import Attention, AttentionMetadata
12
from vllm.config import CacheConfig, VllmConfig
13
from vllm.distributed import get_pp_group, get_tensor_model_parallel_world_size
14
+from vllm.logger import init_logger
15
from vllm.model_executor.layers.activation import SiluAndMul
16
from vllm.model_executor.layers.layernorm import RMSNorm
17
from vllm.model_executor.layers.linear import (MergedColumnParallelLinear,
@@ -35,13 +36,14 @@ from vllm.multimodal.processing import (BaseMultiModalProcessor,
36
BaseProcessingInfo, PromptReplacement)
37
from vllm.multimodal.profiling import BaseDummyInputsBuilder, ProcessorInputs
38
from vllm.sequence import IntermediateTensors
38
-from vllm.utils import print_warning_once
39
40
from .interfaces import SupportsMultiModal, SupportsPP
41
from .utils import (is_pp_missing_parameter,
42
make_empty_intermediate_tensors_factory, make_layers,
43
maybe_prefix, merge_multimodal_embeddings)
44
45
+logger = init_logger(__name__)
46
+
47
48
class ChameleonImagePixelInputs(TypedDict):
49
type: Literal["pixel_values"]
@@ -1111,7 +1113,7 @@ class ChameleonForConditionalGeneration(nn.Module, SupportsMultiModal,
1113
remapped_kv_scale_name = name.replace(
1114
".kv_scale", ".attn.kv_scale")
1115
if remapped_kv_scale_name not in params_dict:
1114
- print_warning_once(
1116
+ logger.warning_once(
1117
"Found kv scale in the checkpoint (e.g. "
1118
f"{name}), but not found the expected name in "
1119
f"the model (e.g. {remapped_kv_scale_name}). "
vllm/model_executor/models/olmoe.py
+4
-2
@@ -20,6 +20,7 @@ from vllm.attention import Attention, AttentionMetadata
20
from vllm.compilation.decorators import support_torch_compile
21
from vllm.config import CacheConfig, VllmConfig
22
from vllm.distributed import get_pp_group, get_tensor_model_parallel_world_size
23
+from vllm.logger import init_logger
24
from vllm.model_executor.layers.fused_moe import FusedMoE
25
from vllm.model_executor.layers.layernorm import RMSNorm
26
from vllm.model_executor.layers.linear import (QKVParallelLinear,
@@ -34,13 +35,14 @@ from vllm.model_executor.layers.vocab_parallel_embedding import (
35
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
36
from vllm.model_executor.sampling_metadata import SamplingMetadata
37
from vllm.sequence import IntermediateTensors
37
-from vllm.utils import print_warning_once
38
39
from .interfaces import SupportsPP
40
from .utils import (is_pp_missing_parameter,
41
make_empty_intermediate_tensors_factory, make_layers,
42
maybe_prefix)
43
44
+logger = init_logger(__name__)
45
+
46
47
class OlmoeMoE(nn.Module):
48
"""A tensor-parallel MoE implementation for Olmoe that shards each expert
@@ -446,7 +448,7 @@ class OlmoeForCausalLM(nn.Module, SupportsPP):
448
remapped_kv_scale_name = name.replace(
449
".kv_scale", ".attn.kv_scale")
450
if remapped_kv_scale_name not in params_dict:
449
- print_warning_once(
451
+ logger.warning_once(
452
"Found kv scale in the checkpoint "
453
f"(e.g. {name}), but not found the expected "
454
f"name in the model "
vllm/model_executor/models/qwen2_moe.py
+4
-2
@@ -34,6 +34,7 @@ from vllm.config import CacheConfig, VllmConfig
34
from vllm.distributed import (get_pp_group,
35
get_tensor_model_parallel_world_size,
36
tensor_model_parallel_all_reduce)
37
+from vllm.logger import init_logger
38
from vllm.model_executor.layers.activation import SiluAndMul
39
from vllm.model_executor.layers.fused_moe import FusedMoE
40
from vllm.model_executor.layers.layernorm import RMSNorm
@@ -50,13 +51,14 @@ from vllm.model_executor.layers.vocab_parallel_embedding import (
51
from vllm.model_executor.model_loader.weight_utils import default_weight_loader
52
from vllm.model_executor.sampling_metadata import SamplingMetadata
53
from vllm.sequence import IntermediateTensors
53
-from vllm.utils import print_warning_once
54
55
from .interfaces import SupportsPP
56
from .utils import (extract_layer_index, is_pp_missing_parameter,
57
make_empty_intermediate_tensors_factory, make_layers,
58
maybe_prefix)
59
60
+logger = init_logger(__name__)
61
+
62
63
class Qwen2MoeMLP(nn.Module):
64
@@ -524,7 +526,7 @@ class Qwen2MoeForCausalLM(nn.Module, SupportsPP):
526
remapped_kv_scale_name = name.replace(
527
".kv_scale", ".attn.kv_scale")
528
if remapped_kv_scale_name not in params_dict:
527
- print_warning_once(
529
+ logger.warning_once(
530
"Found kv scale in the checkpoint "
531
f"(e.g. {name}), but not found the expected "
532
f"name in the model "
vllm/model_executor/models/vision.py
+4
-2
@@ -7,8 +7,10 @@ from transformers import PretrainedConfig
7
import vllm.envs as envs
8
from vllm.attention.selector import (backend_name_to_enum,
9
get_global_forced_attn_backend)
10
+from vllm.logger import init_logger
11
from vllm.platforms import _Backend, current_platform
11
-from vllm.utils import print_warning_once
12
+
13
+logger = init_logger(__name__)
14
15
_C = TypeVar("_C", bound=PretrainedConfig)
16
@@ -87,7 +89,7 @@ def get_vit_attn_backend(support_fa: bool = False) -> _Backend:
89
if is_flash_attn_2_available():
90
selected_backend = _Backend.FLASH_ATTN
91
else:
90
- print_warning_once(
92
+ logger.warning_once(
93
"Current `vllm-flash-attn` has a bug inside vision module, "
94
"so we use xformers backend instead. You can run "
95
"`pip install flash-attn` to use flash-attention backend.")
vllm/utils.py
-12
@@ -696,18 +696,6 @@ def create_kv_caches_with_random(
696
return key_caches, value_caches
697
698
699
-@lru_cache
700
-def print_info_once(msg: str) -> None:
701
- # Set the stacklevel to 2 to print the caller's line info
702
- logger.info(msg, stacklevel=2)
703
-
704
-
705
-@lru_cache
706
-def print_warning_once(msg: str) -> None:
707
- # Set the stacklevel to 2 to print the caller's line info
708
- logger.warning(msg, stacklevel=2)
709
-
710
-
699
@lru_cache(maxsize=None)
700
def is_pin_memory_available() -> bool:
701
from vllm.platforms import current_platform