preload_prompt_prefix
函数功能
预加载前缀kv。
函数原型
preload_prompt_prefix(llm_req: LLMReq, inputs: Any, **kwargs)
参数说明
调用示例
from llm_datadist import LLMDataDist, LLMRole, ModelConfig, ModelRunner, LLMReq llm_datadist = LLMDataDist(LLMRole.DECODER, 0) model_config = ModelConfig() kv_nums = 80 model_config.kv_shapes = ["1,1024" for _ in range(kv_nums)] model_config.kv_dtypes = [DataType.DT_FLOAT for _ in range(kv_nums)] model_options = model_config.generate_options() class TestModelRunner(ModelRunner): def run_model(self, kv_cache: KvCache, input_tensors, **kwargs): return [] llm_model = llm_datadist.add_model(model_options, TestModelRunner()) llm_req = LLMReq() inputs = [Tensor(np.array([1]))] llm_model.preload_prompt_prefix(llm_req, inputs)
返回值
正常情况下无返回值。
异常情况会抛出LLMException。
约束说明
无
父主题: LLMModel