-
Notifications
You must be signed in to change notification settings - Fork 259
How to test huggingface ut.
nate.river edited this page Nov 20, 2025
·
1 revision
- transformers模型用例测试
- diffusers模型用例测试
- 下载mindnlp源码
git clone https://github.com/mindspore-lab/mindnlp/- 下载transformers/diffusers源码
cd mindnlp
cd tests
git clone https://gitee.com/mirrors/huggingface_transformer -b v4.57.1
git clone https://gitee.com/mirrors/diffusers -b v0.35.2
cd ..- 安装mindnlp依赖
pip install -r requirements/requirements.txt- 测试
transformers:
- 单模型测试
python tests/run_test.py -vs tests/huggingface_transformer/tests/models/bert/test_modeling_bert.py- 一类模型测试(以首字母)
python tests/run_test.py -vs tests/huggingface_transformer/tests/models/b*/test_modeling_*.pydiffusers(models + pipelines):
python tests/run_test.py -vs tests/diffusers/tests/test_activations.py- 大类模型测试(以首字母)
python tests/run_test.py -vs tests/huggingface_transformer/tests/models- 测试方法
- 按大类测,如果出现coredump/算子错误导致后续所有用例全挂,找到最开始错的模型,单独测该模型
- 定位报错算子/错误信息,提issue(如果发现不同模型都挂在一个地方,不用重复提,直接在评论区贴截图和模型+用例名:例如 tests/diffusers/tests/test_activations.py::TestActivation::test_bert_activation)
- 如果是精度问题,不提issue(huggingface的测试精度是1e-5,但是在昇腾上大概率误差是1e-3~1e-4, 0.00012)
- 如果发现是缺算子/参数错误等自己能改的,直接提pr改
- 继续测后面的模型