This repository was archived by the owner on Aug 7, 2024. It is now read-only.
Thread the scaling type argument throughout fp8#301
Open
drisspg wants to merge 9 commits intogh/drisspg/1/basefrom
Open
Thread the scaling type argument throughout fp8#301drisspg wants to merge 9 commits intogh/drisspg/1/basefrom
drisspg wants to merge 9 commits intogh/drisspg/1/basefrom
Conversation
drisspg
commented
Jul 3, 2024
| amax_buffer: Optional[torch.Tensor] = None, | ||
| mm_config: Optional[ScaledMMConfig] = None, | ||
| float8_dtype: torch.dtype, | ||
| amax_buffer: Optional[torch.Tensor], |
Contributor
Author
There was a problem hiding this comment.
I removed the defualt args since this is always called from inner func with defualt args
drisspg
commented
Jul 3, 2024
vkuzo
reviewed
Jul 3, 2024
float8_experimental/float8_tensor.py
Outdated
| ) | ||
|
|
||
|
|
||
| class ScalingStrategy(Enum): |
Contributor
There was a problem hiding this comment.
thoughts about using Granularity, which is more specific than Strategy?
Contributor
Author
There was a problem hiding this comment.
Yeah thats a better word, this needed some bikeshedding
vkuzo
reviewed
Jul 3, 2024
| return Float8Tensor(bits_fp8, x_scale, x.dtype, mm_config=mm_config) | ||
| return Float8Tensor( | ||
| bits_fp8, | ||
| x_scale, |
Contributor
There was a problem hiding this comment.
just curious, since we decided to not add scaling_strategy to torch._scaled_mm, why do we need it here?
Contributor
Author
There was a problem hiding this comment.
We could make this a property of Float8Tensor, e.g. infer from the existing scales... hmm
Actually I might like this more..
We need the enum still since we want modules to specify their granularity
This was referenced Jul 3, 2024
# Summary This PR adds a ScalingGranularity Enum, and threads it though the stack to all the places we call 'tensor_to_amax" and tensor_to_scale. - Currently hardcodes TensroWise.Scaling in Float8Linear, Float8DynamicLinear, Float8InferenceLinear. Asserts that granularity is TensorWise for now. - Added this as a property of WeightWithDynamicFloat8CastTensor, since we need to know a prior how do do the scaling for fp8 comms. ### Testing ``` Shell ============================================================================= test session starts ============================================================================= platform linux -- Python 3.12.4, pytest-7.4.0, pluggy-1.5.0 rootdir: /home/drisspg/meta/float8_experimental plugins: hypothesis-6.104.1 collected 9 items test/test_fsdp2/test_fsdp2_eager.py ......... [100%] ============================================================================= 9 passed in 30.77s ============================================================================== all tests successful ``` [ghstack-poisoned]
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR adds a ScalingGranularity Enum, and threads it though the stack to all the places we call 'tensor_to_amax" and tensor_to_scale.
Testing
Stack from ghstack (oldest at bottom):