Skip to content
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

Error while using checkpoint_path to generate embeddings #18

Open
abdoelsayed2016 opened this issue Dec 12, 2024 · 0 comments
Open

Error while using checkpoint_path to generate embeddings #18

abdoelsayed2016 opened this issue Dec 12, 2024 · 0 comments

Comments

@abdoelsayed2016
Copy link

Hello,

I am attempting to generate document embeddings using the checkpoint_path parameter, but I am encountering the following error:

/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/configuration_validator.py:317: LightningDeprecationWarning: The `LightningModule.on_pretrain_routine_start` hook was deprecated in v1.6 and will be removed in v1.8. Please use `LightningModule.on_fit_start` instead.
 rank_zero_deprecation(
Missing logger folder: USER_PLACEHOLDER/reranking/tests/dpr-scale/multirun/2024-12-12/14-19-43/0/lightning_logs
Loading checkpoint from /USER_PLACEHOLDER/reranking/tests/dpr-scale/checkpoint_best.ckpt
/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/utilities/cloud_io.py:47: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
 return torch.load(f, map_location=map_location)
Error executing job with overrides: ['datamodule=generate', 'datamodule.test_path=/USER_PLACEHOLDER/path/dpr-scale/psgs_w100.tsv', 'datamodule.test_batch_size=64', 'datamodule.use_title=False', 'task.transform.max_seq_len=128', '+task.ctx_embeddings_dir=/USER_PLACEHOLDER/path/dpr-scale/wiki-dragon', '+task.checkpoint_path=/USER_PLACEHOLDER/path/dpr-scale/checkpoint_best.ckpt', 'trainer.gpus=1']
Traceback (most recent call last):
 File "/USER_PLACEHOLDER/path/dpr-scale/dpr_scale/generate_embeddings.py", line 25, in main
   trainer.fit(task, datamodule=datamodule)
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 770, in fit
   self._call_and_handle_interrupt(
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 723, in _call_and_handle_interrupt
   return trainer_fn(*args, **kwargs)
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 811, in _fit_impl
   results = self._run(model, ckpt_path=self.ckpt_path)
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1174, in _run
   self._call_setup_hook()  # allow user to setup lightning_module in accelerator environment
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1494, in _call_setup_hook
   self._call_lightning_module_hook("setup", stage=fn)
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1595, in _call_lightning_module_hook
   output = fn(*args, **kwargs)
 File "/USER_PLACEHOLDER/path/dpr-scale/dpr_scale/task/dpr_eval_task.py", line 25, in setup
   self.load_state_dict(checkpoint['state_dict'])
 File "/scratch/USER_PLACEHOLDER/.conda/envs/llama_4/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2215, in load_state_dict
   raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for GenerateEmbeddingsTask:
       Unexpected key(s) in state_dict: "query_encoder.transformer.embeddings.position_ids", "context_encoder.transformer.embeddings.position_ids".

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
PYTHONPATH=.:$PYTHONPATH python dpr_scale/generate_embeddings.py -m \
datamodule=generate \
datamodule.test_path=path/tests/dpr-scale/psgs_w100.tsv \
datamodule.test_batch_size=64 \
datamodule.use_title=False \
task.transform.max_seq_len=128 \
+task.ctx_embeddings_dir=path/tests/dpr-scale/wiki-dragon \
+task.checkpoint_path=path/tests/dpr-scale/checkpoint_best.ckpt \
trainer.gpus=1

Environment:

  1. PyTorch Lightning version: 1.6.0
  2. Python version: 3.9
  3. Hydra version: 1.1
  4. CUDA version: 11.6

Operating system: Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant