-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for vanilla single node deepspeed executions (#10)
- New public interface named `DeepspeedExecutor.for_single_node` - This interface allows calling DeepspeedExecutor with vanilla @kubernetes decorator. - a minimal example to showcase how it can be used
- Loading branch information
Showing
7 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Run a Deepspeed hello world! Checkout `train.py` to see the script passed to the Deepspeed launcher. | ||
|
||
``` | ||
python flow.py run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from metaflow import FlowSpec, step, kubernetes | ||
|
||
IMAGE = "docker.io/eddieob/deepspeed:6" | ||
MEMORY = "16000" | ||
N_CPU = 2 | ||
|
||
|
||
class SingleNodeDeepspeedTest(FlowSpec): | ||
@step | ||
def start(self): | ||
self.next(self.train) | ||
|
||
@kubernetes(image=IMAGE, memory=MEMORY, cpu=N_CPU) | ||
@step | ||
def train(self): | ||
from metaflow.plugins.deepspeed_libs.executor import DeepspeedExecutor | ||
executor = DeepspeedExecutor.for_single_node( | ||
flow=self, | ||
use_gpu=False, | ||
n_slots = N_CPU | ||
) | ||
executor.run(entrypoint="train.py") | ||
self.next(self.end) | ||
|
||
@step | ||
def end(self): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
SingleNodeDeepspeedTest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from argparse import ArgumentParser | ||
import time | ||
from deepspeed import comm as dist | ||
from deepspeed import init_distributed | ||
|
||
if __name__ == "__main__": | ||
parser = ArgumentParser() | ||
parser.add_argument( | ||
"--local_rank", | ||
type=int, | ||
default=-1, | ||
help="local rank passed from distributed launcher", | ||
) | ||
args = parser.parse_args() | ||
init_distributed(dist_backend="gloo") | ||
global_rank = dist.get_rank() | ||
time.sleep(3) | ||
dist.barrier() | ||
print(f"I am global rank {global_rank} | local rank {args.local_rank}") | ||
time.sleep(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters