triton.language.fpsan.homomorphic_cast

triton.language.fpsan.homomorphic_cast(input, dtype: dtype, fp_downcast_rounding: str | None = None, _semantic=None)

Cast to a same-width or narrower floating-point type, preserving FPSan algebra.

With FPSan enabled, retain the low bits of the input’s payload. This preserves addition and multiplication, allowing a downcast to move through arithmetic without changing the signature. Use barrier() to mark a boundary across which moving the cast should be observable.

Without FPSan, perform an ordinary floating-point cast. Widening and integer conversions are not supported. The input’s shape and layout are preserved.

Parameters:
  • input – A floating-point scalar or tensor.

  • dtype – A floating-point destination type no wider than the input.

  • fp_downcast_rounding – Rounding mode for normal execution: "rtne" (default) or "rtz". Only valid for a narrower destination type; FPSan payload truncation is independent of this choice.