-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PyTorch] Float8Tensor uses cached transpose if available #524
Conversation
Signed-off-by: Tim Moon <tmoon@nvidia.com>
/te-ci pytorch |
@@ -263,7 +263,7 @@ def test_transpose( | |||
dims: DimsType, | |||
transpose_dims: Tuple[int, int], | |||
fp8_dtype: tex.DType = tex.DType.kFloat8E4M3, | |||
scale: float = 1, | |||
scale: float = 0.5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was a correctness issue that was hidden by scale=1
, but I don't think it's actually an issue. Making this non-one does a better job stress-testing this in any case though.
Signed-off-by: Tim Moon <tmoon@nvidia.com>
/te-ci pytorch |
Test failures are ONNX-related. This is ready to go. |
@timmoon10 |
The work in this PR was merged in #529. |
This PR changes the transpose behavior of
Float8Tensor
:update_cache == True
, it will compute the transpose and update the cacheupdate_cache == False
and the cache is empty, it will compute the transposeupdate_cache == False
and the cache is populated, it will return the cached transposeThis is somewhat of a kludge to support transpose caching with Megatron GPT (see NVIDIA/NeMo#7909). Its
forward
function doesn't keep track of gradient accumulation steps, so it doesn't passis_first_microbatch
toLayerNormLinear
orLinear
. E.g.:https://github.com/NVIDIA/Megatron-LM/blob/9290c730d04b482be8fae92a4186fe4ff0c95270/megatron/core/transformer/attention.py#L271C31-L271C31
Compare to NeMo GPT, which contains TE-specific logic like
is_first_microbatch
:https://github.com/NVIDIA/NeMo/blob/d81beac52423dbd04b48e4e04567b17df2428e3a/nemo/collections/nlp/modules/common/megatron/transformer.py#L1556
Discussion would be appreciated. This design ping-ponged a few times in #452, e.g. 00b9c31. This approach is convenient with an FP8-aware optimizer since the optimizer doesn't need any access to the TE modules, just the FP8 params. There are also some alternative approaches:
is_first_microbatch
, to keep the current API