-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PicklingError: Can't pickle <function Embedding.forward at XXXXXXX> it's not the same object as torch.nn.modules.sparse.Embedding.forward #2749
Comments
cc @SunMarc |
Hi @arpit2665, thanks for reporting. This is indeed the case since we modify slightly the forward when we use device_map="auto". Could you try to remove the hooks before pickling ? to do that you can use |
Hi @SunMarc - Thanks for your reply. I tried above suggested solutions(both of them individually) and the error message is now changed to PicklingError: Can't pickle function Module.to at XXXXXXX it's not the same object as torch.nn.modules.module.Module.to Could you also explain what you are trying to acheive with ForkingPickler ? Please suggest if there's any solution or workaround to this problem. |
Hi, @SunMarc - Is there any solution or workaround to this problem? |
Hi @arpit2665 , this is most likely due to these lines. Could your try to see with commenting them solves the issue ? If so, if you can provide a quick benchmark of how ForkingPickler speeds up the generation, I will if I can come up with a better solution ! |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
System Info
Information
Tasks
no_trainer
script in theexamples
folder of thetransformers
repo (such asrun_no_trainer_glue.py
)Reproduction
import torch
from transformers import AutoModelForCausualLLM
from torch.multiprocessing.reductions import ForkingPickler
base_model_name = 'mistral-7b-instruct'
#Loading LLM with FP16(Without any quantization) and device_map = {"":0}
base_model_wo_quant = AutoModelForCausalLLM.from_pretrained(f'{base_model_name}', torch.dtype=torch.float16, device_map={"":0}, use_safetensors=True)
#Able to share with the forked processes
_ = base_model_wo_quant.share_memory()
ForkingPickler.dumps(base_model_wo_quant)
#Loading LLM with FP16(Without any quantization) and device_map = 'auto'
base_model_wo_quant_auto = AutoModelForCausalLLM.from_pretrained(f'{base_model_name}', torch.dtype=torch.float16, device_map='auto', use_safetensors=True)
_ = base_model_wo_quant_auto.share_memory()
#Failed to share with the forked processes getting below error
ForkingPickler.dumps(base_model_wo_quant_auto)
#PicklingError: Can't pickle it's not the same object as torch.nn.modules.sparse.Embedding.forward
Expected behavior
Expecting the model to be shared with the forked processes even when device_map = 'auto'
The text was updated successfully, but these errors were encountered: