question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use the non-protected LRScheduler import

See original GitHub issue

🚀 Feature

Motivation

Avoid protected imports

Pitch

https://github.com/pytorch/pytorch/issues/61232 has been merged to PyTorch which renames _LRScheduler to LRScheduler. They have kept the old class for compatibility, but we should still use the new one.

The task is to add logic like this

LRScheduler = (
    torch.optim.lr_scheduler.LRScheduler
    if _TORCH_GREATER_EQUAL_1_14 else 
    torch.optim.lr_scheduler._LRScheduler
)

to https://github.com/Lightning-AI/lightning/blob/d5003b1c07fda783f651a732c86ad48656be42c1/src/lightning_lite/utilities/types.py#L66 and places that use it

Alternatives

Keep using the protected import


If you enjoy Lightning, check out our other projects! ⚡

  • Metrics: Machine learning metrics for distributed, scalable PyTorch applications.

  • Lite: enables pure PyTorch users to scale their existing code on any kind of device while retaining full control over their own loops and optimization logic.

  • Flash: The fastest way to get a Lightning baseline! A collection of tasks for fast prototyping, baselining, fine-tuning, and solving problems with deep learning.

  • Bolts: Pretrained SOTA Deep Learning models, callbacks, and more for research and production with PyTorch Lightning and PyTorch.

  • Lightning Transformers: Flexible interface for high-performance research using SOTA Transformers leveraging PyTorch Lightning, Transformers, and Hydra.

cc @borda

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
qmarufcommented, Nov 13, 2022

Hi @shenoynikhil, i am working on this one.

1reaction
carmoccacommented, Nov 9, 2022

I described the work in the top post. We want to use LRScheduler throughout the codebase by importing a small compatibility variable defined in lightning/src/lightning_lite/utilities/types.py

Read more comments on GitHub >

github_iconTop Results From Across the Web

[FR] rename LR scheduler base class _LRScheduler ... - GitHub
Feature Rename _LRScheduler to something like LRScheduler without ... Use the non-protected LRScheduler import Lightning-AI/lightning#15587.
Read more >
StepLRScheduler | timmdocs
This is the optimizer that will be used for the training process. from timm import create_model from timm.optim import create_optimizer from ...
Read more >
torch.optim.lr_scheduler — Catalyst 20.03.1 documentation
Source code for torch.optim.lr_scheduler. import types import math from torch._six import ...
Read more >
Source code for detectron2.solver.lr_scheduler
_LRScheduler): """ A LRScheduler which uses fvcore :class:`ParamScheduler` to multiply the learning rate of each param in the optimizer.
Read more >
LRScheduler — PyTorch-Ignite v0.4.10 Documentation
LRScheduler (lr_scheduler, save_history=False, use_legacy=False)[source] ... import StepLR torch_lr_scheduler = StepLR(default_optimizer, step_size=3, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found