Use non-persistent buffers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 799
- Avg merge
- 58m
- Merged PRs (30d)
- 3
Description
🚀 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at transforms.Resample and inspect how its buffers are registered and serialized. Confirm the intended behavior during checkpoint loading: recomputable buffers should not create missing-key errors while model behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100