MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / safe_save_model_for_hf_trainer

Function safe_save_model_for_hf_trainer

train/train.py:104–110  ·  view source on GitHub ↗

Collects the state dict and dump to disk.

(trainer: transformers.Trainer, output_dir: str)

Source from the content-addressed store, hash-verified

102 )
103
104def safe_save_model_for_hf_trainer(trainer: transformers.Trainer, output_dir: str):
105 """Collects the state dict and dump to disk."""
106 state_dict = trainer.model.state_dict()
107 if trainer.args.should_save:
108 cpu_state_dict = {key: value.cpu() for key, value in state_dict.items()}
109 del state_dict
110 trainer._save(output_dir, state_dict=cpu_state_dict) # noqa
111
112
113def smart_tokenizer_and_embedding_resize(

Callers 1

trainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected