-
Notifications
You must be signed in to change notification settings - Fork 303
Add DeepSpeed easyblock #3450
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
Open
VRehnberg
wants to merge
16
commits into
easybuilders:develop
Choose a base branch
from
VRehnberg:add_deepspeed
base: develop
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
Add DeepSpeed easyblock #3450
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d90811c
Add DeepSpeed easyblock
VRehnberg 4405ffd
Add suggestions by hound
VRehnberg ea6db74
Add suggestions from review
VRehnberg 521d370
Move functionality between block and config
VRehnberg 63b77a3
Style: remove whitespace
VRehnberg 60bdf5c
Fix typo
VRehnberg 0ad2496
Sanity check number of failed ops
VRehnberg a33927c
Escape brackets in sanity check [NO]
VRehnberg 26f9153
Escaping backslashes
VRehnberg 18f8f94
Fix shebang in Python scripts
VRehnberg 0e61e6e
Fix missing import
VRehnberg 3b323ef
Revert fix_shebang edit, belongs in ec
VRehnberg b8f3470
Add testinstalldir/bin to PATH in runtest
VRehnberg 9522435
Remove unused imports
VRehnberg 1486d87
Use LD_LIBRARY_PATH for testinstall runtest
VRehnberg bd506a8
Merge branch 'easybuilders:develop' into add_deepspeed
VRehnberg 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 hidden or 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,105 @@ | ||
| ## | ||
| # Copyright 2009-2024 Ghent University | ||
| # | ||
| # This file is part of EasyBuild, | ||
| # originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), | ||
| # with support of Ghent University (http://ugent.be/hpc), | ||
| # the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), | ||
| # Flemish Research Foundation (FWO) (http://www.fwo.be/en) | ||
| # and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
| # | ||
| # https://github.com/easybuilders/easybuild | ||
| # | ||
| # EasyBuild is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation v2. | ||
| # | ||
| # EasyBuild is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. | ||
| ## | ||
| """ | ||
| EasyBuild support for building and installing DeepSpeed, implemented as an easyblock | ||
|
|
||
| author: Viktor Rehnberg (Chalmers University of Technology) | ||
| """ | ||
| from easybuild.easyblocks.generic.pythonpackage import PythonPackage | ||
| from easybuild.framework.easyconfig import CUSTOM | ||
| from easybuild.tools.build_log import EasyBuildError | ||
| from easybuild.tools.config import build_option | ||
| import easybuild.tools.environment as env | ||
|
|
||
|
|
||
| class EB_DeepSpeed(PythonPackage): | ||
| """Custom easyblock for DeepSpeed""" | ||
|
|
||
| @staticmethod | ||
| def extra_options(): | ||
| """Change some defaults for easyconfig parameters.""" | ||
| extra_vars = PythonPackage.extra_options() | ||
| extra_vars['use_pip'][0] = True | ||
| extra_vars['download_dep_fail'][0] = True | ||
| extra_vars['sanity_pip_check'][0] = True | ||
|
|
||
| # Add DeepSpeed specific vars | ||
| extra_vars['ds_build_ops_to_skip'] = [[], "For <val> in list will set DS_BUILD_<val>=0 (default: [])", CUSTOM] | ||
| return extra_vars | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| """Initialize DeepSpeed easyblock.""" | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| dep_names = set(dep['name'] for dep in self.cfg.dependencies()) | ||
|
|
||
| # enable building with GPU support if CUDA is included as dependency | ||
| if 'CUDA' in dep_names: | ||
| self.with_cuda = True | ||
| else: | ||
| self.with_cuda = False | ||
|
|
||
| @property | ||
| def cuda_compute_capabilities(self): | ||
| return self.cfg['cuda_compute_capabilities'] or build_option('cuda_compute_capabilities') | ||
|
|
||
| def configure_step(self): | ||
| """Set up DeepSpeed config""" | ||
| # require that PyTorch is listed as dependency | ||
| dep_names = set(dep['name'] for dep in self.cfg.dependencies()) | ||
| if 'PyTorch' not in dep_names: | ||
| raise EasyBuildError('PyTorch not found as a dependency') | ||
|
|
||
| if self.with_cuda: | ||
| # https://github.com/microsoft/DeepSpeed/issues/3358 | ||
| env.setvar('NVCC_PREPEND_FLAGS', '--forward-unknown-opts') | ||
|
|
||
| if self.cuda_compute_capabilities: | ||
| # specify CUDA compute capabilities via $TORCH_CUDA_ARCH_LIST | ||
| env.setvar('TORCH_CUDA_ARCH_LIST', ';'.join(self.cuda_compute_capabilities)) | ||
|
|
||
| # By default prebuild all ops with a few exceptions | ||
| # http://www.deepspeed.ai/tutorials/advanced-install/#pre-install-deepspeed-ops | ||
| # > DeepSpeed will only install any ops that are compatible with your machine | ||
| env.setvar('DS_BUILD_OPS', '1') | ||
|
|
||
| # Some may be problematic for different reasons, these are specified in the easyconfig | ||
| for opt in self.cfg['ds_build_ops_to_skip']: | ||
| env.setvar('DS_BUILD_{}'.format(opt), '0') | ||
|
|
||
| super().configure_step() | ||
|
|
||
| def sanity_check_step(self): | ||
| '''Custom sanity check for DeepSpeed.''' | ||
| custom_paths = { | ||
| 'files': ['bin/deepspeed'], | ||
| 'dirs': [], | ||
| } | ||
| custom_commands = [ | ||
| 'deepspeed --help', | ||
| 'python -m deepspeed.env_report', | ||
| '[ "$(ds_report | grep -c "\\[NO\\]")" -eq "{:d}" ]'.format(len(self.cfg['ds_build_ops_to_skip'])) | ||
| ] | ||
| return super().sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands) | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.