PushKvCache
产品支持情况
产品 |
是否支持 |
---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
函数功能
推送Cache到远端节点,仅当角色为Prompt时可调用。
函数原型
1 2 3 4 5 | Status PushKvCache(const Cache &src_cache, const CacheIndex &dst_cache_index, uint32_t src_batch_index = 0U, int64_t size = -1, const KvCacheExtParam &ext_param = {}); |
参数说明
参数名称 |
输入/输出 |
取值说明 |
---|---|---|
src_cache |
输入 |
本地源Cache。 |
dst_cache_index |
输入 |
远端目的Cache的索引。 |
src_batch_index |
输入 |
本地源batch的下标。 |
size |
输入 |
当前只支持默认值-1。 |
ext_param |
输入 |
当前支持ext_param中src_layer_range和dst_layer_range取值一致,且只支持一次传入某一层的数值。 |
调用示例
1 2 3 4 5 6 7 8 9 10 11 12 | CacheDesc kv_desc{}; kv_desc.data_type = llm_datadist::DT_INT32; kv_desc.shape = {4, 16}; kv_desc.num_tensors = 4; Cache cache{}; llm_datadist.AllocateCache(kv_desc, cache); CacheIndex dst_cache_key{0, 1, 3}; KvCacheExtParam ext_param{}; ext_param.src_layer_range = std::pair<int32_t, int32_t>(3, 3); ext_param.dst_layer_range = std::pair<int32_t, int32_t>(3, 3); ext_param.tensor_num_per_layer = 1; Status ret = llm_datadist.PushKvCache(cache, dst_cache_key, 3, -1, ext_param); |
返回值
- LLM_SUCCESS:成功
- LLM_PARAM_INVALID:参数错误
- LLM_NOT_YET_LINK:与远端cluster没有建链
- LLM_TIMEOUT:推送超时
- LLM_KV_CACHE_NOT_EXIST:本地或远端KV Cache不存在
- 其他:失败
约束说明
需要在Initialize接口初始化完成后调用。src_cache必须为AllocateCache接口申请出的Cache。
父主题: LlmDataDist接口