[Bugfix] Fix extra whitespace in strings caused by newline (#23272)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
This commit is contained in:
@ -958,8 +958,10 @@ class InstructCoderDataset(HuggingFaceDataset):
|
|||||||
for i, item in enumerate(self.data):
|
for i, item in enumerate(self.data):
|
||||||
if len(sampled_requests) >= num_requests:
|
if len(sampled_requests) >= num_requests:
|
||||||
break
|
break
|
||||||
prompt = f"{item['input']}\n\n{item['instruction']} Just output \
|
prompt = (
|
||||||
the code, do not include any explanation."
|
f"{item['input']}\n\n{item['instruction']} Just output "
|
||||||
|
"the code, do not include any explanation."
|
||||||
|
)
|
||||||
|
|
||||||
# apply template
|
# apply template
|
||||||
prompt = tokenizer.apply_chat_template(
|
prompt = tokenizer.apply_chat_template(
|
||||||
|
@ -283,8 +283,10 @@ def run_glm4v(questions: list[str], modality: str) -> ModelRequestData:
|
|||||||
)
|
)
|
||||||
|
|
||||||
prompts = [
|
prompts = [
|
||||||
f"<|user|>\n<|begin_of_image|><|endoftext|><|end_of_image|>\
|
(
|
||||||
{question}<|assistant|>"
|
"<|user|>\n<|begin_of_image|><|endoftext|><|end_of_image|>"
|
||||||
|
f"{question}<|assistant|>"
|
||||||
|
)
|
||||||
for question in questions
|
for question in questions
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -767,15 +769,13 @@ def run_llava_next_video(questions: list[str], modality: str) -> ModelRequestDat
|
|||||||
def run_llava_onevision(questions: list[str], modality: str) -> ModelRequestData:
|
def run_llava_onevision(questions: list[str], modality: str) -> ModelRequestData:
|
||||||
if modality == "video":
|
if modality == "video":
|
||||||
prompts = [
|
prompts = [
|
||||||
f"<|im_start|>user <video>\n{question}<|im_end|> \
|
f"<|im_start|>user <video>\n{question}<|im_end|><|im_start|>assistant\n"
|
||||||
<|im_start|>assistant\n"
|
|
||||||
for question in questions
|
for question in questions
|
||||||
]
|
]
|
||||||
|
|
||||||
elif modality == "image":
|
elif modality == "image":
|
||||||
prompts = [
|
prompts = [
|
||||||
f"<|im_start|>user <image>\n{question}<|im_end|> \
|
f"<|im_start|>user <image>\n{question}<|im_end|><|im_start|>assistant\n"
|
||||||
<|im_start|>assistant\n"
|
|
||||||
for question in questions
|
for question in questions
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -998,8 +998,7 @@ def run_molmo(questions: list[str], modality: str) -> ModelRequestData:
|
|||||||
)
|
)
|
||||||
|
|
||||||
prompts = [
|
prompts = [
|
||||||
f"<|im_start|>user <image>\n{question}<|im_end|> \
|
f"<|im_start|>user <image>\n{question}<|im_end|><|im_start|>assistant\n"
|
||||||
<|im_start|>assistant\n"
|
|
||||||
for question in questions
|
for question in questions
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1289,8 +1289,10 @@ class InstructCoderDataset(HuggingFaceDataset):
|
|||||||
for i, item in enumerate(self.data):
|
for i, item in enumerate(self.data):
|
||||||
if len(sampled_requests) >= num_requests:
|
if len(sampled_requests) >= num_requests:
|
||||||
break
|
break
|
||||||
prompt = f"{item['input']}\n\n{item['instruction']} Just output \
|
prompt = (
|
||||||
the code, do not include any explanation."
|
f"{item['input']}\n\n{item['instruction']} Just output "
|
||||||
|
"the code, do not include any explanation."
|
||||||
|
)
|
||||||
|
|
||||||
# apply template
|
# apply template
|
||||||
prompt = tokenizer.apply_chat_template(
|
prompt = tokenizer.apply_chat_template(
|
||||||
|
@ -98,14 +98,15 @@ class TPUModelLoader(DefaultModelLoader):
|
|||||||
|
|
||||||
# Check parameters
|
# Check parameters
|
||||||
for name, param in model.named_parameters():
|
for name, param in model.named_parameters():
|
||||||
assert param.device.type == device_type, f"Parameter {name} is on \
|
assert param.device.type == device_type, (
|
||||||
{param.device.type} instead of {device_type}"
|
f"Parameter {name} is on {param.device.type} "
|
||||||
|
f"instead of {device_type}")
|
||||||
|
|
||||||
# Check buffers
|
# Check buffers
|
||||||
for name, buffer in model.named_buffers():
|
for name, buffer in model.named_buffers():
|
||||||
assert buffer.device.type == device_type, \
|
assert buffer.device.type == device_type, (
|
||||||
f"Buffer {name} is on {buffer.device.type} instead of \
|
f"Buffer {name} is on {buffer.device.type} "
|
||||||
{device_type}"
|
f"instead of {device_type}")
|
||||||
|
|
||||||
for module in model.modules():
|
for module in model.modules():
|
||||||
if (mesh is not None) and (get_fqn(module) == 'QKVParallelLinear'):
|
if (mesh is not None) and (get_fqn(module) == 'QKVParallelLinear'):
|
||||||
|
@ -929,8 +929,8 @@ class HCXVisionForCausalLM(nn.Module, SupportsMultiModal, SupportsPP):
|
|||||||
target_group_size = 0
|
target_group_size = 0
|
||||||
|
|
||||||
elif video_group_size < target_group_size:
|
elif video_group_size < target_group_size:
|
||||||
raise RuntimeError(f"video_group_size < target_group_size!! \
|
raise RuntimeError(
|
||||||
[{video_group_size} < {target_group_size}]")
|
f"{video_group_size=} < {target_group_size=}")
|
||||||
|
|
||||||
assert len(target_features
|
assert len(target_features
|
||||||
) == 0, f"target_features is not empty!! {target_features}"
|
) == 0, f"target_features is not empty!! {target_features}"
|
||||||
@ -1114,9 +1114,8 @@ def reshape_and_unpad_image_features(
|
|||||||
base_image_feature = image_feature[0]
|
base_image_feature = image_feature[0]
|
||||||
image_feature = image_feature[1:]
|
image_feature = image_feature[1:]
|
||||||
|
|
||||||
assert (height * width == base_image_feature.shape[0]
|
assert height * width == base_image_feature.shape[0], (
|
||||||
), f"height: {height}, width: {width}, \
|
f"{height=} * {width=} != {base_image_feature.shape[0]=}")
|
||||||
base_image_feature.shape[0]: {base_image_feature.shape[0]}"
|
|
||||||
|
|
||||||
num_patch_width, num_patch_height = get_anyres_image_grid_shape(
|
num_patch_width, num_patch_height = get_anyres_image_grid_shape(
|
||||||
image_size, possible_resolutions, grid_size)
|
image_size, possible_resolutions, grid_size)
|
||||||
|
@ -262,9 +262,9 @@ class Phi4MMImageEncoder(nn.Module):
|
|||||||
img_features.shape[1]))
|
img_features.shape[1]))
|
||||||
assert base_feat_height == base_feat_height_target \
|
assert base_feat_height == base_feat_height_target \
|
||||||
and base_feat_width == base_feat_height_target, \
|
and base_feat_width == base_feat_height_target, \
|
||||||
f'base_feat_height: {base_feat_height},"\
|
(f"base_feat_height: {base_feat_height}, "
|
||||||
f" base_feat_width: {base_feat_width}, "\
|
f"base_feat_width: {base_feat_width}, "
|
||||||
f"expect {base_feat_height_target} features for hd transform'
|
f"expect {base_feat_height_target} features for hd transform")
|
||||||
|
|
||||||
# bs x max_num_crops x (24x24) x C
|
# bs x max_num_crops x (24x24) x C
|
||||||
img_features = img_features.view(bs, -1,
|
img_features = img_features.view(bs, -1,
|
||||||
|
@ -61,8 +61,8 @@ class EAGLEConfig(PretrainedConfig):
|
|||||||
else f"Eagle3{arch}" for arch in self.model.architectures
|
else f"Eagle3{arch}" for arch in self.model.architectures
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Invalid method {method}. \
|
raise ValueError(f"Invalid method {method}. "
|
||||||
Supported methods are eagle and eagle3.")
|
"Supported methods are eagle and eagle3.")
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user