与 DeepSpeed 相同的训练时间(尽管批量大小增加)
问题:
嗨!我正在使用 huggingface(不带 Trainer API)和使用 deepspeed 来微调 Electra 模型。应用 Deepspeed 后,我可以增加训练模型的批量大小(64 -> 128,但 OOM 为 256),因此我预计训练时间会减少。 但是,即使我在代码中应用了 deepspeed,训练时间也是相同的。我不确定 Deepspeed 是否按照我的配置工作,如果没有,我想知道如何才能使其正常工作(更快的训练)
我正在 ColabProPlus 中训练模型,规格就像这个
(我每次都分配到相同的GPU - Tesla P100-PCIE-16GB GPU)
(我没有包括处理器 1~7 的规格,因为它们与处理器 0 相同)
"""
from psutil import *
print(cpu_count())
print(cpu_stats())
!cat /proc/cpuinfo
!df -h
"""
outputs:
8
scpustats(ctx_switches=2878445, interrupts=1351912, soft_interrupts=1239827, syscalls=0)
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU @ 2.30GHz
stepping : 0
microcode : 0x1
cpu MHz : 2299.998
cache size : 46080 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear arch_capabilities
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4599.99
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
Filesystem Size Used Avail Use% Mounted on
overlay 167G 43G 125G 26% /
tmpfs 64M 0 64M 0% /dev
shm 25G 0 25G 0% /dev/shm
/dev/root 2.0G 1.2G 817M 59% /sbin/docker-init
tmpfs 26G 28K 26G 1% /var/colab
/dev/sda1 174G 46G 128G 27% /opt/bin/.nvidia
tmpfs 26G 0 26G 0% /proc/acpi
tmpfs 26G 0 26G 0% /proc/scsi
tmpfs 26G 0 26G 0% /sys/firmware
drive 167G 49G 119G 30% /content/drive
我在初始化运行时时运行此命令以使用 deepspeed
!apt-get install libaio-dev
!pip install deepspeed triton==1.0.0
,然后,我的 ds_report 在运行训练代码之前显示这一点。
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
runtime if needed. Op compatibility means that your system
meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
sparse_attn ............ [NO] ....... [OKAY]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
async_io ............... [NO] ....... [OKAY]
utils .................. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/usr/local/lib/python3.7/dist-packages/torch']
torch version .................... 1.10.0+cu111
torch cuda version ............... 11.1
torch hip version ................ None
nvcc version ..................... 11.1
deepspeed install path ........... ['/usr/local/lib/python3.7/dist-packages/deepspeed']
deepspeed info ................... 0.6.0, unknown, unknown
deepspeed wheel compiled w. ...... torch 1.10, cuda 11.1, hip 0.0
我的deepspeed配置是这样的。
"ds_config":{
"stage2": {
"train_micro_batch_size_per_gpu": 128,
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": 5e-05,
"betas": [
0.9,
0.999
],
"eps": 1e-8
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 5e-5,
"warmup_num_steps": 0
}
},
"zero_optimization": {
"stage": 2,
"allgather_partitions": true,
"allgather_bucket_size": 5e8,
"overlap_comm": true,
"reduce_scatter": true,
"reduce_bucket_size": 5e8,
"contiguous_gradients": true,
"cpu_offload": true,
"offload_optimizer": {
"device": "cpu",
"pin_memory": true,
"fast_init": true
}
},
"gradient_accumulation_steps": 1,
"gradient_clipping": 1.0
}
}
我的火车代码与评论中链接的代码几乎相同,只添加了几行来使用 deepspeed,如下所示。
# https://github.com/monologg/KoELECTRA/blob/master/finetune/run_seq_cls.py
...
import deepspeed
...
def train():
...
...
model, optimizer, _, _ = deepspeed.initialize(model=model,
config_params=args['ds_config']['stage2'],
model_parameters=model.parameters())
...
...
for epoch in mb:
epoch_iterator = progress_bar(train_dataloader, parent=mb)
for step, batch in enumerate(epoch_iterator):
model.train()
batch = tuple(t.to(args.device) for t in batch)
inputs = {
"input_ids": batch[0],
"attention_mask": batch[1],
"labels": batch[3]
}
outputs = model(**inputs)
loss = outputs.loss
model.backward(loss)
tr_loss += loss.item()
if (step + 1) % args.gradient_accumulation_steps == 0 or (
len(train_dataloader) <= args.gradient_accumulation_steps
and (step + 1) == len(train_dataloader)
):
#torch.nn.utils.clip_grad_norm_(model.parameters(), args.max_grad_norm)
#optimizer.step()
model.step()
...
def main():
....
deepspeed.init_distributed("nccl")
....
这是我运行训练时的输出日志。
[2022-03-09 04:22:56,048] [WARNING] [runner.py:155:fetch_hostfile] Unable to find hostfile, will proceed with training with local resources only.
[2022-03-09 04:22:56,055] [INFO] [runner.py:438:main] cmd = /usr/bin/python3 -u -m deepspeed.launcher.launch --world_info=eyJsb2NhbGhvc3QiOiBbMF19 --master_addr=127.0.0.1 --master_port=29500 run_seq_cls2.py --dataset pm --mode all --config_dir ./electra/config
[2022-03-09 04:22:57,946] [INFO] [launch.py:96:main] 0 NCCL_VERSION=2.7.8
[2022-03-09 04:22:57,946] [INFO] [launch.py:103:main] WORLD INFO DICT: {'localhost': [0]}
[2022-03-09 04:22:57,946] [INFO] [launch.py:110:main] nnodes=1, num_local_procs=1, node_rank=0
[2022-03-09 04:22:57,946] [INFO] [launch.py:122:main] global_rank_mapping=defaultdict(<class 'list'>, {'localhost': [0]})
[2022-03-09 04:22:57,946] [INFO] [launch.py:123:main] dist_world_size=1
[2022-03-09 04:22:57,946] [INFO] [launch.py:125:main] Setting CUDA_VISIBLE_DEVICES=0
[2022-03-09 04:23:03,174] [INFO] [distributed.py:47:init_distributed] Initializing torch distributed with backend: nccl
03/09/2022 04:23:03 - INFO - torch.distributed.distributed_c10d - Added key: store_based_barrier_key:1 to store for rank: 0
03/09/2022 04:23:03 - INFO - torch.distributed.distributed_c10d - Rank 0: Completed store-based barrier for key:store_based_barrier_key:1 with 1 nodes.
03/09/2022 04:23:03 - INFO - __main__ - Training/evaluation parameters AttrDict({'run_n_fold': 1, 'task': 'spend', 'data_dir': './electra/data', 'ckpt_dir': './electra/ckpt', 'evaluate_test_during_training': False, 'eval_all_checkpoints': False, 'save_optimizer': True, 'do_lower_case': False, 'do_train': True, 'do_eval': True, 'max_seq_len': 128, 'num_train_epochs': 100, 'weight_decay': 0.0, 'gradient_accumulation_steps': 1, 'adam_epsilon': 1e-08, 'warmup_proportion': 0, 'max_steps': -1, 'max_grad_norm': 1.0, 'no_cuda': False, 'model_type': 'koelectra-base-v3', 'model_name_or_path': 'monologg/koelectra-base-v3-discriminator', 'output_dir': 'koelectra-base-v3-spend-ckpt', 'seed': 42, 'train_batch_size': 128, 'eval_batch_size': 128, 'logging_steps': 3000, 'save_steps': 3000, 'logging_epochs': 1, 'save_epochs': 1, 'learning_rate': 5e-05, 'deepspeed': True, 'ds_config': {'stage2': {'train_micro_batch_size_per_gpu': 128, 'fp16': {'enabled': True, 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'optimizer': {'type': 'AdamW', 'params': {'lr': 5e-05, 'betas': [0.9, 0.999], 'eps': 1e-08}}, 'scheduler': {'type': 'WarmupLR', 'params': {'warmup_min_lr': 0, 'warmup_max_lr': 5e-05, 'warmup_num_steps': 0}}, 'zero_optimization': {'stage': 2, 'allgather_partitions': True, 'allgather_bucket_size': 500000000.0, 'overlap_comm': True, 'reduce_scatter': True, 'reduce_bucket_size': 500000000.0, 'contiguous_gradients': True, 'cpu_offload': True, 'offload_optimizer': {'device': 'cpu', 'pin_memory': True, 'fast_init': True}}, 'gradient_accumulation_steps': 1, 'gradient_clipping': 1.0}, 'stage3': {'fp16': {'enabled': 'auto', 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'optimizer': {'type': 'AdamW', 'params': {'lr': 'auto', 'betas': 'auto', 'eps': 'auto', 'weight_decay': 'auto'}}, 'scheduler': {'type': 'WarmupLR', 'params': {'warmup_min_lr': 'auto', 'warmup_max_lr': 'auto', 'warmup_num_steps': 'auto'}}, 'zero_optimization': {'stage': 3, 'offload_optimizer': {'device': 'cpu', 'pin_memory': True}, 'offload_param': {'device': 'cpu', 'pin_memory': True}, 'overlap_comm': True, 'contiguous_gradients': True, 'sub_group_size': 100000000000000.0, 'reduce_bucket_size': 'auto', 'stage3_prefetch_bucket_size': 'auto', 'stage3_param_persistence_threshold': 'auto', 'stage3_max_live_parameters': 1000000000.0, 'stage3_max_reuse_distance': 1000000000.0, 'stage3_gather_fp16_weights_on_model_save': True}, 'gradient_accumulation_steps': 'auto', 'gradient_clipping': 'auto', 'steps_per_print': 2000, 'train_batch_size': 'auto', 'train_micro_batch_size_per_gpu': 'auto', 'wall_clock_breakdown': False}}})
03/09/2022 04:23:12 - INFO - processor.seq_cls - Loading features from cached file ./electra/data/cached_spend_koelectra-base-v3-discriminator_128
[2022-03-09 04:23:55,158] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed info: version=0.6.0, git-hash=unknown, git-branch=unknown
03/09/2022 04:23:55 - INFO - torch.distributed.distributed_c10d - Added key: store_based_barrier_key:2 to store for rank: 0
03/09/2022 04:23:55 - INFO - torch.distributed.distributed_c10d - Rank 0: Completed store-based barrier for key:store_based_barrier_key:2 with 1 nodes.
[2022-03-09 04:23:55,225] [INFO] [engine.py:278:__init__] DeepSpeed Flops Profiler Enabled: False
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /root/.cache/torch_extensions/py37_cu111/cpu_adam/build.ninja...
Building extension module cpu_adam...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module cpu_adam...
Time to load cpu_adam op: 3.290276527404785 seconds
Adam Optimizer #0 is created with AVX2 arithmetic capability.
Config: alpha=0.000050, betas=(0.900000, 0.999000), weight_decay=0.000000, adam_w=1
[2022-03-09 04:24:00,352] [INFO] [engine.py:1066:_configure_optimizer] Using DeepSpeed Optimizer param name adamw as basic optimizer
[2022-03-09 04:24:00,363] [INFO] [engine.py:1073:_configure_optimizer] DeepSpeed Basic Optimizer = DeepSpeedCPUAdam
[2022-03-09 04:24:00,363] [INFO] [utils.py:49:is_zero_supported_optimizer] Checking ZeRO support for optimizer=DeepSpeedCPUAdam type=<class 'deepspeed.ops.adam.cpu_adam.DeepSpeedCPUAdam'>
[2022-03-09 04:24:00,363] [INFO] [logging.py:69:log_dist] [Rank 0] Creating fp16 ZeRO stage 2 optimizer
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:125:__init__] Reduce bucket size 500000000.0
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:126:__init__] Allgather bucket size 500000000.0
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:127:__init__] CPU Offload: True
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:128:__init__] Round robin gradient partitioning: False
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
Emitting ninja build file /root/.cache/torch_extensions/py37_cu111/utils/build.ninja...
Building extension module utils...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module utils...
Time to load utils op: 0.5493736267089844 seconds
Rank: 0 partition count [1] and sizes[(113066686, False)]
[2022-03-09 04:24:01,501] [INFO] [utils.py:824:see_memory_usage] Before initializing optimizer states
[2022-03-09 04:24:01,502] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.47 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:01,502] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 7.89 GB, percent = 15.5%
[2022-03-09 04:24:02,174] [INFO] [utils.py:824:see_memory_usage] After initializing optimizer states
[2022-03-09 04:24:02,176] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.26 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:02,177] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 9.17 GB, percent = 18.0%
[2022-03-09 04:24:02,177] [INFO] [stage_1_and_2.py:497:__init__] optimizer state initialized
[2022-03-09 04:24:02,350] [INFO] [utils.py:824:see_memory_usage] After initializing ZeRO optimizer
[2022-03-09 04:24:02,351] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.26 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:02,351] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 9.17 GB, percent = 18.0%
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed Final Optimizer = adamw
[2022-03-09 04:24:02,352] [INFO] [engine.py:777:_configure_lr_scheduler] DeepSpeed using configured LR scheduler = WarmupLR
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed LR Scheduler = <deepspeed.runtime.lr_schedules.WarmupLR object at 0x7f507ff31f50>
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] step=0, skipped=0, lr=[5e-05], mom=[[0.9, 0.999]]
[2022-03-09 04:24:02,353] [INFO] [config.py:1058:print] DeepSpeedEngine configuration:
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] activation_checkpointing_config {
"partition_activations": false,
"contiguous_memory_optimization": false,
"cpu_checkpointing": false,
"number_checkpoints": null,
"synchronize_checkpoint_boundary": false,
"profile": false
}
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] aio_config ................... {'block_size': 1048576, 'queue_depth': 8, 'thread_count': 1, 'single_submit': False, 'overlap_events': True}
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] amp_enabled .................. False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] amp_params ................... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] autotuning_config ............ {
"enabled": false,
"start_step": null,
"end_step": null,
"metric_path": null,
"arg_mappings": null,
"metric": "throughput",
"model_info": null,
"results_dir": null,
"exps_dir": null,
"overwrite": true,
"fast": true,
"start_profile_step": 3,
"end_profile_step": 5,
"tuner_type": "gridsearch",
"tuner_early_stopping": 5,
"tuner_num_trials": 50,
"model_info_path": null,
"mp_size": 1,
"max_train_batch_size": null,
"min_train_batch_size": 1,
"max_train_micro_batch_size_per_gpu": 1.024000e+03,
"min_train_micro_batch_size_per_gpu": 1,
"num_tuning_micro_batch_sizes": 3
}
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] bfloat16_enabled ............. False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] checkpoint_tag_validation_enabled True
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] checkpoint_tag_validation_fail False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] communication_data_type ...... None
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] curriculum_enabled ........... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] curriculum_params ............ False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] dataloader_drop_last ......... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] disable_allgather ............ False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] dump_state ................... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] dynamic_loss_scale_args ...... {'init_scale': 65536, 'scale_window': 1000, 'delayed_shift': 2, 'min_scale': 1}
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_enabled ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_gas_boundary_resolution 1
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_layer_name ........ bert.encoder.layer
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_layer_num ......... 0
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_max_iter .......... 100
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_stability ......... 1e-06
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_tol ............... 0.01
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_verbose ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] elasticity_enabled ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] flops_profiler_config ........ {
"enabled": false,
"profile_step": 1,
"module_depth": -1,
"top_modules": 1,
"detailed": true,
"output_file": null
}
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_enabled ................. True
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_master_weights_and_gradients False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_mixed_quantize .......... False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] global_rank .................. 0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_accumulation_steps .. 1
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_clipping ............ 1.0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_predivide_factor .... 1.0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] initial_dynamic_scale ........ 65536
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] loss_scale ................... 0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] memory_breakdown ............. False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] optimizer_legacy_fusion ...... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] optimizer_name ............... adamw
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] optimizer_params ............. {'lr': 5e-05, 'betas': [0.9, 0.999], 'eps': 1e-08}
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pipeline ..................... {'stages': 'auto', 'partition': 'best', 'seed_layers': False, 'activation_checkpoint_interval': 0}
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pld_enabled .................. False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pld_params ................... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] prescale_gradients ........... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_change_rate ......... 0.001
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_groups .............. 1
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_offset .............. 1000
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_period .............. 1000
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_rounding ............ 0
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_start_bits .......... 16
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_target_bits ......... 8
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_training_enabled .... False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_type ................ 0
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_verbose ............. False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] scheduler_name ............... WarmupLR
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] scheduler_params ............. {'warmup_min_lr': 0, 'warmup_max_lr': 5e-05, 'warmup_num_steps': 0}
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] sparse_attention ............. None
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] sparse_gradients_enabled ..... False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] steps_per_print .............. 10
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_enabled .......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_job_name ......... DeepSpeedJobName
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_output_path ......
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] train_batch_size ............. 128
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] train_micro_batch_size_per_gpu 128
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] use_quantizer_kernel ......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] wall_clock_breakdown ......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] world_size ................... 1
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] zero_allow_untested_optimizer False
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_config .................. {
"stage": 2,
"contiguous_gradients": true,
"reduce_scatter": true,
"reduce_bucket_size": 5.000000e+08,
"allgather_partitions": true,
"allgather_bucket_size": 5.000000e+08,
"overlap_comm": true,
"load_from_fp32_weights": true,
"elastic_checkpoint": false,
"offload_param": null,
"offload_optimizer": {
"device": null,
"nvme_path": null,
"buffer_count": 4,
"pin_memory": false,
"pipeline_read": false,
"pipeline_write": false,
"fast_init": false
},
"sub_group_size": 1.000000e+09,
"prefetch_bucket_size": 5.000000e+07,
"param_persistence_threshold": 1.000000e+05,
"max_live_parameters": 1.000000e+09,
"max_reuse_distance": 1.000000e+09,
"gather_16bit_weights_on_model_save": false,
"ignore_unused_parameters": true,
"round_robin_gradients": false,
"legacy_stage1": false
}
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_enabled ................. True
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_optimization_stage ...... 2
[2022-03-09 04:24:02,360] [INFO] [config.py:1070:print] json = {
"train_micro_batch_size_per_gpu": 128,
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": 5e-05,
"betas": [0.9, 0.999],
"eps": 1e-08
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 5e-05,
"warmup_num_steps": 0
}
},
"zero_optimization": {
"stage": 2,
"allgather_partitions": true,
"allgather_bucket_size": 5.000000e+08,
"overlap_comm": true,
"reduce_scatter": true,
"reduce_bucket_size": 5.000000e+08,
"contiguous_gradients": true,
"cpu_offload": true,
"offload_optimizer": {
"device": "cpu",
"pin_memory": true,
"fast_init": true
}
},
"gradient_accumulation_steps": 1,
"gradient_clipping": 1.0
}
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
No modifications detected for re-loaded extension module utils, skipping build step...
Loading extension module utils...
Time to load utils op: 0.0008223056793212891 seconds
03/09/2022 04:24:02 - INFO - __main__ - ***** Running training *****
03/09/2022 04:24:02 - INFO - __main__ - Num examples = 234528
03/09/2022 04:24:02 - INFO - __main__ - Num Epochs = 100
03/09/2022 04:24:02 - INFO - __main__ - Total train batch size = 128
03/09/2022 04:24:02 - INFO - __main__ - Gradient Accumulation steps = 1
03/09/2022 04:24:02 - INFO - __main__ - Total optimization steps = 146600
03/09/2022 04:24:02 - INFO - __main__ - Logging steps = 3000
03/09/2022 04:24:02 - INFO - __main__ - Save steps = 3000
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
[2022-03-09 04:24:04,721] [INFO] [stage_1_and_2.py:1656:step] [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 65536, reducing to 65536
<IPython.core.display.HTML object>
[2022-03-09 04:24:06,139] [INFO] [stage_1_and_2.py:1656:step] [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 65536, reducing to 32768.0
我知道 Huggingface 和 Pytorch Trainer API 支持深度集成,但是,我想处理当前的代码并解决问题。提前感谢您的帮助:)
Problem:
Hi! I'm fine-tuning Electra model with using huggingface without Trainer API and with using deepspeed. After I applied deepspeed, I could increase the batch size (64 -> 128, but OOM with 256) of training model so I expected train time would decrease. However, even though I applied deepspeed in my code, the train time is the same. I am not sure if deepspeed is working as my configuration and if not, I wonder how I can make it work well (faster training)
I am training the model in ColabProPlus and spec is like this
( I have been allocated with the same GPU every time - Tesla P100-PCIE-16GB GPU )
( I did not include the specs of processor 1~7 because those are same with processor 0 )
"""
from psutil import *
print(cpu_count())
print(cpu_stats())
!cat /proc/cpuinfo
!df -h
"""
outputs:
8
scpustats(ctx_switches=2878445, interrupts=1351912, soft_interrupts=1239827, syscalls=0)
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 63
model name : Intel(R) Xeon(R) CPU @ 2.30GHz
stepping : 0
microcode : 0x1
cpu MHz : 2299.998
cache size : 46080 KB
physical id : 0
siblings : 8
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear arch_capabilities
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs
bogomips : 4599.99
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
Filesystem Size Used Avail Use% Mounted on
overlay 167G 43G 125G 26% /
tmpfs 64M 0 64M 0% /dev
shm 25G 0 25G 0% /dev/shm
/dev/root 2.0G 1.2G 817M 59% /sbin/docker-init
tmpfs 26G 28K 26G 1% /var/colab
/dev/sda1 174G 46G 128G 27% /opt/bin/.nvidia
tmpfs 26G 0 26G 0% /proc/acpi
tmpfs 26G 0 26G 0% /proc/scsi
tmpfs 26G 0 26G 0% /sys/firmware
drive 167G 49G 119G 30% /content/drive
I run this command to use deepspeed when I initialize runtime
!apt-get install libaio-dev
!pip install deepspeed triton==1.0.0
then, my ds_report shows this before running train code.
--------------------------------------------------
DeepSpeed C++/CUDA extension op report
--------------------------------------------------
NOTE: Ops not installed will be just-in-time (JIT) compiled at
runtime if needed. Op compatibility means that your system
meet the required dependencies to JIT install the op.
--------------------------------------------------
JIT compiled ops requires ninja
ninja .................. [OKAY]
--------------------------------------------------
op name ................ installed .. compatible
--------------------------------------------------
cpu_adam ............... [NO] ....... [OKAY]
cpu_adagrad ............ [NO] ....... [OKAY]
fused_adam ............. [NO] ....... [OKAY]
fused_lamb ............. [NO] ....... [OKAY]
sparse_attn ............ [NO] ....... [OKAY]
transformer ............ [NO] ....... [OKAY]
stochastic_transformer . [NO] ....... [OKAY]
async_io ............... [NO] ....... [OKAY]
utils .................. [NO] ....... [OKAY]
quantizer .............. [NO] ....... [OKAY]
transformer_inference .. [NO] ....... [OKAY]
--------------------------------------------------
DeepSpeed general environment info:
torch install path ............... ['/usr/local/lib/python3.7/dist-packages/torch']
torch version .................... 1.10.0+cu111
torch cuda version ............... 11.1
torch hip version ................ None
nvcc version ..................... 11.1
deepspeed install path ........... ['/usr/local/lib/python3.7/dist-packages/deepspeed']
deepspeed info ................... 0.6.0, unknown, unknown
deepspeed wheel compiled w. ...... torch 1.10, cuda 11.1, hip 0.0
my deepspeed configuration is like this.
"ds_config":{
"stage2": {
"train_micro_batch_size_per_gpu": 128,
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": 5e-05,
"betas": [
0.9,
0.999
],
"eps": 1e-8
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 5e-5,
"warmup_num_steps": 0
}
},
"zero_optimization": {
"stage": 2,
"allgather_partitions": true,
"allgather_bucket_size": 5e8,
"overlap_comm": true,
"reduce_scatter": true,
"reduce_bucket_size": 5e8,
"contiguous_gradients": true,
"cpu_offload": true,
"offload_optimizer": {
"device": "cpu",
"pin_memory": true,
"fast_init": true
}
},
"gradient_accumulation_steps": 1,
"gradient_clipping": 1.0
}
}
My train code is almost same with code of the link in comment and added just few lines to use deepspeed as below.
# https://github.com/monologg/KoELECTRA/blob/master/finetune/run_seq_cls.py
...
import deepspeed
...
def train():
...
...
model, optimizer, _, _ = deepspeed.initialize(model=model,
config_params=args['ds_config']['stage2'],
model_parameters=model.parameters())
...
...
for epoch in mb:
epoch_iterator = progress_bar(train_dataloader, parent=mb)
for step, batch in enumerate(epoch_iterator):
model.train()
batch = tuple(t.to(args.device) for t in batch)
inputs = {
"input_ids": batch[0],
"attention_mask": batch[1],
"labels": batch[3]
}
outputs = model(**inputs)
loss = outputs.loss
model.backward(loss)
tr_loss += loss.item()
if (step + 1) % args.gradient_accumulation_steps == 0 or (
len(train_dataloader) <= args.gradient_accumulation_steps
and (step + 1) == len(train_dataloader)
):
#torch.nn.utils.clip_grad_norm_(model.parameters(), args.max_grad_norm)
#optimizer.step()
model.step()
...
def main():
....
deepspeed.init_distributed("nccl")
....
This is my output log when I run the training.
[2022-03-09 04:22:56,048] [WARNING] [runner.py:155:fetch_hostfile] Unable to find hostfile, will proceed with training with local resources only.
[2022-03-09 04:22:56,055] [INFO] [runner.py:438:main] cmd = /usr/bin/python3 -u -m deepspeed.launcher.launch --world_info=eyJsb2NhbGhvc3QiOiBbMF19 --master_addr=127.0.0.1 --master_port=29500 run_seq_cls2.py --dataset pm --mode all --config_dir ./electra/config
[2022-03-09 04:22:57,946] [INFO] [launch.py:96:main] 0 NCCL_VERSION=2.7.8
[2022-03-09 04:22:57,946] [INFO] [launch.py:103:main] WORLD INFO DICT: {'localhost': [0]}
[2022-03-09 04:22:57,946] [INFO] [launch.py:110:main] nnodes=1, num_local_procs=1, node_rank=0
[2022-03-09 04:22:57,946] [INFO] [launch.py:122:main] global_rank_mapping=defaultdict(<class 'list'>, {'localhost': [0]})
[2022-03-09 04:22:57,946] [INFO] [launch.py:123:main] dist_world_size=1
[2022-03-09 04:22:57,946] [INFO] [launch.py:125:main] Setting CUDA_VISIBLE_DEVICES=0
[2022-03-09 04:23:03,174] [INFO] [distributed.py:47:init_distributed] Initializing torch distributed with backend: nccl
03/09/2022 04:23:03 - INFO - torch.distributed.distributed_c10d - Added key: store_based_barrier_key:1 to store for rank: 0
03/09/2022 04:23:03 - INFO - torch.distributed.distributed_c10d - Rank 0: Completed store-based barrier for key:store_based_barrier_key:1 with 1 nodes.
03/09/2022 04:23:03 - INFO - __main__ - Training/evaluation parameters AttrDict({'run_n_fold': 1, 'task': 'spend', 'data_dir': './electra/data', 'ckpt_dir': './electra/ckpt', 'evaluate_test_during_training': False, 'eval_all_checkpoints': False, 'save_optimizer': True, 'do_lower_case': False, 'do_train': True, 'do_eval': True, 'max_seq_len': 128, 'num_train_epochs': 100, 'weight_decay': 0.0, 'gradient_accumulation_steps': 1, 'adam_epsilon': 1e-08, 'warmup_proportion': 0, 'max_steps': -1, 'max_grad_norm': 1.0, 'no_cuda': False, 'model_type': 'koelectra-base-v3', 'model_name_or_path': 'monologg/koelectra-base-v3-discriminator', 'output_dir': 'koelectra-base-v3-spend-ckpt', 'seed': 42, 'train_batch_size': 128, 'eval_batch_size': 128, 'logging_steps': 3000, 'save_steps': 3000, 'logging_epochs': 1, 'save_epochs': 1, 'learning_rate': 5e-05, 'deepspeed': True, 'ds_config': {'stage2': {'train_micro_batch_size_per_gpu': 128, 'fp16': {'enabled': True, 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'optimizer': {'type': 'AdamW', 'params': {'lr': 5e-05, 'betas': [0.9, 0.999], 'eps': 1e-08}}, 'scheduler': {'type': 'WarmupLR', 'params': {'warmup_min_lr': 0, 'warmup_max_lr': 5e-05, 'warmup_num_steps': 0}}, 'zero_optimization': {'stage': 2, 'allgather_partitions': True, 'allgather_bucket_size': 500000000.0, 'overlap_comm': True, 'reduce_scatter': True, 'reduce_bucket_size': 500000000.0, 'contiguous_gradients': True, 'cpu_offload': True, 'offload_optimizer': {'device': 'cpu', 'pin_memory': True, 'fast_init': True}}, 'gradient_accumulation_steps': 1, 'gradient_clipping': 1.0}, 'stage3': {'fp16': {'enabled': 'auto', 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'optimizer': {'type': 'AdamW', 'params': {'lr': 'auto', 'betas': 'auto', 'eps': 'auto', 'weight_decay': 'auto'}}, 'scheduler': {'type': 'WarmupLR', 'params': {'warmup_min_lr': 'auto', 'warmup_max_lr': 'auto', 'warmup_num_steps': 'auto'}}, 'zero_optimization': {'stage': 3, 'offload_optimizer': {'device': 'cpu', 'pin_memory': True}, 'offload_param': {'device': 'cpu', 'pin_memory': True}, 'overlap_comm': True, 'contiguous_gradients': True, 'sub_group_size': 100000000000000.0, 'reduce_bucket_size': 'auto', 'stage3_prefetch_bucket_size': 'auto', 'stage3_param_persistence_threshold': 'auto', 'stage3_max_live_parameters': 1000000000.0, 'stage3_max_reuse_distance': 1000000000.0, 'stage3_gather_fp16_weights_on_model_save': True}, 'gradient_accumulation_steps': 'auto', 'gradient_clipping': 'auto', 'steps_per_print': 2000, 'train_batch_size': 'auto', 'train_micro_batch_size_per_gpu': 'auto', 'wall_clock_breakdown': False}}})
03/09/2022 04:23:12 - INFO - processor.seq_cls - Loading features from cached file ./electra/data/cached_spend_koelectra-base-v3-discriminator_128
[2022-03-09 04:23:55,158] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed info: version=0.6.0, git-hash=unknown, git-branch=unknown
03/09/2022 04:23:55 - INFO - torch.distributed.distributed_c10d - Added key: store_based_barrier_key:2 to store for rank: 0
03/09/2022 04:23:55 - INFO - torch.distributed.distributed_c10d - Rank 0: Completed store-based barrier for key:store_based_barrier_key:2 with 1 nodes.
[2022-03-09 04:23:55,225] [INFO] [engine.py:278:__init__] DeepSpeed Flops Profiler Enabled: False
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /root/.cache/torch_extensions/py37_cu111/cpu_adam/build.ninja...
Building extension module cpu_adam...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module cpu_adam...
Time to load cpu_adam op: 3.290276527404785 seconds
Adam Optimizer #0 is created with AVX2 arithmetic capability.
Config: alpha=0.000050, betas=(0.900000, 0.999000), weight_decay=0.000000, adam_w=1
[2022-03-09 04:24:00,352] [INFO] [engine.py:1066:_configure_optimizer] Using DeepSpeed Optimizer param name adamw as basic optimizer
[2022-03-09 04:24:00,363] [INFO] [engine.py:1073:_configure_optimizer] DeepSpeed Basic Optimizer = DeepSpeedCPUAdam
[2022-03-09 04:24:00,363] [INFO] [utils.py:49:is_zero_supported_optimizer] Checking ZeRO support for optimizer=DeepSpeedCPUAdam type=<class 'deepspeed.ops.adam.cpu_adam.DeepSpeedCPUAdam'>
[2022-03-09 04:24:00,363] [INFO] [logging.py:69:log_dist] [Rank 0] Creating fp16 ZeRO stage 2 optimizer
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:125:__init__] Reduce bucket size 500000000.0
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:126:__init__] Allgather bucket size 500000000.0
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:127:__init__] CPU Offload: True
[2022-03-09 04:24:00,364] [INFO] [stage_1_and_2.py:128:__init__] Round robin gradient partitioning: False
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
Emitting ninja build file /root/.cache/torch_extensions/py37_cu111/utils/build.ninja...
Building extension module utils...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module utils...
Time to load utils op: 0.5493736267089844 seconds
Rank: 0 partition count [1] and sizes[(113066686, False)]
[2022-03-09 04:24:01,501] [INFO] [utils.py:824:see_memory_usage] Before initializing optimizer states
[2022-03-09 04:24:01,502] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.47 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:01,502] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 7.89 GB, percent = 15.5%
[2022-03-09 04:24:02,174] [INFO] [utils.py:824:see_memory_usage] After initializing optimizer states
[2022-03-09 04:24:02,176] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.26 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:02,177] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 9.17 GB, percent = 18.0%
[2022-03-09 04:24:02,177] [INFO] [stage_1_and_2.py:497:__init__] optimizer state initialized
[2022-03-09 04:24:02,350] [INFO] [utils.py:824:see_memory_usage] After initializing ZeRO optimizer
[2022-03-09 04:24:02,351] [INFO] [utils.py:829:see_memory_usage] MA 0.26 GB Max_MA 0.26 GB CA 0.74 GB Max_CA 1 GB
[2022-03-09 04:24:02,351] [INFO] [utils.py:834:see_memory_usage] CPU Virtual Memory: used = 9.17 GB, percent = 18.0%
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed Final Optimizer = adamw
[2022-03-09 04:24:02,352] [INFO] [engine.py:777:_configure_lr_scheduler] DeepSpeed using configured LR scheduler = WarmupLR
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] DeepSpeed LR Scheduler = <deepspeed.runtime.lr_schedules.WarmupLR object at 0x7f507ff31f50>
[2022-03-09 04:24:02,352] [INFO] [logging.py:69:log_dist] [Rank 0] step=0, skipped=0, lr=[5e-05], mom=[[0.9, 0.999]]
[2022-03-09 04:24:02,353] [INFO] [config.py:1058:print] DeepSpeedEngine configuration:
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] activation_checkpointing_config {
"partition_activations": false,
"contiguous_memory_optimization": false,
"cpu_checkpointing": false,
"number_checkpoints": null,
"synchronize_checkpoint_boundary": false,
"profile": false
}
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] aio_config ................... {'block_size': 1048576, 'queue_depth': 8, 'thread_count': 1, 'single_submit': False, 'overlap_events': True}
[2022-03-09 04:24:02,353] [INFO] [config.py:1062:print] amp_enabled .................. False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] amp_params ................... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] autotuning_config ............ {
"enabled": false,
"start_step": null,
"end_step": null,
"metric_path": null,
"arg_mappings": null,
"metric": "throughput",
"model_info": null,
"results_dir": null,
"exps_dir": null,
"overwrite": true,
"fast": true,
"start_profile_step": 3,
"end_profile_step": 5,
"tuner_type": "gridsearch",
"tuner_early_stopping": 5,
"tuner_num_trials": 50,
"model_info_path": null,
"mp_size": 1,
"max_train_batch_size": null,
"min_train_batch_size": 1,
"max_train_micro_batch_size_per_gpu": 1.024000e+03,
"min_train_micro_batch_size_per_gpu": 1,
"num_tuning_micro_batch_sizes": 3
}
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] bfloat16_enabled ............. False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] checkpoint_tag_validation_enabled True
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] checkpoint_tag_validation_fail False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] communication_data_type ...... None
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] curriculum_enabled ........... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] curriculum_params ............ False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] dataloader_drop_last ......... False
[2022-03-09 04:24:02,354] [INFO] [config.py:1062:print] disable_allgather ............ False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] dump_state ................... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] dynamic_loss_scale_args ...... {'init_scale': 65536, 'scale_window': 1000, 'delayed_shift': 2, 'min_scale': 1}
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_enabled ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_gas_boundary_resolution 1
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_layer_name ........ bert.encoder.layer
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_layer_num ......... 0
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_max_iter .......... 100
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_stability ......... 1e-06
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_tol ............... 0.01
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] eigenvalue_verbose ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] elasticity_enabled ........... False
[2022-03-09 04:24:02,355] [INFO] [config.py:1062:print] flops_profiler_config ........ {
"enabled": false,
"profile_step": 1,
"module_depth": -1,
"top_modules": 1,
"detailed": true,
"output_file": null
}
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_enabled ................. True
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_master_weights_and_gradients False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] fp16_mixed_quantize .......... False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] global_rank .................. 0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_accumulation_steps .. 1
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_clipping ............ 1.0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] gradient_predivide_factor .... 1.0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] initial_dynamic_scale ........ 65536
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] loss_scale ................... 0
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] memory_breakdown ............. False
[2022-03-09 04:24:02,356] [INFO] [config.py:1062:print] optimizer_legacy_fusion ...... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] optimizer_name ............... adamw
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] optimizer_params ............. {'lr': 5e-05, 'betas': [0.9, 0.999], 'eps': 1e-08}
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pipeline ..................... {'stages': 'auto', 'partition': 'best', 'seed_layers': False, 'activation_checkpoint_interval': 0}
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pld_enabled .................. False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] pld_params ................... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] prescale_gradients ........... False
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_change_rate ......... 0.001
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_groups .............. 1
[2022-03-09 04:24:02,357] [INFO] [config.py:1062:print] quantize_offset .............. 1000
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_period .............. 1000
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_rounding ............ 0
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_start_bits .......... 16
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_target_bits ......... 8
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_training_enabled .... False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_type ................ 0
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] quantize_verbose ............. False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] scheduler_name ............... WarmupLR
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] scheduler_params ............. {'warmup_min_lr': 0, 'warmup_max_lr': 5e-05, 'warmup_num_steps': 0}
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] sparse_attention ............. None
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] sparse_gradients_enabled ..... False
[2022-03-09 04:24:02,358] [INFO] [config.py:1062:print] steps_per_print .............. 10
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_enabled .......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_job_name ......... DeepSpeedJobName
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] tensorboard_output_path ......
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] train_batch_size ............. 128
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] train_micro_batch_size_per_gpu 128
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] use_quantizer_kernel ......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] wall_clock_breakdown ......... False
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] world_size ................... 1
[2022-03-09 04:24:02,359] [INFO] [config.py:1062:print] zero_allow_untested_optimizer False
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_config .................. {
"stage": 2,
"contiguous_gradients": true,
"reduce_scatter": true,
"reduce_bucket_size": 5.000000e+08,
"allgather_partitions": true,
"allgather_bucket_size": 5.000000e+08,
"overlap_comm": true,
"load_from_fp32_weights": true,
"elastic_checkpoint": false,
"offload_param": null,
"offload_optimizer": {
"device": null,
"nvme_path": null,
"buffer_count": 4,
"pin_memory": false,
"pipeline_read": false,
"pipeline_write": false,
"fast_init": false
},
"sub_group_size": 1.000000e+09,
"prefetch_bucket_size": 5.000000e+07,
"param_persistence_threshold": 1.000000e+05,
"max_live_parameters": 1.000000e+09,
"max_reuse_distance": 1.000000e+09,
"gather_16bit_weights_on_model_save": false,
"ignore_unused_parameters": true,
"round_robin_gradients": false,
"legacy_stage1": false
}
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_enabled ................. True
[2022-03-09 04:24:02,360] [INFO] [config.py:1062:print] zero_optimization_stage ...... 2
[2022-03-09 04:24:02,360] [INFO] [config.py:1070:print] json = {
"train_micro_batch_size_per_gpu": 128,
"fp16": {
"enabled": true,
"loss_scale": 0,
"loss_scale_window": 1000,
"initial_scale_power": 16,
"hysteresis": 2,
"min_loss_scale": 1
},
"optimizer": {
"type": "AdamW",
"params": {
"lr": 5e-05,
"betas": [0.9, 0.999],
"eps": 1e-08
}
},
"scheduler": {
"type": "WarmupLR",
"params": {
"warmup_min_lr": 0,
"warmup_max_lr": 5e-05,
"warmup_num_steps": 0
}
},
"zero_optimization": {
"stage": 2,
"allgather_partitions": true,
"allgather_bucket_size": 5.000000e+08,
"overlap_comm": true,
"reduce_scatter": true,
"reduce_bucket_size": 5.000000e+08,
"contiguous_gradients": true,
"cpu_offload": true,
"offload_optimizer": {
"device": "cpu",
"pin_memory": true,
"fast_init": true
}
},
"gradient_accumulation_steps": 1,
"gradient_clipping": 1.0
}
Using /root/.cache/torch_extensions/py37_cu111 as PyTorch extensions root...
No modifications detected for re-loaded extension module utils, skipping build step...
Loading extension module utils...
Time to load utils op: 0.0008223056793212891 seconds
03/09/2022 04:24:02 - INFO - __main__ - ***** Running training *****
03/09/2022 04:24:02 - INFO - __main__ - Num examples = 234528
03/09/2022 04:24:02 - INFO - __main__ - Num Epochs = 100
03/09/2022 04:24:02 - INFO - __main__ - Total train batch size = 128
03/09/2022 04:24:02 - INFO - __main__ - Gradient Accumulation steps = 1
03/09/2022 04:24:02 - INFO - __main__ - Total optimization steps = 146600
03/09/2022 04:24:02 - INFO - __main__ - Logging steps = 3000
03/09/2022 04:24:02 - INFO - __main__ - Save steps = 3000
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
[2022-03-09 04:24:04,721] [INFO] [stage_1_and_2.py:1656:step] [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 65536, reducing to 65536
<IPython.core.display.HTML object>
[2022-03-09 04:24:06,139] [INFO] [stage_1_and_2.py:1656:step] [deepscale] OVERFLOW! Rank 0 Skipping step. Attempted loss scale: 65536, reducing to 32768.0
I know Huggingface and Pytorch Trainer API supports deepspeed integration but, I want to work on the current code with fixing problem. Appreciate your help in advance:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论