Skip to content

Support paged stashing for GroupedLinear activations - #3423

Open
lhb8125 wants to merge 2 commits into
NVIDIA:mainfrom
lhb8125:denliu/paged-stash-grouped-tensor
Open

Support paged stashing for GroupedLinear activations#3423
lhb8125 wants to merge 2 commits into
NVIDIA:mainfrom
lhb8125:denliu/paged-stash-grouped-tensor

Conversation

@lhb8125

@lhb8125lhb8125 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Enable paged stashing integrations to identify the activation storage saved by the device-initiated PyTorch GroupedLinear autograd function.

  • Mark input_to_save immediately before prepare_for_saving / save_for_backward.
  • Extend mark_grouped_tensor to support unquantized BF16/FP16 rowwise storage.
  • Preserve the existing quantized columnwise data and scale-inverse markers.
  • Add unit coverage for rowwise and columnwise storage.

This is a follow-up to #3224. The paired Megatron-LM integration is NVIDIA/Megatron-LM#6828.

Validation

  • Black 24.4.2 with the repository pre-commit arguments
  • Ruff
  • Full TE license check
  • Four-rank GB300 Megatron-LM integration test using HybridEP, MXFP8, device-initiated GroupedLinear, and GPU-only paged stash: TestPagedStashingGroupedTensor::test_forward_backward_without_op_fuser
    • all four ranks passed
    • activation metadata captured
    • stash/reload completed without overflow
    • output and input-gradient parity passed

@github-actionsgithub-actionsBot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Aug 25, 2026
@lhb8125
lhb8125 marked this pull request as ready for review August 25, 2026 10:57
@lhb8125
lhb8125 requested a review from ksivaman as a code ownerAugust 25, 2026 10:57
Signed-off-by: hongbinl <hongbinl@nvidia.com>
Signed-off-by: hongbinl <hongbinl@nvidia.com>
@lhb8125
lhb8125force-pushed the denliu/paged-stash-grouped-tensor branch from fb11b5c to e4e4eedCompareAugust 25, 2026 10:57
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR integrates device-initiated GroupedLinear activations with paged stashing while preserving the existing quantized-storage markers.

  • Marks the selected activation immediately before flattening and saving the autograd state.
  • Extends mark_grouped_tensor to mark unquantized rowwise BF16/FP16 storage.
  • Continues marking quantized columnwise data and its inverse-scale metadata.
  • Adds focused tests for plain, unquantized rowwise, and quantized columnwise storage.

Confidence Score: 5/5

The PR appears safe to merge with no concrete correctness, security, or compatibility defects identified.

The marker is attached to the same physical activation and scale tensors subsequently flattened for autograd, and the new branches consistently handle plain, unquantized rowwise, quantized columnwise, and absent saved inputs.

Important Files Changed

FilenameOverview
transformer_engine/pytorch/module/grouped_linear.pyMarks the chosen backward activation immediately before its storage is flattened and passed to autograd.
transformer_engine/pytorch/utils.pyExtends marker placement to plain tensors and unquantized rowwise grouped storage while retaining quantized columnwise metadata handling.
tests/pytorch/test_grouped_tensor.pyAdds focused assertions for marker placement across plain, rowwise-only, and quantized columnwise representations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[GroupedLinear activation] --> B{Saved representation}
B -->|Plain tensor| C[Mark activation]
B -->|Unquantized grouped| D[Mark rowwise data]
B -->|Quantized grouped| E[Mark columnwise data and scale inverse]
C --> F[prepare_for_saving]
D --> F
E --> F
F --> G[PyTorch save_for_backward]
G --> H[Paged stash and reload]
Loading

Reviews (1): Last reviewed commit: "Clarify paged stash grouped tensor marke..." | Re-trigger Greptile

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contributionPRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@lhb8125