Skip to content

Improve torch.compile log message in compile_model #2777

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

Merged
merged 5 commits into from
Jun 1, 2025

Conversation

Vasist10
Copy link
Contributor

@Vasist10 Vasist10 commented Jun 1, 2025

Context

What is the purpose of this PR? Is it to

  • add a new feature
  • fix a bug
  • update tests and/or documentation
  • other (please add here)

Please link to any issues this PR addresses.
Closes #2717

Changelog

What are the changes made in this PR?
-Updated the log message in torchtune/utils/compile_model.py to read:
"Compiling model layers with torch.compile. Expect a relatively slower first step."

-Removed similar/sprinkled references elsewhere in the codebase to centralize this message.

Test plan

Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.

  • run pre-commit hooks and linters (make sure you've first installed via pre-commit install)
  • add unit tests for any new functionality
  • update docstrings for any new or updated methods or classes
  • run unit tests via pytest tests
  • run recipe tests via pytest tests -m integration_test
  • manually run any new or modified recipes with sufficient proof of correctness
  • include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)

UX

If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Here is a docstring example
and a tutorial example

  • I did not change any public API
  • I have added an example to docs or docstrings

Copy link

pytorch-bot bot commented Jun 1, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/torchtune/2777

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 1c2a0da with merge base 5ecae86 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link

Hi @Vasist10!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 1, 2025
@SalmanMohammadi
Copy link
Collaborator

SalmanMohammadi commented Jun 1, 2025

Hi @Vasist10. Thank you for this contribution. I think this looks good, however, the test may be overkill here. If you could please remove the test I'm happy to merge this.

We can also remove the extra log here, and in a similar place across a few of our other recipes. It seems like you mentioned this in your PR but didn't include the changes - could you take a pass at removing the additional logs in the recipes?

@Vasist10
Copy link
Contributor Author

Vasist10 commented Jun 1, 2025

Hi @SalmanMohammadi ,
I've made the following changes :

  • Removed the torch.compile log messages across files :
  • Removed the test from test_utils.py
  • Fixed the tuple return type in _loss_step to avoid the Pylance warning

Thank you

@codecov-commenter
Copy link

codecov-commenter commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 60.08%. Comparing base (86f148b) to head (d352596).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
torchtune/training/_compile.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2777      +/-   ##
==========================================
- Coverage   62.93%   60.08%   -2.85%     
==========================================
  Files         437      435       -2     
  Lines       26710    26742      +32     
==========================================
- Hits        16809    16067     -742     
- Misses       9901    10675     +774     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -8,7 +8,7 @@
import time

from functools import partial
from typing import Any, Optional, Union
from typing import Any, Optional, Union, Tuple
Copy link
Collaborator

Choose a reason for hiding this comment

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

You may need to update your pre-commit hooks as we have moved to PEP 585.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should i change it the previous version which was like this :
def _loss_step( self, batch: dict[str, torch.Tensor] ) -> (torch.Tensor, torch.Tensor):

or should i change it to this ? : def _loss_step( self, batch: dict[str, torch.Tensor] ) -> tuple[torch.Tensor, torch.Tensor]:

i just want to clarify it

@Vasist10
Copy link
Contributor Author

Vasist10 commented Jun 1, 2025

Hey @SalmanMohammadi ,

Apologies for the failing check in _loss_step — that was my mistake.

Would you prefer I revert this change and switch it back to the older version? Let me know, and I’ll update it right away. Thanks again for your guidance!

Copy link
Collaborator

@SalmanMohammadi SalmanMohammadi left a comment

Choose a reason for hiding this comment

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

@Vasist10 No worries at all! This looks good to me pending green CI.

@SalmanMohammadi
Copy link
Collaborator

@Vasist10 Could you run the pre-commit hooks locally and ensure they pass?

@SalmanMohammadi SalmanMohammadi changed the title Improve torch.compile log message in compile_model and add unit test Improve torch.compile log message in compile_model Jun 1, 2025
@SalmanMohammadi SalmanMohammadi merged commit 9cb77af into pytorch:main Jun 1, 2025
14 checks passed
@Vasist10 Vasist10 deleted the improve-compile-model-log branch June 1, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve compile_model logging output
4 participants