Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable step size instead of hard-coded default values for adafactor #535

Open
lamthuy opened this issue Sep 23, 2023 · 0 comments
Open

Comments

@lamthuy
Copy link

lamthuy commented Sep 23, 2023

The current implementation of the adafactor is consistent with the paper's default hyperparameters choice. In particular, in the get_lr function at

def _get_lr(self, param_group: ParamGroup, param_state: State) -> float:

We can see that if relative_step is True, the input learning rate by users is ignored and instead the learning rate is time-dependent defined as:

if param_group["relative_step"]:
            min_step = (
                1e-6 * param_state["step"]
                if param_group["warmup_init"]
                else 1e-2
            )
            rel_step_sz = min(min_step, 1.0 / math.sqrt(param_state["step"]))

That means the learning rate is defined as min(1e-6*t, 1/sqrt(t)) if warmup_init is set to True and min(1e-2, 1/sqrt(t)) otherwise. This hard-coded values 1e-6 and 1e-2 is not an optimal choice and the best values are data-dependent. I would suggest to change those lines to:

if param_group["relative_step"]:
            min_step = (
                param_group["lr"] * param_state["step"]
                if param_group["warmup_init"]
                else param_group["lr"]
            )
            rel_step_sz = min(min_step, 1.0 / math.sqrt(param_state["step"]))

That enables the users to configure those hyper-parameters via the input learning rate.

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

No branches or pull requests

1 participant