Shortcuts

set_seed

torchtune.training.set_seed(seed: Optional[int] = None, debug_mode: Optional[Union[int, str]] = None) int[source]

Function that sets seed for pseudo-random number generators across commonly used libraries.

This seeds PyTorch, NumPy, and the python.random module. For distributed jobs, each local process sets its own seed, computed seed + rank. For more details, see https://pytorch.org/docs/stable/notes/randomness.html.

Parameters:
  • seed (Optional[int]) – the integer value seed. If None, a random seed will be generated and set.

  • debug_mode (Optional[Union[str, int]]) –

    Controls debug_mode settings for deterministic operations within PyTorch.

Returns:

the current seed

Return type:

int

Raises:

ValueError – If the input seed value is outside the required range.

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