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
LayerThinningModifier #623
Comments
Here is the file that will reproduce the error: simple_classification_structured.zip Here are my relevant specs:
|
thanks for filing the issue @vjsrinivas. We're looking into potential causes for this. In the meantime, using our image classification training script ( python integrations/pytorch/train.py \
--recipe-path resnet50-structured.yaml \
--arch-key resnet50 \
--dataset imagenette \
--dataset-path <Path to dataset> \
--pretrained True |
Hi @bfineran, I was able to run the recipe with train.py successfully, but I had some trouble with it initially. I ran
From my searches, it seems related to
But the layer sparisty stats are all zero:
Also, I checked on the pth file output and it's the same size as the original, which I'm guessing means that it did not actually remove any weights? |
Hi @vjsrinivas glad to hear your were able to get the run working.
import torch
PATH_TO_CKPT = "..."
NEW_CKPT_PATH = "..."
checkpoint = torch.load(PATH_TO_CKPT)
torch.save(checkpoint["state_dict"]) The new checkpoint should just contain the model weights. |
re: 1, the shared memory is 16GB: re: 2, I would strongly be in favor of showing the final max sparsity of the overall training cycle rather than the final epoch. re: 3, Yes, I was talking about the PyTorch weight. You were right, the weights are pruned. Now, when loading the pruned weights into original model, it will not fit because the filter and output sizes are different for each layer (expected). Currently, I'm manually editing the model structure with the new weight shapes (gist). It works but is very messy. Is there an easier way? Thank you for the help, btw! |
hm, ok maybe something else is causing the dataloader issue, what batch size are you running at and with how many workers were you trying? that's great news. for re-loading the weights we're currently in the process of rolling out "phased recipes" that will track changes between runs and apply them before weight load. Until then, you can apply the structural changes yourself using the old recipe with the following: from sparseml.pytorch.optim import ScheduledModifierManager
# model definition
model = ...
# load old recipe and apply to make structural changes
OLD_RECIPE_PATH = ...
ScheduledModifierManager.from_yaml(OLD_RECIPE_PATH).apply(model)
# parameter sizes should now line up and weights can be loaded |
Batchsize was 16. I did not set a value for num_worker, but the default value was 4. I'll make sure to use I had a couple of questions about the YAML recipe:
|
No problem, happy to support.
|
@bfineran Thank you for your help! If it is available, do you mind making a YOLOv3 structured pruning recipe available? |
I don't want to resuscitate an old issue, but this error: |
Reference:
Since the other issue is more about TensorRT, I don't want to pollute it with structured pruning related discussion. I ran the YAML for ResNet50 with LayerThinningModifier, but I would get the following error:
It seems like the zeroed weights are removed but the layer objects themselves are still expecting the old weight and bias shapes. I changed the YAML file to run LayerThinningModifier at the end of training, and it successfully trained and removed the weights. I had to recreate the network when loading the pruned weights though.
The text was updated successfully, but these errors were encountered: