[VLM] Support cos sin cache for Qwen3-VL & GLM-4.1V (#15205)

Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
This commit is contained in:
Yuan Luo
2025-12-18 08:39:50 +08:00
committed by GitHub
co-authored by luoyuan.luo
parent d20699a33c
commit 8fa3dc36c5
4 changed files with 100 additions and 80 deletions
@@ -219,6 +219,11 @@ class RotaryEmbedding(CustomOp):
sin.view(-1, 1, 1, last_dim).contiguous(),
)
def get_cos_sin(self, seqlen: int) -> tuple[torch.Tensor, torch.Tensor]:
cos_sin = self.cos_sin_cache[:seqlen]
cos, sin = cos_sin.chunk(2, dim=-1)
return cos, sin
def forward_native(
self,
positions: torch.Tensor,