昇腾社区首页
中文
注册

query_register_mem_status

产品支持情况

产品

是否支持

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

Atlas 800I A2 推理产品/A200I A2 Box 异构组件

Atlas A2 训练系列产品

x

Atlas 200I/500 A2 推理产品

x

Atlas 推理系列产品

x

Atlas 训练系列产品

x

函数功能

在开启CacheManager的场景下(开启方式是在初始化LLMDataDist时设置llm.EnableCacheManager为1),调用此接口查询注册内存状态。

函数原型

1
query_register_mem_status(comm_id: int) -> RegisterMemStatus

参数说明

参数名称

数据类型

取值说明

comm_id

int

link接口的返回值

调用示例

 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
41
42
43
44
45
46
47
48
49
50
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": "x.x.x.x"
        },{
            "device": [
                {
                    "device_id": "0",
                    "device_ip": "x.x.x.x",
                    "rank_id": "0"
                },
            ],
            "server_id": "x.x.x.x"
        }
    ],
    "status": "completed",
    "version": "1.0"
}"""
comm_id = llm_datadist.link("comm1", {1: 0, 2: 1}, rank_table)
print("init link suc:", comm_id)
while True:
    ret = llm_datadist.query_register_mem_status(comm_id)
    if ret == RegisterMemStatus.OK:
        print("query_register_mem_status ok", flush=True)
        break
    elif ret == RegisterMemStatus.FAILED:
        print("query_register_mem_status failed", flush=True)
        raise RuntimeError("link failed")
    print("need check again", flush=True)
    time.sleep(1)

返回值

正常场景下无返回值。

异常场景会抛出LLMException异常。

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

约束说明

需要开启CacheManager模式。