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

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| 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 异构组件。


#### 函数功能

异步分层传输Cache。


#### 函数原型

```
transfer_cache_async(self,
                     src_cache: Cache,
                     layer_synchronizer: LayerSynchronizer,
                     transfer_configs: Union[List[Union[TransferConfig, TransferWithCacheKeyConfig]], Tuple[Union[TransferConfig, TransferWithCacheKeyConfig]]],
                     src_block_indices: Optional[Union[List[int], Tuple[int]]] = None,
                     dst_block_indices: Optional[Union[List[int], Tuple[int]]] = None,
                     dst_block_memory_size: Optional[int] = None) -> CacheTask
```


#### 参数说明

| 参数名称 | 数据类型 | 取值说明 |
| --- | --- | --- |
| src\_cache | Cache | 源Cache。 |
| layer\_synchronizer | LayerSynchronizer | LayerSynchronizer的实现类对象。 |
| transfer\_configs | Union[List[Union[TransferConfig, TransferWithCacheKeyConfig]], Tuple[Union[TransferConfig, TransferWithCacheKeyConfig]]] | 传输配置列表或元组。 |
| src\_block\_indices | Optional[Union[List[int], Tuple[int]]] | 源Cache的block indices，当源Cache为PA场景时设置。 |
| dst\_block\_indices | Optional[Union[List[int], Tuple[int]]] | 目的Cache的block indices，当目的Cache为PA场景时设置。 |
| dst\_block\_memory\_size | Optional[int] | 目的Cache每个block占用的内存大小，当目的Cache为PA场景时设置。如果源Cache也为PA场景，则可省略该参数，此时会自动将其设置为源Cache每个block占用的内存大小。 该参数设置为0时等同于省略该参数。 |


#### 调用示例

```
cache_task = cache_manager.transfer_cache_async(cache, LayerSynchronizerImpl(), transfer_configs)
```


#### 返回值

正常情况下返回CacheTask。

传入数据类型错误，会抛出TypeError或ValueError异常。

传入数据非法，会抛出LLMException异常。


#### 约束说明

- 不支持src_cache是HOST，dst_cache是DEVICE的传输场景。
- 不支持src_cache是PA场景，dst_cache是非PA场景。
- 不支持单进程多卡场景。
- 若dst_cache是HOST，仅支持dst_cache通过  allocate_cache
申请方式申请。
- 需要保证transfer_config中的dst_addrs的有效性，以及在传输dst_block_indices场景下数据的有效性，否则错误未知。
- 开启  enable_remote_cache_accessible
时，transfer_configs中的类型需为  TransferWithCacheKeyConfig
，不开启  enable_remote_cache_accessible
时，transfer_configs中的类型需为  TransferConfig
。
