Skip to content
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

FIlter pruning with LeGR #1689

Open
Hyunseok-Kim0 opened this issue Apr 6, 2023 · 1 comment
Open

FIlter pruning with LeGR #1689

Hyunseok-Kim0 opened this issue Apr 6, 2023 · 1 comment
Assignees

Comments

@Hyunseok-Kim0
Copy link

Hyunseok-Kim0 commented Apr 6, 2023

I am trying to apply filter pruning with LeGR to yolov8 model. It was able to run the pruning itself, but I have few questions about the implementation and result.

  1. In train_step during pruning, NNCFNetwork is trained for few epochs. However, in the early step of pruning, the model already shows almost 0 map even before training is started. is this normal for LeGR? I know normal filter pruning would not work like that, but not sure for LeGR.

  2. In first epoch of train_step, I observed the weight and other things are same with original model. However, the inference output of NNCFNetwork is totally different with original one. The only difference between two models is pruning mask inserted in the model. Is the output difference caused by the mask?

  3. There are few examples about LeGR in the branch https://github.com/mkaglins/nncf_pytorch/tree/mkaglins/RL_experiments. Unfortunately those examples are too old, so it looks sample codes are not fit with the current version. Is there any sample code for current version of LeGR?

  4. As mentioned in issues like parameter count and model size are still the same. #1038, pruned pytorch model have same size with original one. Will the model size decreased based on the pruning mask if I export the model to ONNX?

  5. Training results during each generation looks completely identical. It looks pruning mask does not affect anything to output of network, which is weird since the output itself is different from original network.

    def _predict_action(self) -> Dict:
    """
    Predict action for the current episode. Works as described above.
    :return: new generated action
    """
    np.random.seed(self.random_seed)
    episode_num = self.cur_episode
    action = {}
    if episode_num < self.population_size - 1:
    In line number 106, random seed is reassigned every time _predict_action called. Due to the line, actions within population number always have same value. Is this thing intended or just a bug? Even after I commented out that line, training result and reward are always same.

@daniil-lyakhov
Copy link
Collaborator

daniil-lyakhov commented Feb 15, 2024

Hello, @Hyunseok-Kim0! Sorry for a such a long delay, I've lost your questions in my mail and found it only now. Let me try to answer some of your questions:

1-2) Filter pruning is applying pruning masks to the model during create_compressed_model. Since masks operations are applied, they are zeroing some channels of convolution and linear operations, so despite the fact that all model parameters are the same, activations computation is modified by zero channels of some conv and linear layers.
3) You can try the Torch classification sample with a LEGR config.
4) Unfortunately no, the only way to remove parameters from the model is to use Openvino pruning transformation as it described here
5) The answer for this question requires some experiments and investigations as the LeGR pruning code was modified long time ago last time, please contact me again if you really need the answer for this question.

Hope that will help! Please don't hesitate to contact me directly by mail in case of missed messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants