Skip to content
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] Add heuristics for intializing FP8 params #1300

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

timmoon10
Copy link
Collaborator

@timmoon10 timmoon10 commented Oct 30, 2024

Description

#1127 changed the default behavior of Float8Tensor so that the FP8 transpose is no longer memoized, but rather treated as part of the data layout. This helps us avoid headaches where the cache is invalidated (since the FP8 data and transpose are updated together in Float8Tensor.quantize_) and reduces the FP8-specific logic in the TE modules (e.g. whether to update the transpose in the first microbatch). However, it also means that Float8Tensor needs to know whether to store the FP8 transpose at construction time.

This PR adds a heuristic kwarg to the fp8_model_init context. Right now the only supported value is "memory", which will cause TE modules to initialize FP8 params without FP8 transposes. In the future, I can imagine extending this logic to fp8_autocast so it can handle FP8 data tensors. We could also support other heuristics (e.g. "performance", "communication", etc) and add logic for other quantization schemes. However, I've purposely kept this PR small to avoid interfering with other changes in the quantization infrastructure (see #1251).

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 refractor

Changes

  • Add heuristic option to fp8_model_init context

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

@timmoon10 timmoon10 added the enhancement New feature or request label Oct 30, 2024
@timmoon10
Copy link
Collaborator Author

/te-ci pytorch

@timmoon10 timmoon10 marked this pull request as ready for review October 31, 2024 21:55
@timmoon10
Copy link
Collaborator Author

/te-ci pytorch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant