open-compass / open-compass/VLMEvalKit

Llama4 potential inference bug

Open
#1,101 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
768
Avg merge
2d 27m
Merged PRs (30d)
18

Description

Traceback (most recent call last):
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/run.py", line 375, in main
    model = infer_data_job(
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/vlmeval/inference.py", line 206, in infer_data_job
    model = infer_data(
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/vlmeval/inference.py", line 169, in infer_data
    response = model.generate(message=struct, dataset=dataset_name)
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/vlmeval/vlm/base.py", line 116, in generate
    return self.generate_inner(message, dataset)
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/vlmeval/vlm/llama4.py", line 282, in generate_inner
    return self.generate_inner_transformers(message, dataset=dataset)
  File "/opt/hpcaas/.mounts/fs-0663e2d3c38211883/home/hoangpv/VLMEvalKit/vlmeval/vlm/llama4.py", line 192, in generate_inner_transformers
    outputs = self.model.generate(**inputs, max_new_tokens=max_new_tokens)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/generation/utils.py", line 2597, in generate
    result = self._sample(
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/generation/utils.py", line 3557, in _sample
    outputs = self(**model_inputs, return_dict=True)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/accelerate/hooks.py", line 175, in new_forward
    output = module._old_forward(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/models/llama4/modeling_llama4.py", line 1652, in forward
    outputs = self.language_model(
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/utils/generic.py", line 969, in wrapper
    output = func(self, *args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/models/llama4/modeling_llama4.py", line 936, in forward
    outputs = self.model(
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
    return forward_call(*args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/utils/generic.py", line 969, in wrapper
    output = func(self, *args, **kwargs)
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/models/llama4/modeling_llama4.py", line 578, in forward
    causal_mask, chunk_causal_mask = self._update_causal_mask(
  File "/home/hoangpv/miniconda3/envs/torch/lib/python3.10/site-packages/transformers/models/llama4/modeling_llama4.py", line 739, in _update_causal_mask
    chunked_attention_mask = chunked_attention_mask * local_attention_mask[:, None, None, :]
RuntimeError: The size of tensor a (8192) must match the size of tensor b (8693) at non-singleton dimension 5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in vlmeval/vlm/llama4.py at generate_inner_transformers, then trace the inputs passed to self.model.generate and the reported Llama 4 causal-mask failure. Reproduce the inference run if possible and determine why the sequence lengths differ; done means the Llama4 inference no longer raises the reported tensor-size error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.