/usr/local/lib/python3.6/site-packages/transformers/__pycache__
NameSizeModeActions
activations.cpython-36.pyc77500644editdlrm
activations_tf.cpython-36.pyc41360644editdlrm
configuration_utils.cpython-36.pyc393970644editdlrm
convert_graph_to_onnx.cpython-36.pyc160360644editdlrm
convert_pytorch_checkpoint_to_tf2.cpython-36.pyc91760644editdlrm
convert_slow_tokenizer.cpython-36.pyc304510644editdlrm
convert_slow_tokenizers_checkpoints_to_fast.cpython-36.pyc29500644editdlrm
convert_tf_hub_seq_to_seq_bert_to_pytorch.cpython-36.pyc18310644editdlrm
debug_utils.cpython-36.pyc110980644editdlrm
deepspeed.cpython-36.pyc128870644editdlrm
dependency_versions_check.cpython-36.pyc9610644editdlrm
dependency_versions_table.cpython-36.pyc20390644editdlrm
dynamic_module_utils.cpython-36.pyc139500644editdlrm
feature_extraction_sequence_utils.cpython-36.pyc128480644editdlrm
feature_extraction_utils.cpython-36.pyc225680644editdlrm
file_utils.cpython-36.pyc38030644editdlrm
generation_beam_constraints.cpython-36.pyc165560644editdlrm
generation_beam_search.cpython-36.pyc254400644editdlrm
generation_flax_logits_process.cpython-36.pyc110800644editdlrm
generation_flax_utils.cpython-36.pyc223200644editdlrm
generation_logits_process.cpython-36.pyc283870644editdlrm
generation_stopping_criteria.cpython-36.pyc63520644editdlrm
generation_tf_logits_process.cpython-36.pyc165240644editdlrm
generation_tf_utils.cpython-36.pyc863740644editdlrm
generation_utils.cpython-36.pyc1135760644editdlrm
hf_argparser.cpython-36.pyc89970644editdlrm
image_utils.cpython-36.pyc97300644editdlrm
integrations.cpython-36.pyc314040644editdlrm
keras_callbacks.cpython-36.pyc145290644editdlrm
modelcard.cpython-36.pyc261650644editdlrm
modeling_flax_outputs.cpython-36.pyc348780644editdlrm
modeling_flax_pytorch_utils.cpython-36.pyc83510644editdlrm
modeling_flax_utils.cpython-36.pyc286020644editdlrm
modeling_outputs.cpython-36.pyc590830644editdlrm
modeling_tf_outputs.cpython-36.pyc457330644editdlrm
modeling_tf_pytorch_utils.cpython-36.pyc125920644editdlrm
modeling_tf_utils.cpython-36.pyc709060644editdlrm
modeling_utils.cpython-36.pyc983820644editdlrm
optimization.cpython-36.pyc226530644editdlrm
optimization_tf.cpython-36.pyc134080644editdlrm
processing_utils.cpython-36.pyc85680644editdlrm
pytorch_utils.cpython-36.pyc11180644editdlrm
testing_utils.cpython-36.pyc432770644editdlrm
tf_utils.cpython-36.pyc12510644editdlrm
tokenization_utils.cpython-36.pyc258450644editdlrm
tokenization_utils_base.cpython-36.pyc1292790644editdlrm
tokenization_utils_fast.cpython-36.pyc219790644editdlrm
trainer.cpython-36.pyc818400644editdlrm
trainer_callback.cpython-36.pyc229060644editdlrm
trainer_pt_utils.cpython-36.pyc398290644editdlrm
trainer_seq2seq.cpython-36.pyc80280644editdlrm
trainer_tf.cpython-36.pyc255360644editdlrm
trainer_utils.cpython-36.pyc155710644editdlrm
training_args.cpython-36.pyc546000644editdlrm
training_args_seq2seq.cpython-36.pyc23170644editdlrm
training_args_tf.cpython-36.pyc128690644editdlrm
__init__.cpython-36.pyc1094310644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/__pycache__/deepspeed.cpython-36.pyc (12887B)
3 EgI@sdZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZe rfddlZejeZdd ZGd d d ZGd d d eZdaddZddZddZddZddZdddZdS)z Integration with Deepspeed N)deepcopy) partialmethod)dep_version_check)is_torch_availableloggingcCstjjddk S)N deepspeed) importlibutil find_specr r @/usr/local/lib/python3.6/site-packages/transformers/deepspeed.pyis_deepspeed_available#src@s\eZdZdZddZddZdddZdd d Zd d ZddZ ddZ ddZ ddZ dS)HfDeepSpeedConfigaJ This object contains a DeepSpeed configuration dictionary and can be quickly queried for things like zero stage. A `weakref` of this object is stored in the module's globals to be able to access the config from areas where things like the Trainer object is not available (e.g. `from_pretrained` and `_get_resized_embeddings`). Therefore it's important that this object remains alive while the program is still running. [`Trainer`] uses the `HfTrainerDeepSpeedConfig` subclass instead. That subclass has logic to sync the configuration with values of [`TrainingArguments`] by replacing special placeholder values: `"auto"`. Without this special logic the DeepSpeed configuration is not modified in any way. Args: config_file_or_dict (`Union[str, Dict]`): path to DeepSpeed config file or dict. c Cst|tdt|tr$t|}n:t|trVtj|ddd}tj |}WdQRXnt d||_ |j dd|_ d|_|js|jrtd d g}t|j d |j d g}t||@d krd|_dS)Nrrzutf-8)encodingzJexpecting either a path to a DeepSpeed config file or a pre-populated dictzzero_optimization.stagerFcpuZnvmez*zero_optimization.offload_optimizer.devicez&zero_optimization.offload_param.devicerT)set_hf_deepspeed_configr isinstancedictrstrioopenjsonload ValueErrorconfig get_value_stage_offloadis_zero2is_zero3setlen)selfconfig_file_or_dictrfZoffload_devices_validZoffload_devicesr r r __init__8s$    zHfDeepSpeedConfig.__init__cCsH|j}|jd}|j}x&|D]}|j|}|dkrd|fSqW||fS)N.)rsplitpopget)r% ds_key_longrnodesds_keynoder r r find_config_node[s    z"HfDeepSpeedConfig.find_config_nodeNcCs&|j|\}}|dkr|S|j||S)zG Returns the set value or `default` if no value is set N)r1r,)r%r-defaultrr/r r r rhszHfDeepSpeedConfig.get_valueFcCsj|j}|jd}xB|D]:}|}|j|}|dkr|rLtd|d|jqdSqW|dk rf|j|dS)z Deletes a sub-section of the config file if it's found. Unless `must_exist` is `True` the section doesn't have to exist. r)Nz Can't find z entry in the config: )rr*r,rr+)r%r-Z must_existrr.r0Z parent_configr r r del_config_sub_treeqs   z%HfDeepSpeedConfig.del_config_sub_treecCs|j|}|dkrdSt|S)z Returns `True`/``False` only if the value is set, always `False` otherwise. So use this method to ask the very specific question of whether the value is set to `True` (and it's not set to `False`` or isn't set). NF)rbool)r%r-valuer r r is_trues zHfDeepSpeedConfig.is_truecCs |j|}|dkrdSt| S)z Returns `True`/``False` only if the value is set, always `False` otherwise. So use this method to ask the very specific question of whether the value is set to `False` (and it's not set to `True`` or isn't set). NF)rr4)r%r-r5r r r is_falses zHfDeepSpeedConfig.is_falsecCs |jdkS)N)r)r%r r r r!szHfDeepSpeedConfig.is_zero2cCs |jdkS)N)r)r%r r r r"szHfDeepSpeedConfig.is_zero3cCs|jS)N)r )r%r r r is_offloadszHfDeepSpeedConfig.is_offload)N)F) __name__ __module__ __qualname____doc__r(r1rr3r6r7r!r"r:r r r r r's#  rcsNeZdZdZfddZddZddd Zeed d Zd d Z ddZ Z S)HfTrainerDeepSpeedConfigz The `HfTrainerDeepSpeedConfig` object is meant to be created during `TrainingArguments` object creation and has the same lifespan as the latter. cstj|d|_g|_dS)N)superr(_dtype mismatches)r%r&) __class__r r r(s z!HfTrainerDeepSpeedConfig.__init__cCs|jdkrtd|jS)Nz8trainer_config_process() wasn't called yet to tell dtype)rAr)r%r r r dtypes zHfTrainerDeepSpeedConfig.dtypeNTc Cs~|j|\}}|dkrdS|j|dkr4|||<dS|sr(rDrIrrSrWr^ __classcell__r r )rCr r?s   5r?cCstj|adS)N)weakrefref_hf_deepspeed_config_weak_ref)Zhf_deepspeed_config_objr r r r"srcCs$tdk rtdk rtjSdSdS)NF)rbr"r r r r is_deepspeed_zero3_enabled*s rccCs"tdk rtdk rtjSdSdS)N)rbrr r r r deepspeed_config1srdcs|j}d}d|kr"|jrDtdn"|jr4tjdj}d|d<fdd}d}d |krz|dkrl|}nj|d }||fS) zY A convenience wrapper that deals with optimizer and lr scheduler configuration. N optimizerz|--adafactor was passed, but also found `optimizer` configured in the DeepSpeed config. Only one optimizer can be configured.zDetected ZeRO Offload and non-DeepSpeed optimizers: This combination should work as long as the custom optimizer has both CPU and GPU implementation (except LAMB)TZzero_allow_untested_optimizercsj|dS)N)r]re)create_scheduler)re)r]trainerr r _lr_scheduler_callable`sz5deepspeed_optim_sched.._lr_scheduler_callableZ scheduler)r]re)rZ adafactorrr:loggerinfoZcreate_optimizerrf)rghf_deepspeed_configrVr]rrerh lr_schedulerr )r]rgr deepspeed_optim_sched8s$rmcCs(ddl}|jf|j\}}}}|||fS)a  this is a temp hack based on: https://github.com/microsoft/DeepSpeed/issues/1394#issuecomment-937405374 until Deepspeed fixes a bug where it can't resume from a checkpoint after it did some stepping https://github.com/microsoft/DeepSpeed/issues/1612 rN)r initializedeepspeed_initialize_kwargs)rgrdeepspeed_enginere_rlr r r deepspeed_reinitnsrrFcCs^ddl}ddlm}|j}|j}|j}|j||||j} |j|j |r~|j s\t d|j d|j dd\} } d} n(t ||||\} } ttdd|j} t|| | | | d } |jf| \}} }} | |_|dk rTddl}t|j|d }t|dkrDtjd ||j|d d d \}}|dkrTt d|ntj|d|| | fS)a Init DeepSpeed, after updating the DeepSpeed configuration with any relevant Trainer's args. If `resume_from_checkpoint` was passed then an attempt to resume from a previously saved checkpoint will be made. Args: trainer: Trainer object num_training_steps: per single gpu resume_from_checkpoint: path to a checkpoint if to resume from after normal DeepSpeedEngine load inference: launch in inference mode (no optimizer and no lr scheduler) Returns: model, optimizer, lr_scheduler rN)rizMZeRO inference only makes sense with ZeRO Stage 3 - please adjust your configrerlcSs|jS)N)Z requires_grad)pr r r sz deepspeed_init..)r\model_parametersZ config_paramsrerlz /global_step*zAttempting to resume from T)Zload_optimizer_statesZload_lr_scheduler_statesz-[deepspeed] failed to resume from checkpoint z2 doesn't have deepspeed checkpoints, doing nothing)NN)rZdeepspeed.utilsrir\rVrkr^rsetLevelZget_process_log_levelr"rr3rmlistfilter parametersrrnroglobsortedr$rjZload_checkpoint)rgr]Zresume_from_checkpointZ inferencerZ ds_loggerr\rVrkrrerlrukwargsrprqrzZdeepspeed_checkpoint_dirsZ load_pathr r r deepspeed_initzsH     r})NF)r>importlib.utilr rrr`copyr functoolsrZdependency_versions_checkrutilsrrrU get_loggerr;rirrr?rbrrcrdrmrrr}r r r r s*    ||6