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

PL: --adafactor option #6776

Merged
merged 2 commits into from
Aug 28, 2020
Merged

Conversation

sshleifer
Copy link
Contributor

@sshleifer sshleifer commented Aug 27, 2020

CC @moscow25, @patil-suraj

I used the "External LR" setup and verified that is saves a significant amount of memory on pegasus finetuning.

Happy to add to Trainer.

@@ -137,7 +138,11 @@ def configure_optimizers(self):
"weight_decay": 0.0,
},
]
optimizer = AdamW(optimizer_grouped_parameters, lr=self.hparams.learning_rate, eps=self.hparams.adam_epsilon)
if self.hparams.adafactor:
optimizer = Adafactor(optimizer_grouped_parameters, lr=self.hparams.learning_rate, scale_parameter=False, relative_step=False)
Copy link
Contributor Author

@sshleifer sshleifer Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ignore the adam_epsilon clarg here, since the defaults are different. Could add a --adafactor_epsilon clarg, but I'll wait until somebody asks me to. So many clargs!

@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #6776 into master will decrease coverage by 0.99%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6776      +/-   ##
==========================================
- Coverage   78.47%   77.48%   -1.00%     
==========================================
  Files         157      157              
  Lines       28569    28569              
==========================================
- Hits        22420    22137     -283     
- Misses       6149     6432     +283     
Impacted Files Coverage Δ
src/transformers/modeling_reformer.py 16.87% <0.00%> (-79.30%) ⬇️
src/transformers/configuration_reformer.py 21.62% <0.00%> (-78.38%) ⬇️
src/transformers/modeling_tf_openai.py 22.58% <0.00%> (-72.26%) ⬇️
src/transformers/modeling_tf_flaubert.py 24.53% <0.00%> (-63.81%) ⬇️
src/transformers/modeling_marian.py 60.00% <0.00%> (-30.00%) ⬇️
src/transformers/tokenization_ctrl.py 78.64% <0.00%> (-17.48%) ⬇️
src/transformers/tokenization_xlm_roberta.py 84.52% <0.00%> (-10.72%) ⬇️
src/transformers/activations.py 85.00% <0.00%> (-5.00%) ⬇️
src/transformers/tokenization_dpr.py 53.15% <0.00%> (-4.51%) ⬇️
src/transformers/modeling_bart.py 95.05% <0.00%> (-0.35%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42fddac...c769370. Read the comment docs.

@sshleifer sshleifer merged commit fb78a90 into huggingface:master Aug 28, 2020
@sshleifer sshleifer deleted the adafactor-option branch August 28, 2020 02:19
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Zigur pushed a commit to Zigur/transformers that referenced this pull request Oct 26, 2020
fabiocapsouza pushed a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
fabiocapsouza added a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants