-
Notifications
You must be signed in to change notification settings - Fork 282
add block_mask & retrain_free features #775
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9336718
add retrain_free feature
WeiweiZhang1 24de767
code reorganization and bugfix
WeiweiZhang1 fc8a8ff
fix substandard sparsity issue
WeiweiZhang1 5fc03f9
add llm example
WeiweiZhang1 5bac9e9
Merge branch 'master' into pruning/retrain_free
wenhuach21 115f3e8
refine pruner-types
WeiweiZhang1 b4ca216
refine llm example
WeiweiZhang1 4b75bd0
update llm script
WeiweiZhang1 287c6af
pruner bugfix
WeiweiZhang1 9ac892d
preci bugfix1
WeiweiZhang1 3fd4ae8
add retrain-free test
WeiweiZhang1 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
924 changes: 924 additions & 0 deletions
924
...ples/pytorch/nlp/huggingface_models/language-modeling/pruning/eager/run_clm_no_trainer.py
Large diffs are not rendered by default.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
examples/pytorch/nlp/huggingface_models/language-modeling/pruning/eager/run_llm_pruning.sh
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,17 @@ | ||
| #!/bin/bash | ||
| set -x | ||
| python \ | ||
| examples/pytorch/nlp/huggingface_models/language-modeling/pruning/eager/run_clm_no_trainer.py \ | ||
| --model_name_or_path /path/to/your/model \ | ||
| --dataset_name lambada \ | ||
| --per_device_train_batch_size 2 \ | ||
| --per_device_eval_batch_size 16 \ | ||
| --max_train_steps 3002 \ | ||
| --weight_decay 0 \ | ||
| --block_size 512 \ | ||
| --do_prune \ | ||
| --auto_slim \ | ||
| --output_dir sparse_clm_models/ \ | ||
| --target_sparsity 0.2 \ | ||
| --pruning_pattern channelx1 \ | ||
| --pruning_frequency 500 \ |
33 changes: 33 additions & 0 deletions
33
examples/pytorch/nlp/huggingface_models/language-modeling/pruning/eager/timers.py
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,33 @@ | ||
| import time | ||
| import torch | ||
| class CPUTimer: | ||
| def __init__(self, timelogs): | ||
| self.timelogs = timelogs | ||
|
|
||
| def __enter__(self): | ||
| self.start = time.time() | ||
|
|
||
| def __exit__(self): | ||
| end = time.time() | ||
| self.timelogs.append((end - self.start) * 1000) # ms | ||
|
|
||
| def get_avg_time(self): | ||
| return sum(self.timelogs) / len(self.timelogs) | ||
|
|
||
| class GPUTimer: | ||
| def __init__(self, timelogs): | ||
| self.timelogs = timelogs | ||
|
|
||
| def __enter__(self): | ||
| self.start_event = torch.cuda.Event(enable_timing=True) | ||
| self.end_event = torch.cuda.Event(enable_timing=True) | ||
| self.start_event.record() | ||
|
|
||
| def __exit__(self): | ||
| self.end_event.record() | ||
| self.end_event.synchronize() | ||
| elapsed_time = self.start_event.elapsed_time(self.end_event) | ||
| self.timelogs.append(elapsed_time) | ||
|
|
||
| def get_avg_time(self): | ||
| return sum(self.timelogs) / len(self.timelogs) |
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.
Uh oh!
There was an error while loading. Please reload this page.