Repository navigation
Conversation
Contributor
|
Thank you for your contribution 🤗! CI Security Gate — waiting for maintainer approvalCI is approved automatically only for authors who already have a contribution merged in this repository. A maintainer will review this PR and approve CI to run on it. |
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Fixes evaluation and prediction when
preprocess_logits_for_metricsreturns FP8 tensors to reduce the size of cached logits. The hook is documented as running before prediction caching, butnested_numpifycurrently only promotes BF16. NumPy conversion of the cached FP8 tensors raisesTypeError: Got unsupported ScalarType Float8_e4m3fn.Extend that existing promotion to single-byte floating-point tensors at the NumPy boundary. FP8 tensors can remain in their compact dtype during caching; the resulting NumPy arrays use FP32. Ordinary floating-point and integer conversion paths remain unchanged.
Reproducer
This fails on main
41f9d3992023970fb5a463e70d56232506c80fbcand succeeds with this change, using the default GPT-2 configuration and the real Trainer on CPU:Regression test and validation
The single added regression in the existing Trainer evaluation test file reuses
get_regression_trainer. Its 14 subcases cover four FP8 formats plus BF16/FP32/FP64 controls, with and without per-step CPU accumulation. It checks both nested prediction outputs, labels, metrics and evaluation/prediction loss parity with a partial final batch.make stylepasses.Native validation tests exact commit
bf9a3cbe64372541b9be46b691f033301e6fc1b8with PyTorch 2.14 CPU. This validation does not claim FP8 distributed-collective support or a change to model quantization accuracy.