该模块提供了以下功能:
1、将 mindspore 框架训练的模型转换为 pytorch 框架的模型
2、将分布式训练的 pytorch 模型转为单机模型,方便推理
3、将 pytorch 框架下的单机模型转为分布式训练模型;结合第二点功能,可以实现不同分布式训练策略的转换。
将 mindspore 模型转换为 pytorch 模型
from pcl_pangu.model_converter import ms_2_numpy
ms_2_numpy(ms_ckpt_path='path/of/mindspore/ckpt',
npy_path='path/to/save/numpy/files')
要求安装 mindspore
from pcl_pangu.model_converter import numpy_2_pt
from pcl_pangu.model import alpha
alpha_config = alpha.model_config_gpu(model='2B6')
numpy_2_pt(config = alpha_config,
numpy_ckpt = 'path/to/numpy/files')
要求安装 pytorch
将分布式训练的 pytorch 模型转为单机模型
from pcl_pangu.model import alpha
from pcl_pangu.model_converter import merge_pt
alpha_config = alpha.model_config_gpu(model='2B6')
merge_pt(config = alpha_config,
sharding_path='path/of/your/sharding/models',
num_ranks='num/of/model/rank')
要求安装 pytorch
将单机模型转为分布式模型
from pcl_pangu.model import alpha
from pcl_pangu.model_converter import split_pt
alpha_config = alpha.model_config_gpu(model='2B6')
split_pt(config=alpha_config,
merged_path='path/of/merged/model',
num_ranks='num/of/rank/you/want/to/split')
要求安装 pytorch
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》