Skip to content

fix: iterate individual resblock hooks instead of parent container hooks#2756

Open
Mr-Neutr0n wants to merge 1 commit intoRVC-Project:mainfrom
Mr-Neutr0n:fix/resblocks-hook-iteration
Open

fix: iterate individual resblock hooks instead of parent container hooks#2756
Mr-Neutr0n wants to merge 1 commit intoRVC-Project:mainfrom
Mr-Neutr0n:fix/resblocks-hook-iteration

Conversation

@Mr-Neutr0n
Copy link

Summary

  • Fixed a copy-paste bug in GeneratorNSF.__prepare_scriptable__() in infer/lib/infer_pack/models.py (line 586)
  • The for l in self.resblocks: loop was iterating over self.resblocks._forward_pre_hooks (the parent nn.ModuleList container's hooks) instead of l._forward_pre_hooks (each individual resblock's hooks)
  • This meant weight norm hooks on individual resblocks were never found and never removed during script preparation, while the container's hooks (which typically has none) were checked repeatedly

Details

The identical pattern appears correctly in two other places in the same file:

  • Generator.__prepare_scriptable__() (line 297) — correctly uses l._forward_pre_hooks
  • GeneratorNSF.__prepare_scriptable__() for self.ups (line 575) — correctly uses l._forward_pre_hooks

Only the self.resblocks loop in GeneratorNSF.__prepare_scriptable__() had this bug.

Test plan

  • Verify GeneratorNSF.__prepare_scriptable__() correctly removes weight norm from individual resblocks when preparing for TorchScript
  • Confirm no regression in model inference after the fix

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

Successfully merging this pull request may close these issues.

1 participant