Download runtime/clef_text_math.py from terminusresearch/cloudflare-clef-int8-convrot: direct link, hf CLI and curl.
- Browser
- Download file 669 Bytes
-
https://huggingface.co/terminusresearch/cloudflare-clef-int8-convrot/resolve/main/runtime/clef_text_math.py
- Command line
-
hf download hf://terminusresearch/cloudflare-clef-int8-convrot/runtime/clef_text_math.py
-
curl -L -o clef_text_math.py https://huggingface.co/terminusresearch/cloudflare-clef-int8-convrot/resolve/main/runtime/clef_text_math.py
669 Bytes
| """BF16 text activation math shared by pointwise and GEMM epilogues.""" | |
| import cutlass | |
| import cutlass.cute as cute | |
| from clef_vision_norm import mul_rn | |
| def silu_bf16(value): | |
| """Input is BF16-rounded; validate the complete finite BF16 domain on SM90.""" | |
| denominator = 1.0 + cute.math.exp(-value, fastmath=True) | |
| activated = cutlass.Float32(0) | |
| if value > -87.0: | |
| inverse = cute.math.rcp(denominator, fastmath=True) | |
| activated = mul_rn(value, inverse) | |
| else: | |
| # Preserve tiny negative activations when the reciprocal would flush to zero. | |
| activated = value / denominator | |
| return activated.to(cutlass.BFloat16) | |