pytorch / audio

Data manipulation and transformation for audio signal processing, powered by PyTorch
https://pytorch.org/audio
BSD 2-Clause "Simplified" License
2.49k stars 643 forks source link

Use non-persistent buffers #3059

Open Thylane opened 1 year ago

Thylane commented 1 year ago

🚀 The feature

Suggest using register_buffer() with persistent=False, so the buffer (e.g. window of spectrogram) will not be included in module's state dict.

Motivation, pitch

When I add new transforms to my model and load a pre-existing checkpoint, a missing key error will be raised, e.g. missing resample kernel in transforms.Resample. It can be solved by specifying strict=False at load time, however, I don't see any reason to save the buffers. They can be recomputed on construction time and that won't affect model's behavior.

Alternatives

No response

Additional context

Same motivation as https://github.com/pytorch/pytorch/issues/18056.

mthrok commented 1 year ago

This sounds reasonable to me. @pytorch/team-audio-core any objection?

mthrok commented 1 year ago

The team thinks this is a good change, and we look for contributor to make the change. Feel free to open a PR.

ashikshafi08 commented 1 year ago

Hello,

Is anyone working on this? I'm planning to give it a shot and possibly submit a PR.

mthrok commented 1 year ago

HIi @ashikshafi08

Thanks for the interest. No one is working on it, so feel free to do so.

francislata commented 10 months ago

@mthrok I don’t see recent updates on this issue. I can take a look at this issue if there are no conflicts with others?

mthrok commented 10 months ago

@mthrok I don’t see recent updates on this issue. I can take a look at this issue if there are no conflicts with others?

@francislata Thanks for the suggestion. I don't think anyone is working on it, so feel free to send a PR.