Skip to content

Draft: Feat: Enable torch compile - #496

Closed
jiemingz wants to merge 1 commit into
mainfrom
jiemingz/torch_compile
Closed

jiemingz wants to merge 1 commit into
mainfrom
jiemingz/torch_compile

Conversation

@jiemingz

Copy link
Copy Markdown
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 <[email protected]>
@jiemingz
jiemingz requested a review from terrykong June 10, 2025 14:01
@jiemingz jiemingz self-assigned this Jun 10, 2025
Comment thread examples/configs/dpo.yaml

Copy link
Copy Markdown
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?

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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

@terrykong

Copy link
Copy Markdown
Collaborator

Dependent on #300

@SahilJain314

Copy link
Copy Markdown
Contributor

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

@ahmadki

ahmadki commented Jul 24, 2025

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Jul 25, 2026
Expose TP/ETP shard ranges and global expert identities so NVIDIA-NeMo#496 receivers fetch the correct rank-local Qwen3-MoE slices instead of treating every expert as a full tensor.

Signed-off-by: Kavin Krishnan <[email protected]>
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Jul 25, 2026
Use the served model identity for rendezvous, expose the merged NVIDIA-NeMo#496 receiver route, and avoid serial rollout waves when tree fan-out is disabled.

Signed-off-by: Kavin Krishnan <[email protected]>
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Jul 25, 2026
Capture the validated 16-to-16 layouts and generate GKE RDMA or AWS EFA manifests with explicit transport, device, placement, and NVIDIA-NeMo#496 descriptor-policy settings.

Signed-off-by: Kavin Krishnan <[email protected]>
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Aug 12, 2026
Docstrings, a CLI help string, and a config comment referred to the reshard
path as "NVIDIA-NeMo#496". A PR number tells a reader nothing at the point they are
reading the code, and stops resolving once the PR is merged, so these now say
what the thing is.

Comment text only. The MX_MEGATRON_RESHARD496 environment variable, the
--mx-reshard496 flag, and the [mx-reshard496] log prefix are deliberately
unchanged: retained benchmark evidence records them verbatim, and one analysis
script parses the log prefix directly.

Signed-off-by: Kavin Krishnan <[email protected]>
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Aug 18, 2026
The PR description promises portable recipes with no private cluster detail,
but three headers still carried a colleague's name, an internal design-doc
filename, internal cluster state, and a stale claim that fused grouped-expert
install is unimplemented. That claim is no longer true once ModelExpress NVIDIA-NeMo#635
lands its fused MoE capture fix, so a reader would have been told the dense
recipe works around a gap that no longer exists.

Keep the technical rationale each header carried -- geometry, why a dense arm
isolates non-expert resharding, why the KL sample recipe raises max_new_tokens
-- and drop the parts that only mean something inside the originating cluster.

Also replace the "NVIDIA-NeMo#496" ModelExpress PR reference in
canonicalize_grouped_expert_name with a description of the behaviour it
depends on, since that number resolves to nothing for a NeMo-RL reader.

Signed-off-by: Kavin Krishnan <[email protected]>
KavinKrishnan added a commit to KavinKrishnan/RL that referenced this pull request Aug 19, 2026
The PR description promises portable recipes with no private cluster detail,
but three headers still carried a colleague's name, an internal design-doc
filename, internal cluster state, and a stale claim that fused grouped-expert
install is unimplemented. That claim is no longer true once ModelExpress NVIDIA-NeMo#635
lands its fused MoE capture fix, so a reader would have been told the dense
recipe works around a gap that no longer exists.

Keep the technical rationale each header carried -- geometry, why a dense arm
isolates non-expert resharding, why the KL sample recipe raises max_new_tokens
-- and drop the parts that only mean something inside the originating cluster.

Also replace the "NVIDIA-NeMo#496" ModelExpress PR reference in
canonicalize_grouped_expert_name with a description of the behaviour it
depends on, since that number resolves to nothing for a NeMo-RL reader.

Signed-off-by: Kavin Krishnan <[email protected]>
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