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 14, 05:30 UTC
[Bugfix] Fix extra whitespace in strings caused by newline (#23272)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Cyrus Leung committed
Aug 21, 2025 at 13:03 UTC
0c31e28e9520d96c451cc7f023fd0f0af549766a
7 files changed
+30
-27
benchmarks/benchmark_dataset.py
+4
-2
@@ -958,8 +958,10 @@ class InstructCoderDataset(HuggingFaceDataset):
958
for i, item in enumerate(self.data):
959
if len(sampled_requests) >= num_requests:
960
break
961
- prompt = f"{item['input']}\n\n{item['instruction']} Just output \
962
- the code, do not include any explanation."
961
+ prompt = (
962
+ f"{item['input']}\n\n{item['instruction']} Just output "
963
+ "the code, do not include any explanation."
964
+ )
965
966
# apply template
967
prompt = tokenizer.apply_chat_template(
examples/offline_inference/vision_language.py
+7
-8
@@ -283,8 +283,10 @@ def run_glm4v(questions: list[str], modality: str) -> ModelRequestData:
283
)
284
285
prompts = [
286
- f"<|user|>\n<|begin_of_image|><|endoftext|><|end_of_image|>\
287
- {question}<|assistant|>"
286
+ (
287
+ "<|user|>\n<|begin_of_image|><|endoftext|><|end_of_image|>"
288
+ f"{question}<|assistant|>"
289
+ )
290
for question in questions
291
]
292
@@ -767,15 +769,13 @@ def run_llava_next_video(questions: list[str], modality: str) -> ModelRequestDat
769
def run_llava_onevision(questions: list[str], modality: str) -> ModelRequestData:
770
if modality == "video":
771
prompts = [
770
- f"<|im_start|>user <video>\n{question}<|im_end|> \
771
- <|im_start|>assistant\n"
772
+ f"<|im_start|>user <video>\n{question}<|im_end|><|im_start|>assistant\n"
773
for question in questions
774
]
775
776
elif modality == "image":
777
prompts = [
777
- f"<|im_start|>user <image>\n{question}<|im_end|> \
778
- <|im_start|>assistant\n"
778
+ f"<|im_start|>user <image>\n{question}<|im_end|><|im_start|>assistant\n"
779
for question in questions
780
]
781
@@ -998,8 +998,7 @@ def run_molmo(questions: list[str], modality: str) -> ModelRequestData:
998
)
999
1000
prompts = [
1001
- f"<|im_start|>user <image>\n{question}<|im_end|> \
1002
- <|im_start|>assistant\n"
1001
+ f"<|im_start|>user <image>\n{question}<|im_end|><|im_start|>assistant\n"
1002
for question in questions
1003
]
1004
vllm/benchmarks/datasets.py
+4
-2
@@ -1289,8 +1289,10 @@ class InstructCoderDataset(HuggingFaceDataset):
1289
for i, item in enumerate(self.data):
1290
if len(sampled_requests) >= num_requests:
1291
break
1292
- prompt = f"{item['input']}\n\n{item['instruction']} Just output \
1293
- the code, do not include any explanation."
1292
+ prompt = (
1293
+ f"{item['input']}\n\n{item['instruction']} Just output "
1294
+ "the code, do not include any explanation."
1295
+ )
1296
1297
# apply template
1298
prompt = tokenizer.apply_chat_template(
vllm/model_executor/model_loader/tpu.py
+6
-5
@@ -98,14 +98,15 @@ class TPUModelLoader(DefaultModelLoader):
98
99
# Check parameters
100
for name, param in model.named_parameters():
101
- assert param.device.type == device_type, f"Parameter {name} is on \
102
- {param.device.type} instead of {device_type}"
101
+ assert param.device.type == device_type, (
102
+ f"Parameter {name} is on {param.device.type} "
103
+ f"instead of {device_type}")
104
105
# Check buffers
106
for name, buffer in model.named_buffers():
106
- assert buffer.device.type == device_type, \
107
- f"Buffer {name} is on {buffer.device.type} instead of \
108
- {device_type}"
107
+ assert buffer.device.type == device_type, (
108
+ f"Buffer {name} is on {buffer.device.type} "
109
+ f"instead of {device_type}")
110
111
for module in model.modules():
112
if (mesh is not None) and (get_fqn(module) == 'QKVParallelLinear'):
vllm/model_executor/models/hyperclovax_vision.py
+4
-5
@@ -929,8 +929,8 @@ class HCXVisionForCausalLM(nn.Module, SupportsMultiModal, SupportsPP):
929
target_group_size = 0
930
931
elif video_group_size < target_group_size:
932
- raise RuntimeError(f"video_group_size < target_group_size!! \
933
- [{video_group_size} < {target_group_size}]")
932
+ raise RuntimeError(
933
+ f"{video_group_size=} < {target_group_size=}")
934
935
assert len(target_features
936
) == 0, f"target_features is not empty!! {target_features}"
@@ -1114,9 +1114,8 @@ def reshape_and_unpad_image_features(
1114
base_image_feature = image_feature[0]
1115
image_feature = image_feature[1:]
1116
1117
- assert (height * width == base_image_feature.shape[0]
1118
- ), f"height: {height}, width: {width}, \
1119
- base_image_feature.shape[0]: {base_image_feature.shape[0]}"
1117
+ assert height * width == base_image_feature.shape[0], (
1118
+ f"{height=} * {width=} != {base_image_feature.shape[0]=}")
1119
1120
num_patch_width, num_patch_height = get_anyres_image_grid_shape(
1121
image_size, possible_resolutions, grid_size)
vllm/model_executor/models/phi4mm.py
+3
-3
@@ -262,9 +262,9 @@ class Phi4MMImageEncoder(nn.Module):
262
img_features.shape[1]))
263
assert base_feat_height == base_feat_height_target \
264
and base_feat_width == base_feat_height_target, \
265
- f'base_feat_height: {base_feat_height},"\
266
- f" base_feat_width: {base_feat_width}, "\
267
- f"expect {base_feat_height_target} features for hd transform'
265
+ (f"base_feat_height: {base_feat_height}, "
266
+ f"base_feat_width: {base_feat_width}, "
267
+ f"expect {base_feat_height_target} features for hd transform")
268
269
# bs x max_num_crops x (24x24) x C
270
img_features = img_features.view(bs, -1,
vllm/transformers_utils/configs/eagle.py
+2
-2
@@ -61,8 +61,8 @@ class EAGLEConfig(PretrainedConfig):
61
else f"Eagle3{arch}" for arch in self.model.architectures
62
]
63
else:
64
- raise ValueError(f"Invalid method {method}. \
65
- Supported methods are eagle and eagle3.")
64
+ raise ValueError(f"Invalid method {method}. "
65
+ "Supported methods are eagle and eagle3.")
66
67
super().__init__(**kwargs)
68