Repository: open-compass/opencompass
Issue: [Bug] The test results using lmdeploy are not reproducible, while using vllm is reproducible but yields low scores.
Root cause: Resource Mishandling

### 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

```
{'CUDA available': True,
 'CUDA_HOME': '/usr/local/cuda',
 'GCC': 'x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0',
 'GPU 0,1,2,3,4,5,6,7': 'A100-SXM4-40GB',
 'MMEngine': '0.10.7',
 'MUSA available': False,
 'NVCC': 'Cuda compilation tools, release 12.1, V12.1.105',
 'OpenCV': '4.10.0',
 'PyTorch': '2.4.0+cu121',
 '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 v3.4.2 (Git Hash '
                              '1137e04ec0b5251ca2b4400a4fd3c667ce843d67)\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 12.1\n'
                              '  - NVCC architecture flags: '
                              '-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;-gencode;arch=compute_90,code=sm_90\n'
                              '  - CuDNN 90.1  (built against CUDA 12.4)\n'
                              '  - Magma 2.6.1\n'
                              '  - Build settings: BLAS_INFO=mkl, '
                              'BUILD_TYPE=Release, CUDA_VERSION=12.1, '
                              'CUDNN_VERSION=9.1.0, '
                              'CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, '
                              'CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 '
                              '-fabi-version=11 -fvisibility-inlines-hidden '
                              '-DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO '
                              '-DLIBKINETO_NOROCTRACER -DUSE_FBGEMM '
                              '-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 -Wno-unused-parameter '
                              '-Wno-unused-function -Wno-unused-result '
                              '-Wno-strict-overflow -Wno-strict-aliasing '
                              '-Wno-stringop-overflow -Wsuggest-override '
                              '-Wno-psabi -Wno-error=pedantic '
                              '-Wno-error=old-style-cast -Wno-missing-braces '
                              '-fdiagnostics-color=always -faligned-new '
                              '-Wno-unused-but-set-variable '
                              '-Wno-maybe-uninitialized -fno-math-errno '
                              '-fno-trapping-math -Werror=format '
                              '-Wno-stringop-overflow, LAPACK_INFO=mkl, '
                              'PERF_WITH_AVX=1, PERF_WITH_AVX2=1, '
                              'PERF_WITH_AVX512=1, TORCH_VERSION=2.4.0, '
                              'USE_CUDA=ON, USE_CUDNN=ON, USE_CUSPARSELT=1, '
                              'USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, '
                              'USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, '
                              'USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, '
                              'USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, '
                              'USE_ROCM_KERNEL_ASSERT=OFF, \n',
 'Python': '3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]',
 'TorchVision': '0.19.0+cu121',
 'lmdeploy': '0.7.1',
 'numpy_random_seed': 2147483648,
 'opencompass': '0.4.1+',
 'sys.platform': 'linux',
 'transformers': '4.48.3'}
```

### Reproduces the problem - code/configuration sample

eval_debug.py
```
from mmengine.config import read_base
from opencompass.models import HuggingFacewithChatTemplate, TurboMindModelwithChatTemplate
from opencompass.utils.text_postprocessors import extract_non_reasoning_content

sample_nums=2
abbr="deepseek-r1-distill-qwen-1.5b-hf"
model_path="/models/DeepSeek-R1-Distill-Qwen-1.5B"
max_len = 32768-2048
temperature=0.6
top_p=0.95
tp=1
batch_size=64


with read_base():
    from opencompass.configs.datasets.gpqa.gpqa_openai_gen_repeat8 import GPQADataset,gpqa_reader_cfg,gpqa_infer_cfg,gpqa_eval_cfg

gpqa_subsets = {
    # 'extended': 'gpqa_extended.csv',
    # 'main': 'gpqa_main.csv',
    'diamond': 'gpqa_diamond.csv'
}
split = "diamond"
gpqa_datasets = [
    dict(
        abbr=f'GPQA-diamond-run{idx}',
        type=GPQADataset,
        path='./data/gpqa/',
        name=gpqa_subsets[split],
        reader_cfg=gpqa_reader_cfg,
        infer_cfg=gpqa_infer_cfg,
        eval_cfg=gpqa_eval_cfg,
        num_repeats=1
        )
    for idx in range(sample_nums)
]

datasets = [
    *gpqa_datasets
]

models = [
    dict(
        type=TurboMindModelwithChatTemplate,
        abbr=abbr,
        path=model_path,
        max_seq_len=max_len+2048,
        max_out_len=max_len,
        backend='turbomind',
        gen_config=dict(
                        do_sample=True,
                        temperature=temperature,
                        top_p=top_p,
                        # random_seed=42,
                        max_new_tokens=max_len),
        batch_size=batch_size,
        engine_config=dict(session_len=32768, max_batch_size=batch_size, tp=tp),
        run_cfg=dict(num_gpus=tp),
        pred_postprocessor=dict(type=extract_non_reasoning_content)
    )
]



#######################################################################
#                          PART 4  Summarizer                         #
#######################################################################

summary_groups = sum(
    [v for k, v in locals().items() if k.endswith('_summary_groups')], []
)

summary_groups.extend([
    {
        'name': 'GPQA-diamond-Aveage_{}'.format(sample_nums),
        'subsets': [[f'GPQA-diamond-run{idx}', 'accuracy'] for idx in range(sample_nums)]
    }
])

summarizer = dict(
    summary_groups=summary_groups,
)

work_dir = 'all_baseline_output/DS_1.5B'
```

The test script:
```
opencompass eval_debug.py --max-num-worker 8
```


### Reproduces the problem - command or script

The test script:
```
opencompass eval_debug.py --max-num-worker 8
```

### Reproduces the problem - error message

First run:
```
| dataset | version | metric | mode | deepseek-r1-distill-qwen-1.5b-hf |
|----- | ----- | ----- | ----- | -----|
| GPQA-diamond-run0 | 5aeece | accuracy | gen | 31.31 |
| GPQA-diamond-run1 | 5aeece | accuracy | gen | 33.33 |
| GPQA-diamond-Aveage_2 | - | naive_average | gen | 32.32 |
```

Second run:
```
| dataset | version | metric | mode | deepseek-r1-distill-qwen-1.5b-hf |
|----- | ----- | ----- | ----- | -----|
| GPQA-diamond-run0 | 5aeece | accuracy | gen | 28.79 |
| GPQA-diamond-run1 | 5aeece | accuracy | gen | 31.31 |
| GPQA-diamond-Aveage_2 | - | naive_average | gen | 30.05 |
```


### Other information

Other testing frameworks I have used, such as `Qwen2.5-Math` and `lm-eval`, produce reproducible test results when given the same seed, temperature, and top_p.