vllm: [Performance]: InternVL multi image speed is not improved compare to original

Your current environment

The output of `python collect_env.py`
latest vllm 0.6.1

Model Input Dumps

tt

🐛 Describe the bug

InternVL multi image speed is slower than original

Before submitting a new issue…

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

when diving into the code, i found that internvl2 uses xformer’s attention not the naive one, so, the slow speed maybe come from other part.

@torinchen

https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/intern_vit.py#L271C1-L285C17

The code of vllm is being optimized rapidly, but at least today 20241029 is still using scaled_dot_product_attention

        if self.qk_normalization:
            B_, N_, H_, D_ = q.shape
            q = self.q_norm.forward_native(q.flatten(-2,
                                                     -1)).view(B_, N_, H_, D_)
            k = self.k_norm.forward_native(k.flatten(-2,
                                                     -1)).view(B_, N_, H_, D_)
        q = q.transpose(1, 2)
        k = k.transpose(1, 2)
        v = v.transpose(1, 2)


        x = F.scaled_dot_product_attention(q, k, v, scale=self.scale)
        x = x.transpose(1, 2).view(B, N, -1)


        x = self.proj(x)
        return x

https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/intern_vit.py#L353C4-L371C76