Shortcuts

torchx.deprecations

Platform-agnostic deprecation utilities for TorchX.

Provides deprecated_module() for warning about moved import paths and deprecated() for marking functions/classes as deprecated.

Both emit UserWarning (not DeprecationWarning) so that warnings are always visible to end users — DeprecationWarning is silenced by default outside __main__.

torchx.deprecations.deprecated_module(old_import: str, new_import: str, *, stacklevel: int = 3) → None[source]

Emit a UserWarning for a moved module import.

Call this from backwards-compatibility stub modules so users see a warning on first import:

# torchx/old/path.py (BC stub)
from torchx.deprecations import deprecated_module

deprecated_module(
    old_import="torchx.old.path",
    new_import="torchx.new.path",
)

from torchx.new.path import *  # noqa: F401,F403
Parameters:
  • old_import – The deprecated import path.

  • new_import – The replacement import path.

  • stacklevel – Stack level for the warning. Default 3 works when called from module-level code in a stub (caller -> stub -> this function -> warnings.warn).

torchx.deprecations.deprecated(*, replacement: str | None = None) → Callable[[_F], _F][source]

Mark a function or class as deprecated.

from torchx.deprecations import deprecated

@deprecated(replacement="new_func")
def old_func():
    ...
Parameters:

replacement – Name or import path of the replacement, if any.

Returns:

A decorator that wraps the target to emit UserWarning on each call.

Distributed components

Use torchx.components.dist.torchrun() to launch distributed PyTorch applications. dist.ddp and dist.spmd remain available as deprecated aliases and emit a UserWarning on each call.

  • dist.torchrun retains the dist.ddp defaults: j="1x2", no named host, two CPUs, no GPUs, and 1024 MB of memory per replica.

  • To preserve dist.spmd defaults, pass h="gpu.small", j="1x1".

  • With a named host, dist.torchrun treats a bare j as the node count and infers processes per node from the host’s GPU count, as dist.spmd does. Specify NxP for a host without GPUs.

  • dist.ddp retains its original bare-j meaning: processes on one node. When migrating dist.ddp(h="gpu.small", j="2", ...), use dist.torchrun(h="gpu.small", j="1x2", ...) to keep the same topology.

  • Explicit NxP and elastic MIN:MAXxP topologies are unchanged when migrating from dist.ddp.

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