PaddlePaddle / PaddleSlim

PaddleSlim is an open-source library for deep model compression and architecture search.
https://paddleslim.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.56k stars 345 forks source link

修复与新版本paddle使用时返回值无法对应的问题。fix:paddle._C_ops.layer_norm() #1893

Open micsama opened 2 months ago

micsama commented 2 months ago

我的版本:

paddle2onnx 1.2.9 paddlefsl 1.1.0 paddlenlp 2.8.1 paddlepaddle-gpu 2.6.2 paddleslim 2.6.0

问题: 执行模型压缩的时候,会遇到报错:

Traceback (most recent call last): File "/root/workspace/uie_compress/compress_token_cls.py", line 102, in main() File "/root/workspace/uie_compress/compress_token_cls.py", line 98, in main trainer.compress() File "/opt/conda/lib/python3.10/site-packages/paddlenlp/trainer/trainer_compress.py", line 73, in compress _dynabert(self, self.model) File "/opt/conda/lib/python3.10/site-packages/paddlenlp/trainer/trainer_compress.py", line 158, in _dynabert ofa_model, teacher_model = _dynabert_init(self, model, eval_dataloader) File "/opt/conda/lib/python3.10/site-packages/paddlenlp/trainer/trainer_compress.py", line 300, in _dynabert_init head_importance, neuron_importance = compute_neuron_head_importance( File "/opt/conda/lib/python3.10/site-packages/paddlenlp/transformers/ofa_utils.py", line 307, in compute_neuron_head_importance logits = model(batch) File "/opt/conda/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, *kwargs) File "/opt/conda/lib/python3.10/site-packages/paddlenlp/transformers/ernie/modeling.py", line 709, in forward outputs = self.ernie( File "/opt/conda/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(inputs, kwargs) File "/opt/conda/lib/python3.10/site-packages/paddlenlp/trainer/trainer_compress.py", line 907, in auto_model_dynabert_forward embedding_output = self.embeddings(embedding_kwargs) File "/opt/conda/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, *kwargs) File "/opt/conda/lib/python3.10/site-packages/paddlenlp/transformers/ernie/modeling.py", line 127, in forward embeddings = self.layer_norm(embeddings) File "/opt/conda/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(inputs, kwargs) File "/opt/conda/lib/python3.10/site-packages/paddleslim/nas/ofa/layers.py", line 1301, in forward out, , = paddle._C_ops.layer_norm( ValueError: too many values to unpack (expected 3)

排查后发现是与paddle库的更改未统一。

CLAassistant commented 1 month ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.