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

#### 产品支持情况

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


#### 函数功能

单边建链，由Client单侧发起建链。是Client还是Server与角色prompt或者decoder无关。设置listen_ip_info标识端口侦听，即为Server端。


#### 函数原型

```
link_clusters(clusters: Union[List[LLMClusterInfo], Tuple[LLMClusterInfo]], timeout=3000)
```


#### 参数说明

| 参数名称 | 数据类型 | 取值说明 |
| --- | --- | --- |
| clusters | Union[List[LLMClusterInfo], Tuple[LLMClusterInfo]] | 集群列表。 |
| timeout | int | 超时时间，单位：ms，默认超时时间3000ms。 |


#### 调用示例

请单击Gitcode(https://gitcode.com/cann/hixl)，选择配套版本，从“examples/python”目录中获取样例。


#### 返回值

正常情况下返回两个值的元组，第一个值是接口的返回值，类型是LLMStatusCode，第二个是每个集群建链结果的列表，类型是LLMStatusCode。

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


#### 约束说明

- 建链的要求如下。建链数量过多存在内存OOM及KV Cache传输的性能风险。

  - 允许创建的最大通信数量=512。
- 建议超时时间配置为200ms以上。如果TLS处于开启状态，建议超时时间配置为2000ms以上。查询TLS状态可以使用如下命令：
  hccn_tool [-i %d] -tls -g [host]

- 调用该接口前需提前注册所有内存，否则建链后注册不支持远端访问。
- 容器场景若未配置local_comm_res或配置为空，需在容器内映射“/etc/hccn.conf”文件或者确保默认路径“/usr/local/Ascend/driver/tools”下存在hccn_tool，如果两者都不能满足，则需要用户将hccn_tool所在路径配置到PATH中。配置示例如下，hccn_tool_install_path表示hccn_tool所在路径。

```
export PATH=$PATH:${hccn_tool_install_path}
```
