Skip to content

Commit fc64612

Browse files
fix internvl image token
1 parent ba6e7f3 commit fc64612

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lightllm/models/internvl/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, tokenizer, model_cfg, **kwargs):
3131

3232
self.llm_model_type = model_cfg.get("llm_config").get("model_type")
3333
self.tokenizer = tokenizer
34-
self.image_length = 256
34+
self.image_length = int(os.environ.get("INTERNVL_IMAGE_LENGTH", 256))
3535

3636
self.image_start_tag = IMG_START_TOKEN
3737
self.image_start_id = tokenizer.convert_tokens_to_ids(self.image_start_tag)

lightllm/models/qwen_vl/layer_infer/pre_layer_infer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ def context_forward(self, input_ids, infer_state: LlamaInferStateInfo, layer_wei
5858
img_weight = torch.cat(img_weight, dim=0).to(device=device, dtype=dtype)
5959
else:
6060
img_weight = torch.empty((0, hidden_size), device=device, dtype=dtype)
61+
assert img_weight.shape[1] == hidden_size, (
62+
f"Dimension mismatch: text weight dimension is {hidden_size}, "
63+
f"but image weight dimension is {img_weight.shape[1]}"
64+
)
6165
# each tp will fill the img embeds, should divide by world_size
6266
img_weight = img_weight / self.world_size_
6367
img_start_token_ids = torch.Tensor(img_start_token_ids).to(device=device, dtype=torch.long)

0 commit comments

Comments
 (0)