Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lightllm/models/gemma3/gemma3_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def encode(self, images: List[ImageItem]):
t = self.image_processor.preprocess(image_data, return_tensors="pt")["pixel_values"]
img_tensors.append(t)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


cur_num = img_tensors[-1].shape[0]
valid_ids.append([valid_id, valid_id + cur_num])
Expand Down
2 changes: 1 addition & 1 deletion lightllm/models/internvl/internvl_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def encode(self, images: List[ImageItem]):
t = self.load_image_func(image_data, max_num=img.extra_params["image_patch_max_num"])
img_tensors.append(t)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


cur_num = img_tensors[-1].shape[0]
valid_ids.append([valid_id, valid_id + cur_num])
Expand Down
2 changes: 1 addition & 1 deletion lightllm/models/llava/llava_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def encode(self, images: List[ImageItem]):
t = self.image_processor.preprocess(image_data, return_tensors="pt")["pixel_values"]
img_tensors.append(t)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


cur_num = img_tensors[-1].shape[0]
valid_ids.append([valid_id, valid_id + cur_num])
Expand Down
6 changes: 3 additions & 3 deletions lightllm/models/qwen2_5_vl/qwen2_5_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")
return

def rot_pos_emb(self, grid_thw):
Expand Down Expand Up @@ -346,7 +346,7 @@ def load_image(self, img: List[ImageItem]):
image_data = resize_image(image_data)
pixel_values, image_grid_thw = self.processor.preprocess(image_data)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")

return pixel_values.to(dtype=self.data_type), image_grid_thw

def load_model(self, weight_dir):
Expand Down Expand Up @@ -387,7 +387,7 @@ def encode(self, images: List[ImageItem]):
img_tensors.append(pixel_values)
img_grids.append(image_grid_thw)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


# must devide merge_length
cur_num = img_tensors[-1].shape[0] // (self.spatial_merge_size ** 2)
Expand Down
4 changes: 2 additions & 2 deletions lightllm/models/qwen2_vl/qwen2_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")
return

def load_model(self, weight_dir):
Expand Down Expand Up @@ -319,7 +319,7 @@ def encode(self, images: List[ImageItem]):
img_tensors.append(pixel_values)
img_grids.append(image_grid_thw)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


# must devide merge_length
cur_num = img_tensors[-1].shape[0] // (self.spatial_merge_size ** 2)
Expand Down
2 changes: 1 addition & 1 deletion lightllm/models/qwen3_omni_moe_thinker/qwen3_omni_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")
return

def _freeze_parameters(self):
Expand Down
4 changes: 2 additions & 2 deletions lightllm/models/qwen3_omni_moe_thinker/qwen3_omni_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")
return

def concat_img_embed_and_deepstack_features(self, image_embed, deepstack_feature_lists, valid_ids):
Expand Down Expand Up @@ -388,7 +388,7 @@ def encode(self, images: List[ImageItem]):
img_tensors.append(pixel_values)
img_grids.append(image_grid_thw)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


# must devide merge_length
cur_num = img_tensors[-1].shape[0] // (self.spatial_merge_size ** 2)
Expand Down
4 changes: 2 additions & 2 deletions lightllm/models/qwen3_vl/qwen3_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")
return

def concat_img_embed_and_deepstack_features(self, image_embed, deepstack_feature_lists, valid_ids):
Expand Down Expand Up @@ -386,7 +386,7 @@ def encode(self, images: List[ImageItem]):
img_tensors.append(pixel_values)
img_grids.append(image_grid_thw)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


# must devide merge_length
cur_num = img_tensors[-1].shape[0] // (self.spatial_merge_size ** 2)
Expand Down
2 changes: 1 addition & 1 deletion lightllm/models/qwen_vl/qwen_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def encode(self, image_uuids: List):
t = self.image_transform(image_data)
img_tensors.append(t)
else:
raise Exception("Unsupport input types: {} for {}".format(type(item), item))
raise Exception("Unsupported input types: {} for {}".format(type(item), item))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(item), item))
raise TypeError(f"Unsupported input type: {type(item)} for {item}")


valid_ids.append([valid_id, valid_id + 1])
valid_id += 1
Expand Down
4 changes: 2 additions & 2 deletions lightllm/models/tarsier2/tarsier2_visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __init__(
projector_hidden_act,
)
elif projection_head == "auto_map":
raise Exception("Unsupport projection_head auto_map")
raise Exception("Unsupported projection_head auto_map")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like ValueError when encountering an unsupported configuration value.

Suggested change
raise Exception("Unsupported projection_head auto_map")
raise ValueError("Unsupported projection_head auto_map")

elif projection_head is None:
self.multi_modal_projector = lambda x, *args, **kwargs: x
self.llm_model_type = text_config["model_type"]
Expand Down Expand Up @@ -259,7 +259,7 @@ def encode(self, images: List[ImageItem]):
img_tensors.append(pixel_values)
img_grids.append(image_grid_thw)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


# must devide merge_length
cur_num = img_tensors[-1].shape[0] // (self.merge_size ** 2)
Expand Down
4 changes: 2 additions & 2 deletions lightllm/models/vit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _init_datatype(self):
elif self.data_type in ["fp32", "float32"]:
self.data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {self.data_type}!")
raise ValueError(f"Unsupported datatype {self.data_type}!")

@torch.no_grad()
def forward(self, pixel_values):
Expand All @@ -181,7 +181,7 @@ def encode(self, images: List[ImageItem]):
t = self.load_image_func(image_data, max_num=img.extra_params["image_patch_max_num"])
img_tensors.append(t)
else:
raise Exception("Unsupport input types: {} for {}".format(type(img), img))
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Raising a generic Exception is discouraged in Python. It is better to raise a more specific exception like TypeError when encountering an unsupported input type. Additionally, using f-strings is preferred over .format() for better readability and consistency.

Suggested change
raise Exception("Unsupported input types: {} for {}".format(type(img), img))
raise TypeError(f"Unsupported input type: {type(img)} for {img}")


cur_num = img.token_num
valid_ids.append([valid_id, valid_id + cur_num])
Expand Down
2 changes: 1 addition & 1 deletion lightllm/server/config_server/api_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def visual_websocket_endpoint(websocket: WebSocket):
client_ip, client_port = websocket.client
logger.info(f"ws connected from IP: {client_ip}, Port: {client_port}")
registered_visual_server_obj: VIT_Obj = pickle.loads(await websocket.receive_bytes())
logger.info(f"recieved registered_visual_server_obj {registered_visual_server_obj}")
logger.info(f"received registered_visual_server_obj {registered_visual_server_obj}")
with registered_visual_server_obj_lock:
registered_visual_server_objs[registered_visual_server_obj.node_id] = registered_visual_server_obj

Expand Down
2 changes: 1 addition & 1 deletion lightllm/utils/envs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_llm_data_type() -> torch.dtype:
elif data_type in ["fp32", "float32"]:
data_type = torch.float32
else:
raise ValueError(f"Unsupport datatype {data_type}!")
raise ValueError(f"Unsupported datatype {data_type}!")
return data_type


Expand Down
2 changes: 1 addition & 1 deletion lightllm/utils/torch_dtype_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def get_torch_dtype(data_type: str) -> torch.dtype:
elif data_type in ["fp32", "float32"]:
return torch.float32
else:
raise ValueError(f"Unsupport datatype {data_type}!")
raise ValueError(f"Unsupported datatype {data_type}!")