Skip to content

Add FP8 host-side data types (E4M3/E5M2)#259

Merged
chhwang merged 3 commits into
mainfrom
pr-i-fp8-host
Jun 12, 2026
Merged

Add FP8 host-side data types (E4M3/E5M2)#259
chhwang merged 3 commits into
mainfrom
pr-i-fp8-host

Conversation

@chhwang

@chhwang chhwang commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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.

+1305/−0 across 7 files.

…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.
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.48%. Comparing base (d22a90a) to head (1bf7b2f).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
ark/float8.h 93.66% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
+ Coverage   85.00%   85.48%   +0.48%     
==========================================
  Files         127      129       +2     
  Lines        6181     6457     +276     
==========================================
+ Hits         5254     5520     +266     
- Misses        927      937      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…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 chhwang changed the title ark-dev: Implement P10: FP8 host-side data types E4M3/E5M2 — add ark/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. Add FP8 host-side data types (E4M3/E5M2) Jun 11, 2026
@chhwang
chhwang merged commit 02dcf84 into main Jun 12, 2026
7 of 8 checks passed
@chhwang
chhwang deleted the pr-i-fp8-host branch June 12, 2026 00:24
@chhwang chhwang mentioned this pull request 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.

1 participant