


"""simple docstring"""

from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase     :    Optional[Any]       =			logging.get_logger(__name__)

UpperCamelCase     :    int       =			{
    "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json",
    "tiiuae/falcon-7b": "https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json",
}

class __lowerCAmelCase		(				__SCREAMING_SNAKE_CASE      ):
     lowercase						       =						"falcon"
     lowercase						       =						["past_key_values"]





     def __init__(     self     ,					__UpperCAmelCase=6_5024     ,					__UpperCAmelCase=4544     ,					__UpperCAmelCase=32     ,					__UpperCAmelCase=71     ,					__UpperCAmelCase=1E-5     ,					__UpperCAmelCase=0.0_2     ,					__UpperCAmelCase=True     ,					__UpperCAmelCase=0.0     ,					__UpperCAmelCase=0.0     ,					__UpperCAmelCase=None     ,					__UpperCAmelCase=False     ,					__UpperCAmelCase=False     ,					__UpperCAmelCase=True     ,					__UpperCAmelCase=True     ,					__UpperCAmelCase=False     ,					__UpperCAmelCase=11     ,					__UpperCAmelCase=11     ,					**__UpperCAmelCase     ,					):

      '''simple docstring'''




      __UpperCamelCase      =	vocab_size
      # Backward compatibility with n_embed kwarg
      __UpperCamelCase      =	kwargs.pop('n_embed'     ,					__UpperCAmelCase				)
      __UpperCamelCase      =	hidden_size if n_embed is None else n_embed
      __UpperCamelCase      =	num_hidden_layers
      __UpperCamelCase      =	num_attention_heads
      __UpperCamelCase      =	layer_norm_epsilon
      __UpperCamelCase      =	initializer_range
      __UpperCamelCase      =	use_cache
      __UpperCamelCase      =	hidden_dropout
      __UpperCamelCase      =	attention_dropout

      __UpperCamelCase      =	bos_token_id
      __UpperCamelCase      =	eos_token_id
      __UpperCamelCase      =	num_attention_heads if num_kv_heads is None else num_kv_heads
      __UpperCamelCase      =	alibi
      __UpperCamelCase      =	new_decoder_architecture
      __UpperCamelCase      =	multi_query  # Ignored when new_decoder_architecture is True
      __UpperCamelCase      =	parallel_attn
      __UpperCamelCase      =	bias

      super().__init__(bos_token_id=__UpperCAmelCase     ,					eos_token_id=__UpperCAmelCase     ,					**__UpperCAmelCase				)





     @property
     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      return self.hidden_size // self.num_attention_heads







     @property
     def 						UpperCAmelCase (     self				):

      '''simple docstring'''




      return not self.alibi





"""simple docstring"""

from typing import Union

import fire
import torch
from tqdm import tqdm






def 							A						(    snake_case				:str    , snake_case				:str = "cpu"    , snake_case				:Union[str, None] = None		)				->     None:
 __UpperCamelCase      =	torch.load(snake_case    , map_location=snake_case		)
 for k, v in tqdm(state_dict.items()		):
  if not isinstance(snake_case    , torch.Tensor		):
   raise TypeError('FP16 conversion only works on paths that are saved state dicts, like pytorch_model.bin'		)
  __UpperCamelCase      =	v.half()
 if save_path is None:  # overwrite src_path
  __UpperCamelCase      =	src_path
 torch.save(snake_case    , snake_case		)


if __name__ == "__main__":
      fire.Fire(convert)



