产品 |
是否支持 |
---|---|
√ |
|
x |
|
x |
|
x |
|
x |
在开启CacheManager的场景下,开启方式是在初始化LLMDataDist时设置llm.EnableCacheManager为1,调用此接口通过建立通信域方式建链。
如果要在单机内构造通信域,需要设置HCCL_INTRA_ROCE_ENABLE=1环境变量。
1 | link(comm_name: str, cluster_rank_info: Dict[int, int], rank_table: str) -> int |
参数名称 |
数据类型 |
取值说明 |
---|---|---|
comm_name |
str |
通信域名称 |
cluster_rank_info |
Dict[int, int] |
集群ID到rank ID的映射 例如:{1: 0, 2: 1} |
rank_table |
str |
开发者可以通过该参数配置参与集合通信的NPU资源信息,具体信息请参见《HCCL集合通信库用户指南》中的“通信功能开发 > 集群信息配置 > ranktable文件配置资源信息“章节。配置示例如下。 { "server_count": "2", "server_list": [ { "device": [ { "device_id": "0", "device_ip": "x.x.x.x", "rank_id": "0" }, ], "server_id": "xxxx" },{ "device": [ { "device_id": "0", "device_ip": "x.x.x.x", "rank_id": "1" }, ], "server_id": "xxxx" } ], "status": "completed", "version": "1.0" } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | from llm_datadist import LLMDataDist, LLMRole, LlmConfig device_id = 0 llm_datadist = LLMDataDist(LLMRole.PROMPT, 1) options = { "ge.exec.deviceId": str(device_id), "llm.MemPoolConfig": "{\"memory_size\": 1073741824}" } llm_config = LlmConfig() llm_config.enable_cache_manager = True options.update(llm_config.generate_options()) llm_datadist.init(options) rank_table = """ { "server_count": "2", "server_list": [ { "device": [ { "device_id": "0", "device_ip": "x.x.x.x", "rank_id": "0" }, ], "server_id": "xxxx" },{ "device": [ { "device_id": "0", "device_ip": "x.x.x.x", "rank_id": "1" }, ], "server_id": "xxxx" } ], "status": "completed", "version": "1.0" }""" comm_id = llm_datadist.link("comm1", {1: 0, 2: 1}, rank_table) print("init link suc:", comm_id) |
正常情况下返回标识通信域的ID。
参数错误可能抛出TypeError或ValueError。