metaflow-torchrun
A torchrun decorator for Metaflow
What it is and what it does
metaflow-torchrun is a plugin that bridges Metaflow workflows and PyTorch's torchrun distributed training framework. It provides a @torchrun decorator that lets you run existing PyTorch distributed programs (like DDP training) as parallel steps in a Metaflow DAG without modifying your training code. The decorator automatically handles torchrun argument selection based on Metaflow compute resource requests (CPU, GPU, memory), network discovery, and subprocess orchestration.
You use it by stacking the @torchrun decorator on a Metaflow step, then calling current.torch.run() with your training entrypoint and arguments. This pattern is useful for multi-node training jobs submitted to AWS Batch or Kubernetes, where you want Metaflow to manage task orchestration and torchrun to manage the distributed torch processes within each task.
Use it for:
- Run multi-node PyTorch DDP training as a step in a Metaflow workflow without subprocess boilerplate
- Orchestrate distributed GPT or transformer training across parallel Metaflow tasks on Kubernetes or AWS Batch
- Execute existing torchrun scripts inside Metaflow without rewriting training code for the workflow framework
- Automate network discovery and torchrun argument configuration based on Metaflow resource decorators
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Metaflow decorator that integrates PyTorch distributed training via torchrun, allowing you to run multi-node torch programs as parallel Metaflow tasks without modifying your training code.
Yes, if you use Metaflow and PyTorch distributed training together. The package has no runtime dependencies, low install friction, active maintenance, and solves a real integration gap. License treatment is unclear—verify Apache License compliance before production use. No known vulnerabilities.
Install
metaflow-torchrun on PyPI
pip
pip install metaflow-torchrunuv
uv add metaflow-torchrunpoetry
poetry add metaflow-torchrunInstalling metaflow-torchrun
Before you install
Installation is straightforward with no runtime dependencies. The package is actively maintained with a recent release, though Python version support is unspecified.
License in practice
License treatment is unclear; the description mentions Apache License but SPDX metadata is not present in the package record, so verify the actual license terms before use.
Quickstart
pip install metaflow-torchrun
from metaflow import FlowSpec, step, torchrun
class MyFlow(FlowSpec):
@kubernetes(gpu=1)
@torchrun
@step
def train(self):
current.torch.run(
entrypoint="main.py",
entrypoint_args={"main-arg-1": "123"},
nproc_per_node=1
)
Requires Metaflow to be installed and configured; GPU/compute environment must support the resource decorators used (e.g., @kubernetes or @batch).
Verify before relying
- Exact Python version requirements and compatibility range
- Whether Metaflow itself is a required dependency or assumed to be pre-installed
- GPU/CUDA version requirements for torchrun integration
Package facts
| License | not declared (unclear) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 30 days since the last release |
| First released | |
| Downloads | 82,474/month — #14,161 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: metaflow_torchrun-0.2.2-py3-none-any.whl
Tags
More Distributed Computing packages
gRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
cloudpickleCloudpickle extends Python's standard pickle…
permissive · top 1,000 on PyPI
smart-openProvides a unified, open()-compatible Python…
permissive · top 1,000 on PyPI
portalockerPortalocker provides cross-platform file…
permissive · top 1,000 on PyPI
rayRay is a distributed computing framework that…
permissive · top 1,000 on PyPI
metaflow-prebuiltMetaflow extension that pre-bakes conda and…
permissive · top 15,000 on PyPI
torchtitantorchtitan is a PyTorch-native platform for…
permissive · top 15,000 on PyPI
torchft-nightlyProvides per-step fault tolerance for PyTorch…
unclear · top 15,000 on PyPI
torchxTorchX is a universal job launcher that submits…
permissive · top 15,000 on PyPI
torchrunxtorchrunx distributes PyTorch training…
copyleft · top 15,000 on PyPI
torchtntTNT provides training utilities and tools for…
permissive · top 15,000 on PyPI
metaflow-checkpointProvides decorators for Metaflow workflows to…
unclear · top 15,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
fairscaleFairScale extends PyTorch with distributed…
permissive · top 15,000 on PyPI
metaflowMetaflow is a framework for building,…
permissive · top 5,000 on PyPI