In-For-Disaster-Analytics / sites-and-stories-nlp

Collection of NLP work related to the Sites and Stories efforts
0 stars 0 forks source link

Unable to load model #11

Closed mosoriob closed 11 months ago

mosoriob commented 11 months ago

image

mosoriob commented 11 months ago
Loading checkpoint shards:   0%|          | 0/3 [00:00<?, ?it/s]
4:15:44 PM
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/transformers/modeling_utils.py:519, in load_state_dict(checkpoint_file)
    517         map_location = "cpu"
--> 519     return torch.load(checkpoint_file, map_location=map_location)
    520 except Exception as e:

File /usr/local/lib/python3.10/dist-packages/torch/serialization.py:791, in load(f, map_location, pickle_module, weights_only, **pickle_load_args)
    789     pickle_load_args['encoding'] = 'utf-8'
--> 791 with _open_file_like(f, 'rb') as opened_file:
    792     if _is_zipfile(opened_file):
    793         # The zipfile reader is going to advance the current file position.
    794         # If we want to actually tail call to torch.jit.load, we need to
    795         # reset back to the original position.

File /usr/local/lib/python3.10/dist-packages/torch/serialization.py:271, in _open_file_like(name_or_buffer, mode)
    270 if _is_path(name_or_buffer):
--> 271     return _open_file(name_or_buffer, mode)
    272 else:

File /usr/local/lib/python3.10/dist-packages/torch/serialization.py:252, in _open_file.__init__(self, name, mode)
    251 def __init__(self, name, mode):
--> 252     super().__init__(open(name, mode))

FileNotFoundError: [Errno 2] No such file or directory: '/scratch/07025/mosorio/Llama-2-13b-chat-hf/pytorch_model-00001-of-00003.bin'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
File /work/07025/mosorio/ls6/sites-and-stories-nlp-jupyterenv/LLM_location.py:88, in LLM.on_button_clicked(self, path)
     86 if os.path.exists(self.path)==False:
     87     shutil.copytree(self.get_llm_path(), self.path )
---> 88 self.load_llm()
     89 self.model_loaded=True

File /work/07025/mosorio/ls6/sites-and-stories-nlp-jupyterenv/LLM_location.py:94, in LLM.load_llm(self)
     92 system_prompt = """<|SYSTEM|># Your system prompt here"""
     93 query_wrapper_prompt = PromptTemplate("<|USER|>{query_str}<|ASSISTANT|>")
---> 94 self.llm = HuggingFaceLLM(
     95         context_window=4096,
     96         max_new_tokens=2048,
     97         system_prompt=system_prompt,
     98         query_wrapper_prompt=query_wrapper_prompt,
     99         generate_kwargs={"temperature": 0.0, "do_sample": False},
    100         tokenizer_name=self.path,
    101         model_name=self.path,
    102         device_map="balanced",
    103         model_kwargs={ "load_in_8bit": False, "cache_dir":f"{scratch}"},
    104     )
    105 self.set_service_context()

File ~/.local/lib/python3.10/site-packages/llama_index/llms/huggingface.py:175, in HuggingFaceLLM.__init__(self, context_window, max_new_tokens, query_wrapper_prompt, tokenizer_name, model_name, model, tokenizer, device_map, stopping_ids, tokenizer_kwargs, tokenizer_outputs_to_remove, model_kwargs, generate_kwargs, is_chat_model, callback_manager, system_prompt, messages_to_prompt, completion_to_prompt, pydantic_program_mode, output_parser)
    169     raise ImportError(
    170         f"{type(self).__name__} requires torch and transformers packages.\n"
    171         "Please install both with `pip install transformers[torch]`."
    172     ) from exc
    174 model_kwargs = model_kwargs or {}
--> 175 self._model = model or AutoModelForCausalLM.from_pretrained(
    176     model_name, device_map=device_map, **model_kwargs
    177 )
    179 # check context_window
    180 config_dict = self._model.config.to_dict()

File ~/.local/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py:566, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    564 elif type(config) in cls._model_mapping.keys():
    565     model_class = _get_model_class(config, cls._model_mapping)
--> 566     return model_class.from_pretrained(
    567         pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
    568     )
    569 raise ValueError(
    570     f"Unrecognized configuration class {config.__class__} for this kind of AutoModel: {cls.__name__}.\n"
    571     f"Model type should be one of {', '.join(c.__name__ for c in cls._model_mapping.keys())}."
    572 )

File ~/.local/lib/python3.10/site-packages/transformers/modeling_utils.py:3694, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
   3685     if dtype_orig is not None:
   3686         torch.set_default_dtype(dtype_orig)
   3687     (
   3688         model,
   3689         missing_keys,
   3690         unexpected_keys,
   3691         mismatched_keys,
   3692         offload_index,
   3693         error_msgs,
-> 3694     ) = cls._load_pretrained_model(
   3695         model,
   3696         state_dict,
   3697         loaded_state_dict_keys,  # XXX: rename?
   3698         resolved_archive_file,
   3699         pretrained_model_name_or_path,
   3700         ignore_mismatched_sizes=ignore_mismatched_sizes,
   3701         sharded_metadata=sharded_metadata,
   3702         _fast_init=_fast_init,
   3703         low_cpu_mem_usage=low_cpu_mem_usage,
   3704         device_map=device_map,
   3705         offload_folder=offload_folder,
   3706         offload_state_dict=offload_state_dict,
   3707         dtype=torch_dtype,
   3708         is_quantized=(getattr(model, "quantization_method", None) == QuantizationMethod.BITS_AND_BYTES),
   3709         keep_in_fp32_modules=keep_in_fp32_modules,
   3710     )
   3712 model.is_loaded_in_4bit = load_in_4bit
   3713 model.is_loaded_in_8bit = load_in_8bit

File ~/.local/lib/python3.10/site-packages/transformers/modeling_utils.py:4079, in PreTrainedModel._load_pretrained_model(cls, model, state_dict, loaded_keys, resolved_archive_file, pretrained_model_name_or_path, ignore_mismatched_sizes, sharded_metadata, _fast_init, low_cpu_mem_usage, device_map, offload_folder, offload_state_dict, dtype, is_quantized, keep_in_fp32_modules)
   4077 if shard_file in disk_only_shard_files:
   4078     continue
-> 4079 state_dict = load_state_dict(shard_file)
   4081 # Mistmatched keys contains tuples key/shape1/shape2 of weights in the checkpoint that have a shape not
   4082 # matching the weights in the model.
   4083 mismatched_keys += _find_mismatched_keys(
   4084     state_dict,
   4085     model_state_dict,
   (...)
   4089     ignore_mismatched_sizes,
   4090 )

File ~/.local/lib/python3.10/site-packages/transformers/modeling_utils.py:522, in load_state_dict(checkpoint_file)
    520 except Exception as e:
    521     try:
--> 522         with open(checkpoint_file) as f:
    523             if f.read(7) == "version":
    524                 raise OSError(
    525                     "You seem to have cloned a repository without having git-lfs installed. Please install "
    526                     "git-lfs and run `git lfs install` followed by `git lfs pull` in the folder "
    527                     "you cloned."
    528                 )

FileNotFoundError: [Errno 2] No such file or directory: '/scratch/07025/mosorio/Llama-2-13b-chat-hf/pytorch_model-00001-of-00003.bin'
mosoriob commented 11 months ago

Any ideas? @wmobley