TileOPs-Metax/tests/ops
ray24777 8fe17d8543 test(quant_swiglu): enforce bit-exact fp8 contract with torch
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>
2026-08-05 11:35:44 +00:00
..
attention docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
__init__.py [Refactor] Separate benchmark profiling from unit tests (#224) 2026-02-27 16:46:35 +08:00
gla_test_utils.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_activation.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_ada_layer_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_ada_layer_norm_zero.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_argreduce.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_batch_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_binary_arith.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_bitwise.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_bmm.py [Feat][BMM] Add FP8 BMM op (#1709) 2026-07-16 10:09:14 +08:00
test_comparison.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_convolution.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_cumulative.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_deltanet_chunkwise_bwd.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_deltanet_fwd.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_deltanet_recurrence.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_dropout.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_elementwise_binary_broadcast.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_elementwise_caching_autotune.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_elementwise_compile.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_elementwise_config_dtype.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_elementwise_fp8.py [Test][Kernels] audit fp8/None SUPPORTED_DTYPES + per-family rejection sentinels (#1422) 2026-05-12 09:57:31 +08:00
test_elementwise_independent_fp8.py [Maintain][Kernels] narrow _FLOAT_DTYPES to drop fp8 over-promise (#1418) 2026-05-12 09:57:31 +08:00
test_elementwise_unary_activation_alignment.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_engram.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_fft.py [Refactor][Ops] Infer static metadata from forward inputs (#1734) 2026-07-25 12:05:17 +08:00
test_fp8_lightning_indexer.py [Refactor][Ops] Infer static metadata from forward inputs (#1734) 2026-07-25 12:05:17 +08:00
test_fp8_quant.py [Refactor][Ops] Infer static metadata from forward inputs (#1734) 2026-07-25 12:05:17 +08:00
test_fused_add_layer_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_fused_add_rms_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_fused_gated.py [Refactor][ELEMENTWISE] move strategy into kernel config; drop ctor kwarg (#1778) 2026-07-26 20:39:07 +08:00
test_fused_moe_experts.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_gated_deltanet_chunkwise_bwd.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_gated_deltanet_fwd.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_gated_deltanet_prefill.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_gated_deltanet_recurrence.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_gemm.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_gla_chunkwise_bwd.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_gla_chunkwise_fwd.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_gla_recurrence.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_group_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_grouped_gemm.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_instance_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_kernel_map_install.py [Chore][Release] merge testbed into main: op-family alignment + new ops (#1380) 2026-05-09 00:03:37 +08:00
test_layer_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_logical.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_logical_reduce.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_mamba.py [Refactor][Ops] Infer static metadata from forward inputs (#1734) 2026-07-25 12:05:17 +08:00
test_mhc.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_fused_moe.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_fused_moe_distributed.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_fused_topk.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_grouped_gemm_nopad.py [Test][MOE] add MoeGroupedGemmNopadFwdOp test and bench and flip to implemented (#1491) 2026-05-17 10:12:56 +08:00
test_moe_permute_align.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_permute_nopad.py [Feat][Ops] Infer shape metadata from op inputs (#1651) 2026-07-06 17:51:47 +08:00
test_moe_shared_fused_moe.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_shared_fused_moe_distributed.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_moe_unpermute.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_norm_lazy_cache.py [Feat][NORM_SOFTMAX] Infer shape metadata from inputs (#1690) 2026-07-15 15:40:21 +08:00
test_norm_ops.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_normalization_alignment.py [Feat][NORM_SOFTMAX] Infer shape metadata from inputs (#1690) 2026-07-15 15:40:21 +08:00
test_pool.py docs: add MetaX C500 summer-camp guide on top of upstream dev 2026-07-28 17:55:09 +00:00
test_quant_swiglu_channel_cast_transpose.py test(quant_swiglu): enforce bit-exact fp8 contract with torch 2026-08-05 11:35:44 +00:00
test_reduce.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduce_arithmetic_conformance.py [Test][Reduction] add dim=None/int/tuple conformance tests for sum/mean/amax/amin (#1403) 2026-05-12 09:57:31 +08:00
test_reduce_boolean_conformance.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduce_dim_none.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduce_multidim.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduce_scalar_conformance.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduce_variance_conformance.py [Test][Reduction] add var/std/var_mean conformance across dim x correction (#1406) 2026-05-12 09:57:31 +08:00
test_reduction_defaults.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduction_primitives.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_reduction_scalar_input.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_rms_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_rope.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_softmax.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_special_elementwise.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_special_elementwise_conformance.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_topk_selector.py [Refactor][Ops] Infer static metadata from forward inputs (#1734) 2026-07-25 12:05:17 +08:00
test_unary_math.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_vector_norm.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00
test_welford_non_aligned.py [Chore][Cleanup] repo slimming: dead code, duplicated tests/benches, compat shims, file defragmentation (#1764) 2026-07-26 12:59:48 +08:00