PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.19k stars 2.95k forks source link

[Question]: 2.8版本使用LLM工作流报错缺少fused_ln #8410

Closed weiweiwei010119 closed 6 months ago

weiweiwei010119 commented 6 months ago

请提出你的问题

参考了https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/index.html的教程,执行命令: python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./llama/pretrain-llama2_7b-tp2sd4_stage2.json但产生了下属报错,提示一个叫做fused_ln的东西找不到

报错信息如下: Traceback (most recent call last): File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/utils/lazy_import.py", line 32, in try_import mod = importlib.import_module(module_name) File "/root/anaconda3/envs/paddle/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'fused_ln'

追踪如下 Traceback (most recent call last): File "run_pretrain.py", line 630, in <module> main() File "run_pretrain.py", line 608, in main train_result = trainer.train(resume_from_checkpoint=checkpoint) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/trainer/trainer.py", line 768, in train return self._inner_training_loop( File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/trainer/trainer.py", line 962, in _inner_training_loop tr_loss_step = self.training_step(model, inputs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/trainer/trainer.py", line 2006, in training_step loss = self.compute_loss(model, inputs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/trainer/trainer.py", line 1950, in compute_loss outputs = model(**inputs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__ return self.forward(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/distributed/fleet/meta_parallel/meta_parallel_base.py", line 37, in forward output = self._layers(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__ return self.forward(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/transformers/llama/modeling.py", line 1820, in forward outputs = self.llama( File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__ return self.forward(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/transformers/llama/modeling.py", line 1582, in forward layer_outputs = decoder_layer( File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__ return self.forward(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/transformers/llama/modeling.py", line 1134, in forward hidden_states = self.input_layernorm(hidden_states) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/nn/layer/layers.py", line 1429, in __call__ return self.forward(*inputs, **kwargs) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/transformers/llama/modeling.py", line 413, in forward return rms_norm_fused(hidden_states, self.weight, self.variance_epsilon) File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddlenlp/transformers/llama/modeling.py", line 390, in rms_norm_fused fused_ln = try_import("fused_ln") File "/root/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/utils/lazy_import.py", line 41, in try_import raise ImportError(err_msg) ImportError: Failed importing fused_ln. This likely means that some paddle modules require additional dependencies that have to be manually installed (usually withpip install fused_ln).

并且pip安装不上这个东西,看起来是paddle的内部文件?

weiweiwei010119 commented 6 months ago

自问自答时刻来了,这是因为默认参数里面use_fused_rms_norm为true,所以需要手动安装一下插件,方法是: 需要先cd到model_zoo/gpt-3/external_ops/里面,然后执行python setup.py install。手动安装这个module。

w5688414 commented 6 months ago

按照这个安装即可:

https://github.com/PaddlePaddle/PaddleNLP/blob/9146c1e492971a0fb386ca717c7d2d701441b695/tests/test_tipc/dygraph/hybrid_parallelism/qwen/benchmark_common/prepare.sh#L21