Skip to content

Draft: Feat: Enable torch compile#496

Closed
jiemingz wants to merge 1 commit intomainfrom
jiemingz/torch_compile
Closed

Draft: Feat: Enable torch compile#496
jiemingz wants to merge 1 commit intomainfrom
jiemingz/torch_compile

Conversation

@jiemingz
Copy link
Contributor

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

Signed-off-by: Jimmy Zhang <jiemingz@nvidia.com>
@jiemingz jiemingz requested a review from terrykong June 10, 2025 14:01
@jiemingz jiemingz self-assigned this Jun 10, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add this key to all the configs/recipes?

Copy link
Collaborator

@terrykong terrykong left a comment

Choose a reason for hiding this comment

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

Is this possible to unit test?

@terrykong
Copy link
Collaborator

@jiemingz is the only thing blocking this PR the seq-packing change since we need static shapes for torch.compile?

@terrykong
Copy link
Collaborator

Dependent on #300

@SahilJain314
Copy link
Contributor

Dtensor sequence packing has been merged. @ahmadki to support max-padding packed sequences in DTensor to enable torch.compile (fixed seqlen).

@ahmadki
Copy link
Member

ahmadki commented Jul 24, 2025

Dtensor sequence packing has been merged. @ahmadki to support max-padding packed sequences in DTensor to enable torch.compile (fixed seqlen).

tracking here

)

if self.torch_compile:
self.model = torch.compile(model)

Choose a reason for hiding this comment

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

Could you try model.compile() instead? That should fix the _orig_mod issue. This is also the recommended way of compiling a model now. We'll work on throwing warnings and publicizing to raise awareness on this.

@terrykong terrykong linked an issue Aug 7, 2025 that may be closed by this pull request
@euronymous-aithal
Copy link
Contributor

@yuki-97 can you please review this and take this forward.
(QQ: @ffrujeri and @joyang-nv not sure if Automodel path already enables torch.compile if so we should close this )

@joyang-nv
Copy link
Member

@euronymous-aithal Hi Ashwath, automodel indeed has torch.compile support already. But we have never enabled within nemo RL. I think it is proper to make it fixed with FP8 dtensor is ready @RayenTian is working on it, since FP8 dtensor train requires to enable torch.compile. We still have encounter torch.compile bug when TP>1. Still investigation.

@terrykong
Copy link
Collaborator

Closing since this is w.r.t. v1 and we are currently centralizing efforts around v2 . closing this and reassigned #4 to @joyang-nv for now

@terrykong terrykong closed this Oct 1, 2025
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.

torch.compile for training

7 participants