- Notifications
You must be signed in to change notification settings - Fork34
Open
Description
你好,这篇文章和代码实现细看了下,如果我想接入一个新的模型来支持infLLM,需要哪些满足条件,个人理解:
- 位置编码:新的模型attention内部也必须是RotaryEmbeddingESM编码方式,否则训练的模型与infLLM推理在位置编码等效性上就不一致了;
- 新模型的model.model.forward与InfLLM的model_forward的实现逻辑必须完全一样;
- 新模型的Attention的推理计算入参格式必须满足如下
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_value: Optional[Cache] = None,
output_attentions: bool = False,
use_cache: bool = False,
**kwargs,
) ,目的是为了与InfLLM定义的hf_forward的入参完全保持一致;
感觉应该够了,对吧,还需要其他硬性满足条件吗?
如确实如此,那么接入一个新的开源模型应该很容易对吧?为什么我看你这边只接入了LlamaForCausalLM,MistralForCausalLM,Qwen2ForCausalLM这三个?
Metadata
Metadata
Assignees
Labels
No labels