Lightning-AI / Lightning-AI/pytorch-lightning
[Help needed] How to pass `weights_only` param to `tuner`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
### Description & Motivation
Copied from [ar.ipynb](https://github.com/sktime/pytorch-forecasting/blob/main/docs/source/tutorials/ar.ipynb) tutorial of `pytorch-forecasting`.
```python
# find optimal learning rate
from lightning.pytorch.tuner import Tuner
res = Tuner(trainer).lr_find(
net, train_dataloaders=train_dataloader, val_dataloaders=val_dataloader, min_lr=1e-5
)
print(f"suggested learning rate: {res.suggestion()}")
fig = res.plot(show=True, suggest=True)
fig.show()
net.hparams.learning_rate = res.suggestion()
```
Here the `trainer` is fitted inside `lr_find`.
And because it doesn't have `weights_only` param, it is failing.
we pass `weights_only` param in `trainer.fit`. Is there any way to pass this param here in `lr_find`?
### Another Doubt
I also have one more doubt (not exactly related to `ptf` but out of curiosity), why the default value of `weights_only` param is kept as `None` and not `True` like in `torch.load`(see `torch.load` doc [here](https://docs.pytorch.org/docs/stable/generated/torch.load.html#torch.load)) ? Is this intentional as it may break some code downstream?
See the default values of `weights_only` param in `trainer.fit` [here](https://lightning.ai/docs/pytorch/stable/api/lightning.pytorch.trainer.trainer.Trainer.html#lightning.pytorch.trainer.trainer.Trainer.fit) and `load_from_checkpoint` param [here](https://lightning.ai/docs/pytorch/stable/common/lightning_module.html#id3)
Thanks a lot for this amazing package! I am really a fan of your work. I would really appreciate you helping us with this!
### Pitch
_No response_
### Alternatives
_No response_
### Additional context
_No response_
cc @lantiga
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 with lightning.pytorch.tuner.Tuner.lr_find and the Trainer.fit API/docs, then compare how weights_only is handled in each path. Done means establishing and documenting the supported way to pass weights_only during lr_find, along with the rationale for its default value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100