Shortcuts

get_adapter_state_dict

torchtune.modules.peft.get_adapter_state_dict(state_dict: Dict[str, Any], device: Optional[str] = 'cpu') Dict[str, Any][source]

返回模型中与适配器对应的完整state_dict的子集。 假设“lora”和“magnitude”是适配器参数的唯一名称,并且 state_dict没有被分片。所有返回的参数都被移动到CPU。

Parameters:
  • state_dict (Dict[str, Any]) – 完整的模型状态字典。

  • device (可选[str]) – 将适配器参数移动到的设备。默认值:'cpu'

Returns:

模型状态字典的子集,仅包含适配器参数。

Return type:

字典[str, 任意]