MCPcopy
hub / github.com/huggingface/transformers / save_state

Function save_state

src/transformers/trainer_pt_utils.py:960–970  ·  view source on GitHub ↗

Saves the Trainer state, since Trainer.save_model saves only the tokenizer with the model. Under distributed environment this is done only for a process with rank 0.

(self)

Source from the content-addressed store, hash-verified

958
959# Trainer helper method
960def save_state(self):
961 """
962 Saves the Trainer state, since Trainer.save_model saves only the tokenizer with the model.
963
964 Under distributed environment this is done only for a process with rank 0.
965 """
966 if not self.is_world_process_zero():
967 return
968
969 path = os.path.join(self.args.output_dir, "trainer_state.json")
970 self.state.save_to_json(path)
971
972
973# Trainer helper method

Callers

nothing calls this directly

Calls 3

is_world_process_zeroMethod · 0.80
joinMethod · 0.80
save_to_jsonMethod · 0.80

Tested by

no test coverage detected