---
title: RegisterKvCache
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/hixlug/llmcrv2_42_16.html
sourcePath: /source/zh/canncommercial/900/API/hixlug/llmcrv2_42_16.html
indexId: 809c47d3ed1b246d84ed44a71f464ccf570d3361e0e855101c6b714b3481f2e159
---
# RegisterKvCache

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | x |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | x |
| Atlas 推理系列产品 | x |
| Atlas 训练系列产品 | x |


说明：针对 Atlas A2 训练系列产品 / Atlas A2 推理系列产品 ，仅支持Atlas 800I A2 推理服务器、A200I A2 Box 异构组件。


#### 函数功能

注册本地KV Cache内存。


#### 函数原型

```
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。可用于后续调用传输kv接口时构造Cache。 |


#### 调用示例

单击Gitee(https://gitee.com/ascend/samples/tags)，根据“标签名”下载配套版本的sample包，从“cplusplus/level1_single_api/11_llm_data_dist”目录中获取样例。


#### 返回值

- LLM_SUCCESS：成功
- 其他：失败


#### 约束说明

需要在Initialize接口初始化完成后调用。

当HDK版本低于25.5.0时，最大注册20GB的Host内存；当HDK版本等于或大于25.5.0时，最大注册1TB的Host内存。注册内存越大，占用的OS内存越多。该约束支持的型号如下：

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