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

#### 产品支持情况

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


#### 函数功能

构造TransferWithCacheKeyConfig。


#### 函数原型

```
__init__(cache_key: Union[BlocksCacheKey, CacheKeyByIdAndIndex], src_layer_range: range = None, dst_layer_range: range = None, src_batch_index: int = 0)
```


#### 参数说明

| 参数名 | 数据类型 | 取值说明 |
| --- | --- | --- |
| cache\_key | Union[BlocksCacheKey, CacheKeyByIdAndIndex] | 目的Cache所在实例的cluster\_id。 |
| src\_layer\_range | range | 必选参数，本地要传输的层的范围，step只支持为1。 |
| dst\_layer\_range | range | 必选参数，远端要传输的层的范围，step只支持为1。 |
| src\_batch\_index | int | 本地cache的batch下标。当源Cache为非PA场景时可以设置。 |


#### 调用示例

```
from llm_datadist import TransferWithCacheKeyConfig
TransferWithCacheKeyConfig(BlocksCacheKey(1), range(0, 40), range(0, 40))
```


#### 返回值

正常情况下返回TransferWithCacheKeyConfig的实例。

参数错误可能抛出TypeError、ValueError或LLMException。


#### 约束说明

- src_layer_range表示范围需等于dst_layer_range表示范围。
- cache_key为BlocksCacheKey时，src_batch_index只能为0。
