π Python Library¶
π Overview¶
Launch and train across all your accelerators, using your favorite framework + backend combo.
ezpz
simplifies the process of:
-
Setting up + launching distributed training:
-
import ezpz as ez
-
RANK =
ez.setup_torch(backend=backend)
[forbackend
\(\in\) {DDP
,deepspeed
,horovod
}]{.dim-text} -
RANK =
ez.get_rank()
-
LOCAL_RANK =
ez.get_local_rank()
-
WORLD_SIZE =
ez.get_world_size()
[(see
ezpz/dist.py
for more details).]{.dim-text} -
-
-
Using your favorite framework:
-
framework=pytorch
+backend={DDP, deepspeed, horovod}
-
framework=tensorflow
+backend=horovod
-
ez.get_torch_device()
: {cuda
,xpu
,mps
,cpu
} -
ez.get_torch_backend()
: {nccl
,ccl
,gloo
}
2ez π. (see frameworks for additional details)
-
-
Writing device agnostic code:
-
1 2 3 4 5 6 7 8 9 10
```pycon >>> import ezpz as ez >>> DEVICE = ez.get_torch_device() >>> model = torch.nn.Linear(10, 10) >>> model.to(DEVICE) >>> x = torch.randn((10, 10), device=DEVICE) >>> y = model(x) >>> y.device device(type='mps', index=0) ```
-
-
Using
wandb
:ez.setup_wandb(project_name='ezpz')
- Full support for any {
device
+framework
+backend
}: - device: {
GPU
,XPU
,MPS
,CPU
} - framework: {
torch
,deepspeed
,horovod
,tensorflow
} - backend: {
DDP
,deepspeed
,horovod
}
Install¶
To install1:
π Directory Structure¶
- π
ezpz
/src
/ezpz/
- π
bin/
:utils.sh
: Shell utilities forezpz
- π
conf/
:- βοΈ
config.yaml
: DefaultTrainConfig
object - βοΈ
ds_config.json
: DeepSpeed configuration
- βοΈ
- π
log/
: Logging configuration. - π
__about__.py
: Version information - π
__init__.py
: Main module - π
__main__.py
: Entry point - π
configs.py
: Configuration module - π
cria.py
: Baby Llama - π
dist.py
: Distributed training module - π
history.py
: History module - π
jobs.py
: Jobs module - π
model.py
: Model module - π
plot.py
: Plot modul - π
profile.py
: Profile module - π
runtime.py
: Runtime module - π
test.py
: Test module - π
test_dist.py
: Distributed training test module - π
train.py
: train module - π
trainer.py
: trainer module - π
utils.py
: utility module
-
Note the
--require-virtualenv
isnβt strictly required, but I highly recommend to always try and work within a virtual environment, when possible. ↩