Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: estimate_mfu dt ZeroDivisionError #446

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HildaM
Copy link

@HildaM HildaM commented Mar 2, 2024

Previous estimate_mfu function has ZeroDivisionError error

In model.py 301 line, flops_achieved = flops_per_iter * (1.0/dt) will occur ZeroDivisionError, which means dt will be Zero when the time interval between two consecutive calls to time.time() is so small that it is considered as 0 under floating point precision.

replicate the problem

iter 800: loss 1.4306, time 20.79ms, mfu 18.58%
iter 810: loss 1.4020, time 31.59ms, mfu 17.90%
iter 820: loss 1.4028, time 15.12ms, mfu 18.58%
iter 830: loss 1.3907, time 17.64ms, mfu 18.83%
Traceback (most recent call last):
  File "D:\Coding\AILearning\LLM\LLM_Learning\nanoGPT\train.py", line 325, in <module>
    mfu = raw_model.estimate_mfu(batch_size * gradient_accumulation_steps, dt)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Coding\AILearning\LLM\LLM_Learning\nanoGPT\model.py", line 302, in estimate_mfu
    flops_achieved = flops_per_iter * (1.0/dt) # per second
                                       ~~~^~~
ZeroDivisionError: float division by zero 

I am training on my single 4090 card, and every time I start the training code it will occur ZeroDivisionError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant