Comments (5)
I tried using leave_enabled
on the Imagenette recipe but get leave_enabled == True is only supported for GMPruningModifier
.
Here is the recipe:
# General Epoch/LR variables
num_epochs: &num_epochs 10
lr: &lr 0.008
# Pruning variables
pruning_start_epoch: &pruning_start_epoch 1.0
pruning_end_epoch: &pruning_end_epoch 8.0
pruning_update_frequency: &pruning_update_frequency 0.5
init_sparsity: &init_sparsity 0.05
prune_low_target_sparsity: &prune_low_target_sparsity 0.8
prune_mid_target_sparsity: &prune_mid_target_sparsity 0.85
prune_high_target_sparsity: &prune_high_target_sparsity 0.9
training_modifiers:
- !EpochRangeModifier
start_epoch: 0.0
end_epoch: *num_epochs
- !SetLearningRateModifier
start_epoch: 0.0
learning_rate: *lr
pruning_modifiers:
- !GMPruningModifier
params:
- sections.0.0.conv1.weight
- sections.0.0.conv2.weight
- sections.0.0.conv3.weight
- sections.0.0.identity.conv.weight
- sections.0.1.conv1.weight
- sections.0.1.conv3.weight
- sections.0.2.conv1.weight
- sections.0.2.conv3.weight
- sections.1.0.conv1.weight
- sections.1.0.conv3.weight
- sections.1.2.conv3.weight
- sections.1.3.conv1.weight
- sections.2.0.conv1.weight
- sections.3.0.conv1.weight
- classifier.fc.weight
init_sparsity: *init_sparsity
final_sparsity: *prune_low_target_sparsity
start_epoch: *pruning_start_epoch
end_epoch: *pruning_end_epoch
update_frequency: *pruning_update_frequency
leave_enabled: False
- !GMPruningModifier
params:
- sections.0.1.conv2.weight
- sections.0.2.conv2.weight
- sections.1.0.identity.conv.weight
- sections.1.1.conv1.weight
- sections.1.1.conv2.weight
- sections.1.1.conv3.weight
- sections.1.2.conv1.weight
- sections.1.2.conv2.weight
- sections.1.3.conv2.weight
- sections.1.3.conv3.weight
- sections.2.0.conv3.weight
- sections.2.0.identity.conv.weight
- sections.2.1.conv1.weight
- sections.2.1.conv3.weight
- sections.2.2.conv1.weight
- sections.2.2.conv3.weight
- sections.2.3.conv1.weight
- sections.2.3.conv3.weight
- sections.2.4.conv1.weight
- sections.2.4.conv3.weight
- sections.2.5.conv1.weight
- sections.2.5.conv3.weight
- sections.3.1.conv1.weight
- sections.3.2.conv1.weight
init_sparsity: *init_sparsity
final_sparsity: *prune_mid_target_sparsity
start_epoch: *pruning_start_epoch
end_epoch: *pruning_end_epoch
update_frequency: *pruning_update_frequency
leave_enabled: False
- !GMPruningModifier
params:
- sections.1.0.conv2.weight
- sections.2.0.conv2.weight
- sections.2.1.conv2.weight
- sections.2.2.conv2.weight
- sections.2.3.conv2.weight
- sections.2.4.conv2.weight
- sections.2.5.conv2.weight
- sections.3.0.conv2.weight
- sections.3.0.conv3.weight
- sections.3.0.identity.conv.weight
- sections.3.1.conv2.weight
- sections.3.1.conv3.weight
- sections.3.2.conv2.weight
- sections.3.2.conv3.weight
init_sparsity: *init_sparsity
final_sparsity: *prune_high_target_sparsity
start_epoch: *pruning_start_epoch
end_epoch: *pruning_end_epoch
update_frequency: *pruning_update_frequency
leave_enabled: False
The docs doesn't mention that leave_enabled cannot be False, but the validate code enforces that.
from sparseml.
I reply mainly to have the answer to your question too.
My guess is that this behavior is handled by the leave_enabled
argument in the recipe, which is important mostly if you want to perform additional things like quantization.
Am I correct?
from sparseml.
It's strange given that the doc mentions "should be set to false if..."
from sparseml.
Hi @vjsrinivas and @clementpoiret, glad you've been able to use it and successfully prune some models! The leave_enabled flag is specifically used to reapply the masks when continuing to train after. Without this, the weights will gradually diverge from their masked 0 values as gradient descent continues to update them.
For your question, the weights are removed in an unstructured way so there is no current way to convert that into a structured reduction in the weight matrix dimensions. This means you'll need to use an Engine that supports the unstructured sparsity for performance and/or memory reduction such as DeepSparse. We are actively working on a TensorRT setup as well which has support for sparsity on the newer Ampere GPUs.
If you're looking to reduce the file sizes, you can run a compression algorithm over them to realize the compression gains. Finally, we are working on structured pruning support now and expect to land that in the next week if you're interested in going this route. Structured will prune away whole channels or filters at once enabling decreases in model sizes and faster inference on any deployment environment. The downside is that the maximum sparsity you can achieve will be much less.
Thanks,
Mark
from sparseml.
@markurtz Thank you for the information! I will be eagerly waiting for the structured pruning updates. I'll close this since my main questions have been answered.
from sparseml.
Related Issues (20)
- Search for models in the sparsezoo using architecture_name HOT 7
- Unexpected keyword krgument 'image_size' HOT 5
- Got error on YOLOv8n `sparseml.ultralytics.train` train starting HOT 2
- Llama 2 sparsity support HOT 1
- My own model HOT 1
- PyTorch 2.1.0 and Lightning 2.1.0 Support: AssertionError on `assert self._strategy is not None` HOT 13
- Question on quantization size HOT 2
- Add ScheduledModifierManager.from_str HOT 1
- Adding a `.pre-commit-config.yaml` file for maintaining consistent style and code quality. HOT 3
- Oriented Bounding Box support HOT 1
- Sparse ML not working for Transformers HOT 3
- Models with loops in their graph can't be converted to DeepSparse after QAT HOT 4
- RecursionError when converting LlaMa model to ONNX HOT 6
- Error converting mistral to onnx HOT 13
- SparseML/YOLOv5s - ValueError: Unable to find any modifiers in given recipe. HOT 1
- Feature Request: Oriented Bounding Box Sparsification for YOLOv5/YOLOv8 on Custom Models/Datasets HOT 1
- [Roadmap] SparseML Roadmap Q1 2024 HOT 1
- Regarding the execution speed and model size after Sparsifying ResNet-50 HOT 2
- Class Index change observed when validating a yolov5 pruned sparseml model HOT 2
- yolov5 sparse fine tuning error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sparseml.