-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-16362: pydaos.torch checkpointing #15691
Open
enakta
wants to merge
28
commits into
master
Choose a base branch
from
0xe0f/pydaos.torch.checkpointing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
2ecf810
client: initialize DAOS on Dataset creation rather than on module import
0xE0F a15fe94
tests: PoC of torch tests
0xE0F 1303be9
client: torch module needs lazy DAOS init
0xE0F caa6fb4
ftests: add tests for pydaos.torch.Dataset
0xE0F 70cd817
client: add checkpoint interface to pydaos.torch
0xE0F eaf6b98
ftest: torch checkpoint test
0xE0F 8692003
docs: for pydaos.torch module
0xE0F de147e4
Linter fixes
0xE0F 9cac883
Apply suggestions from code review
enakta b313874
Fixes for copyright linter
0xE0F 5790c94
client: pass mode, oflags, class and chunk size to torch shim layer
0xE0F 65e7c9c
nlt: remove torch tests in favour of functional tests
0xE0F eb0059d
torch: uniform way to return error
0xE0F bd11078
ftest: add iterable dataset to tests
0xE0F b6512c9
linter: oflags -> open_flags
0xE0F 770f45d
torch: add parallel, chunked checkpoint writes
0xE0F 2f3488f
Linter fixes
0xE0F 20d417a
ftests: bump timeout for the checkpoint tests
0xE0F 9354f20
Bandit's checker suggestions
enakta 21d8222
ftest: add torch to the requirements
0xE0F 82c629f
ftests: drop version requirement for pytorch
0xE0F 57301cd
ftest: bump pool size for tests
0xE0F 4e189fc
ftest: be modest with vm test machines
0xE0F d1e2f51
client: torch: use old multiprocess API to support python 3.6
0xE0F f19fe56
torch: linter fix
0xE0F b17a6f7
ftest: bump timout for checkpoint tests
0xE0F 038fb6f
Merge branch 'master' into 0xe0f/pydaos.torch.checkpointing
0xE0F d1d5580
ftest: restarting tests with latest master
0xE0F File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,77 @@ | ||
# DAOS pytorch interface | ||
|
||
PyTorch is fully featured framework for building deep learning models and training them. | ||
It is widely used in the research community and in the industry. | ||
PyTorch allows loading data from various sources and DAOS can be used as a storage backend for training data and models' checkpoints. | ||
|
||
[DFS plugin](https://github.com/daos-stack/daos/tree/master/src/client/pydaos/torch) implements PyTorch interfaces for loading data from DAOS: Map and Iterable style datasets. | ||
This allows to use all features of `torch.utils.data.DataLoader` to load data from DAOS POSIX containers, including parallel data loading, batching, shuffling, etc. | ||
|
||
## Installation | ||
|
||
To install the plugin, you need to have PyTorch installed. Please follow the official [PyTorch installation guide](https://pytorch.org/get-started/). | ||
`pydoas.torch` module comes with DAOS client package. Please refer to DAOS installation guide for your distribution. | ||
|
||
|
||
## Usage | ||
|
||
To use DAOS as a storage backend for PyTorch, you need to have DAOS agent running on the nodes where PyTorch is running and correctly configured ACLs for the container. | ||
|
||
Here's an example of how to use Map-style dataset with DAOS directly: | ||
|
||
```python | ||
import torch | ||
from torch.utils.data import DataLoader | ||
from pydaos.torch import Dataset | ||
|
||
dataset = Dataset(pool='pool', container='container', path='/training/samples') | ||
# That's it, when the Dataset is created, it will connect to DAOS, scan the namaspace of the container | ||
# and will be ready to load data from it. | ||
|
||
for i, sample in enumerate(dataset): | ||
print(f"Sample {i} size: {len(sample)}") | ||
``` | ||
|
||
To use Dataset with DataLoader, you can pass it directly to DataLoader constructor: | ||
|
||
```python | ||
|
||
dataloader = DataLoader(dataset, | ||
batch_size=4, | ||
shuffle=True, | ||
num_workers=4, | ||
worker_init_fn=dataset.worker_init) | ||
|
||
# and use DataLoader as usual | ||
for batch in dataloader: | ||
print(f"Batch size: {len(batch)}") | ||
``` | ||
|
||
The only notable difference is that you need to set `worker_init_fn` method of the dataset to correctly initialize the DAOS connection in the worker processes. | ||
|
||
## Checkpoints | ||
|
||
DAOS can be used to store model checkpoints as well. | ||
PyTorch provides a way to save and load model checkpoints using [torch.save](https://pytorch.org/docs/main/generated/torch.save.html) and [torch.load](https://pytorch.org/docs/main/generated/torch.load.html) functions | ||
|
||
`pydaos.torch` provides a way to save and load model checkpoints directly to/from DAOS container (could be same or different container than the one used for data).: | ||
|
||
```python | ||
import torch | ||
from pydaos.torch import Checkpoint | ||
|
||
# ... | ||
|
||
chkp = Checkpoint(pool, cont, prefix='/training/checkpoints') | ||
|
||
with chkp.writer('model.pt') as w: | ||
torch.save(model.state_dict(), w) | ||
|
||
# Later, to load the model | ||
|
||
with chkp.reader('model.pt') as r: | ||
torch.load(r) | ||
|
||
``` | ||
|
||
See [pydaos.torch](https://github.com/daos-stack/daos/blob/master/src/client/pydaos/torch/Readme.md) plugin for an example of how to use checkpoints with DLIO benchmark |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ avocado-framework-plugin-varianter-yaml-to-mux==82 | |
clustershell | ||
paramiko | ||
distro | ||
torch |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably not touch those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linting was failing without these 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils/cq/check_update_copyright.sh
Just add handling for Enakta there and you should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can still land it with copyright issues though if you just want to change them