Registry / ai-ml / torchx

torchx

JSON →
library0.7.0pypypi✓ verified 83d ago

TorchX is a Python SDK for MLOps that helps you compose, configure, and launch PyTorch applications on various schedulers like local, Docker, Kubernetes, and Ray. It provides a common API for distributed training, serving, and other ML workloads. The current version is 0.7.0, with major releases occurring every few months.

pip install torchx
INSTALL
IMPORT
SIG · TORCHX
T
torchx
ai-mlpythonv0.7.0
Install
3.6s avg
Import
—
Disk
29MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 30MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 3.6s · import 0.000s · 31MB
29MB installed
● package 29MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IMAGE
✓ from torchx import IMAGE
✗ from torchx import TorchxRunner
util
✓ from torchx import util
version
✓ from torchx import version

This quickstart demonstrates how to define a basic `AppDef` with a single role and launch it using `TorchxRunner` on the `local_cwd` scheduler. It prints 'Hello, TorchX!' to the console via the `echo` command.

from torchx import specs from torchx.runner import TorchxRunner # Define a simple application app = specs.AppDef( name='hello-world', roles=[ specs.Role( name='worker', entrypoint='echo', args=['Hello, TorchX!'], num_replicas=1, resource=specs.Resource(cpu=1, memMB=512) ) ] ) # Initialize the TorchX runner runner = TorchxRunner() # Launch the application on the local_cwd scheduler # Ensure you have a 'local_cwd' scheduler configured or just use 'local_cwd' app_handle = runner.run(app, scheduler='local_cwd') print(f"Application '{app.name}' launched with handle: {app_handle}") # You can optionally wait for the application to complete # runner.wait(app_handle, timeout=300) # Waits up to 5 minutes # print(f"Application '{app.name}' completed.")
torchx --version
Debug
Known issues
breakingThe `torchx.schedulers.ddp_scheduler` module was removed and replaced with the `ray_scheduler` for DDP-like workloads.
fix
Migrate from `ddp_scheduler` to `ray_scheduler` or `kubernetes` scheduler for distributed training applications.
affects: >=0.7.0
breakingThe CLI command `torchx run` was renamed to `torchx launch`.
fix
Update your CLI scripts to use `torchx launch` instead of `torchx run`.
affects: >=0.6.0
breakingThe `scheduler` field was removed from `specs.Role`. Scheduler selection now happens at the `runner.run()` level.
fix
Remove the `scheduler` argument from `specs.Role` definitions. Pass the desired scheduler string directly to `TorchxRunner.run(app, scheduler='your_scheduler')`.
affects: >=0.5.0
gotchaUsing Docker-based schedulers (e.g., `local_docker`, `kubernetes` with container images) requires a running Docker daemon.
fix
Ensure Docker Desktop or the Docker daemon is installed and actively running on your system before attempting to launch jobs with Docker-dependent schedulers.
affects: All
gotchaTorchX components like `dist.ddp` are factory functions that return `AppDef` objects, not direct applications or classes.
fix
When using components, pass their output directly to `runner.run()`, e.g., `runner.run(torchx.components.dist.ddp_torchscript(...), ...)` rather than trying to `import ddp` directly.
affects: All
Upgrade
Version history
0.7.0latest on PyPI · released Jul 16, 2024
Audit
Dependencies
torchrequiredCore dependency for defining and running PyTorch applications.
torchvisionrequiredCommonly used with TorchX for computer vision applications.
dockeroptionalRequired for using the 'local_docker' scheduler.
Agent activity
49 hits · last 30 days
node
44
Anthropic
1
OpenAI (training)
1
Resources
torchx — pip install torchx · libregistry