usail-hkust / JailTrickBench

Bag of Tricks: Benchmarking of Jailbreak Attacks on LLMs. Empirical tricks for LLM Jailbreaking. (NeurIPS 2024)
https://arxiv.org/abs/2406.09324
MIT License
89 stars 8 forks source link

Error: merage base_model and lora adapter #2

Closed BXHQu closed 1 month ago

BXHQu commented 5 months ago

ssh://root@connect.nma1.seetacloud.com:24473/root/miniconda3/envs/py311advprompter/bin/python3.11 -u "/root/autodl-tmp/BoT_for_LLMJailbreaking/merage advprompter_model.py" Loading checkpoint shards: 0%| | 0/3 [00:00<?, ?it/s]/root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/torch/_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage() return self.fget.get(instance, owner)() Loading checkpoint shards: 100%|██████████████████| 3/3 [00:04<00:00, 1.47s/it] /root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py:492: UserWarning: do_sample is set to False. However, temperature is set to 0.9 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset temperature. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed. warnings.warn( /root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py:497: UserWarning: do_sample is set to False. However, top_p is set to 0.6 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset top_p. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed. warnings.warn( /root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py:492: UserWarning: do_sample is set to False. However, temperature is set to 0.9 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset temperature. warnings.warn( /root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py:497: UserWarning: do_sample is set to False. However, top_p is set to 0.6 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset top_p. warnings.warn( Some non-default generation parameters are set in the model config. These should go into a GenerationConfig file (https://huggingface.co/docs/transformers/generation_strategies#save-a-custom-decoding-strategy-with-your-model) instead. This warning will be raised to an exception in v4.41. Non-default generation parameters: {'max_length': 4096} Your generation config was originally created from the model config, but the model config has changed since then. Unless you pass the generation_config argument to this model's generate calls, they will revert to the legacy behavior where the base generate parameterization is loaded from the model config instead. To avoid this behavior and this warning, we recommend you to overwrite the generation config model attribute before calling the model's save_pretrained, preferably also removing any generation kwargs from the model config. This warning will be raised to an exception in v4.41. Traceback (most recent call last): File "/root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py", line 661, in save_pretrained raise ValueError(str([w.message for w in caught_warnings])) ValueError: [UserWarning('do_sample is set to False. However, temperature is set to 0.9 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset temperature.'), UserWarning('do_sample is set to False. However, top_p is set to 0.6 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset top_p.')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/autodl-tmp/BoT_for_LLMJailbreaking/merage advprompter_model.py", line 34, in merage_model(org_model_name_or_path=org_model_name_or_path,adapter_model_name_or_path=adapter_model_name_or_path,save_dir=save_dir ) File "/root/autodl-tmp/BoT_for_LLMJailbreaking/merage advprompter_model.py", line 28, in merage_model new_base_model.save_pretrained(save_dir, safe_serialization=False, max_shard_size = '10GB') File "/root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2346, in save_pretrained model_to_save.generation_config.save_pretrained(save_directory) File "/root/miniconda3/envs/py311advprompter/lib/python3.11/site-packages/transformers/generation/configuration_utils.py", line 663, in save_pretrained raise ValueError( ValueError: The generation config instance is invalid -- .validate() throws warnings and/or exceptions. Fix these issues to save the configuration.

Thrown during validation: [UserWarning('do_sample is set to False. However, temperature is set to 0.9 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset temperature.'), UserWarning('do_sample is set to False. However, top_p is set to 0.6 -- this flag is only used in sample-based generation modes. You should set do_sample=True or unset top_p.')]

进程已结束,退出代码1

BXHQu commented 5 months ago

merage base_model and lora adapter is solved. but I have other error:

rank0: File "/root/autodl-tmp/BoT_for_LLM_Jailbreaking/main.py", line 186, in test rank0: models = [load_target_models_advprompter(args)]

rank0: File "/root/autodl-tmp/BoT_for_LLM_Jailbreaking/baseline/AdvPrompter/utils.py", line 12, in load_target_models_advprompter rank0: target_llm = LocalVLLM(

rank0: File "/root/autodl-tmp/BoT_for_LLM_Jailbreaking/baseline/AdvPrompter/llm.py", line 37, in init rank0: self.model = vllm(

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/entrypoints/llm.py", line 144, in init rank0: self.llm_engine = LLMEngine.from_engine_args(

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/engine/llm_engine.py", line 363, in from_engine_args rank0: engine = cls(

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/engine/llm_engine.py", line 236, in init

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/engine/llm_engine.py", line 313, in _initialize_kv_caches

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/executor/gpu_executor.py", line 75, in determine_num_available_blocks rank0: return self.driver_worker.determine_num_available_blocks()

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context rank0: return func(*args, **kwargs)

rank0: File "/root/miniconda3/envs/internlm2024/lib/python3.11/site-packages/vllm/worker/worker.py", line 171, in determine_num_available_blocks rank0: assert peak_memory > 0, ( rank0: AssertionError: Error in memory profiling. This happens when the GPU memory was not properly cleaned up before initializing the vLLM instance.

zhaoxu98 commented 1 month ago

Please clean up GPU memory before using vllm :)