ra_schoonhoven:

Although the recipe for forward pass needs to be defined within this function, one should call the :class:Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.


I’m not the author of that quote, but that states that you should always call module() as opposed to module.forward() if you don’t want to have the hooks ignored. Does the code make an explicit call to forward() by chance? Quickly skimming through it, I found a forward() call here: https://github.com/ahendriksen/msd_pytorch/blob/master/msd_pytorch/msd_model.py#L213 2 and here: https://github.com/ahendriksen/msd_pytorch/blob/master/msd_pytorch/msd_model.py#L250 1
Not sure how and if these are used at all anywhere in your code. BTW, thanks for finding that quote in the docs and doing lots of research into this yourself before raising this issue.
Another potential problem I see is that in the MSDBlock2d’s forward (https://github.com/ahendriksen/msd_pytorch/blob/master/msd_pytorch/msd_block.py#L179-L180 2) you grab the weights from self.parameters() and then pass them to the complicated forward() above. However, the parameters store the unpruned version of the weight tensors. The pruned versions are just attributes attached to the corresponding Modules. So this might also be the cause of the problem you’re seeing.
Other than these quick observations, from the details you provided (i.e., the fact that the hooks do exist and the net is indeed in a pruned state), it sound as if this is not an issue with pruning, but rather an issue with the specific model you’re using and the way it computes the forward pass, which is probably causing it to ignore the hooks for certain parts of the net. Not sure I’m the best person to debug that but I can take a closer look if needed.