LMFlow icon indicating copy to clipboard operation
LMFlow copied to clipboard

[BUG]pydantic.errors.PydanticUserError when running RAFT

Open Randomstar-New opened this issue 3 years ago • 8 comments

Describe the bug After installing the python libraries and run bash ./scripts/run_raft_align.sh. The following content is reported:

  • 'validate_all' has been renamed to 'validate_default' warnings.warn(message, UserWarning) Traceback (most recent call last): File "/home/zhangyichi/anaconda3/envs/lmflow/bin/deepspeed", line 3, in from deepspeed.launcher.runner import main File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/init.py", line 15, in from . import module_inject File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/module_inject/init.py", line 3, in from .replace_module import replace_transformer_layer, revert_transformer_layer, ReplaceWithTensorSlicing, GroupQuantizer, generic_injection File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/module_inject/replace_module.py", line 803, in from ..pipe import PipelineModule File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/pipe/init.py", line 3, in from ..runtime.pipe import PipelineModule, LayerSpec, TiedLayerSpec File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/runtime/pipe/init.py", line 3, in from .module import PipelineModule, LayerSpec, TiedLayerSpec File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/runtime/pipe/module.py", line 16, in from ..activation_checkpointing import checkpointing File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/runtime/activation_checkpointing/checkpointing.py", line 25, in from deepspeed.runtime.config import DeepSpeedConfig File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/runtime/config.py", line 30, in from ..monitor.config import get_monitor_config File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/monitor/config.py", line 70, in class DeepSpeedMonitorConfig(DeepSpeedConfigModel): File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/deepspeed/monitor/config.py", line 82, in DeepSpeedMonitorConfig def check_enabled(cls, values): File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/pydantic/deprecated/class_validators.py", line 222, in root_validator return root_validator()(*__args) # type: ignore File "/home/zhangyichi/anaconda3/envs/lmflow/lib/python3.9/site-packages/pydantic/deprecated/class_validators.py", line 228, in root_validator raise PydanticUserError( pydantic.errors.PydanticUserError: If you use @root_validator with pre=False (the default) you MUST specify skip_on_failure=True. Note that @root_validator is deprecated and should be replaced with @model_validator.

For further information visit https://errors.pydantic.dev/2.0.1/u/root-validator-pre-skip

To Reproduce Steps to reproduce the behavior:

  1. Install the python environment and download the data
  2. run bash ./scripts/run_raft_align.sh
  3. See error

My package version

absl-py 1.4.0 accelerate 0.20.3 aiohttp 3.8.4 aiosignal 1.3.1 annotated-types 0.5.0 antlr4-python3-runtime 4.9.3 appdirs 1.4.4 async-timeout 4.0.2 attrs 23.1.0 bitsandbytes 0.38.1 blinker 1.6.2 certifi 2023.5.7 chardet 5.1.0 charset-normalizer 3.1.0 click 8.1.3 cmake 3.26.4 colorama 0.4.6 cpm-kernels 1.0.11 DataProperty 1.0.0 datasets 2.10.1 deepspeed 0.8.3 dill 0.3.4 docker-pycreds 0.4.0 evaluate 0.4.0 filelock 3.12.2 Flask 2.3.2 Flask-Cors 4.0.0 frozenlist 1.3.3 fsspec 2023.6.0 gitdb 4.0.10 GitPython 3.1.31 hjson 3.1.0 huggingface-hub 0.16.2 icetk 0.0.7 idna 3.4 importlib-metadata 6.7.0 itsdangerous 2.1.2 Jinja2 3.1.2 joblib 1.3.1 jsonlines 3.1.0 lit 16.0.6 lm-eval 0.3.0 lmflow 0.0.1 MarkupSafe 2.1.3 mbstrdecoder 1.1.3 mpi4py 3.1.4 mpmath 1.3.0 multidict 6.0.4 multiprocess 0.70.12.2 networkx 3.1 ninja 1.11.1 nltk 3.8.1 numexpr 2.8.4 numpy 1.24.2 nvidia-cublas-cu11 11.10.3.66 nvidia-cuda-cupti-cu11 11.7.101 nvidia-cuda-nvrtc-cu11 11.7.99 nvidia-cuda-runtime-cu11 11.7.99 nvidia-cudnn-cu11 8.5.0.96 nvidia-cufft-cu11 10.9.0.58 nvidia-curand-cu11 10.2.10.91 nvidia-cusolver-cu11 11.4.0.1 nvidia-cusparse-cu11 11.7.4.91 nvidia-nccl-cu11 2.14.3 nvidia-nvtx-cu11 11.7.91 omegaconf 2.3.0 openai 0.27.8 packaging 23.1 pandas 2.0.3 pathtools 0.1.2 pathvalidate 3.0.0 peft 0.3.0 Pillow 10.0.0 pip 23.1.2 portalocker 2.7.0 protobuf 3.18.3 psutil 5.9.5 py-cpuinfo 9.0.0 pyarrow 12.0.1 pybind11 2.10.4 pycountry 22.3.5 pydantic 2.0.1 pydantic_core 2.0.2 pytablewriter 1.0.0 python-dateutil 2.8.2 pytz 2023.3 PyYAML 6.0 regex 2023.6.3 requests 2.31.0 responses 0.18.0 rouge-score 0.1.2 sacrebleu 1.5.0 safetensors 0.3.1 scikit-learn 1.2.2 scipy 1.11.1 sentencepiece 0.1.99 sentry-sdk 1.27.0 setproctitle 1.3.2 setuptools 67.8.0 six 1.16.0 smmap 5.0.0 sqlitedict 2.1.0 sympy 1.12 tabledata 1.3.1 tcolorpy 0.1.3 threadpoolctl 3.1.0 tokenizers 0.13.3 torch 2.0.0 torchvision 0.15.1 tqdm 4.65.0 tqdm-multiprocess 0.0.11 transformers 4.30.2 triton 2.0.0 trl 0.4.7.dev0 typepy 1.3.1 typing_extensions 4.7.1 tzdata 2023.3 urllib3 2.0.3 wandb 0.14.0 Werkzeug 2.3.6 wheel 0.38.4 xxhash 3.2.0 yarl 1.9.2 zipp 3.15.0 zstandard 0.21.0

