Shortcuts

FormattedCheckpointFiles

class torchtune.training.FormattedCheckpointFiles(filename_format: str, max_filename: str)[source]

This class gives a more concise way to represent a list of filenames of the format file_{i}_of_{n_files}.pth.

Parameters:
  • filename_format (str) – Format string for the filename. Must have exactly two placeholders, e.g. file_{}_of_{}.pth.

  • max_filename (str) – Maximum filename in the list. Should be a string representation of an integer, possibly with leading zeroes.

build_checkpoint_filenames()[source]

Builds a list of checkpoint filenames from the filename format and max filename.

Returns:

List of checkpoint filenames.

Return type:

List[str]

Example

>>> # Example usage
>>> f = FormattedCheckpointFiles(filename_format="file_{}_of_{}.safetensors", max_filename="00003")
>>> f.build_checkpoint_filenames()
>>> ['file_00001_of_00003.safetensors', 'file_00002_of_00003.safetensors', 'file_00003_of_00003.safetensors']

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources