Training machine learning models often requires custom train loop and custom code. As such, we don’t provide an out of the box training loop app. We do however have examples for how you can construct your training app as well as generic components you can use to run your custom training app.

  1. Trainer Example

  2. Component Best Practices

  3. See torchx.components to learn more about authoring components

  4. For more information on distributed training see torchx.components.dist.

Embedded Train Script

For simple apps you can use the torchx.components.utils.python() component to embed the training script as a command line argument to the Python command. This has a size limitation but works for many smaller apps.

>>> from torchx.components.utils import python
>>> app = """
... import sys
... print(f"Hello, {sys.argv[0]}")
... """
>>> python("TorchX user", c=app)
AppDef(..., entrypoint='python', ...)


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources