fp8_e5m2 dtype support#96
Conversation
Code review findingsRanked most-severe first. 1.
|
…tivity PBT, comment fix
Fixes:
|
Adversarial code review — findingsRan a follow-up adversarial pass focused on inputs the earlier reviews didn't probe (rounding boundaries, NaN/inf casts, silent truncation, joinOrdered exhaustively vs 1. e5m2 ±inf → signed int returns wrong value (correctness)Where: Failure: Path: 2. e5m2 ±inf → int32/int64 also wrong (same root cause)
Both cases are the same underlying Suggested fix: make Test gap enabling this: Angles that came back clean
|
…aN; add inf/NaN cast tests
Fixes:
|
Code review — fix commit follow-upReviewing 4f4ebf1 (Float32.toInt inf/NaN fix). The direction is right, but the fix is incomplete and the chosen sentinel values only match numpy at int8/int16 by coincidence. 1. Float32.toInt hard-codes -1 / 0 instead of saturating (correctness, high)
The fix returns
The earlier suggestion was to return
So truncation alone doesn't recover numpy's per-size saturation either — the correct fix probably has to happen inside 2. Float32.toNat was not updated (correctness, high)
3. Float.toInt / Float.toNat (fp64) untouched (correctness)
The fp64 helpers still have the pre-existing bug shape ( 4. Tests only cover int8 (test-coverage)
The new tests exercise e5m2 (+inf / -inf / NaN) → int8 and e5m2 +inf → e4m3. Since -1 truncates the same way at int8 (0xFF = -1) regardless of the underlying saturation choice, this coverage doesn't distinguish the -1-sentinel behavior from the INT_MAX-saturation behavior. Adding equivalent tests for int32, int64, and any of the uint targets would surface #1 and #2. 5. Consider extracting Float32.isNaN / isPosInf / isNegInf (simplification)
Three separate special-case branches ( |
…lpers, updated tests
Fixes:
|
|
Update after implementing the fix — a self-review turned up 6 issues worth flagging. Top one is a real gap: 1. 2. 3. 4. 5. Stale comment at 6. Tautological comment at Will address 1–4 before merging; 5 and 6 are comment-only fixes. |
…at, use helpers in Float.toInt/toNat, fix tautological comment
Fixes:
|
|
Self-review of 1. 2. 3. 4. 5. Suggested direction: the shared helper is fighting two callers with opposite semantics (arithmetic wants wrap, casts want saturate). Options:
The second is smaller and matches the helper's name ( |
Adds support for fp8_e5m2 (1 sign + 5 exponent bits + 2 mantissa)