昇腾社区首页
中文
注册

RegisterKvCache

产品支持情况

产品

是否支持

Atlas A3 训练系列产品/Atlas A3 推理系列产品

Atlas 800I A2 推理产品/A200I A2 Box 异构组件

Atlas A2 训练系列产品

x

Atlas 200I/500 A2 推理产品

x

Atlas 推理系列产品

x

Atlas 训练系列产品

x

函数功能

注册本地KV Cache内存。

函数原型

1
2
3
4
Status RegisterKvCache(const CacheDesc &cache_desc,
                       const std::vector<uint64_t> &addrs,
                       const RegisterCfg &cfg,
                       int64_t &cache_id);

参数说明

参数名称

输入/输出

取值说明

cache_desc

输入

Cache的描述信息。

addrs

输入

Cache的地址。地址个数不超过240。

cfg

输入

预留参数。

cache_id

输出

注册的Cache的ID。

调用示例

1
2
3
4
5
6
7
8
9
CacheDesc cache_desc{};
cache_desc.num_tensors = NUM_TENSORS;
cache_desc.data_type = DT_INT32;
cache_desc.shape = {8, 16};
std::vector<uint64_t> tensor_addrs;
// alloc and fill tensor_addrs
int64_t cache_id = -1;
RegisterCfg cfg{};
auto ret = llm_datadist.RegisterKvCache(cache_desc, tensor_addrs, cfg, cache_id);

返回值

  • LLM_SUCCESS:成功
  • 其他:失败

约束说明

需要在Initialize接口初始化完成后调用。仅在配置了llm.LocalCommRes时支持。