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 CLI time measurement #147

Merged
merged 1 commit into from
Sep 13, 2024
Merged

Conversation

neilmovva
Copy link
Contributor

Torch CUDA operations are async by default.

The original code stops the clock as soon as torch finishes issuing GPU operations, but the results wouldn't actually be ready at that point, so it's an underestimate. We need an explicit sync to correctly time end-to-end execution of the model.

Testing on flux-dev, 1024x768 resolution, 28-steps, on H100 SXM.
Before: 5520ms
After: 6040ms

Exact delta depends on how much the CPU is running ahead of the GPU, which varies significantly across systems. This also means that timings should be more stable after this change.

credit to @donglinz for finding this bug!

Copy link
Contributor

@jenuk jenuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thank you!

@jenuk jenuk merged commit 87f6fff into black-forest-labs:main Sep 13, 2024
andompesta pushed a commit to andompesta/flux that referenced this pull request Nov 14, 2024
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.

2 participants