Skip to content

FP8 Support #226

Closed
naturalcandy wants to merge 4 commits into
chhwang/pythonfrom
noli/fp8
Closed

FP8 Support #226
naturalcandy wants to merge 4 commits into
chhwang/pythonfrom
noli/fp8

Conversation

@naturalcandy

Copy link
Copy Markdown
Contributor
  • E4M5 and E5M2 format support on host side.

chhwang pushed a commit that referenced this pull request Jun 11, 2026
…float8.{h,cpp}, register FP8_E4M3/FP8_E5M2 in data_type, add Python bindings, and write float8_test.cpp coverage. Rebase from PR #226 onto main.
chhwang added a commit that referenced this pull request Jun 12, 2026
Add FP8 host-side data types (E4M3/E5M2)

Add `float8_e4m3_t` and `float8_e5m2_t` host-side types with float
conversion, arithmetic, comparison operators, and `std::numeric_limits`
specializations. Register `FP8_E4M3` and `FP8_E5M2` in the data-type
registry and expose them in the Python bindings.

Ported from PR #226 (`noli/fp8`) with two correctness fixes:
- E4M3 `numeric_limits::lowest()` returns −448.0 (`0xfe`), not +448.0.
- E4M3 `has_infinity` set to `false` (OCP E4M3 has no infinity
encoding).

NumPy and PyTorch have no stable FP8 dtypes, so `np`/`torch` mappings
are set to `None` in the Python registry.

New files:
- `ark/float8.h` — templated `_float8` struct, E4M3/E5M2 type aliases.
- `ark/float8.cpp` — float↔FP8 conversion routines.
- `ark/float8_test.cpp` — 386-line test suite covering both types:
  round-trip, subnormals, ±zero, NaN, ±Inf, overflow saturation,
  arithmetic, all comparison operators, `numeric_limits` invariants.

Changed files:
- `ark/api/data_type.cpp` — register FP8_E4M3, FP8_E5M2.
- `ark/include/ark/data_type.hpp` — declare extern constants.
- `python/data_type_py.cpp` — pybind11 bindings.
- `python/ark/data_type.py` — Python-side constants.
@chhwang

chhwang commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Superseded by #259, which lands FP8 host-side E4M3/E5M2 data types on current main. Closing.

@chhwang chhwang closed this Jun 12, 2026
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

Successfully merging this pull request may close these issues.

2 participants