cherry pick from pr 4270 (#4285)
### What this PR does / why we need it? avoid mrope fusion op when running qwen25vl on x86 machine --------- Signed-off-by: 李少鹏 <lishaopeng21@huawei.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from transformers.configuration_utils import PretrainedConfig
|
||||
from vllm.config import ModelConfig, VllmConfig
|
||||
from vllm.model_executor.layers.rotary_embedding import (
|
||||
DeepseekScalingRotaryEmbedding, MRotaryEmbedding, RotaryEmbedding)
|
||||
from vllm.platforms import CpuArchEnum
|
||||
|
||||
from tests.ut.base import TestBase
|
||||
from vllm_ascend.ascend_forward_context import set_ascend_forward_context
|
||||
@@ -424,11 +425,14 @@ class TestAscendMRotaryEmbedding(unittest.TestCase):
|
||||
return vllm_config
|
||||
|
||||
@patch('torch_npu.npu_mrope')
|
||||
@patch('vllm_ascend.platform.NPUPlatform.get_cpu_architecture')
|
||||
@patch('vllm.config.ModelConfig.__post_init__', MagicMock())
|
||||
@patch('vllm.config.VllmConfig.__post_init__', MagicMock())
|
||||
@patch('vllm.distributed.parallel_state._DP', MagicMock(world_size=1))
|
||||
@patch('vllm.distributed.parallel_state._TP', MagicMock(world_size=1))
|
||||
def test_forward_oot_1d_positions(self, mock_npu_mrope):
|
||||
def test_forward_oot_1d_positions(self, mock_cpu_arc, mock_npu_mrope):
|
||||
mock_cpu_arc.return_value = CpuArchEnum.ARM
|
||||
|
||||
mock_npu_mrope.return_value = (torch.zeros_like(self.query),
|
||||
torch.zeros_like(self.key))
|
||||
|
||||
@@ -443,11 +447,14 @@ class TestAscendMRotaryEmbedding(unittest.TestCase):
|
||||
self.assertEqual(result_q.shape, self.query.shape)
|
||||
|
||||
@patch('torch_npu.npu_mrope')
|
||||
@patch('vllm_ascend.platform.NPUPlatform.get_cpu_architecture')
|
||||
@patch('vllm.config.ModelConfig.__post_init__', MagicMock())
|
||||
@patch('vllm.config.VllmConfig.__post_init__', MagicMock())
|
||||
@patch('vllm.distributed.parallel_state._DP', MagicMock(world_size=1))
|
||||
@patch('vllm.distributed.parallel_state._TP', MagicMock(world_size=1))
|
||||
def test_forward_oot_2d_positions(self, mock_npu_mrope):
|
||||
def test_forward_oot_2d_positions(self, mock_cpu_arc, mock_npu_mrope):
|
||||
mock_cpu_arc.return_value = CpuArchEnum.ARM
|
||||
|
||||
mock_npu_mrope.return_value = (torch.zeros_like(self.query),
|
||||
torch.zeros_like(self.key))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user