动态加载LoRA接口
接口功能
实现LoRA的动态加载功能。调用该接口时,会根据LoRA的实际情况分别判断是否可以加载和等待,并返回对应结果。
接口格式
操作类型:POST
URL:https://{ip}:{port}/v1/load_lora_adapter
- {ip}字段为config.json配置文件中ServerConfig字段下managementIpAddress参数的值,默认值为127.0.0.2。
- {port}字段为config.json配置文件中ServerConfig字段下managementPort参数的值,默认值为1026。
请求参数
参数名 |
是否必选 |
说明 |
取值要求 |
|---|---|---|---|
lora_name |
必选 |
加载的LoRA名称 |
string:非空。 |
lora_path |
必选 |
加载的LoRA路径 |
string:非空,符合路径标准,且真实存在。 |
master_mode |
必选 |
加载的LoRA模型名称 |
string:非空,如果输入为空默认为主模型名称。 |
使用样例
请求样例:
curl -X POST 127.0.0.2:1026/v1/load_lora_adapter -d '{
"lora_name": "lora1",
"lora_path": "/home/data/Qwen2.5-7B-Instruct-lora296",
"master_mode": "qwen2"
}'
响应样例:
Success: Lora adpter 'lora1' added successfully.
响应状态码:
- 状态码200,服务状态正常,消息体没有内容。
- 其他状态码,服务状态异常。
输出说明
返回值 |
类型 |
说明 |
|---|---|---|
"Success: LoRA adapter '{loraName }' added successfully." |
string |
LoRA加载成功。 |
"The LoRA adapter '{loraName }' has already been added." |
string |
LoRA已经被加载。 |
"The LoRA adapter '{loraName }' is waiting to unload." |
string |
加载的LoRA正在被卸载。 |
"Call to load LoRA method failed: The LoRA adapter '{loraName }' is invalid." |
string |
无效的LoRA名称。 |
"Call to load LoRA method failed: Loading LoRA '{loraName }' failed: No adapter found for {loraPath }'." |
string |
无效的LoRA路径。 |
"Call to load LoRA method failed: LoRA rank is greater than max_lora_rank." |
string |
请求的LoRA rank大于最大LoRA rank。 |
"Call to load LoRA method failed: The number of LoRA adapters exceeds 'max_loras', and none are currently unloading." |
string |
请求的LoRA adapters大于最大LoRA数量。 |
"Call to load LoRA method failed: The number of LoRA adapters exceeds 'max_loras', some adapters are currently being unloaded." |
string |
请求的LoRA adapters大于最大LoRA数量,有些adapters正在被卸载。 |
"Call to load LoRA method failed: The LoRA command only supports Python graph, please check the model graph type." |
string |
不支持的组图,请将CPP组图换成PYTHON组图。 |