[Feature] support aclgraph for model runner v2 (#7110)
### What this PR does / why we need it?
This PR aims to support aclgraph for model runner v2, please see RFC
#5208. The PR contains these modifications:
- adapt to newest commit of vllm main branch.
- supply a unified interface of extra forward context for both model
runner v1 and model runner v2.
- implement graph mode for main model.
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
- vLLM version: v0.16.0
- vLLM main:
4034c3d32e
---------
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
This commit is contained in:
@@ -95,7 +95,7 @@ class TestAscendAttentionCPImpl(TestBase):
|
||||
@patch('torch_npu.npu_attention_update')
|
||||
@patch("torch_npu.npu_fused_infer_attention_score")
|
||||
@patch(
|
||||
'vllm_ascend.attention.context_parallel.attention_cp.get_forward_context'
|
||||
'vllm_ascend.ascend_forward_context.get_forward_context'
|
||||
)
|
||||
@patch_distributed_groups(dcp_size=2, pcp_size=2)
|
||||
def test_forward_decode_pcp_dcp(self, mock_all2all, mock_dcp, mock_pcp,
|
||||
|
||||
@@ -212,7 +212,7 @@ class TestAscendAttentionBackendImpl(TestBase):
|
||||
|
||||
@patch('torch_npu._npu_reshape_and_cache')
|
||||
@patch('torch_npu.npu_fused_infer_attention_score')
|
||||
@patch('vllm_ascend.attention.attention_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
def test_forward_fused_infer_attention(
|
||||
self, mock_get_forward_context,
|
||||
mock_npu_fused_infer_attention_score, mock_npu_reshape_and_cache):
|
||||
@@ -248,7 +248,7 @@ class TestAscendAttentionBackendImpl(TestBase):
|
||||
@patch('vllm_ascend.attention.attention_v1.using_paged_attention')
|
||||
@patch('torch_npu._npu_paged_attention')
|
||||
@patch('torch_npu._npu_reshape_and_cache')
|
||||
@patch('vllm_ascend.attention.attention_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
def test_forward_paged_attention(self, mock_get_forward_context,
|
||||
mock_npu_reshape_and_cache,
|
||||
mock_paged_attention,
|
||||
@@ -279,7 +279,7 @@ class TestAscendAttentionBackendImpl(TestBase):
|
||||
mock_paged_attention.assert_called_once()
|
||||
assert output.shape == (4, 8 * 64)
|
||||
|
||||
@patch('vllm_ascend.attention.attention_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
@patch('torch_npu.npu_fused_infer_attention_score')
|
||||
@patch('torch_npu._npu_reshape_and_cache')
|
||||
def test_forward_decode_only_swa(self, mock_npu_reshape_and_cache,
|
||||
@@ -311,7 +311,7 @@ class TestAscendAttentionBackendImpl(TestBase):
|
||||
mock_fused_infer_attention_score.assert_called_once()
|
||||
assert output.shape == (10, 8, 64)
|
||||
|
||||
@patch('vllm_ascend.attention.attention_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
@patch('torch_npu._npu_paged_attention')
|
||||
@patch('torch_npu.npu_fused_infer_attention_score')
|
||||
@patch('torch_npu._npu_reshape_and_cache')
|
||||
|
||||
@@ -449,7 +449,7 @@ class TestAscendMLAImpl(TestBase):
|
||||
self.assertEqual(result.shape[1], N)
|
||||
self.assertEqual(result.shape[2], self.impl.kv_lora_rank + 1)
|
||||
|
||||
@patch('vllm_ascend.attention.context_parallel.mla_cp.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
@patch("torch_npu.npu_fused_infer_attention_score")
|
||||
@patch('torch_npu.npu_attention_update')
|
||||
@patch_distributed_groups(dcp_size=2, pcp_size=2, needs_mocks=False)
|
||||
|
||||
@@ -929,7 +929,7 @@ class TestAscendMLAImpl(TestBase):
|
||||
self.assertEqual(out.shape, prefix_out.shape)
|
||||
self.assertEqual(lse.shape, prefix_lse.shape)
|
||||
|
||||
@patch('vllm_ascend.attention.mla_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
@patch("vllm_ascend.attention.mla_v1.AscendMLAImpl._v_up_proj")
|
||||
@patch("torch_npu.npu_fused_infer_attention_score")
|
||||
def test_forward_decode_without_graph(self,
|
||||
@@ -1095,7 +1095,7 @@ class TestAscendMLAImpl(TestBase):
|
||||
self.assertEqual(k_pe.shape[-1], self.impl.qk_rope_head_dim)
|
||||
self.assertEqual(k_nope.shape[-1], self.impl.kv_lora_rank)
|
||||
|
||||
@patch('vllm_ascend.attention.mla_v1.get_forward_context')
|
||||
@patch('vllm_ascend.ascend_forward_context.get_forward_context')
|
||||
@patch("torch_npu.npu_fused_infer_attention_score")
|
||||
def test_forward_decode(self, mock_npu_fused_infer_attention_score,
|
||||
mock_get_forward_context):
|
||||
|
||||
Reference in New Issue
Block a user