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
UserWarningfor 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
3works 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
UserWarningon 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.torchrunretains thedist.ddpdefaults:j="1x2", no named host, two CPUs, no GPUs, and 1024 MB of memory per replica.To preserve
dist.spmddefaults, passh="gpu.small", j="1x1".With a named host,
dist.torchruntreats a barejas the node count and infers processes per node from the host’s GPU count, asdist.spmddoes. SpecifyNxPfor a host without GPUs.dist.ddpretains its original bare-jmeaning: processes on one node. When migratingdist.ddp(h="gpu.small", j="2", ...), usedist.torchrun(h="gpu.small", j="1x2", ...)to keep the same topology.Explicit
NxPand elasticMIN:MAXxPtopologies are unchanged when migrating fromdist.ddp.