VainF / Torch-Pruning

[CVPR 2023] Towards Any Structural Pruning; LLMs / SAM / Diffusion / Transformers / YOLOv8 / CNNs
https://arxiv.org/abs/2301.12900
MIT License
2.44k stars 308 forks source link

detecting unwrapped parameters #364

Closed NicholasKiefer closed 3 months ago

NicholasKiefer commented 3 months ago

When specifying unwrapped parameters, the function _detect_unwrapped_parameters(...) always fails, in line 664 in torch_pruning.dependency here:

        unwrapped_detected = list( set(unwrapped_detected) - set([p for (p, _) in unwrapped_parameters]) )

because python will fail on [p for (p, _) in unwrapped_parameters], because unwrapped_parameters is a dict. I don't know enough about the code to do a pull request fixing that.

janthmueller commented 3 months ago

It seems the typing hint provided is incorrect. Based on my understanding and examples provided in the documentation, it should be typing.List[typing.Tuple[nn.Parameter, int]]. This can be confirmed by referring to the Wiki for High-level Pruners, specifically looking into the unwrapped_parameters section.