jax-ml / jax-ml/ml_dtypes

TBox

Open
#150 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
361
Forks
60
Avg merge
18h 41m
Merged PRs (30d)
3

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start by reading the current ConvertImpl and the RegisterTwoWayCustomCast stage mentioned in the issue. Trace how conversions are registered and used when the source is 8 bits or less, then compare the proposed ConvertTable behavior with the existing conversion path. Done means the lookup-based conversions preserve current behavior while improving performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.