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

Removes try-except from torch_utils/profile #16750

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open

Removes try-except from torch_utils/profile #16750

wants to merge 49 commits into from

Conversation

Burhan-Q
Copy link
Contributor

@Burhan-Q Burhan-Q commented Oct 7, 2024

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improved error handling for backward operations in the profile function.

πŸ“Š Key Changes

  • Replaced try-except block with a more concise getattr approach to handle backward operation checks.

🎯 Purpose & Impact

  • Simplicity: Makes the code cleaner and more efficient by reducing error-handling overhead.
  • Performance: Ensures backward pass timings are logged correctly, improving profiling accuracy.

@Burhan-Q Burhan-Q added the enhancement New feature or request label Oct 7, 2024
@UltralyticsAssistant
Copy link
Member

πŸ‘‹ Hello @Burhan-Q, thank you for submitting an ultralytics/ultralytics πŸš€ PR! This is an automated response, and an Ultralytics engineer will also assist you soon. To ensure a seamless integration of your work, please review the following checklist:

  • βœ… Define a Purpose: Clearly explain the purpose of your change in the PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • βœ… Synchronize with Source: Confirm your PR is synchronized with the ultralytics/ultralytics main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • βœ… Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • βœ… Update Documentation: Update the relevant documentation for any new or modified features.
  • βœ… Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • βœ… Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • βœ… Minimize Changes: Limit your changes to the minimum necessary for your improvement. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." β€” Bruce Lee

For more guidance, please refer to our Contributing Guide. If your PR addresses a bug, please include a minimum reproducible example (MRE) to assist with verification.

Thank you for contributing to Ultralytics! We appreciate your efforts and look forward to reviewing your improvements. πŸš€πŸ˜Š

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 73.96%. Comparing base (e0f8eda) to head (57c1a4e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16750      +/-   ##
==========================================
- Coverage   74.01%   73.96%   -0.05%     
==========================================
  Files         128      128              
  Lines       17138    17134       -4     
==========================================
- Hits        12684    12674      -10     
- Misses       4454     4460       +6     
Flag Coverage Ξ”
Benchmarks 34.99% <0.00%> (-0.03%) ⬇️
GPU 38.46% <100.00%> (-0.01%) ⬇️
Tests 67.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@Burhan-Q Burhan-Q marked this pull request as ready for review October 8, 2024 01:09
@glenn-jocher
Copy link
Member

@Burhan-Q this might not be a bad idea! Let's try it!

@glenn-jocher
Copy link
Member

@Burhan-Q oh but wait, then with this change we'll have a super fast backwards pass time showing in the profiling, so we actually want an NaN to show here if the operation has no backwards pass.

@Burhan-Q
Copy link
Contributor Author

Burhan-Q commented Oct 16, 2024

Updated to time_sync() if backward pass is successful or float("nan") otherwise

@glenn-jocher
Copy link
Member

Thank you for the update! Using time_sync() for successful backward passes and float("nan") otherwise is a clean and efficient solution to ensure accurate profiling while maintaining clarity in the results.

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

Successfully merging this pull request may close these issues.

3 participants