Desktop (please complete the following information):

  • OS: Ubuntu 20.04

Randomstar-New avatar Jul 05 '23 13:07 Randomstar-New

Is there a more simple way to run a RAFT demo?

Randomstar-New avatar Jul 05 '23 13:07 Randomstar-New

Did you try to install the LMFlow via git clone?

git clone https://github.com/OptimalScale/LMFlow.git cd LMFlow conda create -n lmflow python=3.9 -y conda activate lmflow conda install mpi4py pip install -e .

WeiXiongUST avatar Jul 07 '23 09:07 WeiXiongUST

Did you try to install the LMFlow via git clone?

git clone https://github.com/OptimalScale/LMFlow.git cd LMFlow conda create -n lmflow python=3.9 -y conda activate lmflow conda install mpi4py pip install -e .

Yes, I followed the instruction to set up the python environment. But I met such an error report.

Randomstar-New avatar Jul 07 '23 13:07 Randomstar-New

It might be because the mismatched version of pydantic according to the error report. Could you try with pydantic of a lower version, say, e.g., 1.10.8?

WeiXiongUST avatar Jul 07 '23 13:07 WeiXiongUST

It might be because the mismatched version of pydantic according to the error report. Could you try with pydantic of a lower version, say, e.g., 1.10.8?

Thank you for your advice. The mentioned problem is solved. But when I tried to run the raft demo, another error is reported when loading the reward model. ValueError: Could not load model weqweasdas/hh_rlhf_rm with any of the following classes: (<class 'transformers.models.auto.modeling_auto.AutoModelForSequenceClassification'>, <class 'transformers.models.gpt_neo.modeling_gpt_neo.GPTNeoForSequenceClassification'>).

The detailed bug trace is: ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /home/zhangyichi/LMFlow/examples/raft_align.py:156 in │ │ │ │ 153 │ │ 154 │ │ 155 if name == 'main': │ │ ❱ 156 │ main() │ │ 157 │ │ │ │ /home/zhangyichi/LMFlow/examples/raft_align.py:141 in main │ │ │ │ 138 │ model = AutoModel.get_model(model_args) │ │ 139 │ │ │ 140 │ # Initializes reward function │ │ ❱ 141 │ reward_function = get_reward_function(reward_args, pipeline_args) │ │ 142 │ │ │ 143 │ reward_model_args = ModelArguments(arch_type="text_regression") │ │ 144 │ reward_model = AutoModel.get_model(reward_model_args) │ │ │ │ /home/zhangyichi/LMFlow/examples/raft_align.py:74 in get_reward_function │ │ │ │ 71 │ │ rm_tokenizer.pad_token_id = rm_tokenizer.eos_token_id │ │ 72 │ │ rm_tokenizer.padding_side = "left" │ │ 73 │ │ print(reward_args) │ │ ❱ 74 │ │ hf_pipe = pipeline( │ │ 75 │ │ │ reward_args.reward_task, │ │ 76 │ │ │ model=reward_args.reward_model_or_path, │ │ 77 │ │ │ device=f"cuda:{pipeline_args.local_rank}", │ │ │ │ /home/zhangyichi/anaconda3/envs/vvan/lib/python3.9/site-packages/transformers/pipelines/init │ │ .py:780 in pipeline │ │ │ │ 777 │ # Will load the correct model if possible │ │ 778 │ model_classes = {"tf": targeted_task["tf"], "pt": targeted_task["pt"]} │ │ 779 │ print(model_classes) │ │ ❱ 780 │ framework, model = infer_framework_load_model( │ │ 781 │ │ model, │ │ 782 │ │ model_classes=model_classes, │ │ 783 │ │ config=config, │ │ │ │ /home/zhangyichi/anaconda3/envs/vvan/lib/python3.9/site-packages/transformers/pipelines/base.py: │ │ 271 in infer_framework_load_model │ │ │ │ 268 │ │ │ │ continue │ │ 269 │ │ │ │ 270 │ │ if isinstance(model, str): │ │ ❱ 271 │ │ │ raise ValueError(f"Could not load model {model} with any of the following cl │ │ 272 │ │ │ 273 │ framework = "tf" if "keras.engine.training.Model" in str(inspect.getmro(model.__clas │ │ 274 │ return framework, model │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

How could this problem be solved? The version of my transformers is 4.28.0.

Randomstar-New avatar Jul 08 '23 02:07 Randomstar-New

It seems that the reward model weqweasdas/hh_rlhf_rm is not downloaded due to the pool connection in the server. I would first try to download the reward model.

Randomstar-New avatar Jul 08 '23 02:07 Randomstar-New

You can also try to train your own RM as in the tutorial. Training a 2.7B RM is rather fast.

WeiXiongUST avatar Jul 08 '23 02:07 WeiXiongUST

This issue has been marked as stale because it has not had recent activity. If you think this still needs to be addressed please feel free to reopen this issue. Thanks

shizhediao avatar Sep 30 '23 19:09 shizhediao