{"id":24727,"library":"torchx-nightly","title":"TorchX SDK and Components","description":"TorchX is a Python SDK and set of components for building and launching distributed PyTorch applications. It provides a unified API to run jobs across different schedulers (local, Slurm, Kubernetes, AWS Batch, etc.). Version 2026.4.30 is a nightly release. Release cadence is nightly (torchx-nightly) vs stable (torchx) using semver.","status":"active","version":"2026.4.30","language":"python","source_language":"en","source_url":"https://github.com/pytorch/torchx","tags":["pytorch","distributed","scheduler","ml","kubernetes","slurm","nightly"],"install":[{"cmd":"pip install torchx-nightly","lang":"bash","label":"Install nightly"}],"dependencies":[{"reason":"Core dependency for torchx components","package":"torch","optional":false}],"imports":[{"note":"","wrong":null,"symbol":"TorchX","correct":"from torchx import TorchX"},{"note":"AppDef is now in specs module since 0.5.0","wrong":null,"symbol":"AppDef","correct":"from torchx.specs import AppDef"},{"note":"run moved to torchx.runner in 0.6.0","wrong":"from torchx import run","symbol":"run","correct":"from torchx.runner import run"},{"note":"scheduler factories moved to schedulers module in 0.5.0","wrong":"from torchx.runtime import get_scheduler_factories","symbol":"get_scheduler_factories","correct":"from torchx.schedulers import get_scheduler_factories"}],"quickstart":{"code":"import os\nfrom torchx import TorchX\nfrom torchx.specs import AppDef, Role\n\napp = AppDef(\n    name=\"test_job\",\n    roles=[\n        Role(\n            name=\"worker\",\n            image=\"pytorch/pytorch:latest\",\n            entrypoint=\"python\",\n            args=[\"-c\", \"import torch; print('hello')\"],\n            num_replicas=2,\n        )\n    ],\n)\nscheduler = TorchX.scheduler(\"local_cwd\")\nscheduler.schedule(app)\nprint(\"Job scheduled successfully\")","lang":"python","description":"Create a simple AppDef and schedule it using the local (current working directory) scheduler."},"warnings":[{"fix":"Use `from torchx.runner import run` instead.","message":"In version 0.6.0, the `run` function moved from `torchx` to `torchx.runner`. Old code using `from torchx import run` will break.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use `from torchx.schedulers import get_scheduler_factories`.","message":"In version 0.5.0, scheduler factories were moved from `torchx.runtime` to `torchx.schedulers`. Imports from the old path will fail.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Use a virtual environment and install only one: either `torchx` (stable) or `torchx-nightly` (unstable).","message":"The nightly package `torchx-nightly` can conflict with the stable `torchx` package. Installing both can cause import errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Install PyTorch separately via `pip install torch` (or the appropriate variant for your system).","message":"TorchX requires PyTorch >= 1.11. If not installed, you'll get ImportError on torchx installation.","severity":"gotcha","affected_versions":"all"},{"fix":"Define roles explicitly using `Role` objects and pass them to `AppDef(roles=[...])`.","message":"The `AppDef` constructor argument `dist_role` is deprecated as of 0.7.0. Use the new `Role` API instead.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Use absolute paths or set `workspace` in the TorchX config.","message":"When using `local_cwd` scheduler, the working directory is the current directory. If job artifacts or data are relative, they may not be found.","severity":"gotcha","affected_versions":"all"},{"fix":"Install extra dependencies: `pip install torchx[kubernetes]` or `torchx[slurm]`, etc.","message":"For remote schedulers (Kubernetes, Slurm) you need additional dependencies like `torchx[kubernetes]`. Missing them results in ModuleNotFoundError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"For torchx >=0.6.0, use `from torchx.runner import run`. For older versions, use `from torchx import run`.","cause":"You are using an older version of torchx (<0.6.0) or using the wrong import path.","error":"ModuleNotFoundError: No module named 'torchx.runner'"},{"fix":"Use `from torchx.schedulers import get_scheduler_factories`.","cause":"The function moved to torchx.schedulers in version 0.5.0.","error":"ImportError: cannot import name 'get_scheduler_factories' from 'torchx.runtime'"},{"fix":"Replace `dist_role=...` with a `Role` object in the `roles` list.","cause":"The `dist_role` parameter was removed in version 0.7.0. Use `roles` parameter instead.","error":"TypeError: AppDef.__init__() got an unexpected keyword argument 'dist_role'"},{"fix":"Use `scheduler = TorchX.scheduler('local_cwd')` or `'local_docker'`.","cause":"You are using an invalid scheduler name. The local scheduler is named 'local_cwd' or 'local_docker'.","error":"torchx.schedulers.api.SchedulerNotFoundError: No scheduler factory found for 'local'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}