forked from ccf-ai-infra/TileOPs-Metax
The test now compares both outputs with torch.equal (exact_compare), matching the upstream TileKernels-Metax contract. Three changes were needed to reach bit-exactness: - kernel: fix _pack_e4m3 subnormal branch. The old ``reinterpret(round(v*512), u32) & 0x7`` masked the IEEE bits of a rounded float, so every subnormal encoded as +/-0, and ``& 0x7`` truncated the 8 -> min-normal carry. Now computes the RNE integer of |v|*512 (with ties-to-even correction for roundf's half-away) and preserves the carry. - kernel: drop TL_ENABLE_FAST_MATH. -use-fast-math approximates expf/division and shifts the bf16-rounded absmax by one bf16 quantum at rounding boundaries, breaking bit-exactness. The reference TileKernels-Metax kernel also runs without it. - test: the reference sf/sf_inv must use true IEEE division (tensor/tensor, not scalar) and the kernel's round_sf exponent bit trick ((bits + 0x007FFFFF) & 0x7F800000), not ceil(log2). Perf cost of fast-math removal: ~28% on t8064-h4096-nt128 (0.25 -> 0.32 ms, 668 -> 523 GB/s). Accepted: bit-exactness is the op's contract. Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| kernels | ||
| ops | ||
| perf | ||
| trace | ||
| __init__.py | ||
| compile_contract.py | ||
| conftest.py | ||
| nsa_utils.py | ||
| test_base.py | ||
| test_compile.py | ||
| test_op_base.py | ||
| test_ops_manifest.py | ||
| test_reclaim_action.py | ||
| test_roofline_codegen.py | ||
| test_tier_validation.py | ||
| test_validate_manifest.py | ||