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

TBox #150

Open
vxst opened this issue May 18, 2024 · 1 comment
Open

TBox #150

vxst opened this issue May 18, 2024 · 1 comment

Comments

@vxst
Copy link

vxst commented May 18, 2024

Since there are only 256 values in float8 (whichever flavor), we can utilize a technique similar to the SBox in AES: pre-calculate the mapping for conversion and look it up when performing conversions.

Since conversion is actually one of the most frequently used operations in float8, this method will greatly improve performance for this library. It can be used for conversion between float8 and for conversion from float8 to float16/32/64.

I plan to implement it based on the current ConvertImpl, with a new struct ConvertTable. It utilizes ConvertImpl to calculate the mapping, so the behavior will be exactly the same, just much faster. I plan to build the table at the RegisterTwoWayCustomCast stage and utilize it when the source of the two-way cast is 8 bits or less.

Is there anything I need to pay attention to, or do you have any advice (e.g., regarding naming)? I'm starting to implement it and will make a PR when it's finished.

@vxst
Copy link
Author

vxst commented May 18, 2024

I need your advice on whether to also use ConvertTable for bfloat16 to float8. A 64 KByte lookup table is still relatively small, and building the table is negligible compared to loading a library in Python. I'll implement ConvertTable in a way that can be easily adapted to a 16-bit source format. Perhaps we can discuss it in the PR when I can present more data, such as the performance improvements, to make a better decision on this call.

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

No branches or pull requests

1 participant