Repository: open-compass/opencompass
Issue: [Bug] NoneType object has no attribute SetDefault
Root cause: Validation Gap

### Prerequisite

- [X] I have searched [Issues](https://github.com/open-compass/opencompass/issues/) and [Discussions](https://github.com/open-compass/opencompass/discussions) but cannot get the expected help.
- [X] The bug has not been fixed in the [latest version](https://github.com/open-compass/opencompass).

### Type

I'm evaluating with the officially supported tasks/models/datasets.

### Environment

```python
{'CUDA available': True,
 'CUDA_HOME': '/usr',
 'GCC': 'gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0',
 'GPU 0': 'NVIDIA GeForce RTX 3060 Laptop GPU',
 'MMEngine': '0.8.4',
 'NVCC': 'Cuda compilation tools, release 12.2, V12.2.128',
 'OpenCV': '4.8.0',
 'PyTorch': '2.0.1+cu117',
 'PyTorch compiling details': 'PyTorch built with:\n'
                              '  - GCC 9.3\n'
                              '  - C++ Version: 201703\n'
                              '  - Intel(R) oneAPI Math Kernel Library Version '
                              '2022.2-Product Build 20220804 for Intel(R) 64 '
                              'architecture applications\n'
                              '  - Intel(R) MKL-DNN v2.7.3 (Git Hash '
                              '6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)\n'
                              '  - OpenMP 201511 (a.k.a. OpenMP 4.5)\n'
                              '  - LAPACK is enabled (usually provided by '
                              'MKL)\n'
                              '  - NNPACK is enabled\n'
                              '  - CPU capability usage: AVX2\n'
                              '  - CUDA Runtime 11.7\n'
                              '  - NVCC architecture flags: '
                              '-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86\n'
                              '  - CuDNN 8.9.4  (built against CUDA 12.2)\n'
                              '    - Built with CuDNN 8.5\n'
                              '  - Magma 2.6.1\n'
                              '  - Build settings: BLAS_INFO=mkl, '
                              'BUILD_TYPE=Release, CUDA_VERSION=11.7, '
                              'CUDNN_VERSION=8.5.0, '
                              'CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, '
                              'CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 '
                              '-fabi-version=11 -Wno-deprecated '
                              '-fvisibility-inlines-hidden -DUSE_PTHREADPOOL '
                              '-DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER '
                              '-DUSE_FBGEMM -DUSE_QNNPACK '
                              '-DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK '
                              '-DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC '
                              '-Wall -Wextra -Werror=return-type '
                              '-Werror=non-virtual-dtor -Werror=bool-operation '
                              '-Wnarrowing -Wno-missing-field-initializers '
                              '-Wno-type-limits -Wno-array-bounds '
                              '-Wno-unknown-pragmas -Wunused-local-typedefs '
                              '-Wno-unused-parameter -Wno-unused-function '
                              '-Wno-unused-result -Wno-strict-overflow '
                              '-Wno-strict-aliasing '
                              '-Wno-error=deprecated-declarations '
                              '-Wno-stringop-overflow -Wno-psabi '
                              '-Wno-error=pedantic -Wno-error=redundant-decls '
                              '-Wno-error=old-style-cast '
                              '-fdiagnostics-color=always -faligned-new '
                              '-Wno-unused-but-set-variable '
                              '-Wno-maybe-uninitialized -fno-math-errno '
                              '-fno-trapping-math -Werror=format '
                              '-Werror=cast-function-type '
                              '-Wno-stringop-overflow, LAPACK_INFO=mkl, '
                              'PERF_WITH_AVX=1, PERF_WITH_AVX2=1, '
                              'PERF_WITH_AVX512=1, '
                              'TORCH_DISABLE_GPU_ASSERTS=ON, '
                              'TORCH_VERSION=2.0.1, USE_CUDA=ON, USE_CUDNN=ON, '
                              'USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, '
                              'USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, '
                              'USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, '
                              'USE_OPENMP=ON, USE_ROCM=OFF, \n',
 'Python': '3.9.17 (main, Jul  5 2023, 20:41:20) [GCC 11.2.0]',
 'TorchVision': '0.15.2+cu117',
 'numpy_random_seed': 2147483648,
 'opencompass': '0.1.6+4dd9a3f',
 'sys.platform': 'linux'}
```

### Reproduces the problem - code/configuration sample

```bash
python3 run.py --datasets humaneval_gen --hf-path gpt2 --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --max-seq-len 2048 --max-out-len 100 --batch-size 128  --num-gpus 1  -w outputs/demo --debug
```

This also happened for this model too

```bash
python3 run.py --datasets humaneval_gen --hf-path sshleifer/tiny-gpt2 --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --max-seq-len 2048 --max-out-len 100 --batch-size 128  --num-gpus 1  -w outputs/demo --debug

```

### Reproduces the problem - command or script

```bash
python3 run.py --datasets humaneval_gen --hf-path gpt2 --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --max-seq-len 2048 --max-out-len 100 --batch-size 128  --num-gpus 1  -w outputs/demo --debug
```

This also happened for this model too

```bash
python3 run.py --datasets humaneval_gen --hf-path sshleifer/tiny-gpt2 --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --max-seq-len 2048 --max-out-len 100 --batch-size 128  --num-gpus 1  -w outputs/demo --debug

```

### Reproduces the problem - error message

```
10/23 18:54:57 - OpenCompass - INFO - Loading humaneval_gen: configs/datasets/humaneval/humaneval_gen.py
10/23 18:54:57 - OpenCompass - WARNING - SlurmRunner is not used, so the partition argument is ignored.
10/23 18:54:57 - OpenCompass - DEBUG - Modules of opencompass's partitioner registry have been automatically imported from opencompass.partitioners
10/23 18:54:57 - OpenCompass - DEBUG - Get class `SizePartitioner` from "partitioner" registry in "opencompass"
10/23 18:54:57 - OpenCompass - DEBUG - An `SizePartitioner` instance is built from registry, and its implementation can be found in opencompass.partitioners.size
10/23 18:54:57 - OpenCompass - WARNING - Key eval.runner.task.judge_cfg not found in config, ignored.
10/23 18:54:57 - OpenCompass - INFO - Partitioned into 1 tasks.
10/23 18:54:57 - OpenCompass - DEBUG - Task 0: [opencompass.models.huggingface.HuggingFace_opencompass_gpt2/openai_humaneval]
10/23 18:54:57 - OpenCompass - DEBUG - Modules of opencompass's runner registry have been automatically imported from opencompass.runners
10/23 18:54:57 - OpenCompass - DEBUG - Get class `LocalRunner` from "runner" registry in "opencompass"
10/23 18:54:57 - OpenCompass - DEBUG - An `LocalRunner` instance is built from registry, and its implementation can be found in opencompass.runners.local
10/23 18:54:57 - OpenCompass - DEBUG - Modules of opencompass's task registry have been automatically imported from opencompass.tasks
10/23 18:54:57 - OpenCompass - DEBUG - Get class `OpenICLInferTask` from "task" registry in "opencompass"
10/23 18:54:57 - OpenCompass - DEBUG - An `OpenICLInferTask` instance is built from registry, and its implementation can be found in opencompass.tasks.openicl_infer
10/23 18:54:59 - OpenCompass - INFO - Task [opencompass.models.huggingface.HuggingFace_opencompass_gpt2/openai_humaneval]
2023-10-23 18:55:00.619812: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-10-23 18:55:00.619855: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-10-23 18:55:00.619888: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-10-23 18:55:00.624617: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-10-23 18:55:01.224358: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
10/23 18:55:04 - OpenCompass - WARNING - pad_token_id is not set for the tokenizer.
10/23 18:55:04 - OpenCompass - WARNING - Using eos_token_id as pad_token_id.
10/23 18:55:04 - OpenCompass - WARNING - 
 la False
Traceback (most recent call last):
  File "/home/anindyadeep/workspace/PremAI/opencompass/opencompass/tasks/openicl_infer.py", line 146, in <module>
    inferencer.run()
  File "/home/anindyadeep/workspace/PremAI/opencompass/opencompass/tasks/openicl_infer.py", line 60, in run
    self.model = build_model_from_cfg(model_cfg)
  File "/home/anindyadeep/workspace/PremAI/opencompass/opencompass/utils/build.py", line 23, in build_model_from_cfg
    return MODELS.build(model_cfg)
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/home/anindyadeep/workspace/PremAI/opencompass/opencompass/models/huggingface.py", line 88, in __init__
    self._load_model(path=path,
  File "/home/anindyadeep/workspace/PremAI/opencompass/opencompass/models/huggingface.py", line 140, in _load_model
    model_kwargs.setdefault('torch_dtype', torch.float16)
AttributeError: 'NoneType' object has no attribute 'setdefault'
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 34142) of binary: /home/anindyadeep/anaconda3/envs/llm/bin/python
Traceback (most recent call last):
  File "/home/anindyadeep/anaconda3/envs/llm/bin/torchrun", line 8, in <module>
    sys.exit(main())
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 346, in wrapper
    return f(*args, **kwargs)
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/torch/distributed/run.py", line 794, in main
    run(args)
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/torch/distributed/run.py", line 785, in run
    elastic_launch(
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 134, in __call__
    return launch_agent(self._config, self._entrypoint, list(args))
  File "/home/anindyadeep/anaconda3/envs/llm/lib/python3.9/site-packages/torch/distributed/launcher/api.py", line 250, in launch_agent
    raise ChildFailedError(
torch.distributed.elastic.multiprocessing.errors.ChildFailedError: 
============================================================
/home/anindyadeep/workspace/PremAI/opencompass/opencompass/tasks/openicl_infer.py FAILED
------------------------------------------------------------
Failures:
  <NO_OTHER_FAILURES>
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2023-10-23_18:55:08
  host      : pop-os.localdomain
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 34142)
  error_file: <N/A>
  traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html
============================================================
10/23 18:55:08 - OpenCompass - DEBUG - Get class `NaivePartitioner` from "partitioner" registry in "opencompass"
10/23 18:55:08 - OpenCompass - DEBUG - An `NaivePartitioner` instance is built from registry, and its implementation can be found in opencompass.partitioners.naive
10/23 18:55:08 - OpenCompass - INFO - Partitioned into 1 tasks.
10/23 18:55:08 - OpenCompass - DEBUG - Task 0: [opencompass.models.huggingface.HuggingFace_opencompass_gpt2/openai_humaneval]
10/23 18:55:08 - OpenCompass - DEBUG - Get class `LocalRunner` from "runner" registry in "opencompass"
10/23 18:55:08 - OpenCompass - DEBUG - An `LocalRunner` instance is built from registry, and its implementation can be found in opencompass.runners.local
10/23 18:55:08 - OpenCompass - DEBUG - Get class `OpenICLEvalTask` from "task" registry in "opencompass"
10/23 18:55:08 - OpenCompass - DEBUG - An `OpenICLEvalTask` instance is built from registry, and its implementation can be found in opencompass.tasks.openicl_eval
2023-10-23 18:55:09.387998: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-10-23 18:55:09.388045: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-10-23 18:55:09.388072: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-10-23 18:55:09.393109: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-10-23 18:55:10.077723: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
10/23 18:55:12 - OpenCompass - DEBUG - Modules of opencompass's load_dataset registry have been automatically imported from opencompass.datasets
10/23 18:55:12 - OpenCompass - DEBUG - Get class `HFDataset` from "load_dataset" registry in "opencompass"
10/23 18:55:15 - OpenCompass - DEBUG - An `HFDataset` instance is built from registry, and its implementation can be found in opencompass.datasets.huggingface
10/23 18:55:15 - OpenCompass - ERROR - /home/anindyadeep/workspace/PremAI/opencompass/opencompass/tasks/openicl_eval.py - _score - 174 - Task [opencompass.models.huggingface.HuggingFace_opencompass_gpt2/openai_humaneval]: No predictions found.
10/23 18:55:15 - OpenCompass - DEBUG - An `DefaultSummarizer` instance is built from registry, and its implementation can be found in opencompass.summarizers.default
dataset           version    metric    mode    opencompass.models.huggingface.HuggingFace_opencompass_gpt2
----------------  ---------  --------  ------  -------------------------------------------------------------
openai_humaneval  -          -         -       -

```

### Other information

_No response_

Please try the latest commit.
Feel free to re-open if needed.