Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,25 @@ def maybe_execute_sparse_attention_finished(
maybe_execute_sparse_attention_finished
)

def unified_ascend_attention_with_output(
vllm_ops = torch.ops.vllm
orig_unified_ascend_attention_with_output = (
vllm_ops.unified_ascend_attention_with_output
)

def _wrap_op_overload(orig, impl):
class _Wrapper:
def __init__(self, orig):
self._orig = orig

def __call__(self, *args, **kwargs):
return impl(*args, **kwargs)

def __getattr__(self, name):
return getattr(self._orig, name)

return _Wrapper(orig)

def unified_ascend_attention_with_output_impl(
query: torch.Tensor,
key: torch.Tensor,
value: torch.Tensor,
Expand Down Expand Up @@ -151,8 +169,13 @@ def unified_ascend_attention_with_output(
maybe_save_kv_layer_to_connector(layer_name, kv_cache)
return

vllm_ops.unified_ascend_attention_with_output = _wrap_op_overload(
orig_unified_ascend_attention_with_output,
unified_ascend_attention_with_output_impl,
)

attention_v1.unified_ascend_attention_with_output = (
unified_ascend_attention_with_output
unified_ascend_attention_with_output_impl
)
except ImportError as e:
logger.error(f"Failed to patch attention_v1.py: {e}", exc_info=True)
Expand Down