{"id":19329721,"url":"https://github.com/outerbounds/metaflow-torchrun","last_synced_at":"2026-03-11T19:31:50.030Z","repository":{"id":196451202,"uuid":"696135416","full_name":"outerbounds/metaflow-torchrun","owner":"outerbounds","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-27T19:07:45.000Z","size":537,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-28T04:14:44.666Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outerbounds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-25T06:50:54.000Z","updated_at":"2026-01-27T19:07:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"d4eec53a-fc62-4787-b116-d475e5de00b9","html_url":"https://github.com/outerbounds/metaflow-torchrun","commit_stats":null,"previous_names":["outerbounds/metaflow-torchrun"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/outerbounds/metaflow-torchrun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outerbounds%2Fmetaflow-torchrun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outerbounds%2Fmetaflow-torchrun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outerbounds%2Fmetaflow-torchrun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outerbounds%2Fmetaflow-torchrun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outerbounds","download_url":"https://codeload.github.com/outerbounds/metaflow-torchrun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outerbounds%2Fmetaflow-torchrun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30395597,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T18:46:22.935Z","status":"ssl_error","status_checked_at":"2026-03-11T18:46:17.045Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T02:29:37.010Z","updated_at":"2026-03-11T19:31:50.014Z","avatar_url":"https://github.com/outerbounds.png","language":"Python","funding_links":[],"categories":["Distributed Compute \u0026 Training"],"sub_categories":[],"readme":"# Metaflow torchrun decorator\n\n### Introduction\nThis repository implements a plugin to run parallel Metaflow tasks as nodes in a [torchrun](https://pytorch.org/docs/stable/elastic/run.html) job which can be submitted to AWS Batch or a Kubernetes cluster.\n\n### Features\n- \u003cb\u003eAutomatic torchrun integration:\u003c/b\u003e This extension provides a simple and intuitive way to incorporate PyTorch distributed programs in your Metaflow workflows using the `@torchrun` decorator\n- \u003cb\u003eNo changes to model code:\u003c/b\u003e The `@torchrun` decorator exposes a new method on the Metaflow current object, so you can run your existing torch distributed programs inside Metaflow tasks with no changes in the research code.\n- \u003cb\u003eRun one command:\u003c/b\u003e You don't need to log into many nodes and run commands on each. Instead, the `@torchrun` decorator will select arguments for the torchrun command based on the requests in Metaflow compute decorators like number of GPUs. Network addresses are automatically discoverable. \n- \u003cb\u003eNo user-facing subprocess calls:\u003c/b\u003e At the end of the day, `@torchrun` is calling a subprocess inside a Metaflow task. Although many Metaflow users do this, it can make code difficult to read for beginners. One major goal of this plugin is to motivate hardening and automating a pattern for submitting subprocess calls inside Metaflow tasks.\n\n### Installation\nYou can install it with:\n```\npip install metaflow-torchrun\n```\n\n### Getting Started\nAnd then you can import it and use in parallel steps:\n```\nfrom metaflow import FlowSpec, step, torchrun\n\n...\nclass MyGPT(FlowSpec):\n\n    @step\n    def start(self):\n        self.next(self.torch_multinode, num_parallel=N_NODES)\n\n    @kubernetes(cpu=N_CPU, gpu=N_GPU, memory=MEMORY)\n    @torchrun\n    @step\n    def torch_multinode(self):\n        ...\n        current.torch.run(\n            entrypoint=\"main.py\", # No changes made to original script.\n            entrypoint_args = {\"main-arg-1\": \"123\", \"main-arg-2\": \"777\"},\n            nproc_per_node=1,     # edge case of a torchrun arg user-facing.\n        )\n        ...\n    ...\n```\n\n### Examples\n\n| Directory | torch script description |\n| :--- | ---: |\n| [Hello](examples/hello/README.md) | Each process prints their rank and the world size. |  \n| [Tensor pass](examples/tensor-pass/README.md) | Main process passes a tensor to the workers. |  \n| [Torch DDP](examples/torch-ddp/README.md) | A flow that uses a [script from the torchrun tutorials](https://pytorch.org/tutorials/intermediate/ddp_series_multinode.html) on multi-node DDP. |  \n| [MinGPT](examples/min-gpt/README.md) | A flow that runs a [torchrun GPT demo](https://pytorch.org/tutorials/intermediate/ddp_series_minGPT.html) that simplifies [Karpathy's minGPT](https://github.com/karpathy/minGPT) in a set of parallel Metaflow tasks each contributing their `@resources`. |\n\n### License \n`metaflow-torchrun` is distributed under the \u003cu\u003eApache License\u003c/u\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fouterbounds%2Fmetaflow-torchrun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fouterbounds%2Fmetaflow-torchrun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fouterbounds%2Fmetaflow-torchrun/lists"}