All experiments were run using BartForConditionalGeneration on a batch size of 6 long CNN articles, of uneven length, so some were padded to 1024.
transformers/master- FWD pass: 6.8 GB
- generate (9 steps): 7.982GB
fairseq/master:- forward: 5.0 GB
- generate (9 steps): 5.3 GB
transformers/after_changes- FWD pass: 4.8 GB
- generate: 5.3 GB
I propose 5 independent changes, with the details of each described in the associated PR description:
Bart: not returning attn_weights if they are not needed (600 MB)- PR Link
- Scope of code change:
bart_modeling.py - Scope of speed up: Bart only.
BartDecoder: separate causal_mask and padding_mask (These were previously combined into one broadcastable mask).- (800 MB for
forwardwhen not generating) - PR Link
- (800 MB for
PretrainedModel.generate: call encoder before expandinginput_ids(1.5 GB)Bart: not materializingself.lm_head(200 MB)examples/summarization/evaluate_cnn.py: drop columns that are exclusivelypad_token_idfrom input_ids before callingmodel()- PR Link
- this reduces the runtime to compute EVAL on the CNN examples from 2h to 1:37 before any other changes.
- Does not effect peak memory usage.
Next Steps:
- There is still a small speed gap that I have not deeply investigated, but it is largely resolved.