Skip to content

GroupedTensor Machinery for MXFP8 Dispatch input passed from Megatron - #3660

Open
vthumbe1503 wants to merge 2 commits into
NVIDIA:mainfrom
vthumbe1503:gt_support_for_mxfp8_nccl
Open

vthumbe1503 wants to merge 2 commits into
NVIDIA:mainfrom
vthumbe1503:gt_support_for_mxfp8_nccl

Conversation

@vthumbe1503

Copy link
Copy Markdown
Collaborator

Description

Please include a brief summary of the changes, relevant motivation and context.

Fixes # (issue)

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Signed-off-by: vthumbe1503 <vthumbe@nvidia.com>
@vthumbe1503
vthumbe1503 marked this pull request as ready for review October 9, 2026 20:44
@vthumbe1503
vthumbe1503 requested a review from ksivaman as a code owner October 9, 2026 20:44
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Adds grouped tensor storage lifecycle management for autograd.

The PR appears safe to merge, with non-blocking improvements needed for alias cleanup and backward tests.

Findings

  1. P2 Dead aliases keep accumulating ▶
  2. P2 Backward behavior is not tested ▶

Summary

Adds support for grouped tensors passed through identity autograd functions and scheduler memory release.

  • Identity functions can return same-shape GroupedTensor views.
  • One GroupedTensor storage now clears its shared payload buffers together.
  • GroupedTensor stream tracking now reaches each backing buffer.

Reviews (1) · Last reviewed commit: "Merge branch 'main' into gt_support_for_..." · Reviewed by Greptile

Comment on lines +79 to +81
def register_alias(self, tensor: "GroupedTensor") -> None:
"""Register a wrapper that shares this storage's payload allocations."""
self._aliases.append(weakref.ref(tensor))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Dead aliases keep accumulating

register_alias adds a weak reference for every new wrapper, but dead references are removed only during resize_(0). Repeated detach() calls on a long-lived grouped parameter keep growing this list after the detached wrappers are gone. This wastes host memory and makes later resizing walk a larger list. Remove dead entries when aliases expire or when registering new aliases.

Comment on lines +331 to +339
result = Identity.apply(grouped_tensor)

assert isinstance(result, GroupedTensor)
assert result is not grouped_tensor
assert result._base is grouped_tensor
assert result.grad_fn is not None
assert result.rowwise_data is grouped_tensor.rowwise_data
assert result.first_dims is grouped_tensor.first_dims
assert result.tensor_offsets is grouped_tensor.tensor_offsets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Backward behavior is not tested

test_autograd_identity_supports_varying_shapes checks that grad_fn exists but never runs backward. This PR also changes how alias wrappers set requires_grad, so the test would miss a failure when gradients pass through the new view. Run backward with an explicit gradient and check that the input receives the expected gradient.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

This branch has not been deployed

No deployments
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.

1 participant