switch_role
产品支持情况
函数功能
切换当前LLMDataDist的角色,建议仅在使用PagedAttention的场景使用。
函数原型
switch_role(self, role: LLMRole, switch_options: Optional[Dict[str, str]] = None)
参数说明
|
切换为Prompt时需要设置,其中需包含listen_ip_info配置项。 |
调用示例
from llm_datadist import LLMDataDist, LLMRole
llm_datadist = LLMDataDist(LLMRole.DECODER, 0)
...
switch_options = { 'llm.listenIpInfo': '127.0.0.1:26000' }
llm_datadist.switch_role(LLMRole.PROMPT, switch_options)
返回值
- 正常情况下无返回值。
- 传入数据类型错误情况下会抛出TypeError或ValueError异常。
- 如果初始化LLMDataDist时LLMConfig未使能enable_switch_role,调用该接口则会抛出LLMException,status_code为LLM_FEATURE_NOT_ENABLED。
- 如果switch_role时存在残留链路资源,则会抛出LLMException,status_code为LLM_EXIST_LINK。
- 如果switch_role的目标role与当前role相同,则会抛出LLMException,status_code为LLM_PARAM_INVALID。
- 单进程多卡模式下,不支持调用该接口。
约束说明
无