You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduced a bug during the last few commits where in, implementation of copy_ method in torch dispatch accessed mxfp8 attributes without checking if the both source and estination tensors are indeed mxfp8.
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)
Fixed an AttributeError introduced in the FSDP2 support implementation by reordering conditional checks in the copy_ operation handler within MXFP8Tensor.__torch_dispatch__.
Key Changes:
Moved rowwise_matches and columnwise_matches evaluations inside the type check block
Previously, attribute access on _rowwise_data and _columnwise_data occurred before verifying both src and dst were MXFP8Tensor instances
This caused AttributeError when the copy_ operation was invoked with non-MXFP8Tensor objects
The fix ensures attributes are only accessed after type validation, preventing runtime errors
The change maintains the same logical flow but correctly guards attribute access with type checks, allowing the code to fall back to base class behavior when tensors don't match expected types.
Confidence Score: 5/5
This PR is safe to merge with no risk
The fix addresses a clear bug (AttributeError) by properly ordering type checks before attribute access. The logic is identical to the original implementation, just with corrected guard placement. Pre-commit hooks have validated formatting.
No files require special attention
Important Files Changed
File Analysis
Filename
Score
Overview
transformer_engine/pytorch/tensor/mxfp8_tensor.py
5/5
Fixed AttributeError in copy_ operation by moving attribute access checks inside type validation block
Sequence Diagram
sequenceDiagram
participant Caller
participant MXFP8Tensor
participant torch_dispatch
Caller->>torch_dispatch: copy_(dst, src)
torch_dispatch->>MXFP8Tensor: __torch_dispatch__(copy_.default, ...)
alt Both src and dst are MXFP8Tensor
MXFP8Tensor->>MXFP8Tensor: Check isinstance(src, MXFP8Tensor)
MXFP8Tensor->>MXFP8Tensor: Check isinstance(dst, MXFP8Tensor)
Note over MXFP8Tensor: Type checks pass, safe to access attributes
MXFP8Tensor->>MXFP8Tensor: Check rowwise_matches
MXFP8Tensor->>MXFP8Tensor: Check columnwise_matches
alt Layout matches
MXFP8Tensor->>MXFP8Tensor: Copy rowwise data if present
MXFP8Tensor->>MXFP8Tensor: Copy columnwise data if present
MXFP8Tensor-->>Caller: Return dst
else Layout mismatch
MXFP8Tensor->>torch_dispatch: super().__torch_dispatch__()
torch_dispatch-->>Caller: Default behavior
end
else Type check fails
MXFP8Tensor->>torch_dispatch: super().__torch_dispatch__()
torch_dispatch-->>Caller: Default behavior
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduced a bug during the last few commits where in, implementation of copy_ method in torch dispatch accessed mxfp8 attributes without checking if the both source and estination tensors are indeed mxfp8.
Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: