-
Notifications
You must be signed in to change notification settings - Fork 20
Add more compile compatibility for Float8Tensor ops #285
Conversation
We have been pretty targeted with the ops we support for Float8Tensor, I am curious if you have any concrete usecases for these ops. Could you also add some tests cases. Otherwise thanks for the contributions, I am surprised that the contstructor isnt working correctly would also love a test case there! |
Yes, most of these ops are due to using the Float8Tensor to handle an FP8 kv-cache. The example usage for all of these will be in https://github.com/pytorch-labs/fp468-llm today or tomorrow at the latest. I'll add the tests for both the ops and the constructor. The issue on the constructor was that that it didn't matter what the original dtype was, it always returned fp32 |
@drisspg as I'm writing the unit tests, I'm thinking of what a correct copy_ operation looks like: If we try to copy an FP32/FP16/BF16 tensor into an FP8 one, should we do some scaling if the Float8Tensor has it? Or what does the opposite operation look like as well? Say copying an FP8 tensor with scales into an FP32/FP16 one? should we unscale through the FromFloat8Constructor? |
@ani300 Great questions For a copy from scaled_fp8 to hp_type I think we should unscale and copy into. For copy from hp to an fp8 tensors, I think the semantics are a little hazier. Do you have a clear need for this operation? Otherwise I would potentially ban this for now. Some options:
I actually recently thought about a related problem when adding copy_ dispatch to NF4Tensor. This was to enable Subclass -> Subclass copy_. The most reasonable semantic I could come up with is to use the high-precision dtype as the intermediary between the conversion: pytorch/ao#45 @vkuzo any strong thoughts on the semantics here? |
IMO:
|
For the failing unit test, I'm waiting on pytorch CI not failing to run at all to land this: pytorch/pytorch#128758 |
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.
awesome!
@ani300 failing CI is becuase we are still using last nights nightly |
@drisspg has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
No description provided.