NVIDIA / Megatron-LM

Ongoing research training transformer models at scale
https://docs.nvidia.com/megatron-core/developer-guide/latest/user-guide/index.html#quick-start
Other
9.23k stars 2.08k forks source link

[QUESTION] How to time the code #871

Open Weifan1226 opened 1 week ago

Weifan1226 commented 1 week ago

Hi Megatron team!

I wanted to time some of Megatron's code blocks, but didn't find a good way to do it. But I was surprised to find code like this:

          if config.timers is not None:
                  config.timers('layernorm-grads-all-reduce', log_level=1).start(
                      barrier=config.barrier_with_L1_time
                  )
              _allreduce_layernorm_grads(model, config)
              if config.timers is not None:
                  config.timers('layernorm-grads-all-reduce').stop()

Can I us config.timers() to time the code? If yes, how can i see the output from config.timers.

Thanks!