Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions vllm_gaudi/attention/backends/hpu_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import vllm_gaudi.extension.kernels as kernels
import vllm_gaudi.extension.ops as ops
from vllm_gaudi.extension.runtime import get_config
from vllm_gaudi.extension.utils import (FP8Matmul, Matmul, ModuleFusedSDPA, Softmax, VLLMFP8KVCache, VLLMKVCache)
from vllm_gaudi.extension.utils import (FP8Matmul, Matmul, B2BMatmul, ModuleFusedSDPA, Softmax, VLLMFP8KVCache,
VLLMKVCache)

from vllm.attention.backends.abstract import (AttentionBackend, AttentionImpl, AttentionLayer, AttentionMetadata,
AttentionType)
Expand Down Expand Up @@ -226,9 +227,9 @@ def __init__(
self.softmax = Softmax()
self.matmul_av = Matmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.batch2block_matmul = Matmul() if not self.enable_fp8_attn \
self.batch2block_matmul = B2BMatmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.block2batch_matmul = Matmul() if not self.enable_fp8_attn \
self.block2batch_matmul = B2BMatmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.latent_cache_k = VLLMKVCache() if not self.enable_fp8_attn \
else VLLMFP8KVCache()
Expand Down Expand Up @@ -445,9 +446,9 @@ def __init__(
self.softmax = Softmax()
self.matmul_av = Matmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.batch2block_matmul = Matmul() if not self.enable_fp8_attn \
self.batch2block_matmul = B2BMatmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.block2batch_matmul = Matmul() if not self.enable_fp8_attn \
self.block2batch_matmul = B2BMatmul() if not self.enable_fp8_attn \
else FP8Matmul()
self.k_cache = VLLMKVCache() if not self.enable_fp8_attn \
else VLLMFP8KVCache()
Expand Down
11 changes: 11 additions & 0 deletions vllm_gaudi/extension/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ def __init__(self):
def forward(self, x, y, **kwargs):
return torch.matmul(x, y, **kwargs)

class B2BMatmul(Matmul):
"""Specialized alias for batch2block and batch2block matmul operations.

This class is intentionally kept functionally identical to ``Matmul``.
It exists to provide semantic distinction in the codebase (e.g., for
patterns that specifically require batch2block and block2batch matmul) and to allow
future customization without changing call sites.
Copy link
Contributor

@dudilester dudilester Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe edit the comment to be more specific, change back-to-back to batch2block/block2batch and explain the reasoning for it, that it is used by the INC to adjust the scale to the needed values of the input tensor as some of them are discarded by the 2nd input which is kind of a mask mapping

"""
def __init__(self):
super().__init__()


class Softmax(torch.nn.Module):

Expand Down
Loading