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

FKM dynamic sketchy memory reallocation #610

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions init2winit/optimizer_lib/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def get_optimizer(hps, model=None, batch_axis_name=None):
nesterov=(hps.optimizer == 'nesterov'))
elif hps.optimizer == 'tearfree':
sketch_size = hps.opt_hparams.get('sketchy_rank')
dynamic_size = hps.opt_hparams.get('dynamic_sketchy_rank')
if sketch_size is not None and sketch_size > 0:
opts = tearfree_sketchy.Options(
update_freq=hps.opt_hparams['update_preconditioners_freq'],
Expand All @@ -153,6 +154,25 @@ def get_optimizer(hps, model=None, batch_axis_name=None):
'shampoo_options': None,
'second_order_type': tearfree_second_order.SecondOrderType.SKETCHY,
}
elif dynamic_size is not None and dynamic_size > 0:
opts = tearfree_dynamic_sketchy.Options(
update_freq=hps.opt_hparams['update_preconditioners_freq'],
second_moment_decay=hps.opt_hparams['beta2'],
rank=dynamic_size,
epsilon=hps.opt_hparams.get('matrix_epsilon', 1e-16),
relative_epsilon=hps.opt_hparams.get(
'matrix_relative_epsilon', False
),
delta=hps.opt_hparams.get('delta', 1e-5),
eta=hps.opt_hparams.get('ekfac_svd', 1e-5),
err_tol=hps.opt_hparams.get('err_tol', 1e-5),
seed=hps.opt_hparams.get('seed', 0),
)
opts = {
'dynamic_sketchy_options': opts,
'shampoo_options': None,
'second_order_type': tearfree_second_order.SecondOrderType.DYNAMIC,
}
else:
opts = tearfree_shampoo.Options(
second_moment_decay=hps.opt_hparams['beta2'],
Expand Down
Loading