This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FairScale integration and T5-11B fine-tuning (#271)
* pass ddpwrapper * add options to T5 model * add weights_path param * beam search as a parameter * fix * CHANGELOG * add checkpoint_wrapper arg * ignore missing weights in state dict if tied * update * add improved config * update CHANGELOG * address comments * try fix dep * try fix again * revert * fix config * fix post load state dict hook * rename 'ddp_wrapper' -> 'ddp_accelerator' * fix * update CHANGELOG * revert CI patch
- Loading branch information
Showing
5 changed files
with
151 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,117 @@ | ||
local model_name = "t5-small"; // TODO: change to large model | ||
// =================== Configurable Settings ====================== | ||
|
||
local debug = true; | ||
|
||
local model_name = if debug then "t5-small" else "t5-11b"; | ||
|
||
local batch_size_per_gpu = if debug then 4 else 1; | ||
|
||
// To train "t5-11b" you will probably need 8 GPUs. | ||
local num_gpus = 8; | ||
|
||
// This is probably necessary for t5-11b unless you have more than 8 GPUs. | ||
local activation_checkpointing = true; | ||
|
||
// Set to `false` if you want to skip validation. | ||
local validate = true; | ||
|
||
// AMP is currently unusably slow with t5-11b, which may be due to a bug bug within | ||
// FairScale, but I'm not sure yet. | ||
local use_amp = false; | ||
|
||
// These are reasonable defaults. | ||
local source_length = 512; | ||
local target_length = 54; | ||
|
||
// Set to `true` to log to Weights & Biases. | ||
local use_wandb = false; | ||
|
||
// ================================================================ | ||
|
||
// ------ !! You probably don't need to edit below here !! -------- | ||
|
||
local data_base_url = "https://storage.googleapis.com/allennlp-public-data/cnndm-combined-data-2020.07.13.tar.gz"; | ||
local train_data = data_base_url + "!cnndm-combined-data-2020.07.13/url_lists/all_train.txt"; | ||
local dev_data = data_base_url + "!cnndm-combined-data-2020.07.13/url_lists/all_val.txt"; | ||
|
||
{ | ||
"train_data_path": train_data, | ||
"validation_data_path": dev_data, | ||
"dataset_reader": { | ||
"type": "cnn_dm", | ||
"source_tokenizer": { | ||
local dataset_reader = { | ||
"type": "cnn_dm", | ||
"source_tokenizer": { | ||
"type": "pretrained_transformer", | ||
"model_name": model_name, | ||
}, | ||
"source_token_indexers": { | ||
"tokens": { | ||
"type": "pretrained_transformer", | ||
"model_name": model_name, | ||
}, | ||
"source_token_indexers": { | ||
"tokens": { | ||
"type": "pretrained_transformer", | ||
"model_name": model_name, | ||
"namespace": "tokens", | ||
} | ||
}, | ||
"source_max_tokens": 512, | ||
"target_max_tokens": 54, | ||
"source_prefix": "summarize: ", | ||
"max_instances": 1000 // DEBUG setting | ||
"namespace": "tokens", | ||
} | ||
}, | ||
"source_max_tokens": source_length, | ||
"target_max_tokens": target_length, | ||
"source_prefix": "summarize: ", | ||
}; | ||
|
||
local data_loader = { | ||
"batch_size": batch_size_per_gpu, | ||
"shuffle": true, | ||
}; | ||
|
||
local wandb_callback = { | ||
"type": "wandb", | ||
"project": "allennlp-t5", | ||
"entity": "allenai-team1", | ||
"watch_model": false, | ||
"summary_interval": 1, | ||
"should_log_parameter_statistics": false, | ||
"should_log_learning_rate": false, | ||
}; | ||
|
||
{ | ||
"train_data_path": train_data, | ||
[if validate then "validation_data_path"]: dev_data, | ||
"dataset_reader": dataset_reader + { | ||
[if debug then "max_instances"]: batch_size_per_gpu * 40, | ||
}, | ||
"validation_dataset_reader": dataset_reader + { | ||
"max_instances": if debug then batch_size_per_gpu * 4 else batch_size_per_gpu * 10, | ||
}, | ||
"model": { | ||
"type": "t5", | ||
"model_name": model_name, | ||
"beam_search": { | ||
"beam_size": 3, | ||
"max_steps": if debug then 5 else 50, | ||
}, | ||
[if activation_checkpointing then "checkpoint_wrapper"]: { | ||
"type": "fairscale", | ||
"offload_to_cpu": true, | ||
"maintain_forward_counter": true, | ||
}, | ||
}, | ||
"data_loader": data_loader + { | ||
[if !debug then "max_instances_in_memory"]: batch_size_per_gpu * 128, | ||
[if !debug then "num_workers"]: 1, | ||
}, | ||
"data_loader": { | ||
"batch_size": 4, | ||
"shuffle": true, | ||
"validation_data_loader": data_loader, | ||
"vocabulary": { | ||
"type": "empty", | ||
}, | ||
"trainer": { | ||
"use_amp": use_amp, | ||
[if use_amp then "grad_scaling"]: false, # TODO: use grad scaling once it's fixed in FairScale. | ||
"num_epochs": 3, | ||
"optimizer": { | ||
"type": "huggingface_adamw", | ||
"lr": 3e-5, | ||
"betas": [0.9, 0.999], | ||
"eps": 1e-8, | ||
"correct_bias": true, | ||
}, | ||
"learning_rate_scheduler": { | ||
"type": "polynomial_decay", | ||
"type": "huggingface_adafactor", | ||
}, | ||
"grad_norm": 1.0, | ||
} | ||
[if use_wandb then "callbacks"]: [wandb_callback], | ||
}, | ||
[if num_gpus > 1 then "distributed"]: { | ||
"cuda_devices": std.range(0, num_gpus - 1), | ||
"ddp_accelerator": { | ||
"type": "fairscale_fsdp", | ||
"mixed_precision": use_amp, | ||
}, | ||
}, | ||
} |