[Transformer/PyT] Removing obsolete profiling code
This commit is contained in:
parent
793027c9da
commit
233287038c
|
@ -283,8 +283,7 @@ The following (partial) output is printed when running the sample:
|
|||
```
|
||||
usage: train.py [-h] [--no-progress-bar] [--log-interval N]
|
||||
[--log-format {json,none,simple,tqdm}] [--seed N] [--fp16]
|
||||
[--profile PROFILE] [--task TASK]
|
||||
[--skip-invalid-size-inputs-valid-test] [--max-tokens N]
|
||||
[--task TASK] [--skip-invalid-size-inputs-valid-test] [--max-tokens N]
|
||||
[--max-sentences N] [--sentencepiece] [--train-subset SPLIT]
|
||||
[--valid-subset SPLIT] [--max-sentences-valid N]
|
||||
[--gen-subset SPLIT] [--num-shards N] [--shard-id ID]
|
||||
|
|
|
@ -40,7 +40,6 @@ def get_training_parser():
|
|||
add_checkpoint_args(parser)
|
||||
add_inference_args(parser)
|
||||
add_perf_args(parser)
|
||||
add_profiling_args(parser)
|
||||
return parser
|
||||
|
||||
|
||||
|
@ -304,18 +303,6 @@ def add_inference_args(parser):
|
|||
group.add_argument('--fp16', action='store_true', help='use fp16 precision')
|
||||
return group
|
||||
|
||||
|
||||
def add_profiling_args(parser):
|
||||
group = parser.add_argument_group('Profiling')
|
||||
group.add_argument('--profile', action='store_true',
|
||||
help='Run profiler')
|
||||
group.add_argument('--profiler-steps', type=int, default=10,
|
||||
help='Override to the max steps argument')
|
||||
group.add_argument('--profiler-start-iter', type=int, default=20,
|
||||
help='Start profiling on this iteration')
|
||||
return group
|
||||
|
||||
|
||||
def add_model_args(parser):
|
||||
group = parser.add_argument_group('Model configuration')
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ def setup_logger(args):
|
|||
def main(args):
|
||||
setup_logger(args)
|
||||
|
||||
args.interactive = sys.stdin.isatty() # Just make the code more understendable
|
||||
args.interactive = sys.stdin.isatty() and not args.file # Just make the code more understendable
|
||||
|
||||
if args.file:
|
||||
data_descriptor = open(args.file, 'r')
|
||||
|
|
|
@ -29,9 +29,6 @@ import ctypes
|
|||
|
||||
from copy import deepcopy
|
||||
|
||||
import pyprof
|
||||
import torch.cuda.profiler as profiler
|
||||
|
||||
import torch
|
||||
import sacrebleu
|
||||
import dllogger as DLLogger
|
||||
|
@ -44,12 +41,8 @@ from fairseq.data import data_utils, load_dataset_splits
|
|||
from fairseq.models import build_model
|
||||
from fairseq.log_helper import setup_logger, reset_perf_meters
|
||||
|
||||
|
||||
def main(args):
|
||||
|
||||
if args.profile:
|
||||
pyprof.init(enable_function_stack=True)
|
||||
|
||||
print(args)
|
||||
setup_logger(args)
|
||||
|
||||
|
@ -125,8 +118,7 @@ def main(args):
|
|||
while lr >= args.min_lr and epoch_itr.epoch < max_epoch and trainer.get_num_updates() < max_update and current_bleu < tgt_bleu:
|
||||
DLLogger.log(step=trainer.get_num_updates()+1, data={'epoch': epoch_itr.epoch}, verbosity=0)
|
||||
# train for one epoch
|
||||
with torch.autograd.profiler.emit_nvtx(enabled=args.profile):
|
||||
train(args, trainer, epoch_itr)
|
||||
train(args, trainer, epoch_itr)
|
||||
DLLogger.log(step=trainer.get_num_updates(), data={'walltime': train_meter.sum}, verbosity=1)
|
||||
DLLogger.log(step=trainer.get_num_updates(),
|
||||
data={'avg_epoch_loss': trainer.avg_loss_meter.avg}, verbosity=1)
|
||||
|
@ -179,11 +171,6 @@ def train(args, trainer, epoch_itr):
|
|||
trainer.get_throughput_meter().reset()
|
||||
|
||||
for i, sample in enumerate(itr):
|
||||
# Profiling ---------
|
||||
if trainer.get_num_updates() == args.profiler_start_iter:
|
||||
profiler.start()
|
||||
# -------------------
|
||||
|
||||
if i < num_batches - 1 and (i + 1) % update_freq > 0:
|
||||
# buffer updates according to --update-freq
|
||||
trainer.train_step(sample, update_params=False, last_step=(i == len(itr)-1))
|
||||
|
@ -191,11 +178,6 @@ def train(args, trainer, epoch_itr):
|
|||
else:
|
||||
trainer.train_step(sample, update_params=True, last_step=(i == len(itr)-1))
|
||||
|
||||
# Profiling ---------
|
||||
if trainer.get_num_updates() == args.profiler_start_iter + args.profiler_steps:
|
||||
profiler.stop()
|
||||
# -------------------
|
||||
|
||||
# ignore the first mini-batch in words-per-second calculation
|
||||
if i == 0:
|
||||
trainer.get_throughput_meter().reset()
|
||||
|
|
Loading…
Reference in a new issue