flash_attn_with_kvcache在NPU上的替代方案问题求助
收藏回复举报
flash_attn_with_kvcache在NPU上的替代方案问题求助
t('forum.solved') 已解决
新人帖
发表于2025-08-14 14:54:28
0 查看

flash_attention.py 测试用例,基于GPU(CUDA)使用flash_attn_with_kvcache接口进行测试,调用代码如下:

# q: [batch_size, q_seq_len, q_head_num, head_dim]
# k: [batch_size, max_kv_len, kv_head_num, head_dim]
# v: [batch_size, max_kv_len, kv_head_num, head_dim]
out = flash_attn_with_kvcache(
    q=q, 
    k_cache=k_cache, 
    v_cache=v_cache, 
    cache_seqlens=cache_lens, 
    cache_batch_idx=cache_slot_ids, 
    softmax_scale=self.softmax_scale, 
    causal=True
)

flash_attn_with_kvcache接口描述

基于NPU可以使用什么接口进行替代?如何传参?

我要发帖子