Skip to content

contract: MOSS-Image's reference follows fp32 expf overflow - #4794

Merged
ashhart merged 3 commits into
mainfrom
lead/moss-contract-expf
Nov 24, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/moss-contract-expf

Conversation

@ashhart

@ashhart ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

tf_me_conv is right; the contract's reference is wrong at one input.

At a bf16 tap sum of -89, fp32 expf overflows, so the kernel's silu stores -0. The reference kept float64's exp and expected -1.98e-37, which bf16 can hold, so the sums check failed. The nearest bf16 value on the finite side is -88.5, so no input sits where expf's rounding could go either way.

The failure follows the seed, not the chip. The kernel-contract run draws -89. The moss-contract run draws -104 and -101, which round to 0 on both sides.

This changes only the reference and adds test-moss-contract-host, which fails before the fix. No kernel source or image changes, so output cannot change. It has not been run on SM 11.0.

Refs #4791.

tf_me_conv's silu is z / (1 + expf(-z)) in fp32. At a bf16 tap sum of -89,
expf(89) overflows to inf and the kernel stores -0, on every architecture.
The reference kept float64's exp and asked for -1.98e-37, which bf16 holds,
so the sums gate's interval excluded -0. kernel-contract's seed draws one such
sum among the stress inputs; moss-contract's seed draws only sums at or below
-99, whose reference already rounds to 0.

The reference now returns -0 where expf overflows. The kernels are unchanged.
test-moss-contract-host runs the reference's host test; it fails on main.
@ashhart
ashhart force-pushed the lead/moss-contract-expf branch from 6c0fcdc to 356a7ae Compare November 24, 2026 00:48
@ashhart
ashhart merged commit edecac9 into main Nov 24, 2026
1 check failed
@ashhart
ashhart deleted the lead/moss-contract-expf branch November 24, 2026 00:48
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